[pve-devel] [PATCH 10/18] add loginview

Dominik Csapak d.csapak at proxmox.com
Tue Apr 4 13:48:50 CEST 2017


this replaces the loginwindow, and is responsible for logging in the user

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 js/LoginView.js | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 121 insertions(+)
 create mode 100644 js/LoginView.js

diff --git a/js/LoginView.js b/js/LoginView.js
new file mode 100644
index 0000000..f4e79f5
--- /dev/null
+++ b/js/LoginView.js
@@ -0,0 +1,121 @@
+Ext.define('PMG.LoginView', {
+    extend: 'Ext.container.Container',
+    xtype: 'loginview',
+
+    controller: {
+	xclass: 'Ext.app.ViewController',
+	submitForm: function() {
+	    var me = this;
+	    var loginForm = me.lookupReference('loginForm');
+
+	    if (loginForm.isValid()) {
+		loginForm.mask(gettext('Please wait...'), 'x-mask-loading');
+		loginForm.submit({
+		    success: function(form, action) {
+			// save login data and create cookie
+			PMG.Utils.updateLoginData(action.result.data);
+			// change view to mainview
+			me.getView().destroy();
+			Ext.create({ xtype: 'mainview' });
+		    },
+		    failure: function(form, action) {
+			loginForm.unmask();
+			Ext.MessageBox.alert(
+			    gettext('Error'),
+			    gettext('Login failed. Please try again')
+			);
+		    }
+		});
+	    }
+	},
+
+	control: {
+	    'button[reference=loginButton]': {
+		click: 'submitForm'
+	    }
+	}
+    },
+
+    plugins: 'viewport',
+
+    layout: 'border',
+
+    items: [
+	{
+	    region: 'north',
+	    xtype: 'container',
+	    layout: {
+		type: 'hbox',
+		align: 'middle'
+	    },
+	    margin: '4 5 4 5',
+	    items: [
+		{
+		    xtype: 'proxmoxlogo'
+		},
+		{
+		    xtype: 'versioninfo',
+		    makeApiCall: false,
+		}
+	    ]
+	},
+	{
+	    region: 'center'
+	},
+	{
+	    xtype: 'window',
+	    closable: false,
+	    resizable: false,
+	    autoShow: true,
+	    modal: true,
+
+	    layout: 'auto',
+
+	    title: gettext('Proxmox Mail Gateway Login'),
+
+	    items: [
+		{
+		    xtype: 'form',
+		    layout: 'form',
+		    defaultButton: 'loginButton',
+		    url: '/api2/extjs/access/ticket',
+		    reference: 'loginForm',
+
+		    fieldDefaults: {
+			labelAlign: 'right',
+			allowBlank: false
+		    },
+
+		    items: [
+			{
+			    xtype: 'textfield',
+			    fieldLabel: gettext('User name'),
+			    name: 'username',
+			    itemId: 'usernameField',
+			    reference: 'usernameField',
+			},
+			{
+			    xtype: 'textfield',
+			    inputType: 'password',
+			    fieldLabel: gettext('Password'),
+			    name: 'password',
+			    reference: 'passwordField'
+			},
+			{
+			    xtype: 'hiddenfield',
+			    name: 'realm',
+			    value: 'pam',
+			}
+		    ],
+		    buttons: [
+			{
+			    text: gettext('Login'),
+			    reference: 'loginButton',
+			    formBind: true
+			}
+		    ]
+		}
+	    ]
+	}
+    ]
+});
-- 
2.11.0





More information about the pve-devel mailing list