From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id E03101FF16F for ; Thu, 19 Dec 2024 17:07:38 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D68F8C4A4; Thu, 19 Dec 2024 17:07:38 +0100 (CET) From: Daniel Kral To: f.gruenbichler@proxmox.com Date: Thu, 19 Dec 2024 17:07:30 +0100 Message-Id: <20241219160730.186517-1-d.kral@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20240416122054.733817-14-f.gruenbichler@proxmox.com> References: <20240416122054.733817-14-f.gruenbichler@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.146 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_2 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_4 0.1 random spam to be learned in bayes SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH v2 manager 4/4] ui: add pool limits and usage X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Cc: pve-devel@lists.proxmox.com Content-Type: multipart/mixed; boundary="===============7285959755543848492==" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" --===============7285959755543848492== Content-Transfer-Encoding: quoted-printable On 16/04/2024 14:20, Fabian Gr=C3=BCnbichler wrote:=0D > Signed-off-by: Fabian Gr=C3=BCnbichler =0D > ---=0D > =0D > Notes:=0D > this is very "bare", obviously we'd want=0D > - a nicer grid/.. display of usage=0D > - a way to edit the limits=0D > =0D > I am not yet sure how to integrate this nicely, and wanted to get fee= dback on the rest first.=0D > =0D > v2:=0D > - fold in change I forgot to include in patch:=0D > (=3D=3D vs =3D=3D=3D, ? 1 : 0 vs just using the comparison result)=0D > =0D > add edit window=0D > =0D > www/manager6/pool/StatusView.js | 141 +++++++++++++++++++++++++++++++-=0D > 1 file changed, 140 insertions(+), 1 deletion(-)=0D > =0D > diff --git a/www/manager6/pool/StatusView.js b/www/manager6/pool/StatusVi= ew.js=0D > index 3d46b3b1a..293ee1443 100644=0D > --- a/www/manager6/pool/StatusView.js=0D > +++ b/www/manager6/pool/StatusView.js=0D > @@ -1,12 +1,103 @@=0D > +var labelWidth =3D 200;=0D > +=0D > +Ext.define('PVE.pool.LimitInputPanel', {=0D > + extend: 'Proxmox.panel.InputPanel',=0D > + alias: 'widget.pvePoolLimitInputPanel',=0D > +=0D > + onGetValues: function(values) {=0D > + let ret =3D PVE.Parser.printPropertyString(values, 'type');=0D > + if (ret =3D=3D=3D '') {=0D > + return { 'delete': 'limits' };=0D > + }=0D > + return { limits: ret };=0D > + },=0D > +=0D > + items: [=0D > + {=0D > + xtype: 'proxmoxintegerfield',=0D > + name: 'mem-config',=0D > + minValue: 0,=0D > + value: '0',=0D > + step: 32,=0D > + fieldLabel: gettext('Memory Config Limit') + ' (MiB)',=0D > + labelWidth: labelWidth,=0D > + allowBlank: false,=0D > + },=0D > + {=0D > + xtype: 'proxmoxintegerfield',=0D > + name: 'mem-run',=0D > + minValue: 0,=0D > + value: '0',=0D > + step: 32,=0D > + fieldLabel: gettext('Memory Running Limit') + ' (MiB)',=0D > + labelWidth: labelWidth,=0D > + allowBlank: false,=0D > + },=0D > + {=0D > + xtype: 'proxmoxintegerfield',=0D > + name: 'cpu-config',=0D > + minValue: 0,=0D > + value: '0',=0D > + fieldLabel: gettext('CPU Config Limit'),=0D > + labelWidth: labelWidth,=0D > + allowBlank: false,=0D > + },=0D > + {=0D > + xtype: 'proxmoxintegerfield',=0D > + name: 'cpu-run',=0D > + minValue: 0,=0D > + value: '0',=0D > + fieldLabel: gettext('CPU Running Limit'),=0D > + labelWidth: labelWidth,=0D > + allowBlank: false,=0D > + },=0D > + ],=0D > +});=0D > +=0D > +Ext.define('PVE.pool.EditLimits', {=0D > + extend: 'Proxmox.window.Edit',=0D > +=0D > + width: 640,=0D > + height: 480,=0D > +=0D > + initComponent: function() {=0D > + var me =3D this;=0D > +=0D > + if (!me.pool) {=0D > + throw "no pool specified";=0D > + }=0D > +=0D > + me.url =3D '/pools/';=0D > + me.method =3D 'PUT';=0D > + me.extraRequestParams =3D { poolid: me.pool };=0D > + me.autoLoad =3D true;=0D > +=0D > + Ext.apply(me, {=0D > + subject: gettext('Pool Limits'),=0D > + items: Ext.create('PVE.pool.LimitInputPanel'),=0D > + });=0D > +=0D > + me.callParent();=0D > +=0D > + me.load({=0D > + success: function(response) {=0D > + me.poolconfig =3D response.result.data[0];=0D > + let limits =3D me.poolconfig.limits;=0D > + me.setValues(PVE.Parser.parsePropertyString(limits));=0D > + },=0D > + });=0D > + },=0D > +});=0D > +=0D > Ext.define('PVE.pool.StatusView', {=0D > extend: 'Proxmox.grid.ObjectGrid',=0D > alias: ['widget.pvePoolStatusView'],=0D > - disabled: true,=0D > =0D > title: gettext('Status'),=0D > cwidth1: 150,=0D > interval: 30000,=0D > //height: 195,=0D > +=0D > initComponent: function() {=0D > var me =3D this;=0D > =0D > @@ -15,17 +106,65 @@ Ext.define('PVE.pool.StatusView', {=0D > throw "no pool specified";=0D > }=0D > =0D > + var reload =3D function() {=0D > + me.rstore.load();=0D > + };=0D > +=0D > var rows =3D {=0D > comment: {=0D > header: gettext('Comment'),=0D > renderer: Ext.String.htmlEncode,=0D > required: true,=0D > },=0D > + usage: {=0D > + header: gettext('Usage'),=0D > + required: false,=0D > + renderer: value =3D> {=0D > + if (value =3D=3D=3D null) {=0D > + return '-';=0D > + } else {=0D > + let rendered =3D '';=0D > + let over =3D false;=0D > + for (const [first, second] of Object.entries(value)) {=0D =0D We could append an `.sort()` for `Object.entries(value)` here...=0D =0D > + if (first =3D=3D=3D 'over') {=0D > + over =3D second =3D=3D=3D 1;=0D > + } else {=0D > + for (const [kind, usage] of Object.entries(second)) {=0D =0D ...and here, as the `encode_json` / `decode_json` function in Perl seems=0D to be kinda racy on preserving the order of the sent keys, which made=0D the rendered key-value-pairs jump around in the WebGUI.=0D =0D Better yet, it could be sorted at the API endpoint instead, as we use=0D these values for user-facing displays and those should be the same order=0D every time.=0D =0D > + if (rendered =3D=3D=3D '') {=0D > + rendered =3D `${first}-${kind}=3D${usage}`;=0D > + } else {=0D > + rendered =3D rendered + `, ${first}-${kind}=3D${usage}`;=0D > + }=0D > + }=0D > + }=0D > + }=0D > + if (over) {=0D > + rendered =3D rendered + "\nover limit";=0D > + }=0D > + return rendered;=0D > + }=0D > + },=0D > + },=0D > + limits: {=0D > + header: gettext('Resource Limits'),=0D > + required: false,=0D > + },=0D > };=0D > =0D > Ext.apply(me, {=0D > url: "/api2/json/pools/?poolid=3D" + pool,=0D > rows: rows,=0D > + tbar: [=0D > + {=0D > + text: gettext('Edit Limits'),=0D > + iconCls: 'pve-itype-icon-qemu',=0D > + handler: function() {=0D > + var win =3D Ext.create('PVE.pool.EditLimits', { pool: pool });= =0D > + win.on('destroy', reload);=0D > + win.show();=0D > + },=0D > + },=0D > + ],=0D > });=0D > =0D > me.callParent();=0D > -- =0D > 2.39.2=0D =0D =0D =0D =0D =0D --===============7285959755543848492== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel --===============7285959755543848492==--