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     XXXX : '',
51     listeners : {
52      show : function (_self)
53       {
54           // this dialog is generic for change password for auth user && edit person
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           switch(_this.data.title) {
69               case '_setup':
70                   this.setTitle(this._setup_text);
71                   break;
72               default:
73                   this.setTitle(this._default_text);
74                   break;
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       },
116       xns : Roo.bootstrap,
117       '|xns' : 'Roo.bootstrap'
118      },
119      {
120       xtype : 'Button',
121       html : _this._strings['70d9be9b139893aa6c69b5e77e614311'] /* Confirm */,
122       weight : 'primary',
123       listeners : {
124        click : function (_self, e)
125         {
126             _this.form.doAction('submit');
127         }
128       },
129       xns : Roo.bootstrap,
130       '|xns' : 'Roo.bootstrap'
131      }
132     ],
133     items  : [
134      {
135       xtype : 'Row',
136       xns : Roo.bootstrap,
137       '|xns' : 'Roo.bootstrap',
138       items  : [
139        {
140         xtype : 'Column',
141         xs : 12,
142         xns : Roo.bootstrap,
143         '|xns' : 'Roo.bootstrap',
144         items  : [
145          {
146           xtype : 'Container',
147           html : _this._strings['dc7b0c7f9d3941532bda06cd58eec7bd'] /* 
148           <ol class='qr-list' start="1">          
149     <li>Open Google Authenticator in your phone, and scan this QR code.</li>          
150 </ol>
151           */ ,
152           well : 'sm',
153           xns : Roo.bootstrap,
154           '|xns' : 'Roo.bootstrap'
155          }
156         ]
157        }
158       ]
159      },
160      {
161       xtype : 'Row',
162       xns : Roo.bootstrap,
163       '|xns' : 'Roo.bootstrap',
164       items  : [
165        {
166         xtype : 'Column',
167         cls : 'text-center',
168         xs : 12,
169         xns : Roo.bootstrap,
170         '|xns' : 'Roo.bootstrap',
171         items  : [
172          {
173           xtype : 'Img',
174           cls : 'qr-code',
175           imgResponsive : false,
176           src : 'about:blank',
177           listeners : {
178            render : function (_self)
179             {
180                 _this.qrcode_image = this;
181                 
182                 this.el.setVisibilityMode(Roo.Element.DISPLAY);
183                 
184             }
185           },
186           xns : Roo.bootstrap,
187           '|xns' : 'Roo.bootstrap'
188          }
189         ]
190        }
191       ]
192      },
193      {
194       xtype : 'Row',
195       xns : Roo.bootstrap,
196       '|xns' : 'Roo.bootstrap',
197       items  : [
198        {
199         xtype : 'Column',
200         xs : 12,
201         xns : Roo.bootstrap,
202         '|xns' : 'Roo.bootstrap',
203         items  : [
204          {
205           xtype : 'Container',
206           html : _this._strings['5d412a3d8de0189df31c8f331e2e6630'] /* 
207           <ol class='qr-list' start="2">          
208     <li>After adding this to Google Authenticator, type in the generated number below to confirm.</li>          
209 </ol>
210           */ ,
211           well : 'sm',
212           xns : Roo.bootstrap,
213           '|xns' : 'Roo.bootstrap'
214          }
215         ]
216        }
217       ]
218      },
219      {
220       xtype : 'Row',
221       xns : Roo.bootstrap,
222       '|xns' : 'Roo.bootstrap',
223       items  : [
224        {
225         xtype : 'Column',
226         xs : 12,
227         xns : Roo.bootstrap,
228         '|xns' : 'Roo.bootstrap',
229         items  : [
230          {
231           xtype : 'Form',
232           method : 'GET',
233           url : baseURL + '/Roo/Core_person.php',
234           listeners : {
235            actioncomplete : function (_self, action)
236             {
237                 if(action.type == 'setdata') {
238                     
239                     this.clearInvalid();
240                 }
241                 
242                 if(action.type == 'submit') {
243                     
244                     switch(action.result.data) {
245                         
246                         case 'DONE':
247                             var cb = function() {
248                                 _this.dialog.hide();
249                                 
250                                 if(_this.callback){
251                                     _this.callback.call(_this, true);
252                                 }
253                             };
254                             
255                             Roo.bootstrap.MessageBox.alert('Success', 'Two Factor authentication has been enabled', cb);
256                             return;
257                             
258                         default:
259                             Roo.log('invalid usage');
260                             break;
261                     }
262                 }
263             },
264            actionfailed : function (_self, action)
265             {
266                 if(action.type == 'submit') {
267                     
268                     switch(action.result.errorMsg) {
269                         case '_invalid_auth_code':
270                             Roo.bootstrap.MessageBox.alert(
271                                 'Invalid authentication code',
272                                 'Please re-enter the latest authentication code.'
273                             );
274                             break;
275                         default:
276                             Roo.log('invalid usage');
277                             break;
278                     }
279                 }
280             },
281            render : function (_self)
282             {
283                 _this.form = this;
284             }
285           },
286           xns : Roo.bootstrap,
287           '|xns' : 'Roo.bootstrap',
288           items  : [
289            {
290             xtype : 'NumberField',
291             allowBlank : false,
292             allowDecimals : false,
293             allowNegative : false,
294             allowZero : false,
295             decimalPrecision : 0,
296             fieldLabel : _this._strings['ee468f72ab7fe4937fb014d6fcea540b'] /* Enter Two factor Authentication code */,
297             indicatorpos : 'right',
298             labelAlign : 'top',
299             maxLength : 6,
300             name : 'two_factor_auth_code',
301             xs : 12,
302             xns : Roo.bootstrap,
303             '|xns' : 'Roo.bootstrap'
304            },
305            {
306             xtype : 'Input',
307             inputType : 'hidden',
308             name : 'id',
309             xns : Roo.bootstrap,
310             '|xns' : 'Roo.bootstrap'
311            }
312           ]
313          }
314         ]
315        }
316       ]
317      }
318     ]
319    }  );
320  }
321 });
322 Roo.apply(Pman.Dialog.BAdminStaffTwoFactorQRCode, Pman.Dialog.BAdminStaffTwoFactorQRCode.prototype);