Pman.Dialog.VerifyAccess.bjs
[Pman.Core] / Pman.Dialog.VerifyAccess.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.VerifyAccess= function() {}
8 Roo.apply(Pman.Dialog.VerifyAccess.prototype, {
9
10  _strings : {
11   'e2c9d024b79dfb48b42a7807206c6aed' :"Verify New IP Access",
12   'd41d8cd98f00b204e9800998ecf8427e' :"",
13   'a12a3079e14ced46e69ba52b8a90b21a' :"IP",
14   'f6039d44b29456b20f8f373155ae4973' :"Username",
15   '004bf6c9a40003140292e97330236c53' :"Action",
16   '5a787141d53b573ec9b86e900bfe0d79' :"Expire Date",
17   'dfb790522fdea3859af206d32916fe77' :"User Agent",
18   '70d9be9b139893aa6c69b5e77e614311' :"Confirm"
19  },
20
21  dialog : false,
22  callback:  false,
23
24  show : function(data, cb)
25  {
26   if (!this.dialog) {
27    this.create();
28   }
29
30   this.callback = cb;
31   this.data = data;
32   this.dialog.show(this.data._el);
33   if (this.form) {
34    this.form.reset();
35    this.form.setValues(data);
36    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
37   }
38
39  },
40
41  create : function()
42  {
43   var _this = this;
44   this.dialog = Roo.factory({
45     xtype : 'Modal',
46     allow_close : false,
47     cls : 'enable-overflow',
48     title : _this._strings['e2c9d024b79dfb48b42a7807206c6aed'] /* Verify New IP Access */,
49     listeners : {
50      show : function (_self)
51       {
52           var path = window.location.pathname.split('/');
53           
54           var authorized_key = path.pop();
55           
56           var id = path.pop();
57           
58           new Pman.Request({
59               url: baseURL + '/Core/VerifyAccess',
60               method : 'POST',
61               mask : 'Loading...',
62               params : {
63                   id : id,
64                   authorized_key : authorized_key,
65                   _to_data : 1
66               }, 
67               success : function(res) {
68               
69                   _this.data = res.data;
70                   
71                   if(_this.data.status != 0){
72                       _this.dialog.hide();
73                       Roo.bootstrap.MessageBox.alert('Notice', 'This IP has been verified [' + _this.data.ip + ']');
74                       return;
75                   }
76                   
77                   _this.form.setValues(_this.data);
78                   
79                   if(_this.data.status * 1 == 0){
80                       _this.form.findField('status').reset();
81                   }
82                   
83                   _this.form.clearInvalid();
84                   
85                   return;
86               },
87               failure: function(res) {
88                   
89                   _this.dialog.hide();
90                   
91                   Roo.bootstrap.MessageBox.alert('Error', res.errorMsg);
92                   
93                   return;
94              }
95           });
96       }
97     },
98     xns : Roo.bootstrap,
99     '|xns' : 'Roo.bootstrap',
100     buttons : [
101      {
102       xtype : 'Button',
103       html : _this._strings['70d9be9b139893aa6c69b5e77e614311'] /* Confirm */,
104       weight : 'primary',
105       listeners : {
106        click : function (_self, e)
107         {
108             if(!_this.form.isValid()){
109                 return;
110             }
111         
112             _this.dialog.el.mask('Sending...');
113             _this.form.doAction('submit');
114             
115         }
116       },
117       xns : Roo.bootstrap,
118       '|xns' : 'Roo.bootstrap'
119      }
120     ],
121     items  : [
122      {
123       xtype : 'Form',
124       errorMask : true,
125       labelAlign : 'top',
126       loadMask : false,
127       url : baseURL + '/Core/VerifyAccess',
128       listeners : {
129        actioncomplete : function (_self, action)
130         {
131             if (action.type == 'setdata') {
132                 
133                 return;
134             }
135             if (action.type == 'load') {
136                 
137                 return;
138             }
139             if (action.type =='submit') {
140                 
141                 _this.dialog.hide();
142                 
143                 Roo.bootstrap.MessageBox.alert('Notice', 'You have verified the IP [' + _this.data.ip + ']');
144                 
145                 return;
146             }
147             
148         },
149        actionfailed : function (_self, action)
150         {
151             _this.dialog.el.unmask();
152             Roo.log("action failed");
153             Roo.log(action);
154           
155             if(!action.result.errorMsg){
156                 Roo.bootstrap.MessageBox.alert("Error", "Please contact system adminisrator");
157             }
158            
159             var msg = action.result.errorMsg;
160            
161             if(msg.length >= 200){
162                 msg = msg.substring(0,199) + '...'
163             }
164             
165             Roo.bootstrap.MessageBox.alert("Error", msg);
166         },
167        render : function (_self,e)
168         {
169             _this.form = _self;
170             
171         }
172       },
173       xns : Roo.bootstrap,
174       '|xns' : 'Roo.bootstrap',
175       items  : [
176        {
177         xtype : 'Row',
178         xns : Roo.bootstrap,
179         '|xns' : 'Roo.bootstrap',
180         items  : [
181          {
182           xtype : 'Column',
183           xs : 12,
184           xns : Roo.bootstrap,
185           '|xns' : 'Roo.bootstrap',
186           items  : [
187            {
188             xtype : 'Input',
189             fieldLabel : _this._strings['f6039d44b29456b20f8f373155ae4973'] /* Username */,
190             name : 'email',
191             readOnly : true,
192             xns : Roo.bootstrap,
193             '|xns' : 'Roo.bootstrap'
194            }
195           ]
196          },
197          {
198           xtype : 'Column',
199           xs : 12,
200           xns : Roo.bootstrap,
201           '|xns' : 'Roo.bootstrap',
202           items  : [
203            {
204             xtype : 'Input',
205             fieldLabel : _this._strings['a12a3079e14ced46e69ba52b8a90b21a'] /* IP */,
206             name : 'ip',
207             readOnly : true,
208             xns : Roo.bootstrap,
209             '|xns' : 'Roo.bootstrap'
210            }
211           ]
212          },
213          {
214           xtype : 'Column',
215           xs : 12,
216           xns : Roo.bootstrap,
217           '|xns' : 'Roo.bootstrap',
218           items  : [
219            {
220             xtype : 'TextArea',
221             fieldLabel : _this._strings['dfb790522fdea3859af206d32916fe77'] /* User Agent */,
222             name : 'user_agent',
223             readOnly : true,
224             rows : 3,
225             style : 'margin-bottom: 15px;',
226             xns : Roo.bootstrap,
227             '|xns' : 'Roo.bootstrap'
228            }
229           ]
230          },
231          {
232           xtype : 'Column',
233           xs : 12,
234           xns : Roo.bootstrap,
235           '|xns' : 'Roo.bootstrap',
236           items  : [
237            {
238             xtype : 'ComboBox',
239             allowBlank : false,
240             alwaysQuery : true,
241             displayField : 'value',
242             editable : false,
243             fieldLabel : _this._strings['004bf6c9a40003140292e97330236c53'] /* Action */,
244             forceSelection : true,
245             hiddenName : 'status',
246             indicatorpos : 'right',
247             mode : 'local',
248             name : 'status_name',
249             selectOnFocus : true,
250             tpl : '<div class=\"roo-select2-result\"><b>{value}</b></div>',
251             triggerAction : 'all',
252             valueField : 'code',
253             listeners : {
254              select : function (combo, record, index)
255               {
256                   _this.expire_dt.allowBlank = true;
257                   _this.expire_dt.el.hide();
258                   
259                   if(record.data.code == '-2'){
260                       _this.expire_dt.allowBlank = false;
261                       _this.expire_dt.el.show();
262                   }
263               }
264             },
265             xns : Roo.bootstrap,
266             '|xns' : 'Roo.bootstrap',
267             store : {
268              xtype : 'SimpleStore',
269              data : [
270                  ['1', 'Approve'],
271                  ['-2', 'Temporary'],
272                  ['-1', 'Reject']
273              ],
274              fields : [ 'code', 'value' ],
275              xns : Roo.data,
276              '|xns' : 'Roo.data'
277             }
278            }
279           ]
280          },
281          {
282           xtype : 'Column',
283           xs : 12,
284           xns : Roo.bootstrap,
285           '|xns' : 'Roo.bootstrap',
286           items  : [
287            {
288             xtype : 'DateField',
289             allowBlank : false,
290             fieldLabel : _this._strings['5a787141d53b573ec9b86e900bfe0d79'] /* Expire Date */,
291             format : 'Y-m-d',
292             indicatorpos : 'right',
293             name : 'expire_dt',
294             listeners : {
295              render : function (_self)
296               {
297                   _this.expire_dt = this;
298                   
299                   var d = new Date();
300                   
301                   d.setDate(d.getDate() - 1);
302               
303                   this.setStartDate(d);
304                   
305                   this.el.setVisibilityMode(Roo.Element.DISPLAY);
306                   
307                   this.el.hide();
308               }
309             },
310             xns : Roo.bootstrap,
311             '|xns' : 'Roo.bootstrap'
312            }
313           ]
314          }
315         ]
316        },
317        {
318         xtype : 'Row',
319         xns : Roo.bootstrap,
320         '|xns' : 'Roo.bootstrap',
321         items  : [
322          {
323           xtype : 'Column',
324           xs : 12,
325           xns : Roo.bootstrap,
326           '|xns' : 'Roo.bootstrap',
327           items  : [
328            {
329             xtype : 'Input',
330             inputType : 'hidden',
331             name : 'id',
332             xns : Roo.bootstrap,
333             '|xns' : 'Roo.bootstrap'
334            },
335            {
336             xtype : 'Input',
337             inputType : 'hidden',
338             name : 'authorized_key',
339             xns : Roo.bootstrap,
340             '|xns' : 'Roo.bootstrap'
341            }
342           ]
343          }
344         ]
345        }
346       ]
347      },
348      {
349       xtype : 'Row',
350       listeners : {
351        render : function (_self)
352         {
353             _this.error_row = this;
354             
355             this.el.setVisibilityMode(Roo.Element.DISPLAY);
356             
357             this.el.hide();
358         }
359       },
360       xns : Roo.bootstrap,
361       '|xns' : 'Roo.bootstrap',
362       items  : [
363        {
364         xtype : 'Column',
365         xs : 12,
366         xns : Roo.bootstrap,
367         '|xns' : 'Roo.bootstrap',
368         items  : [
369          {
370           xtype : 'Element',
371           html : _this._strings['d41d8cd98f00b204e9800998ecf8427e'] /*  */,
372           listeners : {
373            render : function (_self)
374             {
375                 _this.text_el = _self;
376             }
377           },
378           xns : Roo.bootstrap,
379           '|xns' : 'Roo.bootstrap'
380          }
381         ]
382        }
383       ]
384      }
385     ]
386    }  );
387  }
388 });
389 Roo.apply(Pman.Dialog.VerifyAccess, Pman.Dialog.VerifyAccess.prototype);