mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Replace deprecated success, error callbacks in $.ajax call with new functions .done and .fail.
This commit is contained in:
committed by
Dave Page
parent
81312d17e2
commit
41a8333145
@@ -503,9 +503,9 @@ define('pgadmin.browser', [
|
||||
$.ajax({
|
||||
url: url_for('misc.cleanup'),
|
||||
type:'POST',
|
||||
success: function() {},
|
||||
error: function() {},
|
||||
});
|
||||
})
|
||||
.done(function() {})
|
||||
.fail(function() {});
|
||||
}, 300000);
|
||||
obj.Events.on('pgadmin:browser:tree:add', obj.onAddTreeNode, obj);
|
||||
obj.Events.on('pgadmin:browser:tree:update', obj.onUpdateTreeNode, obj);
|
||||
@@ -1539,69 +1539,69 @@ define('pgadmin.browser', [
|
||||
type: 'GET',
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
// Node information can come as result/data
|
||||
var data = res.result || res.data;
|
||||
})
|
||||
.done(function(res) {
|
||||
// Node information can come as result/data
|
||||
var data = res.result || res.data;
|
||||
|
||||
data._label = data.label;
|
||||
data.label = _.escape(data.label);
|
||||
var d = ctx.t.itemData(ctx.i);
|
||||
_.extend(d, data);
|
||||
ctx.t.setLabel(ctx.i, {label: _d.label});
|
||||
ctx.t.addIcon(ctx.i, {icon: _d.icon});
|
||||
ctx.t.setId(ctx.i, {id: _d.id});
|
||||
ctx.t.setInode(ctx.i, {inode: data.inode});
|
||||
data._label = data.label;
|
||||
data.label = _.escape(data.label);
|
||||
var d = ctx.t.itemData(ctx.i);
|
||||
_.extend(d, data);
|
||||
ctx.t.setLabel(ctx.i, {label: _d.label});
|
||||
ctx.t.addIcon(ctx.i, {icon: _d.icon});
|
||||
ctx.t.setId(ctx.i, {id: _d.id});
|
||||
ctx.t.setInode(ctx.i, {inode: data.inode});
|
||||
|
||||
if (
|
||||
_n.can_expand && typeof(_n.can_expand) == 'function'
|
||||
) {
|
||||
if (!_n.can_expand(d)) {
|
||||
ctx.t.unload(ctx.i);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
_n.can_expand && typeof(_n.can_expand) == 'function'
|
||||
) {
|
||||
if (!_n.can_expand(d)) {
|
||||
ctx.t.unload(ctx.i);
|
||||
return;
|
||||
}
|
||||
ctx.b._refreshNode(ctx, ctx.branch);
|
||||
var success = (ctx.o && ctx.o.success) || ctx.success;
|
||||
if (success && typeof(success) == 'function') {
|
||||
success();
|
||||
}
|
||||
ctx.b._refreshNode(ctx, ctx.branch);
|
||||
var success = (ctx.o && ctx.o.success) || ctx.success;
|
||||
if (success && typeof(success) == 'function') {
|
||||
success();
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, error, status) {
|
||||
if (
|
||||
!Alertify.pgHandleItemError(
|
||||
xhr, error, status, {item: _i, info: info}
|
||||
)
|
||||
) {
|
||||
var contentType = xhr.getResponseHeader('Content-Type'),
|
||||
jsonResp = (
|
||||
contentType &&
|
||||
contentType.indexOf('application/json') == 0 &&
|
||||
JSON.parse(xhr.responseText)
|
||||
) || {};
|
||||
|
||||
if (xhr.status == 410 && jsonResp.success == 0) {
|
||||
var p = ctx.t.parent(ctx.i);
|
||||
|
||||
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) {
|
||||
var p = ctx.t.parent(ctx.i);
|
||||
|
||||
ctx.t.remove(ctx.i, {
|
||||
success: function() {
|
||||
if (p) {
|
||||
// Try to refresh the parent on error
|
||||
try {
|
||||
pgBrowser.Events.trigger(
|
||||
'pgadmin:browser:tree:refresh', p
|
||||
);
|
||||
} catch (e) { console.warn(e.stack || e); }
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Alertify.pgNotifier(
|
||||
error, xhr, gettext('Error retrieving details for the node.'),
|
||||
function() { console.warn(arguments); }
|
||||
);
|
||||
}
|
||||
},
|
||||
Alertify.pgNotifier(
|
||||
error, xhr, gettext('Error retrieving details for the node.'),
|
||||
function() { console.warn(arguments); }
|
||||
);
|
||||
}
|
||||
});
|
||||
}.bind(this);
|
||||
|
||||
@@ -1786,16 +1786,16 @@ define('pgadmin.browser', [
|
||||
$.ajax({
|
||||
url: childNodeUrl,
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
if (res.success) {
|
||||
arrayChildNodeData.push(res.data);
|
||||
}
|
||||
fetchNodeInfo(_callback);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
fetchNodeInfo(_callback);
|
||||
},
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success) {
|
||||
arrayChildNodeData.push(res.data);
|
||||
}
|
||||
fetchNodeInfo(_callback);
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
fetchNodeInfo(_callback);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -729,30 +729,30 @@ define('pgadmin.browser.node', [
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, input.url, d, true),
|
||||
type: 'DELETE',
|
||||
success: function(res) {
|
||||
if (res.success == 0) {
|
||||
pgBrowser.report_error(res.errormsg, res.info);
|
||||
} else {
|
||||
pgBrowser.removeTreeNode(i, true);
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success == 0) {
|
||||
pgBrowser.report_error(res.errormsg, res.info);
|
||||
} else {
|
||||
pgBrowser.removeTreeNode(i, true);
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.fail(function(jqx) {
|
||||
var msg = jqx.responseText;
|
||||
/* Error from the server */
|
||||
if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) {
|
||||
try {
|
||||
var data = JSON.parse(jqx.responseText);
|
||||
msg = data.errormsg;
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
error: function(jqx) {
|
||||
var msg = jqx.responseText;
|
||||
/* Error from the server */
|
||||
if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) {
|
||||
try {
|
||||
var data = JSON.parse(jqx.responseText);
|
||||
msg = data.errormsg;
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
}
|
||||
pgBrowser.report_error(
|
||||
S(gettext('Error dropping %s: "%s"'))
|
||||
.sprintf(obj.label, objName)
|
||||
.value(), msg);
|
||||
},
|
||||
}
|
||||
pgBrowser.report_error(
|
||||
S(gettext('Error dropping %s: "%s"'))
|
||||
.sprintf(obj.label, objName)
|
||||
.value(), msg);
|
||||
});
|
||||
},
|
||||
null).show();
|
||||
|
||||
@@ -146,16 +146,16 @@ define([
|
||||
$.ajax({
|
||||
async: false,
|
||||
url: full_url,
|
||||
success: function(res) {
|
||||
/*
|
||||
* We will cache this data for short period of time for avoiding
|
||||
* same calls.
|
||||
*/
|
||||
data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data);
|
||||
},
|
||||
error: function() {
|
||||
m.trigger('pgadmin:view:fetch:error', m, self.field);
|
||||
},
|
||||
})
|
||||
.done(function(res) {
|
||||
/*
|
||||
* We will cache this data for short period of time for avoiding
|
||||
* same calls.
|
||||
*/
|
||||
data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data);
|
||||
})
|
||||
.fail(function() {
|
||||
m.trigger('pgadmin:view:fetch:error', m, self.field);
|
||||
});
|
||||
m.trigger('pgadmin:view:fetched', m, self.field);
|
||||
}
|
||||
@@ -387,16 +387,16 @@ define([
|
||||
$.ajax({
|
||||
async: false,
|
||||
url: full_url,
|
||||
success: function(res) {
|
||||
/*
|
||||
* We will cache this data for short period of time for avoiding
|
||||
* same calls.
|
||||
*/
|
||||
data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data);
|
||||
},
|
||||
error: function() {
|
||||
eventHandler.trigger('pgadmin:view:fetch:error', m, column);
|
||||
},
|
||||
})
|
||||
.done(function(res) {
|
||||
/*
|
||||
* We will cache this data for short period of time for avoiding
|
||||
* same calls.
|
||||
*/
|
||||
data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data);
|
||||
})
|
||||
.fail(function() {
|
||||
eventHandler.trigger('pgadmin:view:fetch:error', m, column);
|
||||
});
|
||||
eventHandler.trigger('pgadmin:view:fetched', m, column);
|
||||
}
|
||||
@@ -559,4 +559,4 @@ define([
|
||||
});
|
||||
|
||||
return Backform;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -80,32 +80,32 @@ _.extend(pgBrowser, {
|
||||
setTimeout(function() {
|
||||
$.ajax({
|
||||
url: url_for('preferences.get_all'),
|
||||
success: function(res) {
|
||||
self.preferences_cache = res;
|
||||
self.preference_version(self.generate_preference_version());
|
||||
})
|
||||
.done(function(res) {
|
||||
self.preferences_cache = res;
|
||||
self.preference_version(self.generate_preference_version());
|
||||
|
||||
pgBrowser.keyboardNavigation.init();
|
||||
if(pgBrowser.tree) {
|
||||
modifyAnimation.modifyAcitreeAnimation(self);
|
||||
modifyAnimation.modifyAlertifyAnimation(self);
|
||||
}
|
||||
pgBrowser.keyboardNavigation.init();
|
||||
if(pgBrowser.tree) {
|
||||
modifyAnimation.modifyAcitreeAnimation(self);
|
||||
modifyAnimation.modifyAlertifyAnimation(self);
|
||||
}
|
||||
|
||||
/* Once the cache is loaded after changing the preferences,
|
||||
* notify the modules of the change
|
||||
*/
|
||||
if(modulesChanged) {
|
||||
if(typeof modulesChanged === 'string'){
|
||||
$.event.trigger('prefchange:'+modulesChanged);
|
||||
} else {
|
||||
_.each(modulesChanged, (val, key)=> {
|
||||
$.event.trigger('prefchange:'+key);
|
||||
});
|
||||
}
|
||||
/* Once the cache is loaded after changing the preferences,
|
||||
* notify the modules of the change
|
||||
*/
|
||||
if(modulesChanged) {
|
||||
if(typeof modulesChanged === 'string'){
|
||||
$.event.trigger('prefchange:'+modulesChanged);
|
||||
} else {
|
||||
_.each(modulesChanged, (val, key)=> {
|
||||
$.event.trigger('prefchange:'+key);
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
},
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
});
|
||||
}, 500);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user