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 5F69175A17 for ; Tue, 13 Jul 2021 12:27:31 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5663620679 for ; Tue, 13 Jul 2021 12:27:01 +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 id B3CCE20666 for ; Tue, 13 Jul 2021 12:27:00 +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 8E1B841028 for ; Tue, 13 Jul 2021 12:27:00 +0200 (CEST) From: Dominik Csapak To: pmg-devel@lists.proxmox.com Date: Tue, 13 Jul 2021 12:26:57 +0200 Message-Id: <20210713102659.3004291-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.608 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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: [pmg-devel] [PATCH pmg-gui 1/3] LoginView: add save username checkbox X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jul 2021 10:27:31 -0000 like we have in pbs/pve but only for non-quarantine view we have to increase the width of the window, so it fits together with the 'send quarantine link' button Signed-off-by: Dominik Csapak --- js/LoginView.js | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/js/LoginView.js b/js/LoginView.js index 4770494..7ad695c 100644 --- a/js/LoginView.js +++ b/js/LoginView.js @@ -16,6 +16,9 @@ Ext.define('PMG.LoginView', { return; } + // hide save username field for quarantine view + me.lookup('saveunField').setVisible(false); + realmfield.setValue('quarantine'); // try autologin with quarantine ticket from URL @@ -45,11 +48,25 @@ Ext.define('PMG.LoginView', { let me = this; let view = me.getView(); let loginForm = me.lookupReference('loginForm'); + var unField = me.lookupReference('usernameField'); + var saveunField = me.lookupReference('saveunField'); if (loginForm.isValid()) { if (loginForm.isVisible()) { loginForm.mask(gettext('Please wait...'), 'x-mask-loading'); } + + // set or clear username for admin view + if (view.targetview !== 'quarantineview') { + var sp = Ext.state.Manager.getProvider(); + if (saveunField.getValue() === true) { + sp.set(unField.getStateId(), unField.getValue()); + } else { + sp.clear(unField.getStateId()); + } + sp.set(saveunField.getStateId(), saveunField.getValue()); + } + loginForm.submit({ success: function(form, action) { // save login data and create cookie @@ -108,6 +125,27 @@ Ext.define('PMG.LoginView', { 'button[reference=loginButton]': { click: 'submitForm', }, + 'window[reference=loginwindow]': { + show: function() { + let me = this; + let view = me.getView(); + if (view.targetview !== 'quarantineview') { + var sp = Ext.state.Manager.getProvider(); + var checkboxField = this.lookupReference('saveunField'); + var unField = this.lookupReference('usernameField'); + + var checked = sp.get(checkboxField.getStateId()); + checkboxField.setValue(checked); + + if (checked === true) { + var username = sp.get(unField.getStateId()); + unField.setValue(username); + var pwField = this.lookupReference('passwordField'); + pwField.focus(); + } + } + }, + }, }, }, @@ -147,6 +185,7 @@ Ext.define('PMG.LoginView', { reference: 'loginwindow', autoShow: true, modal: true, + width: 450, defaultFocus: 'usernameField', @@ -178,6 +217,7 @@ Ext.define('PMG.LoginView', { name: 'username', itemId: 'usernameField', reference: 'usernameField', + stateId: 'login-username', }, { xtype: 'textfield', @@ -201,6 +241,16 @@ Ext.define('PMG.LoginView', { }, ], buttons: [ + { + xtype: 'checkbox', + fieldLabel: gettext('Save User name'), + name: 'saveusername', + reference: 'saveunField', + stateId: 'login-saveusername', + labelAlign: 'right', + labelWidth: 150, + submitValue: false, + }, { text: gettext('Request Quarantine Link'), reference: 'quarantineButton', -- 2.30.2