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