mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-07-11 21:30:11 +00:00
utils: improve indentation and better check API result
to avoid dereferencing a null/undefined value. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
abd4706afe
commit
a718654e76
53
src/Utils.js
53
src/Utils.js
@ -449,32 +449,35 @@ utilities: {
|
|||||||
},
|
},
|
||||||
|
|
||||||
checked_command: function(orig_cmd) {
|
checked_command: function(orig_cmd) {
|
||||||
Proxmox.Utils.API2Request({
|
Proxmox.Utils.API2Request(
|
||||||
url: '/nodes/localhost/subscription',
|
{
|
||||||
method: 'GET',
|
url: '/nodes/localhost/subscription',
|
||||||
failure: function(response, opts) {
|
method: 'GET',
|
||||||
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
|
failure: function(response, opts) {
|
||||||
|
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
|
||||||
|
},
|
||||||
|
success: function(response, opts) {
|
||||||
|
let res = response.result;
|
||||||
|
if (res === null || res === undefined || !res || res
|
||||||
|
.data.status !== 'Active') {
|
||||||
|
Ext.Msg.show({
|
||||||
|
title: gettext('No valid subscription'),
|
||||||
|
icon: Ext.Msg.WARNING,
|
||||||
|
message: Proxmox.Utils.getNoSubKeyHtml(res.data.url),
|
||||||
|
buttons: Ext.Msg.OK,
|
||||||
|
callback: function(btn) {
|
||||||
|
if (btn !== 'ok') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
orig_cmd();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
orig_cmd();
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
success: function(response, opts) {
|
);
|
||||||
let data = response.result.data;
|
|
||||||
if (data.status !== 'Active') {
|
|
||||||
Ext.Msg.show({
|
|
||||||
title: gettext('No valid subscription'),
|
|
||||||
icon: Ext.Msg.WARNING,
|
|
||||||
message: Proxmox.Utils.getNoSubKeyHtml(data.url),
|
|
||||||
buttons: Ext.Msg.OK,
|
|
||||||
callback: function(btn) {
|
|
||||||
if (btn !== 'ok') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
orig_cmd();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
orig_cmd();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
assemble_field_data: function(values, data) {
|
assemble_field_data: function(values, data) {
|
||||||
|
Loading…
Reference in New Issue
Block a user