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:
Thomas Lamprecht 2020-08-26 20:02:35 +02:00
parent abd4706afe
commit a718654e76

View File

@ -449,19 +449,21 @@ utilities: {
}, },
checked_command: function(orig_cmd) { checked_command: function(orig_cmd) {
Proxmox.Utils.API2Request({ Proxmox.Utils.API2Request(
{
url: '/nodes/localhost/subscription', url: '/nodes/localhost/subscription',
method: 'GET', method: 'GET',
failure: function(response, opts) { failure: function(response, opts) {
Ext.Msg.alert(gettext('Error'), response.htmlStatus); Ext.Msg.alert(gettext('Error'), response.htmlStatus);
}, },
success: function(response, opts) { success: function(response, opts) {
let data = response.result.data; let res = response.result;
if (data.status !== 'Active') { if (res === null || res === undefined || !res || res
.data.status !== 'Active') {
Ext.Msg.show({ Ext.Msg.show({
title: gettext('No valid subscription'), title: gettext('No valid subscription'),
icon: Ext.Msg.WARNING, icon: Ext.Msg.WARNING,
message: Proxmox.Utils.getNoSubKeyHtml(data.url), message: Proxmox.Utils.getNoSubKeyHtml(res.data.url),
buttons: Ext.Msg.OK, buttons: Ext.Msg.OK,
callback: function(btn) { callback: function(btn) {
if (btn !== 'ok') { if (btn !== 'ok') {
@ -474,7 +476,8 @@ utilities: {
orig_cmd(); orig_cmd();
} }
}, },
}); },
);
}, },
assemble_field_data: function(values, data) { assemble_field_data: function(values, data) {