ui: traffic-control view: make rendere more flexible

do not choke on non-numbers but use the (partially new) widget
toolkit helpers to also be able to parse string based sizes with
units and auto-scale them

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-11-20 21:52:29 +01:00
parent f251367c33
commit 188a37fbed
1 changed files with 3 additions and 7 deletions

View File

@ -5,15 +5,11 @@ Ext.define('pmx-traffic-control', {
'timeframe', 'comment', 'cur-rate-in', 'cur-rate-out',
{
name: 'rateInUsed',
calculate: function(data) {
return (data['cur-rate-in'] || 0) / (data['rate-in'] || Infinity);
},
calculate: d => Proxmox.Utils.size_unit_ratios(d['cur-rate-in'], d['rate-in']),
},
{
name: 'rateOutUsed',
calculate: function(data) {
return (data['cur-rate-out'] || 0) / (data['rate-out'] || Infinity);
},
calculate: d => Proxmox.Utils.size_unit_ratios(d['cur-rate-out'], d['rate-out']),
},
],
idProperty: 'name',
@ -64,7 +60,7 @@ Ext.define('PBS.config.TrafficControlView', {
}).show();
},
render_bandwidth: (value) => value ? Proxmox.Utils.format_size(value) + '/s' : '',
render_bandwidth: v => v ? Proxmox.Utils.autoscale_size_unit(v) + '/s' : '',
reload: function() { this.getView().getStore().rstore.load(); },