[pve-devel] [PATCH manager v1 1/1] fix #4546: ui: notify user if their user account expires soon
Lukas Wagner
l.wagner at proxmox.com
Fri Oct 6 15:16:14 CEST 2023
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 <p.hufnagl at proxmox.com>
> ---
> 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
More information about the pve-devel
mailing list