Pman.Dialog.BAdminPassword.bjs
[Pman.BAdmin] / Pman.Dialog.BAdminPassword.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.BAdminPassword= function() {}
8 Roo.apply(Pman.Dialog.BAdminPassword.prototype, {
9
10  _strings : {
11   '9182ecb4943f2724adde82c820702555' :"Retype New Password",
12   '8f1e77e0d2be21da93cd4d9a939148f7' :"Change Password",
13   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
14   'ae3bb2a1ac61750150b606298091d38a' :"New Password",
15   '51eea3dc60ae3a0b1bb8188bc6337dc2' :"enter password",
16   'bb78dd7992509064b8044b7afe6ec9ed' :"Update Password",
17   '828e70f83623b262e14187c039df99c0' :"Enable Two-Factor Authentication"
18  },
19  _named_strings : {
20   'changePassword_placeholder' : '51eea3dc60ae3a0b1bb8188bc6337dc2' /* enter password */ ,
21   'passwd2_fieldLabel' : '9182ecb4943f2724adde82c820702555' /* Retype New Password */ ,
22   'passwd1_fieldLabel' : 'ae3bb2a1ac61750150b606298091d38a' /* New Password */ ,
23   '_enable_oath_key_boxLabel' : '828e70f83623b262e14187c039df99c0' /* Enable Two-Factor Authentication */ 
24  },
25
26  dialog : false,
27  callback:  false,
28
29  show : function(data, cb)
30  {
31   if (!this.dialog) {
32    this.create();
33   }
34
35   this.callback = cb;
36   this.data = data;
37   this.dialog.show(this.data._el);
38   if (this.form) {
39    this.form.reset();
40    this.form.setValues(data);
41    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
42   }
43
44  },
45
46  create : function()
47  {
48   var _this = this;
49   this.dialog = Roo.factory({
50     xtype : 'Modal',
51     cls : 'enable-overflow',
52     title : _this._strings['8f1e77e0d2be21da93cd4d9a939148f7'] /* Change Password */,
53     listeners : {
54      show : function (_self)
55       {
56           
57       }
58     },
59     xns : Roo.bootstrap,
60     '|xns' : 'Roo.bootstrap',
61     buttons : [
62      {
63       xtype : 'Button',
64       html : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
65       listeners : {
66        click : function (_self, e)
67         {
68             _this.dialog.hide({});
69         },
70        render : function (_self)
71         {
72             _this.cancel_btn = this;
73         }
74       },
75       xns : Roo.bootstrap,
76       '|xns' : 'Roo.bootstrap'
77      },
78      {
79       xtype : 'Button',
80       changeStatus : function(status)
81       {
82           switch(status) {
83               
84               case 'submit':
85                   this.disable();
86                   this.setText('sending...');
87                   break;
88                   
89               case 'loaded':
90                   this.enable();
91                   this.setText('OK');
92                   break;
93               
94               default:
95                   break;
96           }
97       },
98       html : _this._strings['bb78dd7992509064b8044b7afe6ec9ed'] /* Update Password */,
99       weight : 'primary',
100       listeners : {
101        click : function (_self, e)
102         {
103             var p1 = _this.form.findField('passwd1').getValue();
104             var p2 = _this.form.findField('passwd2').getValue();
105             
106             if(
107                 !p1.length ||
108                 !p2.length ||
109                 p1 !== p2
110             ) {
111                 Roo.bootstrap.MessageBox.alert("Error", "Passwords do not match");
112                 return;
113             }
114             
115             _this.form.findField('changePassword').setValue(1);
116             
117             this.changeStatus('submit');
118             
119             _this.form.doAction('submit');
120         },
121        render : function (_self)
122         {
123             _this.submit_button = this;
124         }
125       },
126       xns : Roo.bootstrap,
127       '|xns' : 'Roo.bootstrap'
128      }
129     ],
130     items  : [
131      {
132       xtype : 'Container',
133       style : 'width: 100%',
134       xns : Roo.bootstrap,
135       '|xns' : 'Roo.bootstrap',
136       items  : [
137        {
138         xtype : 'Form',
139         method : 'POST',
140         url : baseURL+'/Login',
141         listeners : {
142          actioncomplete : function (_self, action)
143           {
144               if(action.type == 'setdata'){
145                   
146                   _this.form.reset();
147                   
148                   _this.form.clearInvalid();
149                   
150                   _this.form.findField('_enable_oath_key').setChecked(false,true);
151                  
152                   new Pman.Request({
153                       url: baseURL + '/Login.php',
154                       method: 'POST',
155                       params: {
156                           getAuthUser: true
157                       }, 
158                       success: function(res) {
159                           
160                           if(res.data.oath_key_enable) {
161                               _this.form.findField('_enable_oath_key').setChecked(true,true);
162                           }
163                       }
164                   });
165               }
166               
167               if (action.type == 'load') {
168                   
169                   Roo.log('invalid usage');
170               }
171               
172               if (action.type =='submit') {
173                   
174                   if (_this.callback) {
175                       _this.callback.call(_this, action.result);
176                   }
177                   
178                   _this.form.reset();
179                   
180                   _this.submit_button.changeStatus('loaded');
181                   
182                   _this.dialog.hide({});
183                   
184                   return;
185               }
186           },
187          actionfailed : function (_self, action)
188           {
189               if (action.type =='submit') {
190                   
191                   _this.submit_button.changeStatus('loaded');
192                   
193                   if (_this.callback) {
194                       _this.callback.call(_this, action.result);
195                   }
196               }
197           },
198          render : function (_self)
199           {
200               _this.form_pw = this;
201           }
202         },
203         xns : Roo.bootstrap,
204         '|xns' : 'Roo.bootstrap',
205         items  : [
206          {
207           xtype : 'Row',
208           xns : Roo.bootstrap,
209           '|xns' : 'Roo.bootstrap',
210           items  : [
211            {
212             xtype : 'Column',
213             xs : 12,
214             xns : Roo.bootstrap,
215             '|xns' : 'Roo.bootstrap',
216             items  : [
217              {
218               xtype : 'Input',
219               allowBlank : false,
220               fieldLabel : _this._strings['ae3bb2a1ac61750150b606298091d38a'] /* New Password */,
221               inputType : 'password',
222               labelAlign : 'top',
223               name : 'passwd1',
224               listeners : {
225                change : function (_self, newValue, oldValue)
226                 {
227                     _this.form.findField('passwd2').markInvalid();
228                 }
229               },
230               xns : Roo.bootstrap,
231               '|xns' : 'Roo.bootstrap'
232              },
233              {
234               xtype : 'Input',
235               allowBlank : false,
236               fieldLabel : _this._strings['9182ecb4943f2724adde82c820702555'] /* Retype New Password */,
237               inputType : 'password',
238               labelAlign : 'top',
239               name : 'passwd2',
240               listeners : {
241                valid : function (_self)
242                 {
243                     if (_this.form.findField('passwd1').getValue() !== _this.form.findField('passwd2').getValue()){
244                         _this.form.findField('passwd2').markInvalid();
245                     }
246                 }
247               },
248               xns : Roo.bootstrap,
249               '|xns' : 'Roo.bootstrap'
250              },
251              {
252               xtype : 'Input',
253               allowBlank : false,
254               inputType : 'hidden',
255               labelAlign : 'top',
256               name : 'changePassword',
257               placeholder : _this._strings['51eea3dc60ae3a0b1bb8188bc6337dc2'] /* enter password */,
258               xns : Roo.bootstrap,
259               '|xns' : 'Roo.bootstrap'
260              },
261              {
262               xtype : 'CheckBox',
263               boxLabel : _this._strings['828e70f83623b262e14187c039df99c0'] /* Enable Two-Factor Authentication */,
264               checked : false,
265               name : '_enable_oath_key',
266               listeners : {
267                check : function (_self, checked)
268                 {
269                     // keep firing when showing a dialog with checked checkbox...
270                     
271                     Roo.log(_this.dialog.getEl().isVisible());
272                     
273                     if(!_this.dialog.getEl().isVisible()) {
274                         return;
275                     }
276                 
277                     if(checked) {
278                         
279                         Roo.log('who keep firing the check....');
280                         
281                         Pman.Dialog.BAdminStaffTwoFactorQRCode.show({});
282                         
283                         this.setBoxLabel('Untick to disable Two Factor authentication');
284                         
285                         return;
286                     }
287                     
288                     this.setBoxLabel('Enable Two Factor Authentication');
289                 }
290               },
291               xns : Roo.bootstrap,
292               '|xns' : 'Roo.bootstrap'
293              }
294             ]
295            }
296           ]
297          }
298         ]
299        }
300       ]
301      }
302     ]
303    }  );
304  }
305 });
306 Roo.apply(Pman.Dialog.BAdminPassword, Pman.Dialog.BAdminPassword.prototype);