Improve network/server activity feedback for the user. Fixes #1751

This commit is contained in:
Surinder Kumar authored and Dave Page committed 2016-09-26 15:10:38 +01:00
1 parent f9dacc5237
commit 3b4776ab5f
7 files changed
+99 -14

No files matched your search

+22 -2
View File
@@ -1,6 +1,6 @@
define([
'underscore', 'underscore.string', 'jquery', 'pgadmin.browser',
'alertify', 'pgadmin.alertifyjs'
'alertify', 'pgadmin.alertifyjs', 'pgadmin.browser.messages',
], function(_, S, $, pgBrowser, Alertify) {
if (pgBrowser.ShowNodeDepends)
@@ -234,13 +234,31 @@ define([
this.dependentGrid.columns.models[2].set({'label': 'Restriction'});
}
// Hide the message container and show the grid container.
// Hide message container and show grid container.
$msgContainer.addClass('hidden');
$gridContainer.removeClass('hidden');
var timer = setTimeout(function(){
// notify user if request is taking longer than 1 second
$msgContainer.text(pgBrowser.messages['LOADING_MESSAGE']);
$msgContainer.removeClass('hidden');
if ($gridContainer) {
$gridContainer.addClass('hidden');
}
}, 1000);
// Set the url, fetch the data and update the collection
collection.url = url;
collection.fetch({
reset: true,
success: function() {
clearTimeout(timer);
$gridContainer.removeClass('hidden');
if (!$msgContainer.hasClass('hidden')) {
$msgContainer.addClass('hidden');
}
},
error: function(coll, xhr, error, message) {
var _label = treeHierarchy[n_type].label;
pgBrowser.Events.trigger(
@@ -261,6 +279,8 @@ define([
}
);
}
// show failed message.
$msgContainer.text(pgBrowser.messages['LOADING_FAILED']);
}
});
}
+12 -2
View File
@@ -1,6 +1,6 @@
define([
'underscore', 'underscore.string', 'jquery', 'pgadmin.browser',
'alertify', 'pgadmin.alertifyjs'
'alertify', 'pgadmin.alertifyjs', 'pgadmin.browser.messages',
], function(_, S, $, pgBrowser, Alertify) {
pgBrowser.ShowNodeSQL = pgBrowser.ShowNodeSQL || {};
@@ -84,15 +84,25 @@ define([
if (node.hasSQL) {
sql = '';
var url = node.generate_url(item, 'sql', data, true);
var url = node.generate_url(item, 'sql', data, true),
timer;
$.ajax({
url: url,
type:'GET',
beforeSend: function(jqXHR, settings) {
// Generate a timer for the request
timer = setTimeout(function(){
// notify user if request is taking longer than 1 second
pgAdmin.Browser.editor.setValue(pgBrowser.messages['LOADING_MESSAGE']);
}, 1000);
},
success: function(res) {
if (pgAdmin.Browser.editor.getValue() != res) {
pgAdmin.Browser.editor.setValue(res);
}
clearTimeout(timer);
},
error: function(xhr, error, message) {
var _label = treeHierarchy[n_type].label;
@@ -1,6 +1,6 @@
define([
'underscore', 'underscore.string', 'jquery', 'pgadmin.browser', 'backgrid',
'alertify', 'wcdocker', 'pgadmin.backgrid', 'pgadmin.alertifyjs'
'alertify', 'wcdocker', 'pgadmin.backgrid', 'pgadmin.alertifyjs', 'pgadmin.browser.messages',
], function(_, S, $, pgBrowser, Backgrid, Alertify) {
if (pgBrowser.NodeStatistics)
@@ -175,17 +175,28 @@ define([
$(panel[0]).data('node-prop', treeHierarchy);
if (node.hasStatistics) {
/* Set the message because ajax request may take time to
* fetch the information from the server.
*/
msg = '';
$msgContainer.text(msg);
var timer;
// Set the url, fetch the data and update the collection
$.ajax({
url: url,
type:'GET',
beforeSend: function(jqXHR, settings) {
// Generate a timer for the request
timer = setTimeout(function(){
// notify user if request is taking longer than 1 second
$msgContainer.text(pgBrowser.messages['LOADING_MESSAGE']);
$msgContainer.removeClass('hidden');
if (self.grid) {
self.grid.remove();
}
}, 1000);
},
success: function(res) {
// clear timer and reset message.
clearTimeout(timer);
$msgContainer.text('');
if (res.data) {
var data = res.data;
if (node.hasCollectiveStatistics || data['rows'].length > 1) {
@@ -241,6 +252,8 @@ define([
}
);
}
// show failed message.
$msgContainer.text(pgBrowser.messages['LOADING_FAILED']);
}
});
}