diff --git a/CHANGELOG b/CHANGELOG index 6d70be4649..e2e4fa98eb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ v3.3.18 (XXXX-XX-XX) -------------------- +* fix internal issue #2035: the Web UI now updates its indices view to check + whether new indices exist or not. + * fix internal issue #6808: newly created databases within the Web UI did not appear when used Internet Explorer 11 as a browser. diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/routers/router.js b/js/apps/system/_admin/aardvark/APP/frontend/js/routers/router.js index c20e2d6fbe..e52102f25c 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/routers/router.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/routers/router.js @@ -659,6 +659,9 @@ this.arangoCollectionsStore.fetch({ cache: false, success: function () { + if (self.indicesView) { + self.indicesView.remove(); + } self.indicesView = new window.IndicesView({ collectionName: colname, collection: self.arangoCollectionsStore.findWhere({ diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/views/indicesView.js b/js/apps/system/_admin/aardvark/APP/frontend/js/views/indicesView.js index 7f357b8468..1db9016098 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/views/indicesView.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/views/indicesView.js @@ -9,42 +9,79 @@ el: '#content', initialize: function (options) { + var self = this; this.collectionName = options.collectionName; this.model = this.collection; + + // rerender + self.interval = window.setInterval(function () { + if (window.location.hash.indexOf('cIndices/' + self.collectionName) !== -1 && window.VISIBLE) { + if ($('#collectionEditIndexTable').is(':visible') && !$('#indexDeleteModal').is(':visible')) { + self.rerender(); + } + } + }, self.refreshRate); }, + interval: null, + refreshRate: 10000, + template: templateEngine.createTemplate('indicesView.ejs'), events: { }, + remove: function () { + if (this.interval) { + window.clearInterval(this.interval); + } + this.$el.empty().off(); /* off to unbind the events */ + this.stopListening(); + this.unbind(); + delete this.el; + return this; + }, + render: function () { var self = this; - $.ajax({ - type: 'GET', - cache: false, - url: arangoHelper.databaseUrl('/_api/engine'), - contentType: 'application/json', - processData: false, - success: function (data) { - $(self.el).html(self.template.render({ - model: self.model, - supported: data.supports.indexes - })); + var continueFunction = function (data) { + $(self.el).html(self.template.render({ + model: self.model, + supported: data.supports.indexes + })); - self.breadcrumb(); - window.arangoHelper.buildCollectionSubNav(self.collectionName, 'Indexes'); + self.breadcrumb(); + window.arangoHelper.buildCollectionSubNav(self.collectionName, 'Indexes'); - self.getIndex(); + self.getIndex(); - // check permissions and adjust views - arangoHelper.checkCollectionPermissions(self.collectionName, self.changeViewToReadOnly); - }, - error: function () { - arangoHelper.arangoNotification('Index', 'Could not fetch index information.'); - } - }); + // check permissions and adjust views + arangoHelper.checkCollectionPermissions(self.collectionName, self.changeViewToReadOnly); + }; + + if (!this.engineData) { + $.ajax({ + type: 'GET', + cache: false, + url: arangoHelper.databaseUrl('/_api/engine'), + contentType: 'application/json', + processData: false, + success: function (data) { + self.engineData = data; + continueFunction(data); + }, + error: function () { + arangoHelper.arangoNotification('Index', 'Could not fetch index information.'); + } + }); + } else { + continueFunction(this.engineData); + } + }, + + rerender: function () { + this.getIndex(true); }, changeViewToReadOnly: function () { @@ -61,12 +98,12 @@ ); }, - getIndex: function () { + getIndex: function (rerender) { var callback = function (error, data, id) { if (error) { window.arangoHelper.arangoError('Index', data.errorMessage); } else { - this.renderIndex(data, id); + this.renderIndex(data, id, rerender); } }.bind(this); @@ -152,6 +189,8 @@ } else { arangoHelper.arangoError('Document error', 'Could not create index.'); } + } else { + arangoHelper.arangoNotification('Index', 'Creation in progress. This may take a while.'); } // toggle back self.toggleNewIndexView(); @@ -272,7 +311,7 @@ '' ); }, - renderIndex: function (data, id) { + renderIndex: function (data, id, rerender) { this.index = data; // get pending jobs @@ -325,6 +364,10 @@ var fieldString = ''; var actionString = ''; + if (rerender) { + $('#collectionEditIndexTable tbody').empty(); + } + _.each(this.index.indexes, function (v) { if (v.type === 'primary' || v.type === 'edge') { actionString = '