Replace deprecated success, error callbacks in $.ajax call with new functions .done and .fail.

This commit is contained in:
Aditya Toshniwal 2018-07-09 13:54:00 +01:00 committed by Dave Page
parent 81312d17e2
commit 41a8333145
39 changed files with 2817 additions and 2821 deletions

View File

@ -201,17 +201,15 @@ define('pgadmin.node.cast', [
cache: false, cache: false,
async: false, async: false,
data: {'srctyp' : srcTyp, 'trgtyp' : trgtyp}, data: {'srctyp' : srcTyp, 'trgtyp' : trgtyp},
})
// On success return function list from server // On success return function list from server
success: function(result) { .done(function(result) {
res = result.data; res = result.data;
return res; return res;
}, })
// On failure show error appropriate error message to user
// On failure show error appropriate error message to user .fail(function(xhr, status, error) {
error: function(xhr, status, error) { alertify.pgRespErrorNotify(xhr, error);
alertify.pgRespErrorNotify(xhr, error);
},
}); });
} }
return res; return res;

View File

@ -350,17 +350,17 @@ define('pgadmin.node.foreign_table', [
async: false, async: false,
url: full_url, url: full_url,
data: data, data: data,
success: function(res) { })
/* .done(function(res) {
* We will cache this data for short period of time for avoiding /*
* same calls. * 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); */
data = cache_node.cache(url, node_info, cache_level, res.data);
}, })
error: function() { .fail(function() {
m.trigger('pgadmin:view:fetch:error', m, self.field); m.trigger('pgadmin:view:fetch:error', m, self.field);
},
}); });
m.trigger('pgadmin:view:fetched', m, self.field); m.trigger('pgadmin:view:fetched', m, self.field);

View File

@ -111,20 +111,20 @@ define('pgadmin.node.fts_configuration', [
$.ajax({ $.ajax({
async: false, async: false,
url: full_url, url: full_url,
success: function(res) { })
/* .done(function(res) {
* We will cache this data for short period of time for /*
* avoiding same calls. * We will cache this data for short period of time for
*/ * avoiding same calls.
data = cache_node.cache(url, */
node_info, data = cache_node.cache(url,
cache_level, node_info,
res.data cache_level,
); res.data
}, );
error: function() { })
m.trigger('pgadmin:view:fetch:error', m, self.field); .fail(function() {
}, m.trigger('pgadmin:view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin:view:fetched', m, self.field); m.trigger('pgadmin:view:fetched', m, self.field);
} }

View File

@ -31,12 +31,12 @@ define('pgadmin.node.schema', [
$.ajax({ $.ajax({
async: false, async: false,
url: full_url, url: full_url,
success: function (res) { })
data = res; .done(function (res) {
}, data = res;
error: function() { })
m.trigger('pgadmin-view:fetch:error', m, self.field); .fail(function() {
}, m.trigger('pgadmin-view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin-view:fetched', m, self.field); m.trigger('pgadmin-view:fetched', m, self.field);

View File

@ -154,17 +154,15 @@ define('pgadmin.node.synonym', [
cache: false, cache: false,
async: false, async: false,
data: {'trgTyp' : trgTyp, 'trgSchema' : trgSchema}, data: {'trgTyp' : trgTyp, 'trgSchema' : trgSchema},
})
// On success return function list from server // On success return function list from server
success: function(result) { .done(function(result) {
res = result.data; res = result.data;
return res; return res;
}, })
// On failure show error appropriate error message to user
// On failure show error appropriate error message to user .fail(function(xhr, status, error) {
error: function(xhr, status, error) { alertify.pgRespErrorNotify(xhr, error);
alertify.pgRespErrorNotify(xhr, error);
},
}); });
return res; return res;
}, },

View File

@ -61,21 +61,21 @@ define('pgadmin.node.check_constraint', [
$.ajax({ $.ajax({
url: obj.generate_url(i, 'validate', d, true), url: obj.generate_url(i, 'validate', d, true),
type:'GET', type:'GET',
success: function(res) { })
if (res.success == 1) { .done(function(res) {
alertify.success(res.info); if (res.success == 1) {
t.removeIcon(i); alertify.success(res.info);
data.valid = true; t.removeIcon(i);
data.icon = 'icon-check_constraint'; data.valid = true;
t.addIcon(i, {icon: data.icon}); data.icon = 'icon-check_constraint';
setTimeout(function() {t.deselect(i);}, 10); t.addIcon(i, {icon: data.icon});
setTimeout(function() {t.select(i);}, 100); setTimeout(function() {t.deselect(i);}, 10);
} setTimeout(function() {t.select(i);}, 100);
}, }
error: function(xhr, status, error) { })
alertify.pgRespErrorNotify(xhr, error); .fail(function(xhr, status, error) {
t.unload(i); alertify.pgRespErrorNotify(xhr, error);
}, t.unload(i);
}); });
return false; return false;

View File

@ -82,13 +82,13 @@ define('pgadmin.node.exclusion_constraint', [
async: false, async: false,
data : {indextype:indextype}, data : {indextype:indextype},
url: full_url, url: full_url,
success: function(res) { })
data = res.data; .done(function(res) {
self.column.set('options', data); data = res.data;
}, self.column.set('options', data);
error: function() { })
eventHandler.trigger('pgadmin:view:fetch:error', m, self.column); .fail(function() {
}, eventHandler.trigger('pgadmin:view:fetch:error', m, self.column);
}); });
eventHandler.trigger('pgadmin:view:fetched', m, self.column); eventHandler.trigger('pgadmin:view:fetched', m, self.column);
} }
@ -183,13 +183,13 @@ define('pgadmin.node.exclusion_constraint', [
async: false, async: false,
data : {col_type:col_type}, data : {col_type:col_type},
url: full_url, url: full_url,
success: function(res) { })
data = res.data; .done(function(res) {
self.column.set('options', data); data = res.data;
}, self.column.set('options', data);
error: function() { })
eventHandler.trigger('pgadmin:view:fetch:error', m, self.column); .fail(function() {
}, eventHandler.trigger('pgadmin:view:fetch:error', m, self.column);
}); });
eventHandler.trigger('pgadmin:view:fetched', m, self.column); eventHandler.trigger('pgadmin:view:fetched', m, self.column);
} }

View File

@ -214,12 +214,12 @@ define('pgadmin.node.foreign_key', [
async: false, async: false,
data : {tid:tid}, data : {tid:tid},
url: full_url, url: full_url,
success: function(res) { })
data = res.data; .done(function(res) {
}, data = res.data;
error: function() { })
m.trigger('pgadmin:view:fetch:error', m, self.field); .fail(function() {
}, m.trigger('pgadmin:view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin:view:fetched', m, self.field); m.trigger('pgadmin:view:fetched', m, self.field);
} }
@ -558,12 +558,12 @@ define('pgadmin.node.foreign_key', [
async: false, async: false,
data : {cols:JSON.stringify(cols)}, data : {cols:JSON.stringify(cols)},
url: full_url, url: full_url,
success: function(res) { })
coveringindex = res.data; .done(function(res) {
}, coveringindex = res.data;
error: function() { })
m.trigger('pgadmin:view:fetch:error', m, self.field); .fail(function() {
}, m.trigger('pgadmin:view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin:view:fetched', m, self.field); m.trigger('pgadmin:view:fetched', m, self.field);
} }
@ -653,21 +653,21 @@ define('pgadmin.node.foreign_key', [
$.ajax({ $.ajax({
url: obj.generate_url(i, 'validate', d, true), url: obj.generate_url(i, 'validate', d, true),
type:'GET', type:'GET',
success: function(res) { })
if (res.success == 1) { .done(function(res) {
Alertify.success(res.info); if (res.success == 1) {
t.removeIcon(i); Alertify.success(res.info);
data.valid = true; t.removeIcon(i);
data.icon = 'icon-foreign_key'; data.valid = true;
t.addIcon(i, {icon: data.icon}); data.icon = 'icon-foreign_key';
setTimeout(function() {t.deselect(i);}, 10); t.addIcon(i, {icon: data.icon});
setTimeout(function() {t.select(i);}, 100); setTimeout(function() {t.deselect(i);}, 10);
} setTimeout(function() {t.select(i);}, 100);
}, }
error: function(xhr, status, error) { })
Alertify.pgRespErrorNotify(xhr, error); .fail(function(xhr, status, error) {
t.unload(i); Alertify.pgRespErrorNotify(xhr, error);
}, t.unload(i);
}); });
return false; return false;

View File

@ -134,21 +134,21 @@ function(
type:'PUT', type:'PUT',
data: params, data: params,
dataType: 'json', dataType: 'json',
success: function(res) { })
if (res.success == 1) { .done(function(res) {
Alertify.success(res.info); if (res.success == 1) {
t.unload(i); Alertify.success(res.info);
t.setInode(i);
t.deselect(i);
setTimeout(function() {
t.select(i);
}, 10);
}
},
error: function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i); 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 */ /* Truncate table */
@ -182,25 +182,25 @@ function(
type:'PUT', type:'PUT',
data: params, data: params,
dataType: 'json', dataType: 'json',
success: function(res) { })
if (res.success == 1) { .done(function(res) {
Alertify.success(res.info); if (res.success == 1) {
t.removeIcon(i); Alertify.success(res.info);
data.icon = 'icon-partition'; t.removeIcon(i);
t.addIcon(i, {icon: data.icon}); data.icon = 'icon-partition';
t.unload(i); t.addIcon(i, {icon: data.icon});
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);
t.unload(i); 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() {} function() {}
@ -225,25 +225,25 @@ function(
$.ajax({ $.ajax({
url: obj.generate_url(i, 'reset' , d, true), url: obj.generate_url(i, 'reset' , d, true),
type:'DELETE', type:'DELETE',
success: function(res) { })
if (res.success == 1) { .done(function(res) {
Alertify.success(res.info); if (res.success == 1) {
t.removeIcon(i); Alertify.success(res.info);
data.icon = 'icon-partition'; t.removeIcon(i);
t.addIcon(i, {icon: data.icon}); data.icon = 'icon-partition';
t.unload(i); t.addIcon(i, {icon: data.icon});
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);
t.unload(i); 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({ $.ajax({
url: obj.generate_url(i, 'detach' , d, true), url: obj.generate_url(i, 'detach' , d, true),
type:'PUT', type:'PUT',
success: function(res) { })
if (res.success == 1) { .done(function(res) {
Alertify.success(res.info); if (res.success == 1) {
var n = t.next(i); Alertify.success(res.info);
var n = t.next(i);
if (!n || !n.length) {
n = t.prev(i);
if (!n || !n.length) { if (!n || !n.length) {
n = t.prev(i); n = t.parent(i);
if (!n || !n.length) { t.setInode(n, true);
n = t.parent(i);
t.setInode(n, true);
}
}
t.remove(i);
if (n.length) {
t.select(n);
} }
} }
}, t.remove(i);
error: function(xhr, status, error) { if (n.length) {
Alertify.pgRespErrorNotify(xhr, error); t.select(n);
}, }
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
}); });
} }
}, },
@ -874,19 +874,19 @@ function(
type: 'GET', type: 'GET',
async: false, async: false,
success: function(res) { })
if (res.success == 1) { .done(function(res) {
self.model.table_options = res.data; if (res.success == 1) {
} self.model.table_options = res.data;
else { }
Alertify.alert( else {
gettext('Error fetching tables to be attached'), res.data.result 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')); .fail(function(xhr, status, error) {
}, Alertify.pgRespErrorNotify(xhr, error, gettext('Error fetching tables to be attached'));
}); });
} }
}, },
@ -1148,12 +1148,12 @@ function(
async: false, async: false,
url: full_url, url: full_url,
data: arg, data: arg,
success: function(res) { })
data = cache_node.cache(url, node_info, cache_level, res.data); .done(function(res) {
}, data = cache_node.cache(url, node_info, cache_level, res.data);
error: function() { })
m.trigger('pgadmin:view:fetch:error', m, self.field); .fail(function() {
}, m.trigger('pgadmin:view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin:view:fetched', m, self.field); m.trigger('pgadmin:view:fetched', m, self.field);
data = (data && data.data) || []; data = (data && data.data) || [];

View File

@ -164,25 +164,25 @@ define('pgadmin.node.table', [
type:'PUT', type:'PUT',
data: params, data: params,
dataType: 'json', dataType: 'json',
success: function(res) { })
if (res.success == 1) { .done(function(res) {
Alertify.success(res.info); if (res.success == 1) {
t.removeIcon(i); Alertify.success(res.info);
data.icon = data.is_partitioned ? 'icon-partition': 'icon-table'; t.removeIcon(i);
t.addIcon(i, {icon: data.icon}); data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
t.unload(i); t.addIcon(i, {icon: data.icon});
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);
t.unload(i); 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() {} }, function() {}
@ -207,25 +207,25 @@ define('pgadmin.node.table', [
$.ajax({ $.ajax({
url: obj.generate_url(i, 'reset' , d, true), url: obj.generate_url(i, 'reset' , d, true),
type:'DELETE', type:'DELETE',
success: function(res) { })
if (res.success == 1) { .done(function(res) {
Alertify.success(res.info); if (res.success == 1) {
t.removeIcon(i); Alertify.success(res.info);
data.icon = data.is_partitioned ? 'icon-partition': 'icon-table'; t.removeIcon(i);
t.addIcon(i, {icon: data.icon}); data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
t.unload(i); t.addIcon(i, {icon: data.icon});
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);
t.unload(i); 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({ $.ajax({
url: obj.generate_url(i, 'count_rows' , d, true), url: obj.generate_url(i, 'count_rows' , d, true),
type:'GET', type:'GET',
success: function(res) { })
Alertify.success(res.info); .done(function(res) {
d.rows_cnt = res.data.total_rows; Alertify.success(res.info);
t.unload(i); d.rows_cnt = res.data.total_rows;
t.setInode(i); t.unload(i);
t.deselect(i); t.setInode(i);
setTimeout(function() { t.deselect(i);
t.select(i); setTimeout(function() {
}, 10); t.select(i);
}, }, 10);
error: function(xhr, status, error) { })
Alertify.pgRespErrorNotify(xhr, error); .fail(function(xhr, status, error) {
t.unload(i); Alertify.pgRespErrorNotify(xhr, error);
}, t.unload(i);
}); });
}, },
}, },
@ -983,19 +983,19 @@ define('pgadmin.node.table', [
type: 'GET', type: 'GET',
async: false, async: false,
success: function(res) { })
if (res.success == 1) { .done(function(res) {
self.model.table_options = res.data; if (res.success == 1) {
} self.model.table_options = res.data;
else { }
Alertify.alert( else {
gettext('Error fetching tables to be attached'), res.data.result Alertify.alert(
); gettext('Error fetching tables to be attached'), res.data.result
} );
}, }
error: function(xhr, status, error) { })
Alertify.pgRespErrorNotify(xhr, error); .fail(function(xhr, status, error) {
}, Alertify.pgRespErrorNotify(xhr, error);
}); });
} }
}, },
@ -1261,12 +1261,12 @@ define('pgadmin.node.table', [
async: false, async: false,
url: full_url, url: full_url,
data: arg, data: arg,
success: function(res) { })
data = cache_node.cache(url, node_info, cache_level, res.data); .done(function(res) {
}, data = cache_node.cache(url, node_info, cache_level, res.data);
error: function() { })
m.trigger('pgadmin:view:fetch:error', m, self.field); .fail(function() {
}, m.trigger('pgadmin:view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin:view:fetched', m, self.field); m.trigger('pgadmin:view:fetched', m, self.field);
data = (data && data.data) || []; data = (data && data.data) || [];

View File

@ -118,25 +118,25 @@ define('pgadmin.node.trigger', [
type:'PUT', type:'PUT',
data: {'enable' : true}, data: {'enable' : true},
dataType: 'json', dataType: 'json',
success: function(res) { })
if (res.success == 1) { .done(function(res) {
alertify.success(res.info); if (res.success == 1) {
t.removeIcon(i); alertify.success(res.info);
data.icon = 'icon-trigger'; t.removeIcon(i);
t.addIcon(i, {icon: data.icon}); data.icon = 'icon-trigger';
t.unload(i); t.addIcon(i, {icon: data.icon});
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);
t.unload(i); 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 */ /* Disable trigger */
@ -156,25 +156,25 @@ define('pgadmin.node.trigger', [
type:'PUT', type:'PUT',
data: {'enable' : false}, data: {'enable' : false},
dataType: 'json', dataType: 'json',
success: function(res) { })
if (res.success == 1) { .done(function(res) {
alertify.success(res.info); if (res.success == 1) {
t.removeIcon(i); alertify.success(res.info);
data.icon = 'icon-trigger-bad'; t.removeIcon(i);
t.addIcon(i, {icon: data.icon}); data.icon = 'icon-trigger-bad';
t.unload(i); t.addIcon(i, {icon: data.icon});
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'));
t.unload(i); 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);
}); });
}, },
}, },

View File

@ -423,12 +423,12 @@ define('pgadmin.node.type', [
url: _url, url: _url,
cache: false, cache: false,
data: {'typname' : l_typname}, data: {'typname' : l_typname},
success: function(res) { })
result = res.data; .done(function(res) {
}, result = res.data;
error: function() { })
self.model.trigger('pgadmin:view:fetch:error', self.model, self.field); .fail(function() {
}, self.model.trigger('pgadmin:view:fetch:error', self.model, self.field);
}); });
// //
} }
@ -491,13 +491,13 @@ define('pgadmin.node.type', [
url: _url, url: _url,
cache: false, cache: false,
data: {'name' : name}, data: {'name' : name},
success: function(res) { })
result = res.data; .done(function(res) {
}, result = res.data;
error: function() { })
self.model.trigger('pgadmin:view:fetch:error', .fail(function() {
self.model, self.field); self.model.trigger('pgadmin:view:fetch:error',
}, self.model, self.field);
}); });
} }
return result; return result;
@ -527,13 +527,13 @@ define('pgadmin.node.type', [
url: _url, url: _url,
cache: false, cache: false,
data: {'typname' : l_typname, 'opcname': l_opcname}, data: {'typname' : l_typname, 'opcname': l_opcname},
success: function(res) { })
result = res.data; .done(function(res) {
}, result = res.data;
error: function() { })
self.model.trigger('pgadmin:view:fetch:error', .fail(function() {
self.model, self.field); self.model.trigger('pgadmin:view:fetch:error',
}, self.model, self.field);
}); });
} }
return result; return result;

View File

@ -253,20 +253,20 @@ define('pgadmin.node.mview', [
type: 'PUT', type: 'PUT',
data: {'concurrent': args.concurrent, 'with_data': args.with_data}, data: {'concurrent': args.concurrent, 'with_data': args.with_data},
dataType: 'json', dataType: 'json',
success: function(res) { })
if (res.success == 1) { .done(function(res) {
Alertify.success(gettext('View refreshed successfully')); if (res.success == 1) {
} Alertify.success(gettext('View refreshed successfully'));
else { }
Alertify.alert( else {
gettext('Error refreshing view'), Alertify.alert(
res.data.result gettext('Error refreshing view'),
); res.data.result
} );
}, }
error: function(xhr, status, error) { })
Alertify.pgRespErrorNotify(xhr, error, gettext('Error refreshing view')); .fail(function(xhr, status, error) {
}, Alertify.pgRespErrorNotify(xhr, error, gettext('Error refreshing view'));
}); });
}, },

View File

@ -185,33 +185,33 @@ define('pgadmin.node.database', [
$.ajax({ $.ajax({
url: obj.generate_url(i, 'connect', d, true), url: obj.generate_url(i, 'connect', d, true),
type:'DELETE', type:'DELETE',
success: function(res) { })
if (res.success == 1) { .done(function(res) {
var prv_i = t.parent(i); if (res.success == 1) {
Alertify.success(res.info); var prv_i = t.parent(i);
t.removeIcon(i); Alertify.success(res.info);
data.connected = false; t.removeIcon(i);
data.icon = 'icon-database-not-connected'; data.connected = false;
t.addIcon(i, {icon: data.icon}); data.icon = 'icon-database-not-connected';
t.unload(i); t.addIcon(i, {icon: data.icon});
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);
}
},
error: function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i); 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);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i);
}); });
}, },
function() { return true; }); function() { return true; });

View File

@ -172,13 +172,13 @@ define('pgadmin.node.pga_job', [
$.ajax({ $.ajax({
url: obj.generate_url(i, 'run_now', d, true), url: obj.generate_url(i, 'run_now', d, true),
method:'PUT', method:'PUT',
// 'pgagent.pga_job' table updated with current time to run the job })
// now. // 'pgagent.pga_job' table updated with current time to run the job
success: function() { t.unload(i); }, // now.
error: function(xhr, status, error) { .done(function() { t.unload(i); })
alertify.pgRespErrorNotify(xhr, error); .fail(function(xhr, status, error) {
t.unload(i); alertify.pgRespErrorNotify(xhr, error);
}, t.unload(i);
}); });
return false; return false;

View File

@ -189,38 +189,38 @@ define('pgadmin.node.server', [
$.ajax({ $.ajax({
url: obj.generate_url(i, 'connect', d, true), url: obj.generate_url(i, 'connect', d, true),
type:'DELETE', type:'DELETE',
success: function(res) { })
if (res.success == 1) { .done(function(res) {
Alertify.success(res.info); if (res.success == 1) {
d = t.itemData(i); Alertify.success(res.info);
t.removeIcon(i); d = t.itemData(i);
d.connected = false; t.removeIcon(i);
d.icon = 'icon-server-not-connected'; d.connected = false;
t.addIcon(i, {icon: d.icon}); d.icon = 'icon-server-not-connected';
obj.callbacks.refresh.apply(obj, [null, i]); t.addIcon(i, {icon: d.icon});
if (pgBrowser.serverInfo && d._id in pgBrowser.serverInfo) { obj.callbacks.refresh.apply(obj, [null, i]);
delete pgBrowser.serverInfo[d._id]; 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
);
} }
else { pgBrowser.enable_disable_menus(i);
try { // Trigger server disconnect event
Alertify.error(res.errormsg); pgBrowser.Events.trigger(
} catch (e) { 'pgadmin:server:disconnect',
console.warn(e.stack || e); {item: i, data: d}, false
} );
t.unload(i); }
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); t.unload(i);
}, }
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i);
}); });
}; };
@ -284,18 +284,18 @@ define('pgadmin.node.server', [
$.ajax({ $.ajax({
url: obj.generate_url(i, 'reload', d, true), url: obj.generate_url(i, 'reload', d, true),
method:'GET', method:'GET',
success: function(res) { })
if (res.data.status) { .done(function(res) {
Alertify.success(res.data.result); if (res.data.status) {
} Alertify.success(res.data.result);
else { }
Alertify.error(res.data.result); else {
} Alertify.error(res.data.result);
}, }
error: function(xhr, status, error) { })
Alertify.pgRespErrorNotify(xhr, error); .fail(function(xhr, status, error) {
t.unload(i); Alertify.pgRespErrorNotify(xhr, error);
}, t.unload(i);
}); });
}, },
function() { return true; } function() { return true; }
@ -325,13 +325,13 @@ define('pgadmin.node.server', [
url: obj.generate_url(i, 'restore_point', d, true), url: obj.generate_url(i, 'restore_point', d, true),
method:'POST', method:'POST',
data:{ 'value': JSON.stringify(value) }, data:{ 'value': JSON.stringify(value) },
success: function(res) { })
Alertify.success(res.data.result, 10); .done(function(res) {
}, Alertify.success(res.data.result, 10);
error: function(xhr, status, error) { })
Alertify.pgRespErrorNotify(xhr, error); .fail(function(xhr, status, error) {
t.unload(i); Alertify.pgRespErrorNotify(xhr, error);
}, t.unload(i);
}); });
} else { } else {
evt.cancel = true; evt.cancel = true;
@ -481,27 +481,27 @@ define('pgadmin.node.server', [
url: url, url: url,
method:'POST', method:'POST',
data:{'data': JSON.stringify(args) }, data:{'data': JSON.stringify(args) },
success: function(res) { })
if (res.success) { .done(function(res) {
// Notify user to update pgpass file if (res.success) {
if(is_pgpass_file_used) { // Notify user to update pgpass file
Alertify.alert( if(is_pgpass_file_used) {
gettext('Change Password'), Alertify.alert(
gettext('Please make sure to disconnect the server' gettext('Change Password'),
+ ' and update the new password in the pgpass file' gettext('Please make sure to disconnect the server'
+ ' before performing any other operation') + ' 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);
} }
},
error: function(xhr, status, error) { Alertify.success(res.info);
Alertify.pgRespErrorNotify(xhr, error); 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({ $.ajax({
url: check_pgpass_url, url: check_pgpass_url,
method:'GET', method:'GET',
success: function(res) { })
if (res.success && res.data.is_pgpass) { .done(function(res) {
is_pgpass_file_used = true; if (res.success && res.data.is_pgpass) {
} is_pgpass_file_used = true;
Alertify.changeServerPassword(d).resizeTo('40%','52%'); }
}, Alertify.changeServerPassword(d).resizeTo('40%','52%');
error: function(xhr, status, error) { })
Alertify.pgRespErrorNotify(xhr, error); .fail(function(xhr, status, error) {
}, Alertify.pgRespErrorNotify(xhr, error);
}); });
return false; return false;
@ -542,23 +542,23 @@ define('pgadmin.node.server', [
url: obj.generate_url(i, 'wal_replay' , d, true), url: obj.generate_url(i, 'wal_replay' , d, true),
type:'DELETE', type:'DELETE',
dataType: 'json', dataType: 'json',
success: function(res) { })
if (res.success == 1) { .done(function(res) {
Alertify.success(res.info); if (res.success == 1) {
t.itemData(i).wal_pause=res.data.wal_pause; Alertify.success(res.info);
t.unload(i); t.itemData(i).wal_pause=res.data.wal_pause;
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);
t.unload(i); 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), url: obj.generate_url(i, 'wal_replay' , d, true),
type:'PUT', type:'PUT',
dataType: 'json', dataType: 'json',
success: function(res) { })
if (res.success == 1) { .done(function(res) {
Alertify.success(res.info); if (res.success == 1) {
t.itemData(i).wal_pause=res.data.wal_pause; Alertify.success(res.info);
t.unload(i); t.itemData(i).wal_pause=res.data.wal_pause;
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);
t.unload(i); 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, timeout: 30000,
url: _url, url: _url,
data: $('#frmPassword').serialize(), data: $('#frmPassword').serialize(),
success: function(res) { })
return _onSuccess( .done(function(res) {
res, _node, _data, _tree, _item, _status return _onSuccess(
); res, _node, _data, _tree, _item, _status
}, );
error: function(xhr, status, error) { })
return _onFailure( .fail(function(xhr, status, error) {
xhr, status, error, _node, _data, _tree, _item, _status return _onFailure(
); xhr, status, error, _node, _data, _tree, _item, _status
}, );
}); });
} else { } else {
_onCancel && typeof(_onCancel) == 'function' && _onCancel && typeof(_onCancel) == 'function' &&

View File

@ -303,12 +303,12 @@ define([
$.ajax({ $.ajax({
async: false, async: false,
url: full_url, url: full_url,
success: function (res) { })
data = res.data; .done(function (res) {
}, data = res.data;
error: function() { })
m.trigger('pgadmin-view:fetch:error', m, self.field); .fail(function() {
}, m.trigger('pgadmin-view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin-view:fetched', m, self.field); m.trigger('pgadmin-view:fetched', m, self.field);

View File

@ -277,17 +277,17 @@ define('pgadmin.node.tablespace', [
url: url, url: url,
method:'PUT', method:'PUT',
data:{'data': JSON.stringify(args) }, data:{'data': JSON.stringify(args) },
success: function(res) { })
if (res.success) { .done(function(res) {
Alertify.success(res.info); if (res.success) {
self.close(); Alertify.success(res.info);
} else { self.close();
Alertify.error(res.errormsg); } else {
} Alertify.error(res.errormsg);
}, }
error: function(xhr, status, error) { })
Alertify.pgRespErrorNotify(xhr, error); .fail(function(xhr, status, error) {
}, Alertify.pgRespErrorNotify(xhr, error);
}); });
}, },
function() { function() {

View File

@ -503,9 +503,9 @@ define('pgadmin.browser', [
$.ajax({ $.ajax({
url: url_for('misc.cleanup'), url: url_for('misc.cleanup'),
type:'POST', type:'POST',
success: function() {}, })
error: function() {}, .done(function() {})
}); .fail(function() {});
}, 300000); }, 300000);
obj.Events.on('pgadmin:browser:tree:add', obj.onAddTreeNode, obj); obj.Events.on('pgadmin:browser:tree:add', obj.onAddTreeNode, obj);
obj.Events.on('pgadmin:browser:tree:update', obj.onUpdateTreeNode, obj); obj.Events.on('pgadmin:browser:tree:update', obj.onUpdateTreeNode, obj);
@ -1539,69 +1539,69 @@ define('pgadmin.browser', [
type: 'GET', type: 'GET',
cache: false, cache: false,
dataType: 'json', dataType: 'json',
success: function(res) { })
// Node information can come as result/data .done(function(res) {
var data = res.result || res.data; // Node information can come as result/data
var data = res.result || res.data;
data._label = data.label; data._label = data.label;
data.label = _.escape(data.label); data.label = _.escape(data.label);
var d = ctx.t.itemData(ctx.i); var d = ctx.t.itemData(ctx.i);
_.extend(d, data); _.extend(d, data);
ctx.t.setLabel(ctx.i, {label: _d.label}); ctx.t.setLabel(ctx.i, {label: _d.label});
ctx.t.addIcon(ctx.i, {icon: _d.icon}); ctx.t.addIcon(ctx.i, {icon: _d.icon});
ctx.t.setId(ctx.i, {id: _d.id}); ctx.t.setId(ctx.i, {id: _d.id});
ctx.t.setInode(ctx.i, {inode: data.inode}); ctx.t.setInode(ctx.i, {inode: data.inode});
if ( if (
_n.can_expand && typeof(_n.can_expand) == 'function' _n.can_expand && typeof(_n.can_expand) == 'function'
) { ) {
if (!_n.can_expand(d)) { if (!_n.can_expand(d)) {
ctx.t.unload(ctx.i); ctx.t.unload(ctx.i);
return; return;
}
} }
ctx.b._refreshNode(ctx, ctx.branch); }
var success = (ctx.o && ctx.o.success) || ctx.success; ctx.b._refreshNode(ctx, ctx.branch);
if (success && typeof(success) == 'function') { var success = (ctx.o && ctx.o.success) || ctx.success;
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);
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); }
}
},
});
} }
},
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)
) || {};
if (xhr.status == 410 && jsonResp.success == 0) { Alertify.pgNotifier(
var p = ctx.t.parent(ctx.i); 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); }.bind(this);
@ -1786,16 +1786,16 @@ define('pgadmin.browser', [
$.ajax({ $.ajax({
url: childNodeUrl, url: childNodeUrl,
dataType: 'json', dataType: 'json',
success: function(res) { })
if (res.success) { .done(function(res) {
arrayChildNodeData.push(res.data); if (res.success) {
} arrayChildNodeData.push(res.data);
fetchNodeInfo(_callback); }
}, fetchNodeInfo(_callback);
error: function(xhr, status, error) { })
Alertify.pgRespErrorNotify(xhr, error); .fail(function(xhr, status, error) {
fetchNodeInfo(_callback); Alertify.pgRespErrorNotify(xhr, error);
}, fetchNodeInfo(_callback);
}); });
}; };

View File

@ -729,30 +729,30 @@ define('pgadmin.browser.node', [
$.ajax({ $.ajax({
url: obj.generate_url(i, input.url, d, true), url: obj.generate_url(i, input.url, d, true),
type: 'DELETE', type: 'DELETE',
success: function(res) { })
if (res.success == 0) { .done(function(res) {
pgBrowser.report_error(res.errormsg, res.info); if (res.success == 0) {
} else { pgBrowser.report_error(res.errormsg, res.info);
pgBrowser.removeTreeNode(i, true); } 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);
} }
return true; }
}, pgBrowser.report_error(
error: function(jqx) { S(gettext('Error dropping %s: "%s"'))
var msg = jqx.responseText; .sprintf(obj.label, objName)
/* Error from the server */ .value(), msg);
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);
},
}); });
}, },
null).show(); null).show();

View File

@ -146,16 +146,16 @@ define([
$.ajax({ $.ajax({
async: false, async: false,
url: full_url, url: full_url,
success: function(res) { })
/* .done(function(res) {
* We will cache this data for short period of time for avoiding /*
* same calls. * 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); */
}, data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data);
error: function() { })
m.trigger('pgadmin:view:fetch:error', m, self.field); .fail(function() {
}, m.trigger('pgadmin:view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin:view:fetched', m, self.field); m.trigger('pgadmin:view:fetched', m, self.field);
} }
@ -387,16 +387,16 @@ define([
$.ajax({ $.ajax({
async: false, async: false,
url: full_url, url: full_url,
success: function(res) { })
/* .done(function(res) {
* We will cache this data for short period of time for avoiding /*
* same calls. * 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); */
}, data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data);
error: function() { })
eventHandler.trigger('pgadmin:view:fetch:error', m, column); .fail(function() {
}, eventHandler.trigger('pgadmin:view:fetch:error', m, column);
}); });
eventHandler.trigger('pgadmin:view:fetched', m, column); eventHandler.trigger('pgadmin:view:fetched', m, column);
} }
@ -559,4 +559,4 @@ define([
}); });
return Backform; return Backform;
}); });

View File

@ -80,32 +80,32 @@ _.extend(pgBrowser, {
setTimeout(function() { setTimeout(function() {
$.ajax({ $.ajax({
url: url_for('preferences.get_all'), url: url_for('preferences.get_all'),
success: function(res) { })
self.preferences_cache = res; .done(function(res) {
self.preference_version(self.generate_preference_version()); self.preferences_cache = res;
self.preference_version(self.generate_preference_version());
pgBrowser.keyboardNavigation.init(); pgBrowser.keyboardNavigation.init();
if(pgBrowser.tree) { if(pgBrowser.tree) {
modifyAnimation.modifyAcitreeAnimation(self); modifyAnimation.modifyAcitreeAnimation(self);
modifyAnimation.modifyAlertifyAnimation(self); modifyAnimation.modifyAlertifyAnimation(self);
} }
/* Once the cache is loaded after changing the preferences, /* Once the cache is loaded after changing the preferences,
* notify the modules of the change * notify the modules of the change
*/ */
if(modulesChanged) { if(modulesChanged) {
if(typeof modulesChanged === 'string'){ if(typeof modulesChanged === 'string'){
$.event.trigger('prefchange:'+modulesChanged); $.event.trigger('prefchange:'+modulesChanged);
} else { } else {
_.each(modulesChanged, (val, key)=> { _.each(modulesChanged, (val, key)=> {
$.event.trigger('prefchange:'+key); $.event.trigger('prefchange:'+key);
}); });
}
} }
}, }
error: function(xhr, status, error) { })
Alertify.pgRespErrorNotify(xhr, error); .fail(function(xhr, status, error) {
}, Alertify.pgRespErrorNotify(xhr, error);
}); });
}, 500); }, 500);
}, },

View File

@ -89,17 +89,17 @@ define('pgadmin.dashboard', [
$.ajax({ $.ajax({
url: action_url, url: action_url,
type: 'DELETE', type: 'DELETE',
success: function(res) { })
if (res == gettext('Success')) { .done(function(res) {
Alertify.success(txtSuccess); if (res == gettext('Success')) {
refresh_grid(); Alertify.success(txtSuccess);
} else { refresh_grid();
Alertify.error(txtError); } else {
} Alertify.error(txtError);
}, }
error: function(xhr, status, error) { })
Alertify.pgRespErrorNotify(xhr, error); .fail(function(xhr, status, error) {
}, Alertify.pgRespErrorNotify(xhr, error);
}); });
}, },
function() { function() {
@ -214,14 +214,14 @@ define('pgadmin.dashboard', [
url: url, url: url,
type: 'GET', type: 'GET',
dataType: 'html', dataType: 'html',
success: function(data) { })
$(div).html(data); .done(function(data) {
}, $(div).html(data);
error: function() { })
$(div).html( .fail(function() {
'<div class="alert alert-danger pg-panel-message" role="alert">' + gettext('An error occurred whilst loading the dashboard.') + '</div>' $(div).html(
); '<div class="alert alert-danger pg-panel-message" role="alert">' + gettext('An error occurred whilst loading the dashboard.') + '</div>'
}, );
}); });
// Cache the current IDs for next time // Cache the current IDs for next time
@ -306,14 +306,14 @@ define('pgadmin.dashboard', [
url: url, url: url,
type: 'GET', type: 'GET',
dataType: 'html', dataType: 'html',
success: function(data) { })
$(div).html(data); .done(function(data) {
}, $(div).html(data);
error: function() { })
$(div).html( .fail(function() {
'<div class="alert alert-danger pg-panel-message" role="alert">' + gettext('An error occurred whilst loading the dashboard.') + '</div>' $(div).html(
); '<div class="alert alert-danger pg-panel-message" role="alert">' + gettext('An error occurred whilst loading the dashboard.') + '</div>'
}, );
}); });
$(dashboardPanel).data('server_status', true); $(dashboardPanel).data('server_status', true);
} }
@ -431,43 +431,43 @@ define('pgadmin.dashboard', [
url: path, url: path,
type: 'GET', type: 'GET',
dataType: 'html', dataType: 'html',
success: function(resp) { })
$(container).removeClass('graph-error'); .done(function(resp) {
data = JSON.parse(resp); $(container).removeClass('graph-error');
pgAdmin.Dashboard.render_chart(container, data, dataset, sid, did, url, options, counter, refresh); data = JSON.parse(resp);
}, pgAdmin.Dashboard.render_chart(container, data, dataset, sid, did, url, options, counter, refresh);
error: function(xhr) { })
let err = ''; .fail(function(xhr) {
let msg = ''; let err = '';
let cls = 'info'; let msg = '';
let cls = 'info';
if (xhr.readyState === 0) { if (xhr.readyState === 0) {
msg = gettext('Not connected to the server or the connection to the server has been closed.'); msg = gettext('Not connected to the server or the connection to the server has been closed.');
} else { } else {
err = JSON.parse(xhr.responseText); err = JSON.parse(xhr.responseText);
msg = err.errormsg; msg = err.errormsg;
// If we get a 428, it means the server isn't connected // If we get a 428, it means the server isn't connected
if (xhr.status === 428) { if (xhr.status === 428) {
if (_.isUndefined(msg) || _.isNull(msg)) { if (_.isUndefined(msg) || _.isNull(msg)) {
msg = gettext('Please connect to the selected server to view the graph.'); msg = gettext('Please connect to the selected server to view the graph.');
}
} else {
msg = gettext('An error occurred whilst rendering the graph.');
cls = 'danger';
} }
} else {
msg = gettext('An error occurred whilst rendering the graph.');
cls = 'danger';
} }
}
$(container).addClass('graph-error'); $(container).addClass('graph-error');
$(container).html( $(container).html(
'<div class="alert alert-' + cls + ' pg-panel-message" role="alert">' + msg + '</div>' '<div class="alert alert-' + cls + ' pg-panel-message" role="alert">' + msg + '</div>'
); );
// Try again... // Try again...
if (container.clientHeight > 0 && container.clientWidth > 0) { if (container.clientHeight > 0 && container.clientWidth > 0) {
setTimeout(setTimeoutFunc, refresh * 1000); setTimeout(setTimeoutFunc, refresh * 1000);
} }
},
}); });
}; };

View File

@ -226,18 +226,18 @@ define('misc.bgprocess', [
cache: false, cache: false,
async: true, async: true,
contentType: 'application/json', 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() { setTimeout(function() {
self.update(res); self.update(res);
}, 10); }, 10000);
},
error: function(res) {
// Try after some time only if job id present
if (res.status != 410)
setTimeout(function() {
self.update(res);
}, 10000);
},
}); });
}, },
@ -429,12 +429,12 @@ define('misc.bgprocess', [
cache: false, cache: false,
async: true, async: true,
contentType: 'application/json', contentType: 'application/json',
success: function() { })
return; .done(function() {
}, return;
error: function() { })
console.warn(arguments); .fail(function() {
}, console.warn(arguments);
}); });
}, },
}); });
@ -478,31 +478,31 @@ define('misc.bgprocess', [
cache: false, cache: false,
async: true, async: true,
contentType: 'application/json', contentType: 'application/json',
success: function(res) { })
if (!res || !_.isArray(res)) { .done(function(res) {
return; if (!res || !_.isArray(res)) {
} return;
for (var idx in res) { }
var process = res[idx]; for (var idx in res) {
if ('id' in process) { var process = res[idx];
if (!(process.id in observer.bgprocesses)) { if ('id' in process) {
observer.bgprocesses[process.id] = new BGProcess(process); if (!(process.id in observer.bgprocesses)) {
} observer.bgprocesses[process.id] = new BGProcess(process);
} }
} }
if (recheck && res.length == 0) { }
// Recheck after some more time if (recheck && res.length == 0) {
setTimeout( // Recheck after some more time
function() { setTimeout(
observer.update_process_list(false); function() {
}, 3000 observer.update_process_list(false);
); }, 3000
} );
}, }
error: function() { })
// FIXME:: What to do now? .fail(function() {
console.warn(arguments); // FIXME:: What to do now?
}, console.warn(arguments);
}); });
}, },

View File

@ -82,14 +82,14 @@ module.exports = Alertify.dialog('createModeDlg', function() {
dataType: 'json', dataType: 'json',
contentType: 'application/x-download; charset=utf-8', contentType: 'application/x-download; charset=utf-8',
async: false, async: false,
success: function(resp) { })
var data = resp.data.result; .done(function(resp) {
if (data['Code'] === 1) { var data = resp.data.result;
is_exist = true; if (data['Code'] === 1) {
} else { is_exist = true;
is_exist = false; } else {
} is_exist = false;
}, }
}); });
return is_exist; return is_exist;
}, },
@ -109,19 +109,19 @@ module.exports = Alertify.dialog('createModeDlg', function() {
dataType: 'json', dataType: 'json',
contentType: 'application/json; charset=utf-8', contentType: 'application/json; charset=utf-8',
async: false, async: false,
success: function(resp) { })
var data = resp.data.result; .done(function(resp) {
if (data.Code === 1) { var data = resp.data.result;
permission = true; if (data.Code === 1) {
} else { permission = true;
$('.file_manager_ok').addClass('disabled'); } else {
Alertify.error(data.Error);
}
},
error: function() {
$('.file_manager_ok').addClass('disabled'); $('.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; return permission;
}, },

File diff suppressed because it is too large Load Diff

View File

@ -105,30 +105,30 @@ define('misc.sql', [
); );
}, 1000); }, 1000);
}, },
success: function(res) { })
if (pgAdmin.Browser.editor.getValue() != res) { .done(function(res) {
pgAdmin.Browser.editor.setValue(res); if (pgAdmin.Browser.editor.getValue() != res) {
} pgAdmin.Browser.editor.setValue(res);
clearTimeout(timer); }
}, clearTimeout(timer);
error: function(xhr, error, message) { })
var _label = treeHierarchy[n_type].label; .fail(function(xhr, error, message) {
pgBrowser.Events.trigger( var _label = treeHierarchy[n_type].label;
'pgadmin:node:retrieval:error', 'sql', xhr, error, message, item pgBrowser.Events.trigger(
'pgadmin:node:retrieval:error', 'sql', xhr, error, message, item
);
if (!Alertify.pgHandleItemError(xhr, error, message, {
item: item,
info: treeHierarchy,
})) {
Alertify.pgNotifier(
error, xhr,
S(gettext('Error retrieving the information - %s')).sprintf(
message || _label
).value(),
function() {}
); );
if (!Alertify.pgHandleItemError(xhr, error, message, { }
item: item,
info: treeHierarchy,
})) {
Alertify.pgNotifier(
error, xhr,
S(gettext('Error retrieving the information - %s')).sprintf(
message || _label
).value(),
function() {}
);
}
},
}); });
} }
} }

View File

@ -229,65 +229,65 @@ define('misc.statistics', [
} }
}, 1000); }, 1000);
}, },
success: function(res) { })
// clear timer and reset message. .done(function(res) {
clearTimeout(timer); // clear timer and reset message.
$msgContainer.text(''); clearTimeout(timer);
if (res.data) { $msgContainer.text('');
var data = res.data; if (res.data) {
if (node.hasCollectiveStatistics || data['rows'].length > 1) { var data = res.data;
self.__createMultiLineStatistics.call(self, data, node.statsPrettifyFields); if (node.hasCollectiveStatistics || data['rows'].length > 1) {
} else { self.__createMultiLineStatistics.call(self, data, node.statsPrettifyFields);
self.__createSingleLineStatistics.call(self, data, node.statsPrettifyFields); } else {
} self.__createSingleLineStatistics.call(self, data, node.statsPrettifyFields);
if (self.grid) {
delete self.grid;
self.grid = null;
}
self.grid = new Backgrid.Grid({
columns: self.columns,
collection: self.collection,
className: GRID_CLASSES,
});
self.grid.render();
$gridContainer.empty();
$gridContainer.append(self.grid.$el);
if (!$msgContainer.hasClass('hidden')) {
$msgContainer.addClass('hidden');
}
$gridContainer.removeClass('hidden');
} else if (res.info) {
if (!$gridContainer.hasClass('hidden')) {
$gridContainer.addClass('hidden');
}
$msgContainer.text(res.info);
$msgContainer.removeClass('hidden');
} }
},
error: function(xhr, error, message) { if (self.grid) {
var _label = treeHierarchy[n_type].label; delete self.grid;
pgBrowser.Events.trigger( self.grid = null;
'pgadmin:node:retrieval:error', 'statistics', xhr, error, message, item }
self.grid = new Backgrid.Grid({
columns: self.columns,
collection: self.collection,
className: GRID_CLASSES,
});
self.grid.render();
$gridContainer.empty();
$gridContainer.append(self.grid.$el);
if (!$msgContainer.hasClass('hidden')) {
$msgContainer.addClass('hidden');
}
$gridContainer.removeClass('hidden');
} else if (res.info) {
if (!$gridContainer.hasClass('hidden')) {
$gridContainer.addClass('hidden');
}
$msgContainer.text(res.info);
$msgContainer.removeClass('hidden');
}
})
.fail(function(xhr, error, message) {
var _label = treeHierarchy[n_type].label;
pgBrowser.Events.trigger(
'pgadmin:node:retrieval:error', 'statistics', xhr, error, message, item
);
if (!Alertify.pgHandleItemError(xhr, error, message, {
item: item,
info: treeHierarchy,
})) {
Alertify.pgNotifier(
error, xhr,
S(gettext('Error retrieving the information - %s')).sprintf(
message || _label
).value(),
function() {}
); );
if (!Alertify.pgHandleItemError(xhr, error, message, { }
item: item, // show failed message.
info: treeHierarchy, $msgContainer.text(gettext('Failed to retrieve data from the server.'));
})) {
Alertify.pgNotifier(
error, xhr,
S(gettext('Error retrieving the information - %s')).sprintf(
message || _label
).value(),
function() {}
);
}
// show failed message.
$msgContainer.text(gettext('Failed to retrieve data from the server.'));
},
}); });
} }
} }

View File

@ -33,18 +33,18 @@ define('pgadmin.settings', [
url: url_for('settings.reset_layout'), url: url_for('settings.reset_layout'),
type: 'DELETE', type: 'DELETE',
async: false, async: false,
success: function() { })
// Prevent saving layout on server for next page reload. .done(function() {
$(window).unbind('unload'); // Prevent saving layout on server for next page reload.
window.onbeforeunload = null; $(window).unbind('unload');
// Now reload page window.onbeforeunload = null;
location.reload(true); // Now reload page
}, location.reload(true);
error: function() { })
console.warn( .fail(function() {
'Something went wrong on server while resetting layout.' console.warn(
); 'Something went wrong on server while resetting layout.'
}, );
}); });
}, },

View File

@ -337,25 +337,25 @@ define([
null, 'connect', args.info.server, true, args.info null, 'connect', args.info.server, true, args.info
), ),
dataType: 'json', dataType: 'json',
success: function(res) { })
if (res.success && 'connected' in res.data) { .done(function(res) {
if (res.data.connected) { if (res.success && 'connected' in res.data) {
// Server is connected, but - the connection with the if (res.data.connected) {
// particular database has been lost. // Server is connected, but - the connection with the
pgBrowser.Events.trigger( // particular database has been lost.
'pgadmin:database:connection:lost', args.item, jsonResp pgBrowser.Events.trigger(
); 'pgadmin:database:connection:lost', args.item, jsonResp
return; );
} return;
} }
}
// Serever was not connected, we should first try to connect // Serever was not connected, we should first try to connect
// the server. // the server.
reconnectServer(); reconnectServer();
}, })
error: function() { .fail(function() {
reconnectServer(); reconnectServer();
},
}); });
return true; return true;
} }

View File

@ -79,102 +79,102 @@ define(['jquery', 'sources/gettext', 'sources/url_for'],
$.ajax({ $.ajax({
url: url, url: url,
method: 'GET', method: 'GET',
success: function (res) { })
if(res && res.data) { .done(function (res) {
var status = res.data.status, if(res && res.data) {
msg = res.data.message, var status = res.data.status,
is_status_changed = false; msg = res.data.message,
is_status_changed = false;
// Raise notify messages comes from database server. // Raise notify messages comes from database server.
sqleditor_obj.update_notifications(res.data.notifies); sqleditor_obj.update_notifications(res.data.notifies);
// Inject CSS as required // Inject CSS as required
switch(status) { switch(status) {
// Busy // Busy
case 1: case 1:
// if received busy status more than once then only // if received busy status more than once then only
if(status == sqlEditorUtils.previousStatus && if(status == sqlEditorUtils.previousStatus &&
!$status_el.hasClass('fa-hourglass-half')) { !$status_el.hasClass('fa-hourglass-half')) {
$status_el.removeClass()
.addClass('fa fa-hourglass-half');
is_status_changed = true;
}
break;
// Idle in transaction
case 2:
if(sqlEditorUtils.previousStatus != status &&
!$status_el.hasClass('fa-clock-o')) {
$status_el.removeClass()
.addClass('fa fa-clock-o');
is_status_changed = true;
}
break;
// Failed in transaction
case 3:
if(sqlEditorUtils.previousStatus != status &&
!$status_el.hasClass('fa-exclamation-circle')) {
$status_el.removeClass()
.addClass('fa fa-exclamation-circle');
is_status_changed = true;
}
break;
// Failed in transaction with unknown server side error
case 4:
if(sqlEditorUtils.previousStatus != status &&
!$status_el.hasClass('fa-exclamation-triangle')) {
$status_el.removeClass()
.addClass('fa fa-exclamation-triangle');
is_status_changed = true;
}
break;
default:
if(sqlEditorUtils.previousStatus != status &&
!$status_el.hasClass('fa-query_tool_connected')) {
$status_el.removeClass()
.addClass('fa-custom fa-query-tool-connected');
is_status_changed = true;
}
}
sqlEditorUtils.previousStatus = status;
// Set bootstrap popover message
if(is_status_changed) {
$el.popover('hide');
$el.attr('data-content', msg);
}
} else {
// We come here means we did not receive expected response
// from server, we need to error out
sqlEditorUtils.previousStatus = -99;
msg = gettext('An unexpected error occurred - ' +
'ensure you are logged into the application.');
$el.attr('data-content', msg);
if(!$status_el.hasClass('fa-query-tool-disconnected')) {
$el.popover('hide');
$status_el.removeClass() $status_el.removeClass()
.addClass('fa-custom fa-query-tool-disconnected'); .addClass('fa fa-hourglass-half');
is_status_changed = true;
}
break;
// Idle in transaction
case 2:
if(sqlEditorUtils.previousStatus != status &&
!$status_el.hasClass('fa-clock-o')) {
$status_el.removeClass()
.addClass('fa fa-clock-o');
is_status_changed = true;
}
break;
// Failed in transaction
case 3:
if(sqlEditorUtils.previousStatus != status &&
!$status_el.hasClass('fa-exclamation-circle')) {
$status_el.removeClass()
.addClass('fa fa-exclamation-circle');
is_status_changed = true;
}
break;
// Failed in transaction with unknown server side error
case 4:
if(sqlEditorUtils.previousStatus != status &&
!$status_el.hasClass('fa-exclamation-triangle')) {
$status_el.removeClass()
.addClass('fa fa-exclamation-triangle');
is_status_changed = true;
}
break;
default:
if(sqlEditorUtils.previousStatus != status &&
!$status_el.hasClass('fa-query_tool_connected')) {
$status_el.removeClass()
.addClass('fa-custom fa-query-tool-connected');
is_status_changed = true;
} }
} }
},
error: function (e) {
sqlEditorUtils.previousStatus = -1;
var msg = gettext('Transaction status check failed.');
if (e.readyState == 0) {
msg = gettext('Not connected to the server or the connection to ' +
'the server has been closed.');
} else if (e.responseJSON && e.responseJSON.errormsg) {
msg = e.responseJSON.errormsg;
}
// Set bootstrap popover sqlEditorUtils.previousStatus = status;
// Set bootstrap popover message
if(is_status_changed) {
$el.popover('hide');
$el.attr('data-content', msg);
}
} else {
// We come here means we did not receive expected response
// from server, we need to error out
sqlEditorUtils.previousStatus = -99;
msg = gettext('An unexpected error occurred - ' +
'ensure you are logged into the application.');
$el.attr('data-content', msg); $el.attr('data-content', msg);
// Add error class
if(!$status_el.hasClass('fa-query-tool-disconnected')) { if(!$status_el.hasClass('fa-query-tool-disconnected')) {
$el.popover('hide'); $el.popover('hide');
$status_el.removeClass() $status_el.removeClass()
.addClass('fa-custom fa-query-tool-disconnected'); .addClass('fa-custom fa-query-tool-disconnected');
} }
}, }
})
.fail(function (e) {
sqlEditorUtils.previousStatus = -1;
var msg = gettext('Transaction status check failed.');
if (e.readyState == 0) {
msg = gettext('Not connected to the server or the connection to ' +
'the server has been closed.');
} else if (e.responseJSON && e.responseJSON.errormsg) {
msg = e.responseJSON.errormsg;
}
// Set bootstrap popover
$el.attr('data-content', msg);
// Add error class
if(!$status_el.hasClass('fa-query-tool-disconnected')) {
$el.popover('hide');
$status_el.removeClass()
.addClass('fa-custom fa-query-tool-disconnected');
}
}); });
}, },

View File

@ -323,24 +323,24 @@ define('pgadmin.datagrid', [
async: false, async: false,
contentType: 'application/json', contentType: 'application/json',
data: JSON.stringify(sql), data: JSON.stringify(sql),
success: function(res) { })
if (res.data.status) { .done(function(res) {
// Initialize the data grid. if (res.data.status) {
self.create_transaction(that.baseUrl, null, 'false', parentData.server.server_type, '', grid_title, sql, false); // Initialize the data grid.
} self.create_transaction(that.baseUrl, null, 'false', parentData.server.server_type, '', grid_title, sql, false);
else { }
alertify.alert( else {
gettext('Validation Error'),
res.data.result
);
}
},
error: function(e) {
alertify.alert( alertify.alert(
gettext('Validation Error'), gettext('Validation Error'),
e res.data.result
); );
}, }
})
.fail(function(e) {
alertify.alert(
gettext('Validation Error'),
e
);
}); });
} }
}, },
@ -376,35 +376,35 @@ define('pgadmin.datagrid', [
dataType: 'json', dataType: 'json',
data: JSON.stringify(sql_filter), data: JSON.stringify(sql_filter),
contentType: 'application/json', contentType: 'application/json',
success: function(res) { })
res.data.is_query_tool = is_query_tool; .done(function(res) {
res.data.server_type = server_type; res.data.is_query_tool = is_query_tool;
res.data.sURL = sURL; res.data.server_type = server_type;
res.data.panel_title = panel_title; res.data.sURL = sURL;
target.trigger('pgadmin-datagrid:transaction:created', res.data); res.data.panel_title = panel_title;
}, target.trigger('pgadmin-datagrid:transaction:created', res.data);
error: function(xhr) { })
if (target !== self) { .fail(function(xhr) {
if(xhr.status == 503 && xhr.responseJSON.info != undefined && if (target !== self) {
xhr.responseJSON.info == 'CONNECTION_LOST') { if(xhr.status == 503 && xhr.responseJSON.info != undefined &&
setTimeout(function() { xhr.responseJSON.info == 'CONNECTION_LOST') {
target.handle_connection_lost(true, xhr); setTimeout(function() {
}); target.handle_connection_lost(true, xhr);
return; });
} return;
} }
}
try { try {
var err = JSON.parse(xhr.responseText); var err = JSON.parse(xhr.responseText);
alertify.alert(gettext('Query Tool Initialize Error'), alertify.alert(gettext('Query Tool Initialize Error'),
err.errormsg err.errormsg
); );
} catch (e) { } catch (e) {
alertify.alert( alertify.alert(
e.statusText, gettext('Query Tool Initialize Error') e.statusText, gettext('Query Tool Initialize Error')
); );
} }
},
}); });
}, },
launch_grid: function(trans_obj) { launch_grid: function(trans_obj) {

View File

@ -291,19 +291,19 @@ define([
$.ajax({ $.ajax({
url: _url, url: _url,
cache: false, cache: false,
success: function() { })
self.start_global_debugger(); .done(function() {
}, self.start_global_debugger();
error: function(xhr) { })
try { .fail(function(xhr) {
var err = JSON.parse(xhr.responseText); try {
if (err.success == 0) { var err = JSON.parse(xhr.responseText);
Alertify.alert(gettext('Debugger Error'), err.errormsg); if (err.success == 0) {
} Alertify.alert(gettext('Debugger Error'), err.errormsg);
} catch (e) {
console.warn(e.stack || e);
} }
}, } catch (e) {
console.warn(e.stack || e);
}
}); });
}, },
@ -378,52 +378,52 @@ define([
$.ajax({ $.ajax({
url: baseUrl, url: baseUrl,
method: 'GET', method: 'GET',
success: function(res) { })
var url = url_for('debugger.direct', { .done(function(res) {
'trans_id': res.data.debuggerTransId, var url = url_for('debugger.direct', {
}); 'trans_id': res.data.debuggerTransId,
});
if (res.data.newBrowserTab) { if (res.data.newBrowserTab) {
window.open(url, '_blank'); window.open(url, '_blank');
} else { } else {
pgBrowser.Events.once( pgBrowser.Events.once(
'pgadmin-browser:frame:urlloaded:frm_debugger', 'pgadmin-browser:frame:urlloaded:frm_debugger',
function(frame) { function(frame) {
frame.openURL(url); frame.openURL(url);
});
// Create the debugger panel as per the data received from user input dialog.
var dashboardPanel = pgBrowser.docker.findPanels(
'properties'
),
panel = pgBrowser.docker.addPanel(
'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
);
panel.focus();
// Panel Closed event
panel.on(wcDocker.EVENT.CLOSED, function() {
var closeUrl = url_for('debugger.close', {
'trans_id': res.data.debuggerTransId,
});
$.ajax({
url: closeUrl,
method: 'DELETE',
});
}); });
// Create the debugger panel as per the data received from user input dialog.
var dashboardPanel = pgBrowser.docker.findPanels(
'properties'
),
panel = pgBrowser.docker.addPanel(
'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
);
panel.focus();
// Panel Closed event
panel.on(wcDocker.EVENT.CLOSED, function() {
var closeUrl = url_for('debugger.close', {
'trans_id': res.data.debuggerTransId,
});
$.ajax({
url: closeUrl,
method: 'DELETE',
});
});
}
})
.fail(function(xhr) {
try {
var err = JSON.parse(xhr.responseText);
if (err.success == 0) {
Alertify.alert(gettext('Debugger Error'), err.errormsg);
} }
}, } catch (e) {
error: function(xhr) { console.warn(e.stack || e);
try { }
var err = JSON.parse(xhr.responseText);
if (err.success == 0) {
Alertify.alert(gettext('Debugger Error'), err.errormsg);
}
} catch (e) {
console.warn(e.stack || e);
}
},
}); });
}, },
@ -446,107 +446,107 @@ define([
$.ajax({ $.ajax({
url: _url, url: _url,
cache: false, cache: false,
success: function(res) { })
.done(function(res) {
// Open Alertify the dialog to take the input arguments from user if function having input arguments // Open Alertify the dialog to take the input arguments from user if function having input arguments
if (res.data[0]['require_input']) { if (res.data[0]['require_input']) {
get_function_arguments(res.data[0], 0); get_function_arguments(res.data[0], 0);
} else {
// Initialize the target and create asynchronous connection and unique transaction ID
// If there is no arguments to the functions then we should not ask for for function arguments and
// Directly open the panel
var t = pgBrowser.tree,
i = t.selected(),
d = i && i.length == 1 ? t.itemData(i) : undefined,
node = d && pgBrowser.Nodes[d._type];
if (!d)
return;
var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]),
baseUrl;
if (d._type == 'function') {
baseUrl = url_for(
'debugger.initialize_target_for_function', {
'debug_type': 'direct',
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.function._id,
}
);
} else { } else {
// Initialize the target and create asynchronous connection and unique transaction ID baseUrl = url_for(
// If there is no arguments to the functions then we should not ask for for function arguments and 'debugger.initialize_target_for_function', {
// Directly open the panel 'debug_type': 'direct',
var t = pgBrowser.tree, 'sid': treeInfo.server._id,
i = t.selected(), 'did': treeInfo.database._id,
d = i && i.length == 1 ? t.itemData(i) : undefined, 'scid': treeInfo.schema._id,
node = d && pgBrowser.Nodes[d._type]; 'func_id': debuggerUtils.getProcedureId(treeInfo),
}
);
}
if (!d) $.ajax({
return; url: baseUrl,
method: 'GET',
})
.done(function(res) {
var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]), var url = url_for('debugger.direct', {
baseUrl; 'trans_id': res.data.debuggerTransId,
});
if (d._type == 'function') { if (res.data.newBrowserTab) {
baseUrl = url_for( window.open(url, '_blank');
'debugger.initialize_target_for_function', {
'debug_type': 'direct',
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.function._id,
}
);
} else { } else {
baseUrl = url_for( pgBrowser.Events.once(
'debugger.initialize_target_for_function', { 'pgadmin-browser:frame:urlloaded:frm_debugger',
'debug_type': 'direct', function(frame) {
'sid': treeInfo.server._id, frame.openURL(url);
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': debuggerUtils.getProcedureId(treeInfo),
}
);
}
$.ajax({
url: baseUrl,
method: 'GET',
success: function(res) {
var url = url_for('debugger.direct', {
'trans_id': res.data.debuggerTransId,
}); });
if (res.data.newBrowserTab) { // Create the debugger panel as per the data received from user input dialog.
window.open(url, '_blank'); var dashboardPanel = pgBrowser.docker.findPanels(
} else { 'properties'
pgBrowser.Events.once( ),
'pgadmin-browser:frame:urlloaded:frm_debugger', panel = pgBrowser.docker.addPanel(
function(frame) { 'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
frame.openURL(url);
});
// Create the debugger panel as per the data received from user input dialog.
var dashboardPanel = pgBrowser.docker.findPanels(
'properties'
),
panel = pgBrowser.docker.addPanel(
'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
);
panel.focus();
// Register Panel Closed event
panel.on(wcDocker.EVENT.CLOSED, function() {
var closeUrl = url_for('debugger.close', {
'trans_id': res.data.debuggerTransId,
});
$.ajax({
url: closeUrl,
method: 'DELETE',
});
});
}
},
error: function(e) {
Alertify.alert(
gettext('Debugger Target Initialization Error'),
e.responseJSON.errormsg
); );
},
}); panel.focus();
}
}, // Register Panel Closed event
error: function(xhr) { panel.on(wcDocker.EVENT.CLOSED, function() {
try { var closeUrl = url_for('debugger.close', {
var err = JSON.parse(xhr.responseText); 'trans_id': res.data.debuggerTransId,
if (err.success == 0) { });
Alertify.alert(gettext('Debugger Error'), err.errormsg); $.ajax({
url: closeUrl,
method: 'DELETE',
});
});
} }
} catch (e) { })
console.warn(e.stack || e); .fail(function(e) {
Alertify.alert(
gettext('Debugger Target Initialization Error'),
e.responseJSON.errormsg
);
});
}
})
.fail(function(xhr) {
try {
var err = JSON.parse(xhr.responseText);
if (err.success == 0) {
Alertify.alert(gettext('Debugger Error'), err.errormsg);
} }
}, } catch (e) {
console.warn(e.stack || e);
}
}); });
}, },
}; };

View File

@ -192,26 +192,26 @@ define([
url: _Url, url: _Url,
method: 'GET', method: 'GET',
async: false, async: false,
success: function(res) { })
if (res.data.args_count != 0) { .done(function(res) {
for (i = 0; i < res.data.result.length; i++) { if (res.data.args_count != 0) {
// Below will format the data to be stored in sqlite database for (i = 0; i < res.data.result.length; i++) {
func_args_data.push({ // Below will format the data to be stored in sqlite database
'arg_id': res.data.result[i]['arg_id'], func_args_data.push({
'is_null': res.data.result[i]['is_null'], 'arg_id': res.data.result[i]['arg_id'],
'is_expression': res.data.result[i]['is_expression'], 'is_null': res.data.result[i]['is_null'],
'use_default': res.data.result[i]['use_default'], 'is_expression': res.data.result[i]['is_expression'],
'value': res.data.result[i]['value'], 'use_default': res.data.result[i]['use_default'],
}); 'value': res.data.result[i]['value'],
} });
} }
}, }
error: function() { })
Alertify.alert( .fail(function() {
gettext('Debugger Error'), Alertify.alert(
gettext('Unable to fetch the arguments from server') gettext('Debugger Error'),
); gettext('Unable to fetch the arguments from server')
}, );
}); });
var argname, argtype, argmode, default_args_count, default_args, arg_cnt; var argname, argtype, argmode, default_args_count, default_args, arg_cnt;
@ -701,97 +701,97 @@ define([
data: { data: {
'data': JSON.stringify(args_value_list), 'data': JSON.stringify(args_value_list),
}, },
success: function(res) { })
.done(function(res) {
var url = url_for( var url = url_for(
'debugger.direct', { 'debugger.direct', {
'trans_id': res.data.debuggerTransId,
}
);
if (res.data.newBrowserTab) {
window.open(url, '_blank');
} else {
pgBrowser.Events.once(
'pgadmin-browser:frame:urlloaded:frm_debugger',
function(frame) {
frame.openURL(url);
});
// Create the debugger panel as per the data received from user input dialog.
var dashboardPanel = pgBrowser.docker.findPanels('properties'),
panel = pgBrowser.docker.addPanel(
'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
);
panel.focus();
// Panel Closed event
panel.on(wcDocker.EVENT.CLOSED, function() {
var closeUrl = url_for('debugger.close', {
'trans_id': res.data.debuggerTransId, 'trans_id': res.data.debuggerTransId,
}
);
if (res.data.newBrowserTab) {
window.open(url, '_blank');
} else {
pgBrowser.Events.once(
'pgadmin-browser:frame:urlloaded:frm_debugger',
function(frame) {
frame.openURL(url);
});
// Create the debugger panel as per the data received from user input dialog.
var dashboardPanel = pgBrowser.docker.findPanels('properties'),
panel = pgBrowser.docker.addPanel(
'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
);
panel.focus();
// Panel Closed event
panel.on(wcDocker.EVENT.CLOSED, function() {
var closeUrl = url_for('debugger.close', {
'trans_id': res.data.debuggerTransId,
});
$.ajax({
url: closeUrl,
method: 'DELETE',
});
}); });
} $.ajax({
var _Url; url: closeUrl,
method: 'DELETE',
if (d._type == 'function') {
_Url = url_for('debugger.set_arguments', {
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.function._id,
}); });
} else if (d._type == 'procedure') {
_Url = url_for('debugger.set_arguments', {
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.procedure._id,
});
} else if (d._type == 'edbfunc') {
// Get the existing function parameters available from sqlite database
_Url = url_for('debugger.set_arguments', {
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.edbfunc._id,
});
} else if (d._type == 'edbproc') {
// Get the existing function parameters available from sqlite database
_Url = url_for('debugger.set_arguments', {
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.edbproc._id,
});
}
$.ajax({
url: _Url,
method: 'POST',
data: {
'data': JSON.stringify(sqlite_func_args_list),
},
success: function() {},
error: function() {
Alertify.alert(
gettext('Debugger Error'),
gettext('Unable to set the arguments on the server')
);
},
}); });
}, }
error: function(e) { var _Url;
if (d._type == 'function') {
_Url = url_for('debugger.set_arguments', {
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.function._id,
});
} else if (d._type == 'procedure') {
_Url = url_for('debugger.set_arguments', {
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.procedure._id,
});
} else if (d._type == 'edbfunc') {
// Get the existing function parameters available from sqlite database
_Url = url_for('debugger.set_arguments', {
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.edbfunc._id,
});
} else if (d._type == 'edbproc') {
// Get the existing function parameters available from sqlite database
_Url = url_for('debugger.set_arguments', {
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.edbproc._id,
});
}
$.ajax({
url: _Url,
method: 'POST',
data: {
'data': JSON.stringify(sqlite_func_args_list),
},
})
.done(function() {})
.fail(function() {
Alertify.alert( Alertify.alert(
gettext('Debugger Target Initialization Error'), gettext('Debugger Error'),
e.responseJSON.errormsg gettext('Unable to set the arguments on the server')
); );
}, });
})
.fail(function(e) {
Alertify.alert(
gettext('Debugger Target Initialization Error'),
e.responseJSON.errormsg
);
}); });
} else { } else {
// If the debugging is started again then we should only set the // If the debugging is started again then we should only set the
@ -806,13 +806,13 @@ define([
data: { data: {
'data': JSON.stringify(args_value_list), 'data': JSON.stringify(args_value_list),
}, },
success: function() {}, })
error: function(e) { .done(function() {})
Alertify.alert( .fail(function(e) {
gettext('Debugger Listener Startup Error'), Alertify.alert(
e.responseJSON.errormsg gettext('Debugger Listener Startup Error'),
); e.responseJSON.errormsg
}, );
}); });
// Set the new input arguments given by the user during debugging // Set the new input arguments given by the user during debugging
@ -828,13 +828,13 @@ define([
data: { data: {
'data': JSON.stringify(sqlite_func_args_list), 'data': JSON.stringify(sqlite_func_args_list),
}, },
success: function() {}, })
error: function() { .done(function() {})
Alertify.alert( .fail(function() {
gettext('Debugger Error'), Alertify.alert(
gettext('Unable to set the arguments on the server') gettext('Debugger Error'),
); gettext('Unable to set the arguments on the server')
}, );
}); });
} }

File diff suppressed because it is too large Load Diff

View File

@ -526,23 +526,23 @@ Backform, commonUtils, supportedNodes
data: { data: {
'data': JSON.stringify(this.view.model.toJSON()), 'data': JSON.stringify(this.view.model.toJSON()),
}, },
success: function(res) { })
if (res.success) { .done(function(res) {
Alertify.success(gettext('Import/export job created.'), 5); if (res.success) {
pgBrowser.Events.trigger('pgadmin-bgprocess:created', self); Alertify.success(gettext('Import/export job created.'), 5);
} pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
}, }
error: function(xhr) { })
try { .fail(function(xhr) {
var err = JSON.parse(xhr.responseText); try {
Alertify.alert( var err = JSON.parse(xhr.responseText);
gettext('Import/export job failed.'), Alertify.alert(
err.errormsg gettext('Import/export job failed.'),
); err.errormsg
} catch (e) { );
console.warn(e.stack || e); } catch (e) {
} console.warn(e.stack || e);
}, }
}); });
} }
}, },

View File

@ -385,20 +385,20 @@ define([
data: { data: {
'data': JSON.stringify(this.view.model.toJSON()), 'data': JSON.stringify(this.view.model.toJSON()),
}, },
success: function(res) { })
if (res.data && res.data.status) { .done(function(res) {
//Do nothing as we are creating the job and exiting from the main dialog if (res.data && res.data.status) {
Alertify.success(res.data.info); //Do nothing as we are creating the job and exiting from the main dialog
pgBrowser.Events.trigger('pgadmin-bgprocess:created', self); Alertify.success(res.data.info);
} else { pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
Alertify.error(res.data.errmsg); } else {
} Alertify.error(res.data.errmsg);
}, }
error: function() { })
Alertify.alert( .fail(function() {
gettext('Maintenance job creation failed.') Alertify.alert(
); gettext('Maintenance job creation failed.')
}, );
}); });
} }
}, },

File diff suppressed because it is too large Load Diff

View File

@ -776,17 +776,17 @@ define([
url: ROLEURL, url: ROLEURL,
method: 'GET', method: 'GET',
async: false, async: false,
success: function(res) { })
Roles = res; .done(function(res) {
}, Roles = res;
error: function() { })
setTimeout(function() { .fail(function() {
alertify.alert( setTimeout(function() {
gettext('Error'), alertify.alert(
gettext('Cannot load user roles.') gettext('Error'),
); gettext('Cannot load user roles.')
}, 100); );
}, }, 100);
}); });
var view = this.view = new Backgrid.Grid({ var view = this.view = new Backgrid.Grid({