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