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,
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;

View File

@@ -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);
})
.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);
},
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);

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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;
},

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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) || [];

View File

@@ -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) || [];

View File

@@ -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);
});
},
},

View File

@@ -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;

View File

@@ -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'));
});
},

View File

@@ -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);
}
},
error: function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
})
.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);
}
t.unload(i);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
},
function() { return true; });

View File

@@ -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;

View File

@@ -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' &&

View File

@@ -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);

View File

@@ -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() {