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