Pman.Dialog.BAdminStaffTwoFactorQRCode.bjs
[Pman.BAdmin] / Pman.Dialog.BAdminStaffTwoFactorQRCode.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.BAdminStaffTwoFactorQRCode= function() {}
8 Roo.apply(Pman.Dialog.BAdminStaffTwoFactorQRCode.prototype, {
9
10  _strings : {
11   'dc7b0c7f9d3941532bda06cd58eec7bd' :"<ol class='qr-list' start=\"1\">\n    <li>Open Google Authenticator in your phone, and scan this QR code.</li>\n</ol>",
12   '5d412a3d8de0189df31c8f331e2e6630' :"<ol class='qr-list' start=\"2\">\n    <li>After adding this to Google Authenticator, type in the generated number below to confirm.</li>\n</ol>",
13   '131e3875e777f6c9a8e510f96a4d20d2' :"Skip for now",
14   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
15   'ee468f72ab7fe4937fb014d6fcea540b' :"Enter Two factor Authentication code",
16   '4674ee874911c910f2356ef9ec6ab7f9' :"Scan this into Google Authenticator",
17   '70d9be9b139893aa6c69b5e77e614311' :"Confirm"
18  },
19  _named_strings : {
20   'two_factor_auth_code_fieldLabel' : 'ee468f72ab7fe4937fb014d6fcea540b' /* Enter Two factor Authentication code */ 
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 : true,
49     animate : false,
50     cls : 'enable-overflow coba-qr-dialog',
51     title : _this._strings['4674ee874911c910f2356ef9ec6ab7f9'] /* Scan this into Google Authenticator */,
52     listeners : {
53      hide : function (_self)
54       {
55           if(_this.callback){
56               _this.callback.call(_this, false);
57           }
58           
59       },
60      show : function (_self)
61       {
62           if(!Pman.Login.authUser) {
63               Roo.bootstrap.MessageBox.alert('Error', 'Please login again');
64               return;
65           }
66           
67           if(
68               !_this.data.id ||
69               _this.data.id.length == 0
70           ) {
71               Roo.bootstrap.MessageBox.alert('Error', 'Please select a person again');
72               return;
73           }
74           
75           _this.dialog.closeEl.hide();
76           _this.skipBtn.hide();
77           _this.cancelBtn.hide();
78           
79           if(_this.data.allow_close) {
80               _this.dialog.closeEl.show();
81               _this.skipBtn.show();
82           }
83           
84           if(_this.data.allow_cancel) {
85               _this.cancelBtn.show();
86           }
87           
88           new Pman.Request({
89               url: baseURL + '/Roo/Core_person.php',
90               method : 'GET',
91               mask : 'Loading...',
92               params : {
93                   _to_qr_code : 1,
94                   id: _this.data.id
95               },
96               
97               success : function(res) {
98                   _this.qrcode_image.setSrc(res.data.image);
99               },
100               
101               failure : function(res) {
102                   Roo.log(res);
103               }
104           });
105       }
106     },
107     xns : Roo.bootstrap,
108     '|xns' : 'Roo.bootstrap',
109     buttons : [
110      {
111       xtype : 'Button',
112       html : _this._strings['131e3875e777f6c9a8e510f96a4d20d2'] /* Skip for now */,
113       weight : 'default',
114       listeners : {
115        click : function (_self, e)
116         {
117             _this.dialog.hide();
118             
119             return;
120         },
121        render : function (_self)
122         {
123             _this.skipBtn = this;
124         }
125       },
126       xns : Roo.bootstrap,
127       '|xns' : 'Roo.bootstrap'
128      },
129      {
130       xtype : 'Button',
131       html : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
132       weight : 'default',
133       listeners : {
134        click : function (_self, e)
135         {
136             _this.dialog.hide();
137             
138             return;
139         },
140        render : function (_self)
141         {
142             _this.cancelBtn = this;
143         }
144       },
145       xns : Roo.bootstrap,
146       '|xns' : 'Roo.bootstrap'
147      },
148      {
149       xtype : 'Button',
150       html : _this._strings['70d9be9b139893aa6c69b5e77e614311'] /* Confirm */,
151       weight : 'primary',
152       listeners : {
153        click : function (_self, e)
154         {
155             _this.form.doAction('submit');
156         }
157       },
158       xns : Roo.bootstrap,
159       '|xns' : 'Roo.bootstrap'
160      }
161     ],
162     items  : [
163      {
164       xtype : 'Row',
165       xns : Roo.bootstrap,
166       '|xns' : 'Roo.bootstrap',
167       items  : [
168        {
169         xtype : 'Column',
170         xs : 12,
171         xns : Roo.bootstrap,
172         '|xns' : 'Roo.bootstrap',
173         items  : [
174          {
175           xtype : 'Container',
176           html : _this._strings['dc7b0c7f9d3941532bda06cd58eec7bd'] /* 
177           <ol class='qr-list' start="1">          
178     <li>Open Google Authenticator in your phone, and scan this QR code.</li>          
179 </ol>
180           */ ,
181           well : 'sm',
182           xns : Roo.bootstrap,
183           '|xns' : 'Roo.bootstrap'
184          }
185         ]
186        }
187       ]
188      },
189      {
190       xtype : 'Row',
191       xns : Roo.bootstrap,
192       '|xns' : 'Roo.bootstrap',
193       items  : [
194        {
195         xtype : 'Column',
196         cls : 'text-center',
197         xs : 12,
198         xns : Roo.bootstrap,
199         '|xns' : 'Roo.bootstrap',
200         items  : [
201          {
202           xtype : 'Img',
203           cls : 'qr-code',
204           imgResponsive : false,
205           src : 'about:blank',
206           listeners : {
207            render : function (_self)
208             {
209                 _this.qrcode_image = this;
210                 
211                 this.el.setVisibilityMode(Roo.Element.DISPLAY);
212                 
213             }
214           },
215           xns : Roo.bootstrap,
216           '|xns' : 'Roo.bootstrap'
217          }
218         ]
219        }
220       ]
221      },
222      {
223       xtype : 'Row',
224       xns : Roo.bootstrap,
225       '|xns' : 'Roo.bootstrap',
226       items  : [
227        {
228         xtype : 'Column',
229         xs : 12,
230         xns : Roo.bootstrap,
231         '|xns' : 'Roo.bootstrap',
232         items  : [
233          {
234           xtype : 'Container',
235           html : _this._strings['5d412a3d8de0189df31c8f331e2e6630'] /* 
236           <ol class='qr-list' start="2">          
237     <li>After adding this to Google Authenticator, type in the generated number below to confirm.</li>          
238 </ol>
239           */ ,
240           well : 'sm',
241           xns : Roo.bootstrap,
242           '|xns' : 'Roo.bootstrap'
243          }
244         ]
245        }
246       ]
247      },
248      {
249       xtype : 'Row',
250       xns : Roo.bootstrap,
251       '|xns' : 'Roo.bootstrap',
252       items  : [
253        {
254         xtype : 'Column',
255         xs : 12,
256         xns : Roo.bootstrap,
257         '|xns' : 'Roo.bootstrap',
258         items  : [
259          {
260           xtype : 'Form',
261           method : 'GET',
262           url : baseURL + '/Roo/Core_person.php',
263           listeners : {
264            actioncomplete : function (_self, action)
265             {
266                 if(action.type == 'setdata') {
267                     
268                     this.clearInvalid();
269                 }
270                 
271                 if(action.type == 'submit') {
272                     
273                     switch(action.result.data) {
274                         
275                         case 'DONE':
276                             var cb = function() {
277                                 _this.dialog.hide();
278                             };
279                             
280                             Roo.bootstrap.MessageBox.alert('Success', 'Two Factor authentication has been enabled', cb);
281                             return;
282                             
283                         default:
284                             Roo.log('invalid usage');
285                             break;
286                     }
287                 }
288             },
289            actionfailed : function (_self, action)
290             {
291                 if(action.type == 'submit') {
292                     
293                     switch(action.result.errorMsg) {
294                         case '_invalid_auth_code':
295                             Roo.bootstrap.MessageBox.alert(
296                                 'Invalid authentication code',
297                                 'Please re-enter the latest authentication code.'
298                             );
299                             break;
300                         default:
301                             Roo.log('invalid usage');
302                             break;
303                     }
304                 }
305             },
306            render : function (_self)
307             {
308                 _this.form = this;
309             }
310           },
311           xns : Roo.bootstrap,
312           '|xns' : 'Roo.bootstrap',
313           items  : [
314            {
315             xtype : 'NumberField',
316             allowBlank : false,
317             allowDecimals : false,
318             allowNegative : false,
319             allowZero : false,
320             decimalPrecision : 0,
321             fieldLabel : _this._strings['ee468f72ab7fe4937fb014d6fcea540b'] /* Enter Two factor Authentication code */,
322             indicatorpos : 'right',
323             labelAlign : 'top',
324             maxLength : 6,
325             name : 'two_factor_auth_code',
326             xs : 12,
327             xns : Roo.bootstrap,
328             '|xns' : 'Roo.bootstrap'
329            },
330            {
331             xtype : 'Input',
332             inputType : 'hidden',
333             name : 'id',
334             xns : Roo.bootstrap,
335             '|xns' : 'Roo.bootstrap'
336            }
337           ]
338          }
339         ]
340        }
341       ]
342      }
343     ]
344    }  );
345  }
346 });
347 Roo.apply(Pman.Dialog.BAdminStaffTwoFactorQRCode, Pman.Dialog.BAdminStaffTwoFactorQRCode.prototype);