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