Pman.Tab.BAdminIPAccess.bjs
[Pman.BAdmin] / Pman.Tab.BAdminIPAccess.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.Tab');
6
7 Pman.Tab.BAdminIPAccess = new Roo.XComponent({
8
9  _strings : {
10   'ce8ae9da5b7cd6c3df2929543a9af92d' :"Email",
11   'ec211f7c20af43e742bf2570c3cb84f9' :"Add",
12   '0eceeb45861f9585dd7a97a3e36f85c6' :"Created",
13   '86f16ddf147752b95ffe69e2dfa769a1' :"Authorized By",
14   'ec53a8c4f07baed5d8825072c89799be' :"Status",
15   '7dce122004969d56ae2e0245cb754d35' :"Edit",
16   'a12a3079e14ced46e69ba52b8a90b21a' :"IP",
17   'dae8ace18bdcbcc6ae5aece263e14fe8' :"Options",
18   'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
19   'e3030abfa75de4573fb37032affa11e7' :"IP Access"
20  },
21
22   part     :  ["BAdmin", "IPAccess" ],
23   order    : '006-Pman.Tab.BAdminIPAccess',
24   region   : 'center',
25   parent   : 'Pman.Tab.BAdmin',
26   name     : "unnamed module",
27   disabled : false, 
28   permname : '', 
29   _tree : function(_data)
30   {
31    var _this = this;
32    var MODULE = this;
33    return {
34    xtype : 'Nest',
35    background : true,
36    title : _this._strings['e3030abfa75de4573fb37032affa11e7'] /* IP Access */,
37    xns : Roo.bootstrap.panel,
38    '|xns' : 'Roo.bootstrap.panel',
39    layout : {
40     xtype : 'Border',
41     xns : Roo.bootstrap.layout,
42     '|xns' : 'Roo.bootstrap.layout',
43     center : {
44      xtype : 'Region',
45      hideTabs : true,
46      tabPosition : 'top',
47      xns : Roo.bootstrap.layout,
48      '|xns' : 'Roo.bootstrap.layout'
49     },
50     items  : [
51      {
52       xtype : 'Grid',
53       background : false,
54       fitContainer : true,
55       fitToFrame : true,
56       region : 'center',
57       title : _this._strings['dae8ace18bdcbcc6ae5aece263e14fe8'] /* Options */,
58       listeners : {
59        activate : function (_self)
60         {
61             _this.edit_btn.hide();
62             _this.delete_btn.hide();
63             
64             if (_this.option_grid) {
65                 _this.option_grid.store.load({});
66             }
67         },
68        render : function (_self)
69         {
70             _this.option_panel = _self;
71         }
72       },
73       xns : Roo.bootstrap.panel,
74       '|xns' : 'Roo.bootstrap.panel',
75       toolbar : {
76        xtype : 'NavSimplebar',
77        xns : Roo.bootstrap,
78        '|xns' : 'Roo.bootstrap',
79        items  : [
80         {
81          xtype : 'NavGroup',
82          xns : Roo.bootstrap,
83          '|xns' : 'Roo.bootstrap',
84          items  : [
85           {
86            xtype : 'NavItem',
87            xns : Roo.bootstrap,
88            '|xns' : 'Roo.bootstrap',
89            items  : [
90             {
91              xtype : 'Element',
92              xns : Roo.bootstrap,
93              '|xns' : 'Roo.bootstrap',
94              items  : [
95               {
96                xtype : 'Row',
97                cls : 'roo-toolbar',
98                xns : Roo.bootstrap,
99                '|xns' : 'Roo.bootstrap',
100                items  : [
101                 {
102                  xtype : 'Column',
103                  md : 12,
104                  xns : Roo.bootstrap,
105                  '|xns' : 'Roo.bootstrap',
106                  items  : [
107                   {
108                    xtype : 'Button',
109                    cls : 'roo-toolbar-button',
110                    glyphicon : 'plus',
111                    html : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
112                    weight : 'default',
113                    listeners : {
114                     click : function (_self, e)
115                      {
116                          var sel = _this.type_grid.getSelectionModel().getSelected();
117                          
118                          if(!sel || sel.data.id * 1 < 1 || !sel.data.name.length ){
119                              Roo.bootstrap.MessageBox.alert('Error', 'Please select a type');
120                              return;
121                          }
122                      
123                          Pman.Dialog.BAdminCoreEnum.show({ 
124                              id : 0,
125                              etype : sel.data.name
126                          }, function(res) {
127                              _this.option_grid.store.load({});
128                          });
129                      
130                      }
131                    },
132                    xns : Roo.bootstrap,
133                    '|xns' : 'Roo.bootstrap'
134                   },
135                   {
136                    xtype : 'Button',
137                    cls : 'roo-toolbar-button',
138                    glyphicon : 'edit',
139                    html : _this._strings['7dce122004969d56ae2e0245cb754d35'] /* Edit */,
140                    weight : 'default',
141                    listeners : {
142                     click : function (_self, e)
143                      {
144                          var sel = _this.option_grid.getSelectionModel().getSelected();
145                          
146                          if(!sel || sel.data.id * 1 < 1){
147                              Roo.bootstrap.MessageBox.alert('Error', 'Please select a option');
148                              return;
149                          }
150                      
151                          Pman.Dialog.BAdminCoreEnum.show({ 
152                              id : sel.data.id
153                          }, function(res) {
154                              _this.option_grid.store.load({});
155                          });
156                      
157                      },
158                     render : function (_self)
159                      {
160                          _this.edit_btn = this;
161                          
162                          this.hide();
163                      }
164                    },
165                    xns : Roo.bootstrap,
166                    '|xns' : 'Roo.bootstrap'
167                   },
168                   {
169                    xtype : 'Button',
170                    cls : 'roo-toolbar-button',
171                    glyphicon : 'trash',
172                    html : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
173                    weight : 'primary',
174                    listeners : {
175                     click : function (_self, e)
176                      {
177                          var sel = _this.option_grid.getSelectionModel().getSelected();
178                          
179                          if(!sel || sel.data.id * 1 < 1){
180                              Roo.bootstrap.MessageBox.alert('Error', 'Please select a option');
181                              return;
182                          }
183                      
184                          new Pman.Request({
185                              url: baseURL + '/Roo/Core_enum.php',
186                              method : 'POST',
187                              params : {
188                                  _delete : sel.data.id
189                              }, 
190                              success : function(res) {
191                                  _this.option_grid.store.load({});
192                              }
193                          });
194                      
195                      },
196                     render : function (_self)
197                      {
198                          _this.delete_btn = this;
199                          
200                          this.hide();
201                      }
202                    },
203                    xns : Roo.bootstrap,
204                    '|xns' : 'Roo.bootstrap'
205                   }
206                  ]
207                 }
208                ]
209               }
210              ]
211             }
212            ]
213           }
214          ]
215         }
216        ]
217       },
218       grid : {
219        xtype : 'Table',
220        cellSelection : true,
221        cls : 'table-fixed',
222        footerShow : false,
223        hover : true,
224        loadMask : true,
225        responsive : true,
226        rowSelection : true,
227        striped : true,
228        listeners : {
229         cellclick : function (_self, el, rowIndex, columnIndex, e)
230          {
231              var di = _this.option_grid.colModel.getDataIndex(columnIndex);
232              
233              if (di != 'active') {
234                  return;
235              }
236               
237              var rec = _this.option_grid.store.getAt(rowIndex);
238              
239              rec.set('active', rec.data.active ? 0 : 1);
240              
241              rec.commit();
242          },
243         render : function (_self)
244          {
245              _this.option_grid = _self; 
246          
247          },
248         rowdblclick : function (_self, el, rowIndex, e)
249          {
250              var sel = _this.option_grid.store.getAt(rowIndex);
251              
252              if(!sel || sel.data.id * 1 < 1){
253                  return;
254              }
255              
256              Pman.Dialog.BAdminCoreEnum.show({ 
257                  id : sel.data.id
258              }, function(res) {
259                  _this.option_grid.store.load({});
260              });
261              
262          }
263        },
264        xns : Roo.bootstrap,
265        '|xns' : 'Roo.bootstrap',
266        store : {
267         xtype : 'Store',
268         remoteSort : true,
269         sortinfo : { field : 'display_name', direction: 'ASC' },
270         listeners : {
271          beforeload : function (_self, o)
272           {
273               o.params = o.params || {};
274               
275               
276           },
277          load : function (_self, records, options)
278           {
279               _this.edit_btn.hide();
280               _this.delete_btn.hide();
281           },
282          update : function (_self, record, operation)
283           {
284               if (operation != 'commit') {
285                   return;
286               }
287           
288               new Pman.Request({
289                   url : baseURL + '/Roo/Core_enum',
290                   method :'POST',
291                   params : {
292                       id : record.data.id,
293                       active: record.data.active
294                   },
295                   success : function() {
296           
297                   },
298                   failure : function() 
299                   {
300                       Roo.bootstrap.MessageBox.alert("Error", "saving failed", function() {
301                           _this.grid.footer.onClick('first');
302                       });
303                   }
304               });
305           }
306         },
307         xns : Roo.data,
308         '|xns' : 'Roo.data',
309         proxy : {
310          xtype : 'HttpProxy',
311          method : 'GET',
312          url : baseURL + '/Roo/Core_ip_access.php',
313          xns : Roo.data,
314          '|xns' : 'Roo.data'
315         },
316         reader : {
317          xtype : 'JsonReader',
318          fields : [
319              {
320                  'name': 'id',
321                  'type': 'int'
322              },
323              {
324                  'name': 'created_dt',
325                  'type': 'date',
326                  'formatDate' : 'Y-m-d'
327              },
328              {
329                  'name': 'status',
330                  'type': 'int'
331              },
332              {
333                  'name': 'authorized_by',
334                  'type': 'int'
335              },
336              {
337                  'name': 'authorized_by_name',
338                  'type': 'string'
339              },
340              {
341                  'name': 'authorized_by_email',
342                  'type': 'string'
343              },
344              {
345                  'name': 'authorized_key',
346                  'type': 'string'
347              },
348              {
349                  'name': 'email',
350                  'type': 'string'
351              },
352              {
353                  'name': 'expire_dt',
354                  'type': 'date',
355                  'formatDate' : 'Y-m-d'
356              },
357              {
358                  'name': 'user_agent',
359                  'type': 'string'
360              },
361              {
362                  'name': 'updated_by',
363                  'type': 'int'
364              },
365              {
366                  'name': 'updated_by_name',
367                  'type': 'string'
368              },
369              {
370                  'name': 'updated_by_email',
371                  'type': 'string'
372              }
373              
374          ],
375          id : 'id',
376          root : 'data',
377          totalProperty : 'total',
378          xns : Roo.data,
379          '|xns' : 'Roo.data'
380         }
381        },
382        sm : {
383         xtype : 'RowSelectionModel',
384         singleSelect : true,
385         listeners : {
386          selectionchange : function (_self)
387           {
388               _this.edit_btn.hide();
389               _this.delete_btn.hide();
390               
391               if (!this.getSelected()) {
392                   return;
393               }
394               
395               _this.edit_btn.show();
396               _this.delete_btn.show();
397               
398           }
399         },
400         xns : Roo.bootstrap.Table,
401         '|xns' : 'Roo.bootstrap.Table'
402        },
403        cm : [
404         {
405          xtype : 'ColumnModel',
406          cursor : 'pointer',
407          dataIndex : 'created_dt',
408          header : _this._strings['0eceeb45861f9585dd7a97a3e36f85c6'] /* Created */,
409          renderer : function(v,x,r) { 
410              return String.format('{0}', v ? v.format('Y-m-d') : '');
411          },
412          sortable : true,
413          xns : Roo.grid,
414          '|xns' : 'Roo.grid'
415         },
416         {
417          xtype : 'ColumnModel',
418          cursor : 'pointer',
419          dataIndex : 'ip',
420          header : _this._strings['a12a3079e14ced46e69ba52b8a90b21a'] /* IP */,
421          renderer : function(v,x,r) { 
422              return String.format('{0}', v ? v : '');
423          },
424          sortable : true,
425          xns : Roo.grid,
426          '|xns' : 'Roo.grid'
427         },
428         {
429          xtype : 'ColumnModel',
430          cursor : 'pointer',
431          dataIndex : 'email',
432          header : _this._strings['ce8ae9da5b7cd6c3df2929543a9af92d'] /* Email */,
433          renderer : function(v,x,r) 
434          { 
435              return String.format('<a href="mailto:{0}">{0}</a>', v ? v : '')
436          },
437          sortable : true,
438          xns : Roo.grid,
439          '|xns' : 'Roo.grid'
440         },
441         {
442          xtype : 'ColumnModel',
443          cursor : 'pointer',
444          dataIndex : 'authorized_by',
445          header : _this._strings['86f16ddf147752b95ffe69e2dfa769a1'] /* Authorized By */,
446          renderer : function(v,x,r) 
447          { 
448              return String.format('<a href="mailto:{0}">{0}</a>', v ? v : '')
449          },
450          sortable : true,
451          xns : Roo.grid,
452          '|xns' : 'Roo.grid'
453         },
454         {
455          xtype : 'ColumnModel',
456          cursor : 'pointer',
457          dataIndex : 'status',
458          header : _this._strings['ec53a8c4f07baed5d8825072c89799be'] /* Status */,
459          renderer : function(v,x,r) 
460          {
461              v = v * 1;
462              
463              var status = 'Pending';
464              
465              switch (v) {
466                  case 1 :
467                      status = 'Approve';
468                      break;
469                  case -1 :
470                      status = 'Reject';
471                      break;
472                  case -2 :
473                      status = 'Temporary';
474                      break;
475                  default : 
476                      break;
477              }
478              
479              return String.format('{0}', status);
480              
481          },
482          sortable : true,
483          xns : Roo.grid,
484          '|xns' : 'Roo.grid'
485         }
486        ]
487       }
488      }
489     ]
490    }
491   };  }
492 });