public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pmg-devel] [PATCH pmg-gui 1/3] LoginView: add save username checkbox
@ 2021-07-13 10:26 Dominik Csapak
  2021-07-13 10:26 ` [pmg-devel] [PATCH pmg-gui 2/3] ServerStatus: update column width on state change Dominik Csapak
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dominik Csapak @ 2021-07-13 10:26 UTC (permalink / raw)
  To: pmg-devel

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 <d.csapak@proxmox.com>
---
 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





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-13 12:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-13 10:26 [pmg-devel] [PATCH pmg-gui 1/3] LoginView: add save username checkbox Dominik Csapak
2021-07-13 10:26 ` [pmg-devel] [PATCH pmg-gui 2/3] ServerStatus: update column width on state change Dominik Csapak
2021-07-13 10:26 ` [pmg-devel] [PATCH pmg-gui 3/3] add Settings window Dominik Csapak
2021-07-13 12:31 ` [pmg-devel] applied-series: [PATCH pmg-gui 1/3] LoginView: add save username checkbox Thomas Lamprecht

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