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