Pman.Tab.CoreOAuthClient.bjs
[Pman.Core] / Pman.Tab.CoreOAuthClient.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Tab.CoreOAuthClient = new Roo.XComponent({
6     part     :  ["Core","OAuthClient"],
7     order    : '900-Pman.Tab.CoreOAuthClient',
8     region   : 'center',
9     parent   : 'Pman.Tab.Admin',
10     name     : "unnamed module",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'NestedLayoutPanel',
19             xns: Roo,
20             region : 'center',
21             title : "Oauth2 Clients",
22             layout : {
23                 xtype: 'BorderLayout',
24                 xns: Roo,
25                 items : [
26                     {
27                         xtype: 'GridPanel',
28                         xns: Roo,
29                         listeners : {
30                             activate : function() {
31                                 _this.panel = this;
32                                 
33                                 if (_this.grid) {
34                                     _this.grid.footer.onClick('first');
35                                 }
36                             }
37                         },
38                         background : true,
39                         fitContainer : true,
40                         fitToframe : true,
41                         region : 'center',
42                         tableName : 'core_oauth_clients',
43                         title : "Oauth2 Clients",
44                         grid : {
45                             xtype: 'EditorGrid',
46                             xns: Roo.grid,
47                             listeners : {
48                                 render : function() 
49                                 {
50                                     _this.grid = this; 
51                                     if (_this.panel.active) {
52                                        this.footer.onClick('first');
53                                     }
54                                 },
55                                 afteredit : function (e)
56                                 {
57                                     if(e.originalValue == e.value || !e.value.length){
58                                         return false;
59                                     }
60                                     
61                                     Roo.log('commit it');
62                                     e.record.commit();
63                                 }
64                             },
65                             autoExpandColumn : 'redirect_uri',
66                             clicksToEdit : 1,
67                             loadMask : true,
68                             dataSource : {
69                                 xtype: 'Store',
70                                 xns: Roo.data,
71                                 listeners : {
72                                     beforeload : function (_self, o){
73                                         o.params = o.params || {};
74                                     
75                                     },
76                                     update : function (_self, record, operation)
77                                     {
78                                         if (operation != Roo.data.Record.COMMIT) {
79                                             return;
80                                         }
81                                     
82                                         if (!record.data.client_id.length || !record.data.client_secret.length) {
83                                             return;
84                                         }
85                                         
86                                         new Pman.Request({
87                                             url : baseURL + '/Core/Core_oauth_clients.php',
88                                             method : 'POST',
89                                             params : record.data,
90                                             success : function(res) {
91                                                 _this.gird.footer.onClick('refresh');
92                                             }
93                                         });
94                                         
95                                     }
96                                 },
97                                 remoteSort : true,
98                                 sortInfo : { field : 'client_id', direction: 'ASC' },
99                                 proxy : {
100                                     xtype: 'HttpProxy',
101                                     xns: Roo.data,
102                                     method : 'GET',
103                                     url : baseURL + '/Roo/Core_oauth_clients'
104                                 },
105                                 reader : {
106                                     xtype: 'JsonReader',
107                                     xns: Roo.data,
108                                     id : 'id',
109                                     root : 'data',
110                                     totalProperty : 'total',
111                                     fields : [
112                                         {
113                                             'name': 'client_id',
114                                             'type': 'string'
115                                         },
116                                         {
117                                             'name': 'client_secret',
118                                             'type': 'string'
119                                         },
120                                         {
121                                             'name': 'redirect_uri',
122                                             'type': 'string'
123                                         }
124                                     ]
125                                 }
126                             },
127                             toolbar : {
128                                 xtype: 'Toolbar',
129                                 xns: Roo,
130                                 items : [
131                                     {
132                                         xtype: 'Button',
133                                         xns: Roo.Toolbar,
134                                         listeners : {
135                                             click : function()
136                                             {
137                                                 
138                                                 var nr = _this.grid.ds.reader.newRow({
139                                                     client_id : '',
140                                                     client_secret : '',
141                                                     redirect_uri : ''
142                                                 });
143                                                 
144                                                 _this.grid.stopEditing();
145                                                 _this.grid.ds.insert(_this.grid.ds.getCount(), nr); 
146                                                 _this.grid.startEditing(_this.grid.ds.getCount()-1, 1);
147                                             }
148                                         },
149                                         cls : 'x-btn-text-icon',
150                                         text : "Add",
151                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
152                                     },
153                                     {
154                                         xtype: 'Button',
155                                         xns: Roo.Toolbar,
156                                         listeners : {
157                                             click : function ()
158                                             {   
159                                                 var cs = _this.grid.getSelectionModel().getSelectedCell();
160                                                 if (!cs) {
161                                                     Roo.MessageBox.alert("Error", "Select a cell");
162                                                     return;
163                                                 }
164                                                 _this.grid.stopEditing();
165                                              
166                                                 var r = _this.grid.ds.getAt(cs[0]);
167                                                 
168                                                 _this.grid.ds.remove(r);
169                                                
170                                             }
171                                         },
172                                         cls : 'x-btn-text-icon',
173                                         text : "Remove",
174                                         icon : rootURL + '/Pman/templates/images/trash.gif'
175                                     }
176                                 ]
177                             },
178                             footer : {
179                                 xtype: 'PagingToolbar',
180                                 xns: Roo,
181                                 displayInfo : true,
182                                 emptyMsg : "No Clients found",
183                                 pageSize : 25
184                             },
185                             colModel : [
186                                 {
187                                     xtype: 'ColumnModel',
188                                     xns: Roo.grid,
189                                     dataIndex : 'client_id',
190                                     header : 'Client ID',
191                                     width : 150,
192                                     renderer : function(v) { 
193                                         return String.format('{0}', v ? v : '');
194                                     },
195                                     editor : {
196                                         xtype: 'GridEditor',
197                                         xns: Roo.grid,
198                                         field : {
199                                             xtype: 'TextField',
200                                             xns: Roo.form,
201                                             allowBlank : false
202                                         }
203                                     }
204                                 },
205                                 {
206                                     xtype: 'ColumnModel',
207                                     xns: Roo.grid,
208                                     dataIndex : 'client_secret',
209                                     header : 'Client Secret',
210                                     width : 150,
211                                     renderer : function(v) { 
212                                         return String.format('{0}', v ? v : '');
213                                     },
214                                     editor : {
215                                         xtype: 'GridEditor',
216                                         xns: Roo.grid,
217                                         field : {
218                                             xtype: 'TextField',
219                                             xns: Roo.form,
220                                             allowBlank : false
221                                         }
222                                     }
223                                 },
224                                 {
225                                     xtype: 'ColumnModel',
226                                     xns: Roo.grid,
227                                     dataIndex : 'redirect_uri',
228                                     header : 'Redirect URI',
229                                     width : 150,
230                                     renderer : function(v) { 
231                                         return String.format('{0}', v ? v : '');
232                                     },
233                                     editor : {
234                                         xtype: 'GridEditor',
235                                         xns: Roo.grid,
236                                         field : {
237                                             xtype: 'TextField',
238                                             xns: Roo.form
239                                         }
240                                     }
241                                 }
242                             ]
243                         }
244                     }
245                 ],
246                 center : {
247                     xtype: 'LayoutRegion',
248                     xns: Roo,
249                     autoScroll : false,
250                     split : true
251                 }
252             }
253         };
254     }
255 });