From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D3E9A9819A for ; Fri, 6 Oct 2023 15:16:17 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AD52BAE4 for ; Fri, 6 Oct 2023 15:16:17 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 6 Oct 2023 15:16:15 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 539F544871 for ; Fri, 6 Oct 2023 15:16:15 +0200 (CEST) Message-ID: <118ba2e9-8c9e-4029-8738-9f806f49f73b@proxmox.com> Date: Fri, 6 Oct 2023 15:16:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Lukas Wagner To: Proxmox VE development discussion , Philipp Hufnagl References: <20230922143658.1639173-1-p.hufnagl@proxmox.com> <20230922143658.1639173-2-p.hufnagl@proxmox.com> Content-Language: de-AT, en-US In-Reply-To: <20230922143658.1639173-2-p.hufnagl@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.028 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 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 manager v1 1/1] fix #4546: ui: notify user if their user account expires soon 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: , X-List-Received-Date: Fri, 06 Oct 2023 13:16:17 -0000 Comments inline. On 9/22/23 16:36, Philipp Hufnagl wrote: > When the user account that is currently logged in will expire soon, the > user icon will turn into a yellow exclamation mark. In the user menu > there will be a new element informing the user briefly about it. If the ^ Well, the warning is permanent, so I wouldn't call it 'briefly' ;) > element is clicked, a popup will appear informing the user in detail > about it > > Signed-off-by: Philipp Hufnagl > --- > www/manager6/Workspace.js | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/www/manager6/Workspace.js b/www/manager6/Workspace.js > index 18d574b7..9d166493 100644 > --- a/www/manager6/Workspace.js > +++ b/www/manager6/Workspace.js > @@ -42,6 +42,7 @@ Ext.define('PVE.Workspace', { > Proxmox.Utils.authClear(); > Ext.state.Manager.clear('GuiCap'); > Proxmox.UserName = null; > + Proxmox.UserExpires = null; Another variable name might convey the meaning better, as this name somewhat reads booleanesque. How about Proxmox.AccountExpiresAt or Proxmox.AccountExpirationDate? > me.loginData = null; > > if (!me.login) { > @@ -198,6 +199,18 @@ Ext.define('PVE.StdWorkspace', { > let me = this; > let ui = me.query('#userinfo')[0]; > ui.setText(Ext.String.htmlEncode(Proxmox.UserName || '')); > + let label = me.query('#expirewarning')[0]; > + if (Proxmox.UserExpires !== null) { > + let expieWariningThreshold = Ext.Date.add(new Date(), Ext.Date.DAY, 7); ^ Typo in 'Warning' Nit: Also I'd not abbreviate: expiryWarningThreshold > + let expireDate = new Date(Proxmox.UserExpires * 1000); > + if (expieWariningThreshold >= expireDate) { > + ui.setIconCls('fa fa-exclamation-triangle warning'); > + label.setHidden(false); > + } > + } else { > + label.setHidden(true); > + ui.setIconCls('fa fa-user'); > + } > ui.updateLayout(); > }, > > @@ -367,6 +380,21 @@ Ext.define('PVE.StdWorkspace', { > }, > iconCls: 'fa fa-user', > menu: [ > + { > + iconCls: 'fa fa-exclamation-triangle warning', > + itemId: 'expirewarning', > + text: gettext('Account expiring soon!'), > + hidden: true, > + handler: function() { > + let expireDate = new Date(Proxmox.UserExpires * 1000); > + Ext.Msg.show({ > + title: gettext('Account expiring soon!'), > + icon: Ext.Msg.WARNING, > + message: Ext.String.format(gettext("Your account is expiring on {0} . After that you won't be able to log in!"), expireDate), > + buttons: Ext.Msg.OK, > + }); > + }, > + }, > { > iconCls: 'fa fa-gear', > text: gettext('My Settings'), -- - Lukas