[pve-devel] [PATCH manager 1/4] ui: Utils: use render functions from widget-toolkit
Dominik Csapak
d.csapak at proxmox.com
Mon Apr 19 13:00:45 CEST 2021
they live there now, so we can delete them here and use the ones from
widget-toolkit instead
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
www/manager6/Utils.js | 58 +-----------------------
www/manager6/ceph/OSD.js | 2 +-
www/manager6/ceph/Pool.js | 4 +-
www/manager6/ceph/Status.js | 4 +-
www/manager6/data/ResourceStore.js | 6 +--
www/manager6/dc/Summary.js | 4 +-
www/manager6/form/NodeSelector.js | 2 +-
www/manager6/ha/GroupEdit.js | 2 +-
www/manager6/node/StatusView.js | 19 +++-----
www/manager6/node/ZFS.js | 2 +-
www/manager6/panel/GuestStatusView.js | 6 +--
www/manager6/panel/StatusView.js | 4 +-
www/manager6/panel/TemplateStatusView.js | 6 +--
www/manager6/window/Migrate.js | 2 +-
14 files changed, 30 insertions(+), 91 deletions(-)
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index f502950f..48d94a64 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -935,22 +935,6 @@ Ext.define('PVE.Utils', {
return PVE.Utils.log_severity_hash[value] || value;
},
- render_cpu: function(value, metaData, record, rowIndex, colIndex, store) {
- if (!(record.data.uptime && Ext.isNumeric(value))) {
- return '';
- }
-
- var maxcpu = record.data.maxcpu || 1;
-
- if (!Ext.isNumeric(maxcpu) && maxcpu >= 1) {
- return '';
- }
-
- var per = value * 100;
-
- return per.toFixed(1) + '% of ' + maxcpu.toString() + (maxcpu > 1 ? 'CPUs' : 'CPU');
- },
-
calculate_hostcpu: function(data) {
if (!(data.uptime && Ext.isNumeric(data.cpu))) {
@@ -1001,14 +985,6 @@ Ext.define('PVE.Utils', {
return per.toFixed(1) + '% of ' + maxcpu.toString() + (maxcpu > 1 ? 'CPUs' : 'CPU');
},
- render_size: function(value, metaData, record, rowIndex, colIndex, store) {
- if (!Ext.isNumeric(value)) {
- return '';
- }
-
- return Proxmox.Utils.format_size(value);
- },
-
render_bandwidth: function(value) {
if (!Ext.isNumeric(value)) {
return '';
@@ -1113,7 +1089,7 @@ Ext.define('PVE.Utils', {
return '';
}
- return PVE.Utils.render_size(value);
+ return Proxmox.Utils.render_size(value);
},
calculate_disk_usage: function(data) {
@@ -1147,7 +1123,7 @@ Ext.define('PVE.Utils', {
return '';
}
- return PVE.Utils.render_size(value);
+ return Proxmox.Utils.render_size(value);
},
get_object_icon_class: function(type, record) {
@@ -1197,36 +1173,6 @@ Ext.define('PVE.Utils', {
return Proxmox.Utils.format_task_description(type, id);
},
- /* render functions for new status panel */
-
- render_usage: function(val) {
- return (val*100).toFixed(2) + '%';
- },
-
- render_cpu_usage: function(val, max) {
- return Ext.String.format(gettext('{0}% of {1}') +
- ' ' + gettext('CPU(s)'), (val*100).toFixed(2), max);
- },
-
- render_size_usage: function(val, max) {
- if (max === 0) {
- return gettext('N/A');
- }
- return (val*100/max).toFixed(2) + '% '+ '(' +
- Ext.String.format(gettext('{0} of {1}'),
- PVE.Utils.render_size(val), PVE.Utils.render_size(max)) + ')';
- },
-
- /* this is different for nodes */
- render_node_cpu_usage: function(value, record) {
- return PVE.Utils.render_cpu_usage(value, record.cpus);
- },
-
- /* this is different for nodes */
- render_node_size_usage: function(record) {
- return PVE.Utils.render_size_usage(record.used, record.total);
- },
-
render_optional_url: function(value) {
var match;
if (value && (match = value.match(/^https?:\/\//)) !== null) {
diff --git a/www/manager6/ceph/OSD.js b/www/manager6/ceph/OSD.js
index 51409163..13cd2fc5 100644
--- a/www/manager6/ceph/OSD.js
+++ b/www/manager6/ceph/OSD.js
@@ -536,7 +536,7 @@ Ext.define('PVE.node.CephOsdTree', {
},
render_osd_size: function(value, metaData, rec) {
- return this.render_osd_val(PVE.Utils.render_size(value), metaData, rec);
+ return this.render_osd_val(Proxmox.Utils.render_size(value), metaData, rec);
},
control: {
diff --git a/www/manager6/ceph/Pool.js b/www/manager6/ceph/Pool.js
index 5dabd4e6..e1c73e87 100644
--- a/www/manager6/ceph/Pool.js
+++ b/www/manager6/ceph/Pool.js
@@ -169,11 +169,11 @@ Ext.define('PVE.node.CephPoolList', {
text: gettext('Total'),
width: 100,
sortable: true,
- renderer: PVE.Utils.render_size,
+ renderer: Proxmox.Utils.render_size,
align: 'right',
dataIndex: 'bytes_used',
summaryType: 'sum',
- summaryRenderer: PVE.Utils.render_size,
+ summaryRenderer: Proxmox.Utils.render_size,
},
],
},
diff --git a/www/manager6/ceph/Status.js b/www/manager6/ceph/Status.js
index 96b190c0..c3545d37 100644
--- a/www/manager6/ceph/Status.js
+++ b/www/manager6/ceph/Status.js
@@ -309,8 +309,8 @@ Ext.define('PVE.node.CephStatus', {
let total = pgmap.bytes_total;
var text = Ext.String.format(gettext('{0} of {1}'),
- PVE.Utils.render_size(used),
- PVE.Utils.render_size(total),
+ Proxmox.Utils.render_size(used),
+ Proxmox.Utils.render_size(total),
);
// update the usage widget
diff --git a/www/manager6/data/ResourceStore.js b/www/manager6/data/ResourceStore.js
index 4854b8fe..948ee410 100644
--- a/www/manager6/data/ResourceStore.js
+++ b/www/manager6/data/ResourceStore.js
@@ -145,7 +145,7 @@ Ext.define('PVE.data.ResourceStore', {
maxdisk: {
header: gettext('Disk size'),
type: 'integer',
- renderer: PVE.Utils.render_size,
+ renderer: Proxmox.Utils.render_size,
sortable: true,
hidden: true,
width: 100,
@@ -170,7 +170,7 @@ Ext.define('PVE.data.ResourceStore', {
maxmem: {
header: gettext('Memory size'),
type: 'integer',
- renderer: PVE.Utils.render_size,
+ renderer: Proxmox.Utils.render_size,
hidden: true,
sortable: true,
width: 100,
@@ -178,7 +178,7 @@ Ext.define('PVE.data.ResourceStore', {
cpu: {
header: gettext('CPU usage'),
type: 'float',
- renderer: PVE.Utils.render_cpu,
+ renderer: Proxmox.Utils.render_cpu,
sortable: true,
width: 100,
},
diff --git a/www/manager6/dc/Summary.js b/www/manager6/dc/Summary.js
index 5b09116b..67d5e95b 100644
--- a/www/manager6/dc/Summary.js
+++ b/www/manager6/dc/Summary.js
@@ -209,10 +209,10 @@ Ext.define('PVE.dc.Summary', {
var text = Ext.String.format(gettext('of {0} CPU(s)'), maxcpu);
cpustat.updateValue(cpu/maxcpu, text);
- text = Ext.String.format(gettext('{0} of {1}'), PVE.Utils.render_size(memory), PVE.Utils.render_size(maxmem));
+ text = Ext.String.format(gettext('{0} of {1}'), Proxmox.Utils.render_size(memory), Proxmox.Utils.render_size(maxmem));
memorystat.updateValue(memory/maxmem, text);
- text = Ext.String.format(gettext('{0} of {1}'), PVE.Utils.render_size(used), PVE.Utils.render_size(total));
+ text = Ext.String.format(gettext('{0} of {1}'), Proxmox.Utils.render_size(used), Proxmox.Utils.render_size(total));
storagestat.updateValue(used/total, text);
gueststatus.updateValues(qemu, lxc, error);
diff --git a/www/manager6/form/NodeSelector.js b/www/manager6/form/NodeSelector.js
index 4a0f7da7..1a0b5915 100644
--- a/www/manager6/form/NodeSelector.js
+++ b/www/manager6/form/NodeSelector.js
@@ -54,7 +54,7 @@ Ext.define('PVE.form.NodeSelector', {
},
{
header: gettext('CPU usage'),
- renderer: PVE.Utils.render_cpu,
+ renderer: Proxmox.Utils.render_cpu,
sortable: true,
width: 100,
dataIndex: 'cpu',
diff --git a/www/manager6/ha/GroupEdit.js b/www/manager6/ha/GroupEdit.js
index b061cfa0..d3b34953 100644
--- a/www/manager6/ha/GroupEdit.js
+++ b/www/manager6/ha/GroupEdit.js
@@ -66,7 +66,7 @@ Ext.define('PVE.ha.GroupInputPanel', {
},
{
header: gettext('CPU usage'),
- renderer: PVE.Utils.render_cpu,
+ renderer: Proxmox.Utils.render_cpu,
sortable: true,
width: 150,
dataIndex: 'cpu',
diff --git a/www/manager6/node/StatusView.js b/www/manager6/node/StatusView.js
index 2af7fb04..bc16da6a 100644
--- a/www/manager6/node/StatusView.js
+++ b/www/manager6/node/StatusView.js
@@ -27,7 +27,7 @@ Ext.define('PVE.node.StatusView', {
title: gettext('CPU usage'),
valueField: 'cpu',
maxField: 'cpuinfo',
- renderer: PVE.Utils.render_node_cpu_usage,
+ renderer: Proxmox.Utils.render_node_cpu_usage,
},
{
itemId: 'wait',
@@ -54,7 +54,7 @@ Ext.define('PVE.node.StatusView', {
title: gettext('RAM usage'),
valueField: 'memory',
maxField: 'memory',
- renderer: PVE.Utils.render_node_size_usage,
+ renderer: Proxmox.Utils.render_node_size_usage,
},
{
itemId: 'ksm',
@@ -62,7 +62,7 @@ Ext.define('PVE.node.StatusView', {
title: gettext('KSM sharing'),
textField: 'ksm',
renderer: function(record) {
- return PVE.Utils.render_size(record.shared);
+ return Proxmox.Utils.render_size(record.shared);
},
padding: '0 15 10 15',
},
@@ -72,7 +72,7 @@ Ext.define('PVE.node.StatusView', {
title: gettext('HD space') + '(root)',
valueField: 'rootfs',
maxField: 'rootfs',
- renderer: PVE.Utils.render_node_size_usage,
+ renderer: Proxmox.Utils.render_node_size_usage,
},
{
iconCls: 'fa fa-fw fa-refresh',
@@ -81,7 +81,7 @@ Ext.define('PVE.node.StatusView', {
title: gettext('SWAP usage'),
valueField: 'swap',
maxField: 'swap',
- renderer: PVE.Utils.render_node_size_usage,
+ renderer: Proxmox.Utils.render_node_size_usage,
},
{
xtype: 'box',
@@ -94,14 +94,7 @@ Ext.define('PVE.node.StatusView', {
printBar: false,
title: gettext('CPU(s)'),
textField: 'cpuinfo',
- renderer: function(cpuinfo) {
- return cpuinfo.cpus + " x " + cpuinfo.model + " (" +
- cpuinfo.sockets.toString() + " " +
- (cpuinfo.sockets > 1
- ? gettext('Sockets')
- : gettext('Socket')
- ) + ")";
- },
+ renderer: Proxmox.Utils.render_cpu_model,
value: '',
},
{
diff --git a/www/manager6/node/ZFS.js b/www/manager6/node/ZFS.js
index 06d48c8f..e7b58c3c 100644
--- a/www/manager6/node/ZFS.js
+++ b/www/manager6/node/ZFS.js
@@ -139,7 +139,7 @@ Ext.define('PVE.node.CreateZFS', {
{
text: gettext('Size'),
dataIndex: 'size',
- renderer: PVE.Utils.render_size,
+ renderer: Proxmox.Utils.render_size,
flex: 1,
},
{
diff --git a/www/manager6/panel/GuestStatusView.js b/www/manager6/panel/GuestStatusView.js
index 8dab4c19..83a3ce9d 100644
--- a/www/manager6/panel/GuestStatusView.js
+++ b/www/manager6/panel/GuestStatusView.js
@@ -71,7 +71,7 @@ Ext.define('PVE.panel.GuestStatusView', {
title: gettext('CPU usage'),
valueField: 'cpu',
maxField: 'cpus',
- renderer: PVE.Utils.render_cpu_usage,
+ renderer: Proxmox.Utils.render_cpu_usage,
// in this specific api call
// we already have the correct value for the usage
calculate: Ext.identityFn,
@@ -106,9 +106,9 @@ Ext.define('PVE.panel.GuestStatusView', {
var me = this;
me.setPrintBar(used > 0);
if (used === 0) {
- return PVE.Utils.render_size(max);
+ return Proxmox.Utils.render_size(max);
} else {
- return PVE.Utils.render_size_usage(used, max);
+ return Proxmox.Utils.render_size_usage(used, max);
}
},
},
diff --git a/www/manager6/panel/StatusView.js b/www/manager6/panel/StatusView.js
index 757cd164..a8f01ce8 100644
--- a/www/manager6/panel/StatusView.js
+++ b/www/manager6/panel/StatusView.js
@@ -32,9 +32,9 @@ Ext.define('PVE.panel.StatusView', {
}
if (!Ext.isNumeric(max) || max === 1) {
- return PVE.Utils.render_usage(val);
+ return Proxmox.Utils.render_usage(val);
}
- return PVE.Utils.render_size_usage(val, max);
+ return Proxmox.Utils.render_size_usage(val, max);
},
fieldCalculator: function(used, max) {
diff --git a/www/manager6/panel/TemplateStatusView.js b/www/manager6/panel/TemplateStatusView.js
index 7b60a8b8..f7080043 100644
--- a/www/manager6/panel/TemplateStatusView.js
+++ b/www/manager6/panel/TemplateStatusView.js
@@ -45,21 +45,21 @@ Ext.define('PVE.panel.TemplateStatusView', {
iconCls: 'fa fa-fw pve-itype-icon-memory pve-icon',
title: gettext('Memory'),
textField: 'maxmem',
- renderer: PVE.Utils.render_size,
+ renderer: Proxmox.Utils.render_size,
},
{
itemId: 'swap',
iconCls: 'fa fa-refresh fa-fw',
title: gettext('Swap'),
textField: 'maxswap',
- renderer: PVE.Utils.render_size,
+ renderer: Proxmox.Utils.render_size,
},
{
itemId: 'disk',
iconCls: 'fa fa-hdd-o fa-fw',
title: gettext('Bootdisk size'),
textField: 'maxdisk',
- renderer: PVE.Utils.render_size,
+ renderer: Proxmox.Utils.render_size,
},
{
xtype: 'box',
diff --git a/www/manager6/window/Migrate.js b/www/manager6/window/Migrate.js
index 817d99ed..8b30c820 100644
--- a/www/manager6/window/Migrate.js
+++ b/www/manager6/window/Migrate.js
@@ -263,7 +263,7 @@ Ext.define('PVE.window.Migrate', {
});
}
} else {
- var size_string = disk.size ? '(' + PVE.Utils.render_size(disk.size) + ')' : '';
+ var size_string = disk.size ? '(' + Proxmox.Utils.render_size(disk.size) + ')' : '';
migration['with-local-disks'] = 1;
migration.preconditions.push({
text: Ext.String.format('Migration with local disk might take long: {0} {1}',
--
2.20.1
More information about the pve-devel
mailing list