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