Ext.define('PVE.dc.Guests', {
extend: 'Ext.panel.Panel',
alias: 'widget.pveDcGuests',
title: gettext('Guests'),
height: 250,
layout: {
type: 'table',
columns: 2,
tableAttrs: {
style: {
width: '100%',
},
},
},
bodyPadding: '0 20 20 20',
defaults: {
xtype: 'box',
padding: '0 50 0 50',
style: {
'text-align': 'center',
'line-height': '1.5em',
'font-size': '14px',
},
},
items: [
{
itemId: 'qemu',
data: {
running: 0,
paused: 0,
stopped: 0,
template: 0,
},
cls: 'centered-flex-column',
tpl: [
'
' + gettext("Virtual Machines") + '
',
'',
'
',
' ',
gettext('Running'),
'
',
'
{running}
',
'
',
'',
'',
'
',
' ',
gettext('Paused'),
'
',
'
{paused}
',
'
',
'',
'',
'
',
' ',
gettext('Stopped'),
'
',
'
{stopped}
',
'
',
'',
'',
'
',
' ',
gettext('Templates'),
'
',
'
{template}
',
'
',
'',
],
},
{
itemId: 'lxc',
data: {
running: 0,
paused: 0,
stopped: 0,
template: 0,
},
cls: 'centered-flex-column',
tpl: [
'' + gettext("LXC Container") + '
',
'',
'
',
' ',
gettext('Running'),
'
',
'
{running}
',
'
',
'',
'',
'
',
' ',
gettext('Paused'),
'
',
'
{paused}
',
'
',
'',
'',
'
',
' ',
gettext('Stopped'),
'
',
'
{stopped}
',
'
',
'',
'',
'
',
' ',
gettext('Templates'),
'
',
'
{template}
',
'
',
'',
],
},
{
itemId: 'error',
colspan: 2,
data: {
num: 0,
},
columnWidth: 1,
padding: '10 250 0 250',
tpl: [
'',
'',
' ',
gettext('Error'),
'
',
'{num}
',
'',
],
},
],
updateValues: function(qemu, lxc, error) {
let me = this;
let lazyUpdate = (query, newData) => {
let el = me.getComponent(query);
let currentData = el.data;
let keys = Object.keys(newData);
if (keys.length === Object.keys(currentData).length) {
if (keys.every(k => newData[k] === currentData[k])) {
return; // all stayed the same here, return early to avoid bogus regeneration
}
}
el.update(newData);
};
lazyUpdate('qemu', qemu);
lazyUpdate('lxc', lxc);
lazyUpdate('error', { num: error });
},
});