diff --git a/web/pgadmin/browser/server_groups/servers/databases/casts/static/js/cast.js b/web/pgadmin/browser/server_groups/servers/databases/casts/static/js/cast.js index 2e41ed62..eabd79ba 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/casts/static/js/cast.js +++ b/web/pgadmin/browser/server_groups/servers/databases/casts/static/js/cast.js @@ -201,17 +201,15 @@ define('pgadmin.node.cast', [ cache: false, async: false, data: {'srctyp' : srcTyp, 'trgtyp' : trgtyp}, - - // On success return function list from server - success: function(result) { - res = result.data; - return res; - }, - - // On failure show error appropriate error message to user - error: function(xhr, status, error) { - alertify.pgRespErrorNotify(xhr, error); - }, + }) + // On success return function list from server + .done(function(result) { + res = result.data; + return res; + }) + // On failure show error appropriate error message to user + .fail(function(xhr, status, error) { + alertify.pgRespErrorNotify(xhr, error); }); } return res; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.js index 24f5e1a7..4da0a2d0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.js @@ -350,17 +350,17 @@ define('pgadmin.node.foreign_table', [ async: false, url: full_url, data: data, - success: function(res) { - /* - * We will cache this data for short period of time for avoiding - * same calls. - */ - data = cache_node.cache(url, node_info, cache_level, res.data); - - }, - error: function() { - m.trigger('pgadmin:view:fetch:error', m, self.field); - }, + }) + .done(function(res) { + /* + * We will cache this data for short period of time for avoiding + * same calls. + */ + data = cache_node.cache(url, node_info, cache_level, res.data); + + }) + .fail(function() { + m.trigger('pgadmin:view:fetch:error', m, self.field); }); m.trigger('pgadmin:view:fetched', m, self.field); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.js index cba62789..935cc84c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.js @@ -111,20 +111,20 @@ define('pgadmin.node.fts_configuration', [ $.ajax({ async: false, url: full_url, - success: function(res) { - /* - * We will cache this data for short period of time for - * avoiding same calls. - */ - data = cache_node.cache(url, - node_info, - cache_level, - res.data - ); - }, - error: function() { - m.trigger('pgadmin:view:fetch:error', m, self.field); - }, + }) + .done(function(res) { + /* + * We will cache this data for short period of time for + * avoiding same calls. + */ + data = cache_node.cache(url, + node_info, + cache_level, + res.data + ); + }) + .fail(function() { + m.trigger('pgadmin:view:fetch:error', m, self.field); }); m.trigger('pgadmin:view:fetched', m, self.field); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js index 3b9b0f35..43f9cfda 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js @@ -31,12 +31,12 @@ define('pgadmin.node.schema', [ $.ajax({ async: false, url: full_url, - success: function (res) { - data = res; - }, - error: function() { - m.trigger('pgadmin-view:fetch:error', m, self.field); - }, + }) + .done(function (res) { + data = res; + }) + .fail(function() { + m.trigger('pgadmin-view:fetch:error', m, self.field); }); m.trigger('pgadmin-view:fetched', m, self.field); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js index 25fa40f7..a146dabc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js @@ -154,17 +154,15 @@ define('pgadmin.node.synonym', [ cache: false, async: false, data: {'trgTyp' : trgTyp, 'trgSchema' : trgSchema}, - - // On success return function list from server - success: function(result) { - res = result.data; - return res; - }, - - // On failure show error appropriate error message to user - error: function(xhr, status, error) { - alertify.pgRespErrorNotify(xhr, error); - }, + }) + // On success return function list from server + .done(function(result) { + res = result.data; + return res; + }) + // On failure show error appropriate error message to user + .fail(function(xhr, status, error) { + alertify.pgRespErrorNotify(xhr, error); }); return res; }, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.js index d8dc2ae7..05722546 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.js @@ -61,21 +61,21 @@ define('pgadmin.node.check_constraint', [ $.ajax({ url: obj.generate_url(i, 'validate', d, true), type:'GET', - success: function(res) { - if (res.success == 1) { - alertify.success(res.info); - t.removeIcon(i); - data.valid = true; - data.icon = 'icon-check_constraint'; - t.addIcon(i, {icon: data.icon}); - setTimeout(function() {t.deselect(i);}, 10); - setTimeout(function() {t.select(i);}, 100); - } - }, - error: function(xhr, status, error) { - alertify.pgRespErrorNotify(xhr, error); - t.unload(i); - }, + }) + .done(function(res) { + if (res.success == 1) { + alertify.success(res.info); + t.removeIcon(i); + data.valid = true; + data.icon = 'icon-check_constraint'; + t.addIcon(i, {icon: data.icon}); + setTimeout(function() {t.deselect(i);}, 10); + setTimeout(function() {t.select(i);}, 100); + } + }) + .fail(function(xhr, status, error) { + alertify.pgRespErrorNotify(xhr, error); + t.unload(i); }); return false; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.js index adccf2e9..8b097034 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.js @@ -82,13 +82,13 @@ define('pgadmin.node.exclusion_constraint', [ async: false, data : {indextype:indextype}, url: full_url, - success: function(res) { - data = res.data; - self.column.set('options', data); - }, - error: function() { - eventHandler.trigger('pgadmin:view:fetch:error', m, self.column); - }, + }) + .done(function(res) { + data = res.data; + self.column.set('options', data); + }) + .fail(function() { + eventHandler.trigger('pgadmin:view:fetch:error', m, self.column); }); eventHandler.trigger('pgadmin:view:fetched', m, self.column); } @@ -183,13 +183,13 @@ define('pgadmin.node.exclusion_constraint', [ async: false, data : {col_type:col_type}, url: full_url, - success: function(res) { - data = res.data; - self.column.set('options', data); - }, - error: function() { - eventHandler.trigger('pgadmin:view:fetch:error', m, self.column); - }, + }) + .done(function(res) { + data = res.data; + self.column.set('options', data); + }) + .fail(function() { + eventHandler.trigger('pgadmin:view:fetch:error', m, self.column); }); eventHandler.trigger('pgadmin:view:fetched', m, self.column); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.js index 9899df92..9d11ec7f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.js @@ -214,12 +214,12 @@ define('pgadmin.node.foreign_key', [ async: false, data : {tid:tid}, url: full_url, - success: function(res) { - data = res.data; - }, - error: function() { - m.trigger('pgadmin:view:fetch:error', m, self.field); - }, + }) + .done(function(res) { + data = res.data; + }) + .fail(function() { + m.trigger('pgadmin:view:fetch:error', m, self.field); }); m.trigger('pgadmin:view:fetched', m, self.field); } @@ -558,12 +558,12 @@ define('pgadmin.node.foreign_key', [ async: false, data : {cols:JSON.stringify(cols)}, url: full_url, - success: function(res) { - coveringindex = res.data; - }, - error: function() { - m.trigger('pgadmin:view:fetch:error', m, self.field); - }, + }) + .done(function(res) { + coveringindex = res.data; + }) + .fail(function() { + m.trigger('pgadmin:view:fetch:error', m, self.field); }); m.trigger('pgadmin:view:fetched', m, self.field); } @@ -653,21 +653,21 @@ define('pgadmin.node.foreign_key', [ $.ajax({ url: obj.generate_url(i, 'validate', d, true), type:'GET', - success: function(res) { - if (res.success == 1) { - Alertify.success(res.info); - t.removeIcon(i); - data.valid = true; - data.icon = 'icon-foreign_key'; - t.addIcon(i, {icon: data.icon}); - setTimeout(function() {t.deselect(i);}, 10); - setTimeout(function() {t.select(i);}, 100); - } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); - t.unload(i); - }, + }) + .done(function(res) { + if (res.success == 1) { + Alertify.success(res.info); + t.removeIcon(i); + data.valid = true; + data.icon = 'icon-foreign_key'; + t.addIcon(i, {icon: data.icon}); + setTimeout(function() {t.deselect(i);}, 10); + setTimeout(function() {t.select(i);}, 100); + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); + t.unload(i); }); return false; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js index 74649721..ecb28e16 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js @@ -134,21 +134,21 @@ function( type:'PUT', data: params, dataType: 'json', - success: function(res) { - if (res.success == 1) { - Alertify.success(res.info); - t.unload(i); - t.setInode(i); - t.deselect(i); - setTimeout(function() { - t.select(i); - }, 10); - } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); + }) + .done(function(res) { + if (res.success == 1) { + Alertify.success(res.info); t.unload(i); - }, + t.setInode(i); + t.deselect(i); + setTimeout(function() { + t.select(i); + }, 10); + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); + t.unload(i); }); }, /* Truncate table */ @@ -182,25 +182,25 @@ function( type:'PUT', data: params, dataType: 'json', - success: function(res) { - if (res.success == 1) { - Alertify.success(res.info); - t.removeIcon(i); - data.icon = 'icon-partition'; - t.addIcon(i, {icon: data.icon}); - t.unload(i); - t.setInode(i); - t.deselect(i); - // Fetch updated data from server - setTimeout(function() { - t.select(i); - }, 10); - } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); + }) + .done(function(res) { + if (res.success == 1) { + Alertify.success(res.info); + t.removeIcon(i); + data.icon = 'icon-partition'; + t.addIcon(i, {icon: data.icon}); t.unload(i); - }, + t.setInode(i); + t.deselect(i); + // Fetch updated data from server + setTimeout(function() { + t.select(i); + }, 10); + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); + t.unload(i); }); }}, function() {} @@ -225,25 +225,25 @@ function( $.ajax({ url: obj.generate_url(i, 'reset' , d, true), type:'DELETE', - success: function(res) { - if (res.success == 1) { - Alertify.success(res.info); - t.removeIcon(i); - data.icon = 'icon-partition'; - t.addIcon(i, {icon: data.icon}); - t.unload(i); - t.setInode(i); - t.deselect(i); - // Fetch updated data from server - setTimeout(function() { - t.select(i); - }, 10); - } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); + }) + .done(function(res) { + if (res.success == 1) { + Alertify.success(res.info); + t.removeIcon(i); + data.icon = 'icon-partition'; + t.addIcon(i, {icon: data.icon}); t.unload(i); - }, + t.setInode(i); + t.deselect(i); + // Fetch updated data from server + setTimeout(function() { + t.select(i); + }, 10); + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); + t.unload(i); }); } }, @@ -268,26 +268,26 @@ function( $.ajax({ url: obj.generate_url(i, 'detach' , d, true), type:'PUT', - success: function(res) { - if (res.success == 1) { - Alertify.success(res.info); - var n = t.next(i); + }) + .done(function(res) { + if (res.success == 1) { + Alertify.success(res.info); + var n = t.next(i); + if (!n || !n.length) { + n = t.prev(i); if (!n || !n.length) { - n = t.prev(i); - if (!n || !n.length) { - n = t.parent(i); - t.setInode(n, true); - } - } - t.remove(i); - if (n.length) { - t.select(n); + n = t.parent(i); + t.setInode(n, true); } } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); - }, + t.remove(i); + if (n.length) { + t.select(n); + } + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); }); } }, @@ -874,19 +874,19 @@ function( type: 'GET', async: false, - success: function(res) { - if (res.success == 1) { - self.model.table_options = res.data; - } - else { - Alertify.alert( - gettext('Error fetching tables to be attached'), res.data.result - ); - } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error, gettext('Error fetching tables to be attached')); - }, + }) + .done(function(res) { + if (res.success == 1) { + self.model.table_options = res.data; + } + else { + Alertify.alert( + gettext('Error fetching tables to be attached'), res.data.result + ); + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error, gettext('Error fetching tables to be attached')); }); } }, @@ -1148,12 +1148,12 @@ function( async: false, url: full_url, data: arg, - success: function(res) { - data = cache_node.cache(url, node_info, cache_level, res.data); - }, - error: function() { - m.trigger('pgadmin:view:fetch:error', m, self.field); - }, + }) + .done(function(res) { + data = cache_node.cache(url, node_info, cache_level, res.data); + }) + .fail(function() { + m.trigger('pgadmin:view:fetch:error', m, self.field); }); m.trigger('pgadmin:view:fetched', m, self.field); data = (data && data.data) || []; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js index 1f9bcf97..530cd118 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js @@ -164,25 +164,25 @@ define('pgadmin.node.table', [ type:'PUT', data: params, dataType: 'json', - success: function(res) { - if (res.success == 1) { - Alertify.success(res.info); - t.removeIcon(i); - data.icon = data.is_partitioned ? 'icon-partition': 'icon-table'; - t.addIcon(i, {icon: data.icon}); - t.unload(i); - t.setInode(i); - t.deselect(i); - // Fetch updated data from server - setTimeout(function() { - t.select(i); - }, 10); - } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); + }) + .done(function(res) { + if (res.success == 1) { + Alertify.success(res.info); + t.removeIcon(i); + data.icon = data.is_partitioned ? 'icon-partition': 'icon-table'; + t.addIcon(i, {icon: data.icon}); t.unload(i); - }, + t.setInode(i); + t.deselect(i); + // Fetch updated data from server + setTimeout(function() { + t.select(i); + }, 10); + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); + t.unload(i); }); } }, function() {} @@ -207,25 +207,25 @@ define('pgadmin.node.table', [ $.ajax({ url: obj.generate_url(i, 'reset' , d, true), type:'DELETE', - success: function(res) { - if (res.success == 1) { - Alertify.success(res.info); - t.removeIcon(i); - data.icon = data.is_partitioned ? 'icon-partition': 'icon-table'; - t.addIcon(i, {icon: data.icon}); - t.unload(i); - t.setInode(i); - t.deselect(i); - // Fetch updated data from server - setTimeout(function() { - t.select(i); - }, 10); - } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); + }) + .done(function(res) { + if (res.success == 1) { + Alertify.success(res.info); + t.removeIcon(i); + data.icon = data.is_partitioned ? 'icon-partition': 'icon-table'; + t.addIcon(i, {icon: data.icon}); t.unload(i); - }, + t.setInode(i); + t.deselect(i); + // Fetch updated data from server + setTimeout(function() { + t.select(i); + }, 10); + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); + t.unload(i); }); } }, @@ -245,20 +245,20 @@ define('pgadmin.node.table', [ $.ajax({ url: obj.generate_url(i, 'count_rows' , d, true), type:'GET', - success: function(res) { - Alertify.success(res.info); - d.rows_cnt = res.data.total_rows; - t.unload(i); - t.setInode(i); - t.deselect(i); - setTimeout(function() { - t.select(i); - }, 10); - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); - t.unload(i); - }, + }) + .done(function(res) { + Alertify.success(res.info); + d.rows_cnt = res.data.total_rows; + t.unload(i); + t.setInode(i); + t.deselect(i); + setTimeout(function() { + t.select(i); + }, 10); + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); + t.unload(i); }); }, }, @@ -983,19 +983,19 @@ define('pgadmin.node.table', [ type: 'GET', async: false, - success: function(res) { - if (res.success == 1) { - self.model.table_options = res.data; - } - else { - Alertify.alert( - gettext('Error fetching tables to be attached'), res.data.result - ); - } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); - }, + }) + .done(function(res) { + if (res.success == 1) { + self.model.table_options = res.data; + } + else { + Alertify.alert( + gettext('Error fetching tables to be attached'), res.data.result + ); + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); }); } }, @@ -1261,12 +1261,12 @@ define('pgadmin.node.table', [ async: false, url: full_url, data: arg, - success: function(res) { - data = cache_node.cache(url, node_info, cache_level, res.data); - }, - error: function() { - m.trigger('pgadmin:view:fetch:error', m, self.field); - }, + }) + .done(function(res) { + data = cache_node.cache(url, node_info, cache_level, res.data); + }) + .fail(function() { + m.trigger('pgadmin:view:fetch:error', m, self.field); }); m.trigger('pgadmin:view:fetched', m, self.field); data = (data && data.data) || []; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js index a6e79ce2..85aab40b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js @@ -118,25 +118,25 @@ define('pgadmin.node.trigger', [ type:'PUT', data: {'enable' : true}, dataType: 'json', - success: function(res) { - if (res.success == 1) { - alertify.success(res.info); - t.removeIcon(i); - data.icon = 'icon-trigger'; - t.addIcon(i, {icon: data.icon}); - t.unload(i); - t.setInode(false); - t.deselect(i); - // Fetch updated data from server - setTimeout(function() { - t.select(i); - }, 10); - } - }, - error: function(xhr, status, error) { - alertify.pgRespErrorNotify(xhr, error); + }) + .done(function(res) { + if (res.success == 1) { + alertify.success(res.info); + t.removeIcon(i); + data.icon = 'icon-trigger'; + t.addIcon(i, {icon: data.icon}); t.unload(i); - }, + t.setInode(false); + t.deselect(i); + // Fetch updated data from server + setTimeout(function() { + t.select(i); + }, 10); + } + }) + .fail(function(xhr, status, error) { + alertify.pgRespErrorNotify(xhr, error); + t.unload(i); }); }, /* Disable trigger */ @@ -156,25 +156,25 @@ define('pgadmin.node.trigger', [ type:'PUT', data: {'enable' : false}, dataType: 'json', - success: function(res) { - if (res.success == 1) { - alertify.success(res.info); - t.removeIcon(i); - data.icon = 'icon-trigger-bad'; - t.addIcon(i, {icon: data.icon}); - t.unload(i); - t.setInode(false); - t.deselect(i); - // Fetch updated data from server - setTimeout(function() { - t.select(i); - }, 10); - } - }, - error: function(xhr, status, error) { - alertify.pgRespErrorNotify(xhr, error, gettext('Disable trigger failed')); + }) + .done(function(res) { + if (res.success == 1) { + alertify.success(res.info); + t.removeIcon(i); + data.icon = 'icon-trigger-bad'; + t.addIcon(i, {icon: data.icon}); t.unload(i); - }, + t.setInode(false); + t.deselect(i); + // Fetch updated data from server + setTimeout(function() { + t.select(i); + }, 10); + } + }) + .fail(function(xhr, status, error) { + alertify.pgRespErrorNotify(xhr, error, gettext('Disable trigger failed')); + t.unload(i); }); }, }, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.js index 5860a752..12045cf1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.js @@ -423,12 +423,12 @@ define('pgadmin.node.type', [ url: _url, cache: false, data: {'typname' : l_typname}, - success: function(res) { - result = res.data; - }, - error: function() { - self.model.trigger('pgadmin:view:fetch:error', self.model, self.field); - }, + }) + .done(function(res) { + result = res.data; + }) + .fail(function() { + self.model.trigger('pgadmin:view:fetch:error', self.model, self.field); }); // } @@ -491,13 +491,13 @@ define('pgadmin.node.type', [ url: _url, cache: false, data: {'name' : name}, - success: function(res) { - result = res.data; - }, - error: function() { - self.model.trigger('pgadmin:view:fetch:error', - self.model, self.field); - }, + }) + .done(function(res) { + result = res.data; + }) + .fail(function() { + self.model.trigger('pgadmin:view:fetch:error', + self.model, self.field); }); } return result; @@ -527,13 +527,13 @@ define('pgadmin.node.type', [ url: _url, cache: false, data: {'typname' : l_typname, 'opcname': l_opcname}, - success: function(res) { - result = res.data; - }, - error: function() { - self.model.trigger('pgadmin:view:fetch:error', - self.model, self.field); - }, + }) + .done(function(res) { + result = res.data; + }) + .fail(function() { + self.model.trigger('pgadmin:view:fetch:error', + self.model, self.field); }); } return result; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js index dcfdd54b..cda9636d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js @@ -253,20 +253,20 @@ define('pgadmin.node.mview', [ type: 'PUT', data: {'concurrent': args.concurrent, 'with_data': args.with_data}, dataType: 'json', - success: function(res) { - if (res.success == 1) { - Alertify.success(gettext('View refreshed successfully')); - } - else { - Alertify.alert( - gettext('Error refreshing view'), - res.data.result - ); - } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error, gettext('Error refreshing view')); - }, + }) + .done(function(res) { + if (res.success == 1) { + Alertify.success(gettext('View refreshed successfully')); + } + else { + Alertify.alert( + gettext('Error refreshing view'), + res.data.result + ); + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error, gettext('Error refreshing view')); }); }, diff --git a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js index 1bb67598..d3902717 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js +++ b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js @@ -185,33 +185,33 @@ define('pgadmin.node.database', [ $.ajax({ url: obj.generate_url(i, 'connect', d, true), type:'DELETE', - success: function(res) { - if (res.success == 1) { - var prv_i = t.parent(i); - Alertify.success(res.info); - t.removeIcon(i); - data.connected = false; - data.icon = 'icon-database-not-connected'; - t.addIcon(i, {icon: data.icon}); - t.unload(i); - t.setInode(i); - setTimeout(function() { - t.select(prv_i); - }, 10); - - } else { - try { - Alertify.error(res.errormsg); - } catch (e) { - console.warn(e.stack || e); - } - t.unload(i); + }) + .done(function(res) { + if (res.success == 1) { + var prv_i = t.parent(i); + Alertify.success(res.info); + t.removeIcon(i); + data.connected = false; + data.icon = 'icon-database-not-connected'; + t.addIcon(i, {icon: data.icon}); + t.unload(i); + t.setInode(i); + setTimeout(function() { + t.select(prv_i); + }, 10); + + } else { + try { + Alertify.error(res.errormsg); + } catch (e) { + console.warn(e.stack || e); } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); t.unload(i); - }, + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); + t.unload(i); }); }, function() { return true; }); diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/static/js/pga_job.js b/web/pgadmin/browser/server_groups/servers/pgagent/static/js/pga_job.js index 74c99a40..44a6b5c1 100644 --- a/web/pgadmin/browser/server_groups/servers/pgagent/static/js/pga_job.js +++ b/web/pgadmin/browser/server_groups/servers/pgagent/static/js/pga_job.js @@ -172,13 +172,13 @@ define('pgadmin.node.pga_job', [ $.ajax({ url: obj.generate_url(i, 'run_now', d, true), method:'PUT', - // 'pgagent.pga_job' table updated with current time to run the job - // now. - success: function() { t.unload(i); }, - error: function(xhr, status, error) { - alertify.pgRespErrorNotify(xhr, error); - t.unload(i); - }, + }) + // 'pgagent.pga_job' table updated with current time to run the job + // now. + .done(function() { t.unload(i); }) + .fail(function(xhr, status, error) { + alertify.pgRespErrorNotify(xhr, error); + t.unload(i); }); return false; diff --git a/web/pgadmin/browser/server_groups/servers/static/js/server.js b/web/pgadmin/browser/server_groups/servers/static/js/server.js index 9e0b6279..86247b53 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/server.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/server.js @@ -189,38 +189,38 @@ define('pgadmin.node.server', [ $.ajax({ url: obj.generate_url(i, 'connect', d, true), type:'DELETE', - success: function(res) { - if (res.success == 1) { - Alertify.success(res.info); - d = t.itemData(i); - t.removeIcon(i); - d.connected = false; - d.icon = 'icon-server-not-connected'; - t.addIcon(i, {icon: d.icon}); - obj.callbacks.refresh.apply(obj, [null, i]); - if (pgBrowser.serverInfo && d._id in pgBrowser.serverInfo) { - delete pgBrowser.serverInfo[d._id]; - } - pgBrowser.enable_disable_menus(i); - // Trigger server disconnect event - pgBrowser.Events.trigger( - 'pgadmin:server:disconnect', - {item: i, data: d}, false - ); + }) + .done(function(res) { + if (res.success == 1) { + Alertify.success(res.info); + d = t.itemData(i); + t.removeIcon(i); + d.connected = false; + d.icon = 'icon-server-not-connected'; + t.addIcon(i, {icon: d.icon}); + obj.callbacks.refresh.apply(obj, [null, i]); + if (pgBrowser.serverInfo && d._id in pgBrowser.serverInfo) { + delete pgBrowser.serverInfo[d._id]; } - else { - try { - Alertify.error(res.errormsg); - } catch (e) { - console.warn(e.stack || e); - } - t.unload(i); + pgBrowser.enable_disable_menus(i); + // Trigger server disconnect event + pgBrowser.Events.trigger( + 'pgadmin:server:disconnect', + {item: i, data: d}, false + ); + } + else { + try { + Alertify.error(res.errormsg); + } catch (e) { + console.warn(e.stack || e); } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); t.unload(i); - }, + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); + t.unload(i); }); }; @@ -284,18 +284,18 @@ define('pgadmin.node.server', [ $.ajax({ url: obj.generate_url(i, 'reload', d, true), method:'GET', - success: function(res) { - if (res.data.status) { - Alertify.success(res.data.result); - } - else { - Alertify.error(res.data.result); - } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); - t.unload(i); - }, + }) + .done(function(res) { + if (res.data.status) { + Alertify.success(res.data.result); + } + else { + Alertify.error(res.data.result); + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); + t.unload(i); }); }, function() { return true; } @@ -325,13 +325,13 @@ define('pgadmin.node.server', [ url: obj.generate_url(i, 'restore_point', d, true), method:'POST', data:{ 'value': JSON.stringify(value) }, - success: function(res) { - Alertify.success(res.data.result, 10); - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); - t.unload(i); - }, + }) + .done(function(res) { + Alertify.success(res.data.result, 10); + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); + t.unload(i); }); } else { evt.cancel = true; @@ -481,27 +481,27 @@ define('pgadmin.node.server', [ url: url, method:'POST', data:{'data': JSON.stringify(args) }, - success: function(res) { - if (res.success) { - // Notify user to update pgpass file - if(is_pgpass_file_used) { - Alertify.alert( - gettext('Change Password'), - gettext('Please make sure to disconnect the server' - + ' and update the new password in the pgpass file' - + ' before performing any other operation') - ); - } - - Alertify.success(res.info); - self.close(); - } else { - Alertify.error(res.errormsg); + }) + .done(function(res) { + if (res.success) { + // Notify user to update pgpass file + if(is_pgpass_file_used) { + Alertify.alert( + gettext('Change Password'), + gettext('Please make sure to disconnect the server' + + ' and update the new password in the pgpass file' + + ' before performing any other operation') + ); } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); - }, + + Alertify.success(res.info); + self.close(); + } else { + Alertify.error(res.errormsg); + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); }); } }, @@ -513,15 +513,15 @@ define('pgadmin.node.server', [ $.ajax({ url: check_pgpass_url, method:'GET', - success: function(res) { - if (res.success && res.data.is_pgpass) { - is_pgpass_file_used = true; - } - Alertify.changeServerPassword(d).resizeTo('40%','52%'); - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); - }, + }) + .done(function(res) { + if (res.success && res.data.is_pgpass) { + is_pgpass_file_used = true; + } + Alertify.changeServerPassword(d).resizeTo('40%','52%'); + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); }); return false; @@ -542,23 +542,23 @@ define('pgadmin.node.server', [ url: obj.generate_url(i, 'wal_replay' , d, true), type:'DELETE', dataType: 'json', - success: function(res) { - if (res.success == 1) { - Alertify.success(res.info); - t.itemData(i).wal_pause=res.data.wal_pause; - t.unload(i); - t.setInode(i); - t.deselect(i); - // Fetch updated data from server - setTimeout(function() { - t.select(i); - }, 10); - } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); + }) + .done(function(res) { + if (res.success == 1) { + Alertify.success(res.info); + t.itemData(i).wal_pause=res.data.wal_pause; t.unload(i); - }, + t.setInode(i); + t.deselect(i); + // Fetch updated data from server + setTimeout(function() { + t.select(i); + }, 10); + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); + t.unload(i); }); }, @@ -577,23 +577,23 @@ define('pgadmin.node.server', [ url: obj.generate_url(i, 'wal_replay' , d, true), type:'PUT', dataType: 'json', - success: function(res) { - if (res.success == 1) { - Alertify.success(res.info); - t.itemData(i).wal_pause=res.data.wal_pause; - t.unload(i); - t.setInode(i); - t.deselect(i); - // Fetch updated data from server - setTimeout(function() { - t.select(i); - }, 10); - } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); + }) + .done(function(res) { + if (res.success == 1) { + Alertify.success(res.info); + t.itemData(i).wal_pause=res.data.wal_pause; t.unload(i); - }, + t.setInode(i); + t.deselect(i); + // Fetch updated data from server + setTimeout(function() { + t.select(i); + }, 10); + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); + t.unload(i); }); }, }, @@ -1128,16 +1128,16 @@ define('pgadmin.node.server', [ timeout: 30000, url: _url, data: $('#frmPassword').serialize(), - success: function(res) { - return _onSuccess( - res, _node, _data, _tree, _item, _status - ); - }, - error: function(xhr, status, error) { - return _onFailure( - xhr, status, error, _node, _data, _tree, _item, _status - ); - }, + }) + .done(function(res) { + return _onSuccess( + res, _node, _data, _tree, _item, _status + ); + }) + .fail(function(xhr, status, error) { + return _onFailure( + xhr, status, error, _node, _data, _tree, _item, _status + ); }); } else { _onCancel && typeof(_onCancel) == 'function' && diff --git a/web/pgadmin/browser/server_groups/servers/static/js/variable.js b/web/pgadmin/browser/server_groups/servers/static/js/variable.js index 9e48b4f9..987c3bab 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/variable.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/variable.js @@ -303,12 +303,12 @@ define([ $.ajax({ async: false, url: full_url, - success: function (res) { - data = res.data; - }, - error: function() { - m.trigger('pgadmin-view:fetch:error', m, self.field); - }, + }) + .done(function (res) { + data = res.data; + }) + .fail(function() { + m.trigger('pgadmin-view:fetch:error', m, self.field); }); m.trigger('pgadmin-view:fetched', m, self.field); diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.js b/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.js index d8371aa0..90e97f0a 100644 --- a/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.js +++ b/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.js @@ -277,17 +277,17 @@ define('pgadmin.node.tablespace', [ url: url, method:'PUT', data:{'data': JSON.stringify(args) }, - success: function(res) { - if (res.success) { - Alertify.success(res.info); - self.close(); - } else { - Alertify.error(res.errormsg); - } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); - }, + }) + .done(function(res) { + if (res.success) { + Alertify.success(res.info); + self.close(); + } else { + Alertify.error(res.errormsg); + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); }); }, function() { diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js index f8a56938..decbd98d 100644 --- a/web/pgadmin/browser/static/js/browser.js +++ b/web/pgadmin/browser/static/js/browser.js @@ -503,9 +503,9 @@ define('pgadmin.browser', [ $.ajax({ url: url_for('misc.cleanup'), type:'POST', - success: function() {}, - error: function() {}, - }); + }) + .done(function() {}) + .fail(function() {}); }, 300000); obj.Events.on('pgadmin:browser:tree:add', obj.onAddTreeNode, obj); obj.Events.on('pgadmin:browser:tree:update', obj.onUpdateTreeNode, obj); @@ -1539,69 +1539,69 @@ define('pgadmin.browser', [ type: 'GET', cache: false, dataType: 'json', - success: function(res) { - // Node information can come as result/data - var data = res.result || res.data; - - data._label = data.label; - data.label = _.escape(data.label); - var d = ctx.t.itemData(ctx.i); - _.extend(d, data); - ctx.t.setLabel(ctx.i, {label: _d.label}); - ctx.t.addIcon(ctx.i, {icon: _d.icon}); - ctx.t.setId(ctx.i, {id: _d.id}); - ctx.t.setInode(ctx.i, {inode: data.inode}); + }) + .done(function(res) { + // Node information can come as result/data + var data = res.result || res.data; + + data._label = data.label; + data.label = _.escape(data.label); + var d = ctx.t.itemData(ctx.i); + _.extend(d, data); + ctx.t.setLabel(ctx.i, {label: _d.label}); + ctx.t.addIcon(ctx.i, {icon: _d.icon}); + ctx.t.setId(ctx.i, {id: _d.id}); + ctx.t.setInode(ctx.i, {inode: data.inode}); - if ( - _n.can_expand && typeof(_n.can_expand) == 'function' - ) { - if (!_n.can_expand(d)) { - ctx.t.unload(ctx.i); - return; - } - } - ctx.b._refreshNode(ctx, ctx.branch); - var success = (ctx.o && ctx.o.success) || ctx.success; - if (success && typeof(success) == 'function') { - success(); + if ( + _n.can_expand && typeof(_n.can_expand) == 'function' + ) { + if (!_n.can_expand(d)) { + ctx.t.unload(ctx.i); + return; } - }, - error: function(xhr, error, status) { - if ( - !Alertify.pgHandleItemError( - xhr, error, status, {item: _i, info: info} - ) - ) { - var contentType = xhr.getResponseHeader('Content-Type'), - jsonResp = ( - contentType && - contentType.indexOf('application/json') == 0 && - JSON.parse(xhr.responseText) - ) || {}; + } + ctx.b._refreshNode(ctx, ctx.branch); + var success = (ctx.o && ctx.o.success) || ctx.success; + if (success && typeof(success) == 'function') { + success(); + } + }) + .fail(function(xhr, error, status) { + if ( + !Alertify.pgHandleItemError( + xhr, error, status, {item: _i, info: info} + ) + ) { + var contentType = xhr.getResponseHeader('Content-Type'), + jsonResp = ( + contentType && + contentType.indexOf('application/json') == 0 && + JSON.parse(xhr.responseText) + ) || {}; - if (xhr.status == 410 && jsonResp.success == 0) { - var p = ctx.t.parent(ctx.i); + if (xhr.status == 410 && jsonResp.success == 0) { + var p = ctx.t.parent(ctx.i); - ctx.t.remove(ctx.i, { - success: function() { - if (p) { - // Try to refresh the parent on error - try { - pgBrowser.Events.trigger( - 'pgadmin:browser:tree:refresh', p - ); - } catch (e) { console.warn(e.stack || e); } - } - }, - }); - } - - Alertify.pgNotifier( - error, xhr, gettext('Error retrieving details for the node.'), - function() { console.warn(arguments); } - ); + ctx.t.remove(ctx.i, { + success: function() { + if (p) { + // Try to refresh the parent on error + try { + pgBrowser.Events.trigger( + 'pgadmin:browser:tree:refresh', p + ); + } catch (e) { console.warn(e.stack || e); } + } + }, + }); } - }, + + Alertify.pgNotifier( + error, xhr, gettext('Error retrieving details for the node.'), + function() { console.warn(arguments); } + ); + } }); }.bind(this); @@ -1786,16 +1786,16 @@ define('pgadmin.browser', [ $.ajax({ url: childNodeUrl, dataType: 'json', - success: function(res) { - if (res.success) { - arrayChildNodeData.push(res.data); - } - fetchNodeInfo(_callback); - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); - fetchNodeInfo(_callback); - }, + }) + .done(function(res) { + if (res.success) { + arrayChildNodeData.push(res.data); + } + fetchNodeInfo(_callback); + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); + fetchNodeInfo(_callback); }); }; diff --git a/web/pgadmin/browser/static/js/node.js b/web/pgadmin/browser/static/js/node.js index 35eca24b..bef03ae5 100644 --- a/web/pgadmin/browser/static/js/node.js +++ b/web/pgadmin/browser/static/js/node.js @@ -729,30 +729,30 @@ define('pgadmin.browser.node', [ $.ajax({ url: obj.generate_url(i, input.url, d, true), type: 'DELETE', - success: function(res) { - if (res.success == 0) { - pgBrowser.report_error(res.errormsg, res.info); - } else { - pgBrowser.removeTreeNode(i, true); - } - return true; - }, - error: function(jqx) { - var msg = jqx.responseText; - /* Error from the server */ - if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) { - try { - var data = JSON.parse(jqx.responseText); - msg = data.errormsg; - } catch (e) { - console.warn(e.stack || e); - } + }) + .done(function(res) { + if (res.success == 0) { + pgBrowser.report_error(res.errormsg, res.info); + } else { + pgBrowser.removeTreeNode(i, true); + } + return true; + }) + .fail(function(jqx) { + var msg = jqx.responseText; + /* Error from the server */ + if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) { + try { + var data = JSON.parse(jqx.responseText); + msg = data.errormsg; + } catch (e) { + console.warn(e.stack || e); } - pgBrowser.report_error( - S(gettext('Error dropping %s: "%s"')) - .sprintf(obj.label, objName) - .value(), msg); - }, + } + pgBrowser.report_error( + S(gettext('Error dropping %s: "%s"')) + .sprintf(obj.label, objName) + .value(), msg); }); }, null).show(); diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js index 227b4571..064ca312 100644 --- a/web/pgadmin/browser/static/js/node.ui.js +++ b/web/pgadmin/browser/static/js/node.ui.js @@ -146,16 +146,16 @@ define([ $.ajax({ async: false, url: full_url, - success: function(res) { - /* - * We will cache this data for short period of time for avoiding - * same calls. - */ - data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data); - }, - error: function() { - m.trigger('pgadmin:view:fetch:error', m, self.field); - }, + }) + .done(function(res) { + /* + * We will cache this data for short period of time for avoiding + * same calls. + */ + data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data); + }) + .fail(function() { + m.trigger('pgadmin:view:fetch:error', m, self.field); }); m.trigger('pgadmin:view:fetched', m, self.field); } @@ -387,16 +387,16 @@ define([ $.ajax({ async: false, url: full_url, - success: function(res) { - /* - * We will cache this data for short period of time for avoiding - * same calls. - */ - data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data); - }, - error: function() { - eventHandler.trigger('pgadmin:view:fetch:error', m, column); - }, + }) + .done(function(res) { + /* + * We will cache this data for short period of time for avoiding + * same calls. + */ + data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data); + }) + .fail(function() { + eventHandler.trigger('pgadmin:view:fetch:error', m, column); }); eventHandler.trigger('pgadmin:view:fetched', m, column); } @@ -559,4 +559,4 @@ define([ }); return Backform; -}); \ No newline at end of file +}); diff --git a/web/pgadmin/browser/static/js/preferences.js b/web/pgadmin/browser/static/js/preferences.js index b0c6dc48..1e84bd41 100644 --- a/web/pgadmin/browser/static/js/preferences.js +++ b/web/pgadmin/browser/static/js/preferences.js @@ -80,32 +80,32 @@ _.extend(pgBrowser, { setTimeout(function() { $.ajax({ url: url_for('preferences.get_all'), - success: function(res) { - self.preferences_cache = res; - self.preference_version(self.generate_preference_version()); - - pgBrowser.keyboardNavigation.init(); - if(pgBrowser.tree) { - modifyAnimation.modifyAcitreeAnimation(self); - modifyAnimation.modifyAlertifyAnimation(self); + }) + .done(function(res) { + self.preferences_cache = res; + self.preference_version(self.generate_preference_version()); + + pgBrowser.keyboardNavigation.init(); + if(pgBrowser.tree) { + modifyAnimation.modifyAcitreeAnimation(self); + modifyAnimation.modifyAlertifyAnimation(self); + } + + /* Once the cache is loaded after changing the preferences, + * notify the modules of the change + */ + if(modulesChanged) { + if(typeof modulesChanged === 'string'){ + $.event.trigger('prefchange:'+modulesChanged); + } else { + _.each(modulesChanged, (val, key)=> { + $.event.trigger('prefchange:'+key); + }); } - - /* Once the cache is loaded after changing the preferences, - * notify the modules of the change - */ - if(modulesChanged) { - if(typeof modulesChanged === 'string'){ - $.event.trigger('prefchange:'+modulesChanged); - } else { - _.each(modulesChanged, (val, key)=> { - $.event.trigger('prefchange:'+key); - }); - } - } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); - }, + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); }); }, 500); }, diff --git a/web/pgadmin/dashboard/static/js/dashboard.js b/web/pgadmin/dashboard/static/js/dashboard.js index 5c812bf5..02c7d439 100644 --- a/web/pgadmin/dashboard/static/js/dashboard.js +++ b/web/pgadmin/dashboard/static/js/dashboard.js @@ -89,17 +89,17 @@ define('pgadmin.dashboard', [ $.ajax({ url: action_url, type: 'DELETE', - success: function(res) { - if (res == gettext('Success')) { - Alertify.success(txtSuccess); - refresh_grid(); - } else { - Alertify.error(txtError); - } - }, - error: function(xhr, status, error) { - Alertify.pgRespErrorNotify(xhr, error); - }, + }) + .done(function(res) { + if (res == gettext('Success')) { + Alertify.success(txtSuccess); + refresh_grid(); + } else { + Alertify.error(txtError); + } + }) + .fail(function(xhr, status, error) { + Alertify.pgRespErrorNotify(xhr, error); }); }, function() { @@ -214,14 +214,14 @@ define('pgadmin.dashboard', [ url: url, type: 'GET', dataType: 'html', - success: function(data) { - $(div).html(data); - }, - error: function() { - $(div).html( - '' - ); - }, + }) + .done(function(data) { + $(div).html(data); + }) + .fail(function() { + $(div).html( + '' + ); }); // Cache the current IDs for next time @@ -306,14 +306,14 @@ define('pgadmin.dashboard', [ url: url, type: 'GET', dataType: 'html', - success: function(data) { - $(div).html(data); - }, - error: function() { - $(div).html( - '' - ); - }, + }) + .done(function(data) { + $(div).html(data); + }) + .fail(function() { + $(div).html( + '' + ); }); $(dashboardPanel).data('server_status', true); } @@ -431,43 +431,43 @@ define('pgadmin.dashboard', [ url: path, type: 'GET', dataType: 'html', - success: function(resp) { - $(container).removeClass('graph-error'); - data = JSON.parse(resp); - pgAdmin.Dashboard.render_chart(container, data, dataset, sid, did, url, options, counter, refresh); - }, - error: function(xhr) { - let err = ''; - let msg = ''; - let cls = 'info'; - - if (xhr.readyState === 0) { - msg = gettext('Not connected to the server or the connection to the server has been closed.'); - } else { - err = JSON.parse(xhr.responseText); - msg = err.errormsg; - - // If we get a 428, it means the server isn't connected - if (xhr.status === 428) { - if (_.isUndefined(msg) || _.isNull(msg)) { - msg = gettext('Please connect to the selected server to view the graph.'); - } - } else { - msg = gettext('An error occurred whilst rendering the graph.'); - cls = 'danger'; + }) + .done(function(resp) { + $(container).removeClass('graph-error'); + data = JSON.parse(resp); + pgAdmin.Dashboard.render_chart(container, data, dataset, sid, did, url, options, counter, refresh); + }) + .fail(function(xhr) { + let err = ''; + let msg = ''; + let cls = 'info'; + + if (xhr.readyState === 0) { + msg = gettext('Not connected to the server or the connection to the server has been closed.'); + } else { + err = JSON.parse(xhr.responseText); + msg = err.errormsg; + + // If we get a 428, it means the server isn't connected + if (xhr.status === 428) { + if (_.isUndefined(msg) || _.isNull(msg)) { + msg = gettext('Please connect to the selected server to view the graph.'); } + } else { + msg = gettext('An error occurred whilst rendering the graph.'); + cls = 'danger'; } + } - $(container).addClass('graph-error'); - $(container).html( - '' - ); + $(container).addClass('graph-error'); + $(container).html( + '' + ); - // Try again... - if (container.clientHeight > 0 && container.clientWidth > 0) { - setTimeout(setTimeoutFunc, refresh * 1000); - } - }, + // Try again... + if (container.clientHeight > 0 && container.clientWidth > 0) { + setTimeout(setTimeoutFunc, refresh * 1000); + } }); }; diff --git a/web/pgadmin/misc/bgprocess/static/js/bgprocess.js b/web/pgadmin/misc/bgprocess/static/js/bgprocess.js index 0934ae40..986a5401 100644 --- a/web/pgadmin/misc/bgprocess/static/js/bgprocess.js +++ b/web/pgadmin/misc/bgprocess/static/js/bgprocess.js @@ -226,18 +226,18 @@ define('misc.bgprocess', [ cache: false, async: true, contentType: 'application/json', - success: function(res) { + }) + .done(function(res) { + setTimeout(function() { + self.update(res); + }, 10); + }) + .fail(function(res) { + // Try after some time only if job id present + if (res.status != 410) setTimeout(function() { self.update(res); - }, 10); - }, - error: function(res) { - // Try after some time only if job id present - if (res.status != 410) - setTimeout(function() { - self.update(res); - }, 10000); - }, + }, 10000); }); }, @@ -429,12 +429,12 @@ define('misc.bgprocess', [ cache: false, async: true, contentType: 'application/json', - success: function() { - return; - }, - error: function() { - console.warn(arguments); - }, + }) + .done(function() { + return; + }) + .fail(function() { + console.warn(arguments); }); }, }); @@ -478,31 +478,31 @@ define('misc.bgprocess', [ cache: false, async: true, contentType: 'application/json', - success: function(res) { - if (!res || !_.isArray(res)) { - return; - } - for (var idx in res) { - var process = res[idx]; - if ('id' in process) { - if (!(process.id in observer.bgprocesses)) { - observer.bgprocesses[process.id] = new BGProcess(process); - } + }) + .done(function(res) { + if (!res || !_.isArray(res)) { + return; + } + for (var idx in res) { + var process = res[idx]; + if ('id' in process) { + if (!(process.id in observer.bgprocesses)) { + observer.bgprocesses[process.id] = new BGProcess(process); } } - if (recheck && res.length == 0) { - // Recheck after some more time - setTimeout( - function() { - observer.update_process_list(false); - }, 3000 - ); - } - }, - error: function() { - // FIXME:: What to do now? - console.warn(arguments); - }, + } + if (recheck && res.length == 0) { + // Recheck after some more time + setTimeout( + function() { + observer.update_process_list(false); + }, 3000 + ); + } + }) + .fail(function() { + // FIXME:: What to do now? + console.warn(arguments); }); }, diff --git a/web/pgadmin/misc/file_manager/static/js/create_dialogue.js b/web/pgadmin/misc/file_manager/static/js/create_dialogue.js index 8deb7200..c640473a 100644 --- a/web/pgadmin/misc/file_manager/static/js/create_dialogue.js +++ b/web/pgadmin/misc/file_manager/static/js/create_dialogue.js @@ -82,14 +82,14 @@ module.exports = Alertify.dialog('createModeDlg', function() { dataType: 'json', contentType: 'application/x-download; charset=utf-8', async: false, - success: function(resp) { - var data = resp.data.result; - if (data['Code'] === 1) { - is_exist = true; - } else { - is_exist = false; - } - }, + }) + .done(function(resp) { + var data = resp.data.result; + if (data['Code'] === 1) { + is_exist = true; + } else { + is_exist = false; + } }); return is_exist; }, @@ -109,19 +109,19 @@ module.exports = Alertify.dialog('createModeDlg', function() { dataType: 'json', contentType: 'application/json; charset=utf-8', async: false, - success: function(resp) { - var data = resp.data.result; - if (data.Code === 1) { - permission = true; - } else { - $('.file_manager_ok').addClass('disabled'); - Alertify.error(data.Error); - } - }, - error: function() { + }) + .done(function(resp) { + var data = resp.data.result; + if (data.Code === 1) { + permission = true; + } else { $('.file_manager_ok').addClass('disabled'); - Alertify.error(gettext('Error occurred while checking access permission.')); - }, + Alertify.error(data.Error); + } + }) + .fail(function() { + $('.file_manager_ok').addClass('disabled'); + Alertify.error(gettext('Error occurred while checking access permission.')); }); return permission; }, diff --git a/web/pgadmin/misc/file_manager/static/js/utility.js b/web/pgadmin/misc/file_manager/static/js/utility.js index dc787e3f..14a5226a 100644 --- a/web/pgadmin/misc/file_manager/static/js/utility.js +++ b/web/pgadmin/misc/file_manager/static/js/utility.js @@ -242,40 +242,40 @@ define([ dataType: 'json', contentType: 'application/json; charset=utf-8', async: false, - success: function(resp) { - var result = resp.data.result; - if (result.Code === 1) { - var newPath = result['New Path'], - newName = result['New Name'], - title = $('#preview h1').attr('title'); - - if (typeof title != 'undefined' && title == oldPath) { - $('#preview h1').text(newName); - } + }) + .done(function(resp) { + var result = resp.data.result; + if (result.Code === 1) { + var newPath = result['New Path'], + newName = result['New Name'], + title = $('#preview h1').attr('title'); + + if (typeof title != 'undefined' && title == oldPath) { + $('#preview h1').text(newName); + } - if ($('.fileinfo').data('view') == 'grid') { - $('.fileinfo span[data-alt="' + oldPath + '"]').parent().next('p span').text(newName); - $('.fileinfo span[data-alt="' + oldPath + '"]').attr('data-alt', newPath); - } else { - $('.fileinfo td[title="' + oldPath + '"]').text(newName); - $('.fileinfo td[title="' + oldPath + '"]').attr('title', newPath); - } - $('#preview h1').html(newName); + if ($('.fileinfo').data('view') == 'grid') { + $('.fileinfo span[data-alt="' + oldPath + '"]').parent().next('p span').text(newName); + $('.fileinfo span[data-alt="' + oldPath + '"]').attr('data-alt', newPath); + } else { + $('.fileinfo td[title="' + oldPath + '"]').text(newName); + $('.fileinfo td[title="' + oldPath + '"]').attr('title', newPath); + } + $('#preview h1').html(newName); - // actualized data for binding - data.Path = newPath; - data.Filename = newName; + // actualized data for binding + data.Path = newPath; + data.Filename = newName; - // UnBind toolbar functions. - $('.fileinfo').find('button.rename, button.delete, button.download').off(); + // UnBind toolbar functions. + $('.fileinfo').find('button.rename, button.delete, button.download').off(); - Alertify.success(lg.successful_rename); - } else { - Alertify.error(result.Error); - } + Alertify.success(lg.successful_rename); + } else { + Alertify.error(result.Error); + } - finalName = result['New Name']; - }, + finalName = result['New Name']; }); } }; @@ -305,21 +305,21 @@ define([ dataType: 'json', contentType: 'application/json; charset=utf-8', async: false, - success: function(resp) { - var result = resp.data.result; - if (result.Code === 1) { - isDeleted = true; - if (isDeleted) { - Alertify.success(lg.successful_delete); - var rootpath = result.Path.substring(0, result.Path.length - 1); // removing the last slash - rootpath = rootpath.substr(0, rootpath.lastIndexOf('/') + 1); - getFolderInfo(rootpath); - } - } else { - isDeleted = false; - Alertify.error(result.Error); + }) + .done(function(resp) { + var result = resp.data.result; + if (result.Code === 1) { + isDeleted = true; + if (isDeleted) { + Alertify.success(lg.successful_delete); + var rootpath = result.Path.substring(0, result.Path.length - 1); // removing the last slash + rootpath = rootpath.substr(0, rootpath.lastIndexOf('/') + 1); + getFolderInfo(rootpath); } - }, + } else { + isDeleted = false; + Alertify.error(result.Error); + } }); return isDeleted; }; @@ -356,34 +356,34 @@ define([ dataType: 'json', contentType: 'application/json; charset=utf-8', async: false, - success: function(resp) { - var data = resp.data.result; - if (data.Code === 1) { - $('.file_manager_ok').removeClass('disabled'); - $('.file_manager_ok').attr('disabled', false); - data.Capabilities = capabilities; - bindToolbar(data); - if (data.FileType == 'Directory') { - // Enable/Disable level up button - enab_dis_level_up(); - $('.file_manager_ok').addClass('disabled'); - $('.file_manager_ok').attr('disabled', true); - $('.file_manager button.delete, .file_manager button.rename').attr('disabled', 'disabled'); - $('.file_manager button.download').attr('disabled', 'disabled'); + }) + .done(function(resp) { + var data = resp.data.result; + if (data.Code === 1) { + $('.file_manager_ok').removeClass('disabled'); + $('.file_manager_ok').attr('disabled', false); + data.Capabilities = capabilities; + bindToolbar(data); + if (data.FileType == 'Directory') { + // Enable/Disable level up button + enab_dis_level_up(); + $('.file_manager_ok').addClass('disabled'); + $('.file_manager_ok').attr('disabled', true); + $('.file_manager button.delete, .file_manager button.rename').attr('disabled', 'disabled'); + $('.file_manager button.download').attr('disabled', 'disabled'); - if (file.charAt(file.length - 1) != '/' && file.charAt(file.length - 1) != '\\') { - file += '/'; - } - getFolderInfo(file); - } else { - is_file_valid = true; + if (file.charAt(file.length - 1) != '/' && file.charAt(file.length - 1) != '\\') { + file += '/'; } + getFolderInfo(file); } else { - $('.file_manager_ok').addClass('disabled'); - $('.file_manager_ok').attr('disabled', true); - Alertify.error(data.Error); + is_file_valid = true; } - }, + } else { + $('.file_manager_ok').addClass('disabled'); + $('.file_manager_ok').attr('disabled', true); + Alertify.error(data.Error); + } }); return is_file_valid; }; @@ -402,23 +402,23 @@ define([ dataType: 'json', contentType: 'application/json; charset=utf-8', async: false, - success: function(resp) { - var data = resp.data.result; - if (data.Code === 1) { - permission = true; - } else { - $('.file_manager_ok').addClass('disabled'); - $('.file_manager_ok').attr('disabled', true); - Alertify.error(data.Error); - } - }, - error: function() { + }) + .done(function(resp) { + var data = resp.data.result; + if (data.Code === 1) { + permission = true; + } else { $('.file_manager_ok').addClass('disabled'); $('.file_manager_ok').attr('disabled', true); - Alertify.error( - gettext('Error occurred while checking access permission.') - ); - }, + Alertify.error(data.Error); + } + }) + .fail(function() { + $('.file_manager_ok').addClass('disabled'); + $('.file_manager_ok').attr('disabled', true); + Alertify.error( + gettext('Error occurred while checking access permission.') + ); }); return permission; }; @@ -488,515 +488,515 @@ define([ dataType: 'json', contentType: 'application/json; charset=utf-8', async: false, - success: function(resp) { - $('.storage_dialog #uploader .input-path').prop('disabled', false); - var result = '', - data = resp.data.result; - - // hide activity indicator - $('.fileinfo').find('span.activity').hide(); - if (data.Code === 0) { - Alertify.error(data.Error); - return; - } - - var $this, orig_value, newvalue; - - // generate HTML for files/folder and render into container - if (!_.isEmpty(data)) { - if ($('.fileinfo').data('view') == 'grid') { - result += '