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 + '/Roo/Core_oauth_clients',
88                                             method : 'POST',
89                                             params : record.data,
90                                             success : function(res) {
91                                                 _this.grid.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': 'id',
114                                             'type': 'int'
115                                         },
116                                         {
117                                             'name': 'client_id',
118                                             'type': 'string'
119                                         },
120                                         {
121                                             'name': 'client_secret',
122                                             'type': 'string'
123                                         },
124                                         {
125                                             'name': 'redirect_uri',
126                                             'type': 'string'
127                                         }
128                                     ]
129                                 }
130                             },
131                             toolbar : {
132                                 xtype: 'Toolbar',
133                                 xns: Roo,
134                                 items : [
135                                     {
136                                         xtype: 'Button',
137                                         xns: Roo.Toolbar,
138                                         listeners : {
139                                             click : function()
140                                             {
141                                                 
142                                                 var nr = _this.grid.ds.reader.newRow({
143                                                     id : 0,
144                                                     client_id : '',
145                                                     client_secret : '',
146                                                     redirect_uri : ''
147                                                 });
148                                                 
149                                                 _this.grid.stopEditing();
150                                                 _this.grid.ds.insert(_this.grid.ds.getCount(), nr); 
151                                                 _this.grid.startEditing(_this.grid.ds.getCount()-1, 0);
152                                             }
153                                         },
154                                         cls : 'x-btn-text-icon',
155                                         text : "Add",
156                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
157                                     },
158                                     {
159                                         xtype: 'Button',
160                                         xns: Roo.Toolbar,
161                                         listeners : {
162                                             click : function ()
163                                             {   
164                                                 var cs = _this.grid.getSelectionModel().getSelectedCell();
165                                                 if (!cs) {
166                                                     Roo.MessageBox.alert("Error", "Select a cell");
167                                                     return;
168                                                 }
169                                                 _this.grid.stopEditing();
170                                              
171                                                 var r = _this.grid.ds.getAt(cs[0]);
172                                                 
173                                                 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this client?", function (v){
174                                                     if (v != 'yes') {
175                                                         return;
176                                                     }
177                                                     
178                                                     new Pman.Request({
179                                                         url : baseURL + '/Roo/Core_oauth_clients',
180                                                         method : 'POST',
181                                                         params : {
182                                                             _delete : r.data.id
183                                                         },
184                                                         success : function(res) {
185                                                             _this.grid.footer.onClick('refresh');
186                                                         }
187                                                     });
188                                                 });
189                                             }
190                                         },
191                                         cls : 'x-btn-text-icon',
192                                         text : "Remove",
193                                         icon : rootURL + '/Pman/templates/images/trash.gif'
194                                     }
195                                 ]
196                             },
197                             footer : {
198                                 xtype: 'PagingToolbar',
199                                 xns: Roo,
200                                 displayInfo : true,
201                                 emptyMsg : "No Clients found",
202                                 pageSize : 25
203                             },
204                             colModel : [
205                                 {
206                                     xtype: 'ColumnModel',
207                                     xns: Roo.grid,
208                                     dataIndex : 'client_id',
209                                     header : 'Client ID',
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 : 'client_secret',
228                                     header : 'Client Secret',
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                                             allowBlank : false
240                                         }
241                                     }
242                                 },
243                                 {
244                                     xtype: 'ColumnModel',
245                                     xns: Roo.grid,
246                                     dataIndex : 'redirect_uri',
247                                     header : 'Redirect URI',
248                                     width : 150,
249                                     renderer : function(v) { 
250                                         return String.format('{0}', v ? v : '');
251                                     },
252                                     editor : {
253                                         xtype: 'GridEditor',
254                                         xns: Roo.grid,
255                                         field : {
256                                             xtype: 'TextField',
257                                             xns: Roo.form
258                                         }
259                                     }
260                                 }
261                             ]
262                         }
263                     }
264                 ],
265                 center : {
266                     xtype: 'LayoutRegion',
267                     xns: Roo,
268                     autoScroll : false,
269                     split : true
270                 }
271             }
272         };
273     }
274 });