]> git.proxmox.com Git - pmg-gui.git/blame - js/LoginView.js
bump version to 1.0-3
[pmg-gui.git] / js / LoginView.js
CommitLineData
cd6bb503
DC
1Ext.define('PMG.LoginView', {
2 extend: 'Ext.container.Container',
3 xtype: 'loginview',
4
5 controller: {
6 xclass: 'Ext.app.ViewController',
7 submitForm: function() {
8 var me = this;
9 var loginForm = me.lookupReference('loginForm');
10
11 if (loginForm.isValid()) {
12 loginForm.mask(gettext('Please wait...'), 'x-mask-loading');
13 loginForm.submit({
14 success: function(form, action) {
15 // save login data and create cookie
16 PMG.Utils.updateLoginData(action.result.data);
17 // change view to mainview
18 me.getView().destroy();
19 Ext.create({ xtype: 'mainview' });
20 },
21 failure: function(form, action) {
22 loginForm.unmask();
23 Ext.MessageBox.alert(
24 gettext('Error'),
25 gettext('Login failed. Please try again')
26 );
27 }
28 });
29 }
30 },
31
32 control: {
33 'button[reference=loginButton]': {
34 click: 'submitForm'
35 }
36 }
37 },
38
39 plugins: 'viewport',
40
41 layout: 'border',
42
43 items: [
44 {
45 region: 'north',
46 xtype: 'container',
47 layout: {
48 type: 'hbox',
49 align: 'middle'
50 },
51 margin: '4 5 4 5',
52 items: [
53 {
54 xtype: 'proxmoxlogo'
55 },
56 {
57 xtype: 'versioninfo',
58 makeApiCall: false,
59 }
60 ]
61 },
62 {
63 region: 'center'
64 },
65 {
66 xtype: 'window',
67 closable: false,
68 resizable: false,
69 autoShow: true,
70 modal: true,
71
72 layout: 'auto',
73
74 title: gettext('Proxmox Mail Gateway Login'),
75
76 items: [
77 {
78 xtype: 'form',
79 layout: 'form',
80 defaultButton: 'loginButton',
81 url: '/api2/extjs/access/ticket',
82 reference: 'loginForm',
83
84 fieldDefaults: {
85 labelAlign: 'right',
86 allowBlank: false
87 },
88
89 items: [
90 {
91 xtype: 'textfield',
92 fieldLabel: gettext('User name'),
93 name: 'username',
94 itemId: 'usernameField',
95 reference: 'usernameField',
96 },
97 {
98 xtype: 'textfield',
99 inputType: 'password',
100 fieldLabel: gettext('Password'),
101 name: 'password',
102 reference: 'passwordField'
103 },
104 {
105 xtype: 'hiddenfield',
106 name: 'realm',
107 value: 'pam',
108 }
109 ],
110 buttons: [
111 {
112 text: gettext('Login'),
113 reference: 'loginButton',
114 formBind: true
115 }
116 ]
117 }
118 ]
119 }
120 ]
121});