ui: maintenance mode: refactor renderer
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
556eda0537
commit
73ce2ae1c7
25
www/Utils.js
25
www/Utils.js
@ -641,23 +641,28 @@ Ext.define('PBS.Utils', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
renderMaintenance: function(mode, activeTasks) {
|
renderMaintenance: function(mode, activeTasks) {
|
||||||
if (!mode) return gettext('None');
|
if (!mode) {
|
||||||
let [type, _message] = mode.split(",");
|
return gettext('None');
|
||||||
|
}
|
||||||
|
// FIXME: this "parser" is brittle and relies on the order the arguments will appear in
|
||||||
|
let [type, message] = mode.split(",");
|
||||||
type = type.split("=").pop();
|
type = type.split("=").pop();
|
||||||
|
|
||||||
const conflictingTasks = activeTasks.write + (type === 'offline' ? activeTasks.read : 0);
|
const conflictingTasks = activeTasks.write + (type === 'offline' ? activeTasks.read : 0);
|
||||||
const checkmarkIcon = '<i class="fa fa-check"></i>';
|
|
||||||
const spinnerIcon = '<i class="fa fa-spinner fa-pulse fa-fw"></i>';
|
let extra = '';
|
||||||
const conflictingTasksMessage = `<i>${conflictingTasks} conflicting tasks still active</i>`;
|
if (conflictingTasks > 0) {
|
||||||
const extra = conflictingTasks > 0 ? `| ${spinnerIcon} ${conflictingTasksMessage}` : checkmarkIcon;
|
extra += '| <i class="fa fa-spinner fa-pulse fa-fw"></i> ';
|
||||||
|
extra += Ext.String.format(gettext('{0} conflicting tasks still active.'), conflictingTasks);
|
||||||
|
} else {
|
||||||
|
extra += '<i class="fa fa-check"></i>';
|
||||||
|
}
|
||||||
|
|
||||||
let modeText = Proxmox.Utils.unknownText;
|
let modeText = Proxmox.Utils.unknownText;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'read-only':
|
case 'read-only': modeText = gettext("Read-only");
|
||||||
modeText = gettext("Read-only");
|
|
||||||
break;
|
break;
|
||||||
case 'offline':
|
case 'offline': modeText = gettext("Offline");
|
||||||
modeText = gettext("Offline");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return `${modeText} ${extra}`;
|
return `${modeText} ${extra}`;
|
||||||
|
Loading…
Reference in New Issue
Block a user