gui: show lock in status bar of vms/cts

also add 'tbarSpacing' parameter to ConfigPanel, that controls
the spacing after the title

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2019-03-21 10:55:20 +01:00 committed by Thomas Lamprecht
parent 0b985d6f23
commit 375d291810
3 changed files with 43 additions and 3 deletions

View File

@ -160,10 +160,23 @@ Ext.define('PVE.lxc.Config', {
vmid: vmid
});
var statusTxt = Ext.create('Ext.toolbar.TextItem', {
data: {
lock: undefined
},
tpl: [
'<tpl if="lock">',
'<i class="fa fa-lg fa-lock"></i> ({lock})',
'</tpl>'
]
});
Ext.apply(me, {
title: Ext.String.format(gettext("Container {0} on node '{1}'"), vm.text, nodename),
hstateid: 'lxctab',
tbar: [ startBtn, shutdownBtn, migrateBtn, consoleBtn, moreBtn ],
tbarSpacing: false,
tbar: [ statusTxt, '->', startBtn, shutdownBtn, migrateBtn, consoleBtn, moreBtn ],
defaults: { statusStore: me.statusStore },
items: [
{
@ -314,6 +327,7 @@ Ext.define('PVE.lxc.Config', {
me.mon(me.statusStore, 'load', function(s, records, success) {
var status;
var lock;
if (!success) {
status = 'unknown';
} else {
@ -321,7 +335,12 @@ Ext.define('PVE.lxc.Config', {
status = rec ? rec.data.value : 'unknown';
rec = s.data.get('template');
template = rec.data.value || false;
rec = s.data.get('lock');
lock = rec ? rec.data.value : undefined;
}
statusTxt.update({ lock: lock });
startBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'running' || template);
shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running');
stopBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'stopped');

View File

@ -46,6 +46,8 @@ Ext.define('PVE.panel.Config', {
showSearch: true, // add a ressource grid with a search button as first tab
viewFilter: undefined, // a filter to pass to that ressource grid
tbarSpacing: true, // if true, adds a spacer after the title in tbar
dockedItems: [{
// this is needed for the overflow handler
xtype: 'toolbar',
@ -183,7 +185,9 @@ Ext.define('PVE.panel.Config', {
}
}
if (me.tbarSpacing) {
tbar.unshift('->');
}
tbar.unshift({
xtype: 'tbtext',
text: title,

View File

@ -175,10 +175,22 @@ Ext.define('PVE.qemu.Config', {
vmid: vmid
});
var statusTxt = Ext.create('Ext.toolbar.TextItem', {
data: {
lock: undefined
},
tpl: [
'<tpl if="lock">',
'<i class="fa fa-lg fa-lock"></i> ({lock})',
'</tpl>'
]
});
Ext.apply(me, {
title: Ext.String.format(gettext("Virtual Machine {0} on node '{1}'"), vm.text, nodename),
hstateid: 'kvmtab',
tbar: [ resumeBtn, startBtn, shutdownBtn, migrateBtn, consoleBtn, moreBtn ],
tbarSpacing: false,
tbar: [ statusTxt, '->', resumeBtn, startBtn, shutdownBtn, migrateBtn, consoleBtn, moreBtn ],
defaults: { statusStore: me.statusStore },
items: [
{
@ -331,6 +343,7 @@ Ext.define('PVE.qemu.Config', {
var qmpstatus;
var spice = false;
var xtermjs = false;
var lock;
if (!success) {
status = qmpstatus = 'unknown';
@ -341,6 +354,8 @@ Ext.define('PVE.qemu.Config', {
qmpstatus = rec ? rec.data.value : 'unknown';
rec = s.data.get('template');
template = rec.data.value || false;
rec = s.data.get('lock');
lock = rec ? rec.data.value : undefined;
spice = s.data.get('spice') ? true : false;
xtermjs = s.data.get('serial') ? true : false;
@ -362,6 +377,8 @@ Ext.define('PVE.qemu.Config', {
consoleBtn.setEnableSpice(spice);
consoleBtn.setEnableXtermJS(xtermjs);
statusTxt.update({ lock: lock });
startBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'running' || template);
shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running');
me.down('#removeBtn').setDisabled(!caps.vms['VM.Allocate'] || status !== 'stopped');