X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=Utils.js;h=22eddd2c3ef83b7c8e5badbf134be57a336cb22b;hb=8ae40b73f1eca2e637ccd4470f9a3566b5e4389b;hp=8eee10b6951ef40035bbd8a0c58dd41e434cf3aa;hpb=16c0a0b570dd950a9108fa5a20233f7f4a9544c1;p=proxmox-widget-toolkit.git diff --git a/Utils.js b/Utils.js index 8eee10b..22eddd2 100644 --- a/Utils.js +++ b/Utils.js @@ -42,6 +42,7 @@ Ext.define('Proxmox.Utils', { utilities: { enabledText: gettext('Enabled'), disabledText: gettext('Disabled'), noneText: gettext('none'), + NoneText: gettext('None'), errorText: gettext('Error'), unknownText: gettext('Unknown'), defaultText: gettext('Default'), @@ -57,6 +58,7 @@ Ext.define('Proxmox.Utils', { utilities: { groupText: gettext('Group'), language_map: { + ar: 'Arabic', ca: 'Catalan', da: 'Danish', de: 'German', @@ -233,6 +235,23 @@ Ext.define('Proxmox.Utils', { utilities: { } }, + getResponseErrorMessage: (err) => { + if (!err.statusText) { + return gettext('Connection error'); + } + let msg = `${err.statusText} (${err.status})`; + if (err.response && err.response.responseText) { + let txt = err.response.responseText; + try { + let res = JSON.parse(txt) + for (let [key, value] of Object.entries(res.errors)) { + msg += `
${key}: ${value}`; + } + } catch (e) { /* TODO? */ } + } + return msg; + }, + monStoreErrors: function(me, store, clearMaskBeforeLoad) { if (clearMaskBeforeLoad) { me.mon(store, 'beforeload', function(s, operation, eOpts) { @@ -256,15 +275,8 @@ Ext.define('Proxmox.Utils', { utilities: { return; } - var msg; - /*jslint nomen: true */ - var operation = request._operation; - var error = operation.getError(); - if (error.statusText) { - msg = error.statusText + ' (' + error.status + ')'; - } else { - msg = gettext('Connection error'); - } + let error = request._operation.getError(); + let msg = Proxmox.Utils.getResponseErrorMessage(error); Proxmox.Utils.setErrorMask(me, msg); }); }, @@ -453,6 +465,8 @@ Ext.define('Proxmox.Utils', { utilities: { acmerefresh: [ 'ACME Account', gettext('Refresh') ], acmerenew: [ 'SRV', gettext('Renew Certificate') ], acmerevoke: [ 'SRV', gettext('Revoke Certificate') ], + 'auth-realm-sync': [ gettext('Realm'), gettext('Sync') ], + 'auth-realm-sync-test': [ gettext('Realm'), gettext('Sync Preview')], 'move_volume': [ 'CT', gettext('Move Volume') ], clustercreate: [ '', gettext('Create Cluster') ], clusterjoin: [ '', gettext('Join Cluster') ], @@ -497,9 +511,12 @@ Ext.define('Proxmox.Utils', { utilities: { vzreboot: ['CT', gettext('Reboot') ], vzsuspend: [ 'CT', gettext('Suspend') ], vzresume: [ 'CT', gettext('Resume') ], + push_file: ['CT', gettext('Push file')], + pull_file: ['CT', gettext('Pull file')], hamigrate: [ 'HA', gettext('Migrate') ], hastart: [ 'HA', gettext('Start') ], hastop: [ 'HA', gettext('Stop') ], + hashutdown: [ 'HA', gettext('Shutdown') ], srvstart: ['SRV', gettext('Start') ], srvstop: ['SRV', gettext('Stop') ], srvrestart: ['SRV', gettext('Restart') ], @@ -586,17 +603,20 @@ Ext.define('Proxmox.Utils', { utilities: { parse_task_upid: function(upid) { var task = {}; - var res = upid.match(/^UPID:(\S+):([0-9A-Fa-f]{8}):([0-9A-Fa-f]{8,9}):([0-9A-Fa-f]{8}):([^:\s]+):([^:\s]*):([^:\s]+):$/); + var res = upid.match(/^UPID:([^\s:]+):([0-9A-Fa-f]{8}):([0-9A-Fa-f]{8,9}):(([0-9A-Fa-f]{8,16}):)?([0-9A-Fa-f]{8}):([^:\s]+):([^:\s]*):([^:\s]+):$/); if (!res) { throw "unable to parse upid '" + upid + "'"; } task.node = res[1]; task.pid = parseInt(res[2], 16); task.pstart = parseInt(res[3], 16); - task.starttime = parseInt(res[4], 16); - task.type = res[5]; - task.id = res[6]; - task.user = res[7]; + if (res[5] !== undefined) { + task.task_id = parseInt(res[5], 16); + } + task.starttime = parseInt(res[6], 16); + task.type = res[7]; + task.id = res[8]; + task.user = res[9]; task.desc = Proxmox.Utils.format_task_description(task.type, task.id); @@ -690,5 +710,7 @@ Ext.define('Proxmox.Utils', { utilities: { me.HostPort_match = new RegExp("^(" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")(:\\d+)?$"); me.HostPortBrackets_match = new RegExp("^\\[(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")\\](:\\d+)?$"); me.IP6_dotnotation_match = new RegExp("^" + IPV6_REGEXP + "(\\.\\d+)?$"); + me.Vlan_match = new RegExp('^vlan(\\d+)'); + me.VlanInterface_match = new RegExp('(\\w+)\\.(\\d+)'); } });