[indexer] Scoped JS on the page to avoid leaking into Hue 4
@@ -389,6 +389,8 @@ ${ assist.assistPanel() }
<script type="text/javascript">
+ var IndexesViewModel = (function () {
+
var Alias = function (vm) {
var self = this;
@@ -397,7 +399,9 @@ ${ assist.assistPanel() }
self.name = ko.observable('');
self.chosenCollections = ko.observableArray();
self.availableCollections = ko.computed(function () {
- return $.grep(vm.indexes(), function(index) { return index.type() == 'collection'; });
+ return $.grep(vm.indexes(), function (index) {
+ return index.type() == 'collection';
+ });
});
self.create = function () {
@@ -476,7 +480,9 @@ ${ assist.assistPanel() }
self.columnFilter = ko.observable('');
self.selectedIndexes = ko.computed(function () {
- return $.grep(self.indexes(), function(index) { return index.isSelected(); });
+ return $.grep(self.indexes(), function (index) {
+ return index.isSelected();
+ });
});
self.isLoading = ko.observable(false);
@@ -502,8 +508,7 @@ ${ assist.assistPanel() }
self.datatable = null;
self.fetchIndexes = function () {
- $.post("${ url('indexer:list_indexes') }", {
- }, function(data) {
+ $.post("${ url('indexer:list_indexes') }", {}, function (data) {
if (data.status == 0) {
var indexes = []
data.collections.forEach(function (index) {
@@ -553,9 +558,11 @@ ${ assist.assistPanel() }
hueAnalytics.log('indexes', 'delete_indexes');
};
};
+ return IndexesViewModel;
+ })();
- var viewModel;
+ (function () {
$(document).ready(function () {
var options = {
user: '${ user.username }',
@@ -563,11 +570,12 @@ ${ assist.assistPanel() }
hue4: true,
% endif
};
- viewModel = new IndexesViewModel(options);
+ var viewModel = new IndexesViewModel(options);
ko.applyBindings(viewModel, $('#indexesComponents')[0]);
viewModel.fetchIndexes();
});
+ })();
</script>
%if not is_embeddable:
