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