Доработка окна авторизации

1 parent 1b4cf51f
...@@ -14,6 +14,12 @@ Ext.define('MyMA.controller.Viewport', { ...@@ -14,6 +14,12 @@ Ext.define('MyMA.controller.Viewport', {
}, { }, {
selector: 'authorize > form', selector: 'authorize > form',
ref: 'authForm' ref: 'authForm'
}, {
selector: 'authorize > form #authorize',
ref: 'authButton'
}, {
selector: 'authorize > form #autherrormsg',
ref: 'authErrorMsg'
}], }],
/** /**
...@@ -45,6 +51,13 @@ Ext.define('MyMA.controller.Viewport', { ...@@ -45,6 +51,13 @@ Ext.define('MyMA.controller.Viewport', {
this.control({ this.control({
'authorize > form > toolbar > button': { 'authorize > form > toolbar > button': {
click: this.Authorize click: this.Authorize
},
'authorize > form field': {
specialkey: function(field, e) {
if (e.getKey() == e.ENTER) {
this.Authorize();
}
}
} }
}); });
...@@ -61,12 +74,14 @@ Ext.define('MyMA.controller.Viewport', { ...@@ -61,12 +74,14 @@ Ext.define('MyMA.controller.Viewport', {
if (this.getAuthPanel()) { if (this.getAuthPanel()) {
var form = this.getAuthPanel().down('form').getForm(); var form = this.getAuthPanel().down('form').getForm();
if(form.isValid()) { if(form.isValid()) {
this.getAuthButton().setIconCls('x-ibtn-loading x-ibtn-def');
form.submit({ form.submit({
url: Ext.Ajax.getRestUrl('api','login', 'authorize', 0), url: Ext.Ajax.getRestUrl('api','login', 'authorize', 0),
method: 'PUT', method: 'PUT',
clientValidation: true, clientValidation: true,
scope: this, scope: this,
success: this.successLogin success: this.successLogin,
failure: this.failLogin
}) })
} }
} }
...@@ -119,6 +134,50 @@ Ext.define('MyMA.controller.Viewport', { ...@@ -119,6 +134,50 @@ Ext.define('MyMA.controller.Viewport', {
}, },
/**
* If login failed this function will show debug message if
* debug mode is on
*/
failLogin: function(form, action) {
try {
this.getAuthButton().setIconCls('');
var data = Ext.decode(action.response.responseText);
if(data.error.trace) {
Ext.Msg.showError({
msg: data
});
}
else {
var msg = this.getAuthErrorMsg();
msg.tpl.overwrite(msg.getEl(), { message: data.error.message || data.error.title});
if(msg && !msg.isVisible()) {
msg.show();
}
msg.stopAnimation();
msg.animate({
duration: 5,
to: {
opacity: 1
}
});
msg.animate({
duration: 5000,
to: {
opacity: 0
}
});
}
}
catch(e) { }
},
/** /**
* Logout * Logout
* public * public
......
...@@ -24,11 +24,35 @@ Ext.define('MyMA.view.Authorize', { ...@@ -24,11 +24,35 @@ Ext.define('MyMA.view.Authorize', {
monitorValid: true, monitorValid: true,
frame: false, frame: false,
border: false, border: false,
bodyStyle: {
border: 0,
background: 'transparent'
},
defaults: { defaults: {
anchor: '100%' anchor: '100%'
}, },
tbar: {
border: false,
height: 20,
style: {
border: 0,
background: 'transparent',
padding: 0
},
items: {
xtype: 'container',
itemId: 'autherrormsg',
hidden: true,
style: {
color: 'red'
},
tpl: '{message}',
data: { message: '' }
}
},
buttons: [{ buttons: [{
text: 'Login' text: 'Login',
itemId: 'authorize'
}], }],
items: [{ items: [{
fieldLabel: 'Login', fieldLabel: 'Login',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!