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