]>
git.proxmox.com Git - proxmox-backup.git/blob - www/LoginView.js
1 Ext
.define('PBS.LoginView', {
2 extend
: 'Ext.container.Container',
6 xclass
: 'Ext.app.ViewController',
8 submitForm: function() {
10 var loginForm
= me
.lookupReference('loginForm');
11 var unField
= me
.lookupReference('usernameField');
12 var saveunField
= me
.lookupReference('saveunField');
14 if (!loginForm
.isValid()) {
18 let params
= loginForm
.getValues();
20 params
.username
= params
.username
+ '@' + params
.realm
;
23 if (loginForm
.isVisible()) {
24 loginForm
.mask(gettext('Please wait...'), 'x-mask-loading');
27 // set or clear username
28 var sp
= Ext
.state
.Manager
.getProvider();
29 if (saveunField
.getValue() === true) {
30 sp
.set(unField
.getStateId(), unField
.getValue());
32 sp
.clear(unField
.getStateId());
34 sp
.set(saveunField
.getStateId(), saveunField
.getValue());
36 Proxmox
.Utils
.API2Request({
37 url
: '/api2/extjs/access/ticket',
40 success: function(resp
, opts
) {
41 // save login data and create cookie
42 PBS
.Utils
.updateLoginData(resp
.result
.data
);
43 PBS
.app
.changeView('mainview');
45 failure: function(resp
, opts
) {
46 Proxmox
.Utils
.authClear();
50 gettext('Login failed. Please try again'),
57 'field[name=username]': {
58 specialkey: function(f
, e
) {
59 if (e
.getKey() === e
.ENTER
) {
60 var pf
= this.lookupReference('passwordField');
68 change: function(f
, value
) {
69 var dt
= Ext
.Date
.add(new Date(), Ext
.Date
.YEAR
, 10);
70 Ext
.util
.Cookies
.set('PBSLangCookie', value
, dt
);
71 this.getView().mask(gettext('Please wait...'), 'x-mask-loading');
72 window
.location
.reload();
75 'button[reference=loginButton]': {
78 'window[reference=loginwindow]': {
80 var sp
= Ext
.state
.Manager
.getProvider();
81 var checkboxField
= this.lookupReference('saveunField');
82 var unField
= this.lookupReference('usernameField');
84 var checked
= sp
.get(checkboxField
.getStateId());
85 checkboxField
.setValue(checked
);
87 if (checked
=== true) {
88 var username
= sp
.get(unField
.getStateId());
89 unField
.setValue(username
);
90 var pwField
= this.lookupReference('passwordField');
116 xtype
: 'proxmoxlogo',
120 xtype
: 'versioninfo',
132 reference
: 'loginwindow',
137 defaultFocus
: 'usernameField',
143 title
: gettext('Proxmox Backup Server Login'),
151 defaultButton
: 'loginButton',
152 url
: '/api2/extjs/access/ticket',
153 reference
: 'loginForm',
163 fieldLabel
: gettext('User name'),
165 itemId
: 'usernameField',
166 reference
: 'usernameField',
167 stateId
: 'login-username',
171 inputType
: 'password',
172 fieldLabel
: gettext('Password'),
174 itemId
: 'passwordField',
175 reference
: 'passwordField',
178 xtype
: 'pmxRealmComboBox',
182 xtype
: 'proxmoxLanguageSelector',
183 fieldLabel
: gettext('Language'),
184 value
: Ext
.util
.Cookies
.get('PBSLangCookie') || Proxmox
.defaultLang
|| 'en',
186 reference
: 'langField',
193 fieldLabel
: gettext('Save User name'),
194 name
: 'saveusername',
195 reference
: 'saveunField',
196 stateId
: 'login-saveusername',
202 text
: gettext('Login'),
203 reference
: 'loginButton',