public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Noel Ullreich <n.ullreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-manager 2/2] ui: fix: change units of memory/swap for containers
Date: Thu, 27 Jul 2023 12:30:49 +0200	[thread overview]
Message-ID: <20230727103049.38556-3-n.ullreich@proxmox.com> (raw)
In-Reply-To: <20230727103049.38556-1-n.ullreich@proxmox.com>

This patch adds a dropdown-menu (in the web interface) of units, MiB, GiB,
and TiB, (although PiB could easily be added in the future) for ram
and swapsize of containers.

Signed-off-by: Noel Ullreich <n.ullreich@proxmox.com>
---
 www/manager6/lxc/ResourceEdit.js | 59 +++++++++++++++++++++-----------
 1 file changed, 39 insertions(+), 20 deletions(-)

diff --git a/www/manager6/lxc/ResourceEdit.js b/www/manager6/lxc/ResourceEdit.js
index 9f4f7e08..8c1f57c3 100644
--- a/www/manager6/lxc/ResourceEdit.js
+++ b/www/manager6/lxc/ResourceEdit.js
@@ -1,10 +1,10 @@
-var labelWidth = 120;
+let labelWidth = 100;
 
 Ext.define('PVE.lxc.MemoryEdit', {
     extend: 'Proxmox.window.Edit',
 
     initComponent: function() {
-	var me = this;
+	let me = this;
 
 	Ext.apply(me, {
 	    subject: gettext('Memory'),
@@ -69,7 +69,7 @@ Ext.define('PVE.lxc.CPUInputPanel', {
 	return values;
     },
 
-    advancedColumn1: [
+   advancedColumn1: [
 	{
 	    xtype: 'numberfield',
 	    name: 'cpulimit',
@@ -102,7 +102,7 @@ Ext.define('PVE.lxc.CPUInputPanel', {
     ],
 
     initComponent: function() {
-	var me = this;
+	let me = this;
 
 	me.column1 = [
 	    {
@@ -130,29 +130,48 @@ Ext.define('PVE.lxc.MemoryInputPanel', {
 
     insideWizard: false,
 
+    onGetValues: function(values) {
+	let ret = {};
+
+	ret.memory = values.memory;
+	ret.swap = values.swap;
+
+	return ret;
+    },
+
+/*
+    onSetValues: function(values) {
+	// TODO: I would have thought that manually setting the combobox here
+	// might make it possible to set `ok` on the selector when changing the
+	// unit in the combobox
+	values.memunit = 'GiB';
+	values.swapunit = 'TiB';
+
+	return values;
+    },
+*/
+
     initComponent: function() {
-	var me = this;
+	let me = this;
 
-	var items = [
+	let items = [
 	    {
-		xtype: 'proxmoxintegerfield',
+		xtype: 'pmxSizeField',
+		fieldLabel: gettext('Memory'),
 		name: 'memory',
-		minValue: 16,
-		value: '512',
-		step: 32,
-		fieldLabel: gettext('Memory') + ' (MiB)',
-		labelWidth: labelWidth,
-		allowBlank: false,
+		unitname: 'memunit',
+		steparray: [32, 1, 1],
+		minarray: [16, 1, 1],
+		datastore: Object.keys(Proxmox.Utils.SizeUnits).slice(2, 5),
+		backendUnit: 'MiB',
 	    },
 	    {
-		xtype: 'proxmoxintegerfield',
+		xtype: 'pmxSizeField',
+		fieldLabel: gettext('Swap'),
 		name: 'swap',
-		minValue: 0,
-		value: '512',
-		step: 32,
-		fieldLabel: gettext('Swap') + ' (MiB)',
-		labelWidth: labelWidth,
-		allowBlank: false,
+		unitname: 'swapunit',
+		datastore: Object.keys(Proxmox.Utils.SizeUnits).slice(2, 5),
+		backendUnit: 'MiB',
 	    },
 	];
 
-- 
2.39.2





  parent reply	other threads:[~2023-07-27 10:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-27 10:30 [pve-devel] [PATCH pve-manager 0/2] change unit of memory for ct/vm Noel Ullreich
2023-07-27 10:30 ` [pve-devel] [PATCH pve-manager 1/2] ui: fix #3760: change unit of memory of a VM Noel Ullreich
2023-07-27 10:30 ` Noel Ullreich [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-06-16  9:54 [pve-devel] [PATCH pve-manager 0/2] ui: fix #3760: change units of ram/swap Noel Ullreich
2023-06-16  9:54 ` [pve-devel] [PATCH pve-manager 2/2] ui: fix: change units of memory/swap for containers Noel Ullreich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230727103049.38556-3-n.ullreich@proxmox.com \
    --to=n.ullreich@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal