Consistent busy indication. Fixes #1242

This commit is contained in:
Surinder Kumar
2016-06-29 12:16:02 +01:00
committed by Dave Page
parent 9396cb03d5
commit 53434030c1
13 changed files with 194 additions and 101 deletions

View File

@@ -175,11 +175,30 @@ define(
},
// Fetch the actual data and update the collection
__updateCollection: function(collection, panel, url, messages, node) {
__updateCollection: function(collection, panel, url, messages, node, item, type) {
var msg = messages[0],
$container = panel[0].layout().scene().find('.pg-panel-content'),
$msgContainer = $container.find('.pg-panel-depends-message'),
$gridContainer = $container.find('.pg-panel-depends-container');
treeHierarchy = node.getTreeNodeHierarchy(item),
n_value = -1,
n_type = type;
// Avoid unnecessary reloads
if (_.isUndefined(treeHierarchy[n_type]) ||
_.isUndefined(treeHierarchy[n_type]._id)) {
n_value = -1;
} else {
n_value = treeHierarchy[n_type]._id;
}
if (n_value == $(panel[0]).data(n_type)) {
return;
}
// Cache the current IDs for next time
$(panel[0]).data(n_type, n_value);
// Hide the grid container and show the default message container
if (!$gridContainer.hasClass('hidden'))
@@ -210,19 +229,12 @@ define(
this.dependentGrid.columns.models[2].set({'label': 'Restriction'});
}
// Hide the message container and show the grid container.
$msgContainer.addClass('hidden');
$gridContainer.removeClass('hidden');
// Set the url, fetch the data and update the collection
collection.url = url;
collection.fetch({
reset: true,
success: function(res) {
// In case of success hide the message container and show the grid container.
$gridContainer.removeClass('hidden');
$msgContainer.addClass('hidden');
},
error: function() {
}
});
collection.fetch({ reset: true });
}
}
if (msg != '') {
@@ -250,7 +262,9 @@ define(
node.generate_url(item, 'dependent', data, true),
['No object selected.', 'No dependent information is available for the current object.',
'Fetching dependent information from the server...'],
node
node,
item,
data._type
), 400
);
},
@@ -292,7 +306,9 @@ define(
node.generate_url(item, 'dependency', data, true),
['Please select an object in the tree view.', 'No dependency information is available for the current object.',
'Fetching dependency information from the server...'],
node
node,
item,
data._type
), 400
);
},

View File

@@ -16,7 +16,7 @@ function(_, $, pgBrowser) {
this.initialized = true;
_.bindAll(this, 'showSQL', 'sqlPanelVisibilityChanged');
var sqlPanels = pgBrowser.docker.findPanels('sql');
this.sqlPanels = sqlPanels = pgBrowser.docker.findPanels('sql');
// We will listend to the visibility change of the SQL panel
pgBrowser.Events.on(
@@ -61,6 +61,26 @@ function(_, $, pgBrowser) {
sql = '-- ' + pgBrowser.messages.NODE_HAS_NO_SQL;
if (node.hasSQL) {
var self = this,
n_type = data._type,
n_value = -1,
treeHierarchy = node.getTreeNodeHierarchy(item);
// Avoid unnecessary reloads
if (_.isUndefined(treeHierarchy[n_type]) ||
_.isUndefined(treeHierarchy[n_type]._id)) {
n_value = -1;
} else {
n_value = treeHierarchy[n_type]._id;
}
if (n_value == $(sqlPanels[0]).data(n_type)) {
return;
}
// Cache the current IDs for next time
$(this.sqlPanels[0]).data(n_type, n_value);
sql = '';
var url = node.generate_url(item, 'sql', data, true);

View File

@@ -139,14 +139,15 @@ function(_, $, pgBrowser, Backgrid) {
},
// Fetch the actual data and update the collection
__updateCollection: function(url, node) {
__updateCollection: function(url, node, item, node_type) {
var $container = this.panel[0].layout().scene().find('.pg-panel-content'),
$msgContainer = $container.find('.pg-panel-statistics-message'),
$gridContainer = $container.find('.pg-panel-statistics-container'),
collection = this.collection,
panel = this.panel,
self = this,
msg = '';
msg = '',
n_type = node_type;
if (node) {
msg = pgBrowser.messages.NODE_HAS_NO_STATISTICS;
@@ -154,6 +155,24 @@ function(_, $, pgBrowser, Backgrid) {
* showStatistics function.
*/
if (node.hasStatistics) {
// Avoid unnecessary reloads
var treeHierarchy = node.getTreeNodeHierarchy(item);
if (_.isUndefined(treeHierarchy[n_type]) ||
_.isUndefined(treeHierarchy[n_type]._id)) {
n_value = undefined,
n_value = -1;
} else {
n_value = treeHierarchy[n_type]._id;
}
if (n_value == $(this.panel[0]).data(n_type)) {
return;
}
// Cache the current IDs for next time
$(this.panel[0]).data(n_type, n_value);
/* Set the message because ajax request may take time to
* fetch the information from the server.
*/
@@ -236,7 +255,7 @@ function(_, $, pgBrowser, Backgrid) {
self.timeout = setTimeout(
function() {
self.__updateCollection.call(
self, node.generate_url(item, 'stats', data, true), node
self, node.generate_url(item, 'stats', data, true), node, item, data._type
);
}, 400);
}