Pman.Dialog.Login.bjs
[Pman.BAdmin] / Pman.Dialog.Login.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Dialog');
6
7 Pman.Dialog.Login= function() {}
8 Roo.apply(Pman.Dialog.Login.prototype, {
9
10  _strings : {
11   'e50b62fb8271673bacc2cfd9d80fbe7a' :"Login to the Management Portal",
12   '99dea78007133396a7b8ed70578ac6ae' :"Login",
13   'cfcd208495d565ef66e7dff9f98764da' :"0",
14   'cd4bcecae78474ea24c3f28350758a8c' :"Forgot your password ?",
15   'dc647eb65e6711e155375218212b3964' :"Password",
16   '06cf692a8d2bb0ab8318dc6c839ae931' :"Two-Factor Authentication Number (if relevant)",
17   '11163ed17ad9afc7680bb9e92f15d6fd' :"We have sent you a link to reset your password",
18   '5047040b025ce0295b58d42250014417' :"<div id=\"login-err\" class=\"dialog-err\" style=\"color:red\"></div>",
19   '24efa7ee4511563b16144f39706d594f' :"Notice",
20   '643a860f992333b8600ea264aca7c4fc' :"Email Address"
21  },
22
23  dialog : false,
24  callback:  false,
25
26  show : function(data, cb)
27  {
28   if (!this.dialog) {
29    this.create();
30   }
31
32   this.callback = cb;
33   this.data = data;
34   this.dialog.show(this.data._el);
35   if (this.form) {
36    this.form.reset();
37    this.form.setValues(data);
38    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
39   }
40
41  },
42
43  create : function()
44  {
45   var _this = this;
46   this.dialog = Roo.factory({
47     xtype : 'Modal',
48     allow_close : false,
49     buttonPosition : 'center',
50     cls : 'enable-overflow login-dialog',
51     _dialog_title_login : _this._strings['e50b62fb8271673bacc2cfd9d80fbe7a'] /* Login to the Management Portal */,
52     listeners : {
53      btnclick : function (e)
54       {
55           if(e == 'cancel'){
56               _this.dialog.hide();
57               return;
58           }
59           
60           _this.dialog.el.select('.modal-content', true).first().mask('Sending...');
61           _this.form.doAction('submit');
62       },
63      render : function (_self) {
64       
65           Roo.get('login-err').dom.innerHTML = "";
66           _this.dialog.el.select('.modal-content', true).first().unmask();
67           
68           if(Roo.isTouch){
69               this.animate = false;
70           }
71       },
72      show : function (_self)
73       {
74        
75           
76           this.setTitle( _this.dialog._dialog_title_login );
77           
78           if (!Roo.state.Manager.getProvider().expires) {
79               Roo.state.Manager.setProvider(new Roo.state.CookieProvider());
80           }
81           
82           _this.lastLogin = Roo.state.Manager.get('Pman.Login', {});
83           _this.form.findField('username').focus();
84           
85           
86       }
87     },
88     xns : Roo.bootstrap,
89     '|xns' : 'Roo.bootstrap',
90     buttons : [
91      {
92       xtype : 'Button',
93       html : _this._strings['99dea78007133396a7b8ed70578ac6ae'] /* Login */,
94       name : 'OK',
95       style : 'float: right',
96       weight : 'primary',
97       xns : Roo.bootstrap,
98       '|xns' : 'Roo.bootstrap'
99      },
100      {
101       xtype : 'Button',
102       _forgot_passwd_success_body : _this._strings['11163ed17ad9afc7680bb9e92f15d6fd'] /* We have sent you a link to reset your password */,
103       _forgot_passwd_success_title : _this._strings['24efa7ee4511563b16144f39706d594f'] /* Notice */,
104       href : '#',
105       html : _this._strings['cd4bcecae78474ea24c3f28350758a8c'] /* Forgot your password ? */,
106       removeClass : true,
107       style : 'float: left',
108       tag : 'a',
109       weight : 'link',
110       listeners : {
111        click : function () {
112         
113             _this.dialog.hide();
114             
115             var email = _this.form.findField('username').getValue();
116             
117             var _self = this;
118             
119             Pman.Dialog.BAdminForgotPassword.show({email : email}, function(){
120                 Roo.bootstrap.MessageBox.alert(_self._forgot_passwd_success_title, _self._forgot_passwd_success_body);
121             });
122         }
123       },
124       xns : Roo.bootstrap,
125       '|xns' : 'Roo.bootstrap'
126      }
127     ],
128     items  : [
129      {
130       xtype : 'Row',
131       listeners : {
132        render : function (_self)
133         {
134             _this.login = this;
135             
136             this.el.setVisibilityMode(Roo.Element.DISPLAY);
137         }
138       },
139       xns : Roo.bootstrap,
140       '|xns' : 'Roo.bootstrap',
141       items  : [
142        {
143         xtype : 'Column',
144         xs : 12,
145         xns : Roo.bootstrap,
146         '|xns' : 'Roo.bootstrap',
147         items  : [
148          {
149           xtype : 'Row',
150           style : 'margin-top:20px;',
151           xns : Roo.bootstrap,
152           '|xns' : 'Roo.bootstrap',
153           items  : [
154            {
155             xtype : 'Container',
156             cls : 'col-md-12',
157             xns : Roo.bootstrap,
158             '|xns' : 'Roo.bootstrap',
159             items  : [
160              {
161               xtype : 'Form',
162               labelAlign : 'left',
163               loadMask : false,
164               method : 'POST',
165               url : baseURL + '/Login',
166               listeners : {
167                actioncomplete : function (_self, action) {
168                     
169                     if(action.type == 'setdata'){
170                 
171                         if(
172                             _this.lastLogin && 
173                             _this.lastLogin.login_provider == ''
174                         ){
175                             _this.form.findField('username').setValue(_this.lastLogin.email);
176                         }
177                         
178                         Roo.get('login-err').dom.innerHTML = "";
179                         _this.dialog.el.select('.modal-content', true).first().unmask();
180                         this.clearInvalid();
181                         return;
182                     }
183                      
184                     if(action.type == 'load'){
185                         
186                         return;
187                     }
188                     
189                     if (action.type =='submit') {
190                     
191                         _this.dialog.hide();
192                     
193                         if (_this.callback) {
194                             _this.callback.call(_this, action.result);
195                          }
196                          
197                          _this.form.reset();
198                          
199                          return;
200                     }
201                 },
202                actionfailed : function (_self, action) {
203                     Roo.log('action failed?!');
204                     Roo.log(action);
205                     
206                     _this.dialog.el.select('.modal-content', true).first().unmask();
207                     
208                     if (typeof(action) != 'undefined' && action.failureType == 'server') {
209                         
210                         switch (action.result.errorMsg) {
211                                     
212                             case 'Authenticated' :
213                                 
214                                 var data = Roo.apply(action.result.errors);
215                                 
216                                 data.target = _this.form.findField('username').getValue();
217                                 
218                                 Roo.bootstrap.MessageBox.alert("Error", "odd error messages");
219                                 
220                                 break;
221                                 
222                             case 'NEW-IP-ADDRESS' :
223                             case 'PENDING-IP-ADDRESS' :
224                             case 'BAD-IP-ADDRESS' :
225                             case 'BLOCKED-IP-ADDRESS' :
226                                 
227                                 _this.dialog.hide();
228                                 
229                                 Pman.Dialog.LoginNotice.show({
230                                     status : action.result.errorMsg,
231                                     ip : action.result.errors.ip
232                                 });
233                                 
234                                 break;
235                                 
236                             default:
237                                 Roo.get('login-err').dom.innerHTML = action.result.errorMsg;
238                                 break;
239                         }
240                         
241                         return;
242                     }
243                     
244                     Roo.get('login-err').dom.innerHTML = "Fill in all the required fields";
245                 },
246                render : function (_self) {
247                     _this.form = _self;
248                 }
249               },
250               xns : Roo.bootstrap,
251               '|xns' : 'Roo.bootstrap',
252               items  : [
253                {
254                 xtype : 'Container',
255                 cls : 'col-sm-12',
256                 xns : Roo.bootstrap,
257                 '|xns' : 'Roo.bootstrap',
258                 items  : [
259                  {
260                   xtype : 'Input',
261                   allowBlank : false,
262                   inputType : 'email',
263                   name : 'username',
264                   placeholder : _this._strings['643a860f992333b8600ea264aca7c4fc'] /* Email Address */,
265                   vtype : 'email',
266                   listeners : {
267                    specialkey : function (_self, e)
268                     {
269                         if(e.getKey() == 13){
270                             _this.dialog.el.select('.modal-content', true).first().mask('Sending...');
271                             _this.form.doAction('submit');
272                         }
273                         
274                     }
275                   },
276                   xns : Roo.bootstrap,
277                   '|xns' : 'Roo.bootstrap'
278                  },
279                  {
280                   xtype : 'Input',
281                   allowBlank : false,
282                   inputType : 'password',
283                   name : 'password',
284                   placeholder : _this._strings['dc647eb65e6711e155375218212b3964'] /* Password */,
285                   listeners : {
286                    specialkey : function (_self, e)
287                     {
288                         if(e.getKey() == 13){
289                             _this.dialog.el.select('.modal-content', true).first().mask('Sending...');
290                             _this.form.doAction('submit');
291                         }
292                     }
293                   },
294                   xns : Roo.bootstrap,
295                   '|xns' : 'Roo.bootstrap'
296                  },
297                  {
298                   xtype : 'NumberField',
299                   allowBlank : true,
300                   maxLength : 6,
301                   name : 'oath_password',
302                   placeholder : _this._strings['06cf692a8d2bb0ab8318dc6c839ae931'] /* Two-Factor Authentication Number (if relevant) */,
303                   listeners : {
304                    specialkey : function (_self, e)
305                     {
306                         if(e.getKey() == 13){
307                             _this.dialog.el.select('.modal-content', true).first().mask('Sending...');
308                             _this.form.doAction('submit');
309                         }
310                     }
311                   },
312                   xns : Roo.bootstrap,
313                   '|xns' : 'Roo.bootstrap'
314                  },
315                  {
316                   xtype : 'Input',
317                   inputType : 'hidden',
318                   name : '_force',
319                   value : 0,
320                   xns : Roo.bootstrap,
321                   '|xns' : 'Roo.bootstrap'
322                  }
323                 ]
324                }
325               ]
326              }
327             ]
328            }
329           ]
330          },
331          {
332           xtype : 'Row',
333           xns : Roo.bootstrap,
334           '|xns' : 'Roo.bootstrap',
335           items  : [
336            {
337             xtype : 'Container',
338             cls : 'col-md-12',
339             xns : Roo.bootstrap,
340             '|xns' : 'Roo.bootstrap',
341             items  : [
342              {
343               xtype : 'Container',
344               cls : 'bg-danger',
345               html : _this._strings['5047040b025ce0295b58d42250014417'] /* <div id="login-err" class="dialog-err" style="color:red"></div> */,
346               style : 'margin-top:20px;',
347               xns : Roo.bootstrap,
348               '|xns' : 'Roo.bootstrap'
349              }
350             ]
351            }
352           ]
353          }
354         ]
355        }
356       ]
357      }
358     ]
359    }  );
360  }
361 });
362 Roo.apply(Pman.Dialog.Login, Pman.Dialog.Login.prototype);