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