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