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