mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-05-29 20:43:29 +00:00
api request: add wide spread alert-error logic as smart-on option
The "smartness" is mostly "enable it automatically if the caller did not specify an explicit override and there's neither a failure nor callback function define", but that should cover most cases. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
cf93d1da50
commit
319d450bec
@ -418,6 +418,10 @@ utilities: {
|
|||||||
waitMsg: gettext('Please wait...'),
|
waitMsg: gettext('Please wait...'),
|
||||||
}, reqOpts);
|
}, reqOpts);
|
||||||
|
|
||||||
|
// default to enable if user isn't handling the failure already explicitly
|
||||||
|
let autoErrorAlert = reqOpts.autoErrorAlert ??
|
||||||
|
(typeof reqOpts.failure !== 'function' && typeof reqOpts.callback !== 'function');
|
||||||
|
|
||||||
if (!newopts.url.match(/^\/api2/)) {
|
if (!newopts.url.match(/^\/api2/)) {
|
||||||
newopts.url = '/api2/extjs' + newopts.url;
|
newopts.url = '/api2/extjs' + newopts.url;
|
||||||
}
|
}
|
||||||
@ -439,6 +443,9 @@ utilities: {
|
|||||||
response.htmlStatus = Proxmox.Utils.extractRequestError(result, true);
|
response.htmlStatus = Proxmox.Utils.extractRequestError(result, true);
|
||||||
Ext.callback(callbackFn, options.scope, [options, false, response]);
|
Ext.callback(callbackFn, options.scope, [options, false, response]);
|
||||||
Ext.callback(failureFn, options.scope, [response, options]);
|
Ext.callback(failureFn, options.scope, [response, options]);
|
||||||
|
if (autoErrorAlert) {
|
||||||
|
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Ext.callback(callbackFn, options.scope, [options, true, response]);
|
Ext.callback(callbackFn, options.scope, [options, true, response]);
|
||||||
|
Loading…
Reference in New Issue
Block a user