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

1 parent 1b4cf51f
......@@ -14,6 +14,12 @@ Ext.define('MyMA.controller.Viewport', {
}, {
selector: 'authorize > form',
ref: 'authForm'
}, {
selector: 'authorize > form #authorize',
ref: 'authButton'
}, {
selector: 'authorize > form #autherrormsg',
ref: 'authErrorMsg'
}],
/**
......@@ -45,6 +51,13 @@ Ext.define('MyMA.controller.Viewport', {
this.control({
'authorize > form > toolbar > button': {
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', {
if (this.getAuthPanel()) {
var form = this.getAuthPanel().down('form').getForm();
if(form.isValid()) {
this.getAuthButton().setIconCls('x-ibtn-loading x-ibtn-def');
form.submit({
url: Ext.Ajax.getRestUrl('api','login', 'authorize', 0),
method: 'PUT',
clientValidation: true,
scope: this,
success: this.successLogin
success: this.successLogin,
failure: this.failLogin
})
}
}
......@@ -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
* public
......
......@@ -24,11 +24,35 @@ Ext.define('MyMA.view.Authorize', {
monitorValid: true,
frame: false,
border: false,
bodyStyle: {
border: 0,
background: 'transparent'
},
defaults: {
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: [{
text: 'Login'
text: 'Login',
itemId: 'authorize'
}],
items: [{
fieldLabel: 'Login',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!