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

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

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;