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