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

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

View File

@@ -291,19 +291,19 @@ define([
$.ajax({
url: _url,
cache: false,
success: function() {
self.start_global_debugger();
},
error: 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);
})
.done(function() {
self.start_global_debugger();
})
.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);
}
});
},
@@ -378,52 +378,52 @@ define([
$.ajax({
url: baseUrl,
method: 'GET',
success: function(res) {
var url = url_for('debugger.direct', {
'trans_id': res.data.debuggerTransId,
});
})
.done(function(res) {
var url = url_for('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,
});
$.ajax({
url: closeUrl,
method: 'DELETE',
});
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',
});
});
}
})
.fail(function(xhr) {
try {
var err = JSON.parse(xhr.responseText);
if (err.success == 0) {
Alertify.alert(gettext('Debugger Error'), err.errormsg);
}
},
error: 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);
}
},
} catch (e) {
console.warn(e.stack || e);
}
});
},
@@ -446,107 +446,107 @@ define([
$.ajax({
url: _url,
cache: false,
success: function(res) {
})
.done(function(res) {
// Open Alertify the dialog to take the input arguments from user if function having input arguments
if (res.data[0]['require_input']) {
get_function_arguments(res.data[0], 0);
// Open Alertify the dialog to take the input arguments from user if function having input arguments
if (res.data[0]['require_input']) {
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 {
// 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];
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': debuggerUtils.getProcedureId(treeInfo),
}
);
}
if (!d)
return;
$.ajax({
url: baseUrl,
method: 'GET',
})
.done(function(res) {
var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]),
baseUrl;
var url = url_for('debugger.direct', {
'trans_id': res.data.debuggerTransId,
});
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,
}
);
if (res.data.newBrowserTab) {
window.open(url, '_blank');
} else {
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': debuggerUtils.getProcedureId(treeInfo),
}
);
}
$.ajax({
url: baseUrl,
method: 'GET',
success: function(res) {
var url = url_for('debugger.direct', {
'trans_id': res.data.debuggerTransId,
pgBrowser.Events.once(
'pgadmin-browser:frame:urlloaded:frm_debugger',
function(frame) {
frame.openURL(url);
});
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();
// 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
// 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]
);
},
});
}
},
error: function(xhr) {
try {
var err = JSON.parse(xhr.responseText);
if (err.success == 0) {
Alertify.alert(gettext('Debugger Error'), err.errormsg);
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',
});
});
}
} 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,
method: 'GET',
async: false,
success: function(res) {
if (res.data.args_count != 0) {
for (i = 0; i < res.data.result.length; i++) {
// Below will format the data to be stored in sqlite database
func_args_data.push({
'arg_id': res.data.result[i]['arg_id'],
'is_null': res.data.result[i]['is_null'],
'is_expression': res.data.result[i]['is_expression'],
'use_default': res.data.result[i]['use_default'],
'value': res.data.result[i]['value'],
});
}
})
.done(function(res) {
if (res.data.args_count != 0) {
for (i = 0; i < res.data.result.length; i++) {
// Below will format the data to be stored in sqlite database
func_args_data.push({
'arg_id': res.data.result[i]['arg_id'],
'is_null': res.data.result[i]['is_null'],
'is_expression': res.data.result[i]['is_expression'],
'use_default': res.data.result[i]['use_default'],
'value': res.data.result[i]['value'],
});
}
},
error: function() {
Alertify.alert(
gettext('Debugger Error'),
gettext('Unable to fetch the arguments from server')
);
},
}
})
.fail(function() {
Alertify.alert(
gettext('Debugger Error'),
gettext('Unable to fetch the arguments from server')
);
});
var argname, argtype, argmode, default_args_count, default_args, arg_cnt;
@@ -701,97 +701,97 @@ define([
data: {
'data': JSON.stringify(args_value_list),
},
success: function(res) {
})
.done(function(res) {
var url = url_for(
'debugger.direct', {
var url = url_for(
'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,
}
);
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',
});
});
}
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,
$.ajax({
url: closeUrl,
method: 'DELETE',
});
} 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(
gettext('Debugger Target Initialization Error'),
e.responseJSON.errormsg
gettext('Debugger Error'),
gettext('Unable to set the arguments on the server')
);
},
});
})
.fail(function(e) {
Alertify.alert(
gettext('Debugger Target Initialization Error'),
e.responseJSON.errormsg
);
});
} else {
// If the debugging is started again then we should only set the
@@ -806,13 +806,13 @@ define([
data: {
'data': JSON.stringify(args_value_list),
},
success: function() {},
error: function(e) {
Alertify.alert(
gettext('Debugger Listener Startup Error'),
e.responseJSON.errormsg
);
},
})
.done(function() {})
.fail(function(e) {
Alertify.alert(
gettext('Debugger Listener Startup Error'),
e.responseJSON.errormsg
);
});
// Set the new input arguments given by the user during debugging
@@ -828,13 +828,13 @@ define([
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')
);
},
})
.done(function() {})
.fail(function() {
Alertify.alert(
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': JSON.stringify(this.view.model.toJSON()),
},
success: function(res) {
if (res.success) {
Alertify.success(gettext('Import/export job created.'), 5);
pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
}
},
error: function(xhr) {
try {
var err = JSON.parse(xhr.responseText);
Alertify.alert(
gettext('Import/export job failed.'),
err.errormsg
);
} catch (e) {
console.warn(e.stack || e);
}
},
})
.done(function(res) {
if (res.success) {
Alertify.success(gettext('Import/export job created.'), 5);
pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
}
})
.fail(function(xhr) {
try {
var err = JSON.parse(xhr.responseText);
Alertify.alert(
gettext('Import/export job failed.'),
err.errormsg
);
} catch (e) {
console.warn(e.stack || e);
}
});
}
},

View File

@@ -385,20 +385,20 @@ define([
data: {
'data': JSON.stringify(this.view.model.toJSON()),
},
success: function(res) {
if (res.data && res.data.status) {
//Do nothing as we are creating the job and exiting from the main dialog
Alertify.success(res.data.info);
pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
} else {
Alertify.error(res.data.errmsg);
}
},
error: function() {
Alertify.alert(
gettext('Maintenance job creation failed.')
);
},
})
.done(function(res) {
if (res.data && res.data.status) {
//Do nothing as we are creating the job and exiting from the main dialog
Alertify.success(res.data.info);
pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
} else {
Alertify.error(res.data.errmsg);
}
})
.fail(function() {
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,
method: 'GET',
async: false,
success: function(res) {
Roles = res;
},
error: function() {
setTimeout(function() {
alertify.alert(
gettext('Error'),
gettext('Cannot load user roles.')
);
}, 100);
},
})
.done(function(res) {
Roles = res;
})
.fail(function() {
setTimeout(function() {
alertify.alert(
gettext('Error'),
gettext('Cannot load user roles.')
);
}, 100);
});
var view = this.view = new Backgrid.Grid({