fix #5871: ui: resize disk: show current and new size
The resize dialogs of VMs and containers only ask for the size increment, so users have to look up the current size of the disk in the config to know which size the disk will have afterwards. Load the config of the guest in the dialogs and show the current size of the disk, and the size it will have with the entered increment, which gets updated while typing. As the dialogs load the size themselves, callers do not need to change. The size of the config is in the 'disk-size' format, where the units are binary, while Proxmox.Utils.parse_size_unit() takes 'G' as GB, so add a small parser for it, like parse_size() of PVE::JSONSchema. Signed-off-by: Michal Fox <me@dualfroz.com>
This commit is contained in:
1 parent
b72e8c92b5
commit
f1c3f66086
3 files changed
+92
-1
No files matched your search
@@ -1148,6 +1148,16 @@ Ext.define('PVE.Utils', {
|
||||
return `${per.toFixed(1)}% of ${maxcpu} ${cpu_label}`;
|
||||
},
|
||||
|
||||
// parses a size in the 'disk-size' format of the API, like '32G', into bytes
|
||||
parse_disk_size: function (value) {
|
||||
let match = /^(\d+(?:\.\d+)?)(?:([KMGT])(?:iB)?)?$/.exec(value);
|
||||
if (!match) {
|
||||
return undefined;
|
||||
}
|
||||
let exponent = ['', 'K', 'M', 'G', 'T'].indexOf(match[2] ?? '');
|
||||
return parseFloat(match[1]) * 1024 ** exponent;
|
||||
},
|
||||
|
||||
render_bandwidth: function (value) {
|
||||
if (!Ext.isNumeric(value)) {
|
||||
return '';
|
||||
|
||||
Reference in new issue
Block a user