DataObjects/Core_person_signup.php
[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 : {
90                                                 id : record.data.id,
91                                                 client_id : record.data.client_id,
92                                                 client_secret : record.data.client_secret,
93                                                 redirect_uri : record.data.redirect_uri
94                                             },
95                                             success : function(res) {
96                                                 _this.grid.footer.onClick('refresh');
97                                             }
98                                         });
99                                         
100                                     }
101                                 },
102                                 remoteSort : true,
103                                 sortInfo : { field : 'client_id', direction: 'ASC' },
104                                 proxy : {
105                                     xtype: 'HttpProxy',
106                                     xns: Roo.data,
107                                     method : 'GET',
108                                     url : baseURL + '/Roo/Core_oauth_clients'
109                                 },
110                                 reader : {
111                                     xtype: 'JsonReader',
112                                     xns: Roo.data,
113                                     id : 'id',
114                                     root : 'data',
115                                     totalProperty : 'total',
116                                     fields : [
117                                         {
118                                             'name': 'id',
119                                             'type': 'int'
120                                         },
121                                         {
122                                             'name': 'client_id',
123                                             'type': 'string'
124                                         },
125                                         {
126                                             'name': 'client_secret',
127                                             'type': 'string'
128                                         },
129                                         {
130                                             'name': 'redirect_uri',
131                                             'type': 'string'
132                                         }
133                                     ]
134                                 }
135                             },
136                             toolbar : {
137                                 xtype: 'Toolbar',
138                                 xns: Roo,
139                                 items : [
140                                     {
141                                         xtype: 'Button',
142                                         xns: Roo.Toolbar,
143                                         listeners : {
144                                             click : function()
145                                             {
146                                                 
147                                                 var nr = _this.grid.ds.reader.newRow({
148                                                     id : 0,
149                                                     client_id : '',
150                                                     client_secret : '',
151                                                     redirect_uri : ''
152                                                 });
153                                                 
154                                                 _this.grid.stopEditing();
155                                                 _this.grid.ds.insert(_this.grid.ds.getCount(), nr); 
156                                                 _this.grid.startEditing(_this.grid.ds.getCount()-1, 0);
157                                             }
158                                         },
159                                         cls : 'x-btn-text-icon',
160                                         text : "Add",
161                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
162                                     },
163                                     {
164                                         xtype: 'Button',
165                                         xns: Roo.Toolbar,
166                                         listeners : {
167                                             click : function ()
168                                             {   
169                                                 var cs = _this.grid.getSelectionModel().getSelectedCell();
170                                                 if (!cs) {
171                                                     Roo.MessageBox.alert("Error", "Select a cell");
172                                                     return;
173                                                 }
174                                                 _this.grid.stopEditing();
175                                              
176                                                 var r = _this.grid.ds.getAt(cs[0]);
177                                                 
178                                                 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete this client?", function (v){
179                                                     if (v != 'yes') {
180                                                         return;
181                                                     }
182                                                     
183                                                     new Pman.Request({
184                                                         url : baseURL + '/Roo/Core_oauth_clients',
185                                                         method : 'POST',
186                                                         params : {
187                                                             _delete : r.data.id
188                                                         },
189                                                         success : function(res) {
190                                                             _this.grid.footer.onClick('refresh');
191                                                         }
192                                                     });
193                                                 });
194                                             }
195                                         },
196                                         cls : 'x-btn-text-icon',
197                                         text : "Remove",
198                                         icon : rootURL + '/Pman/templates/images/trash.gif'
199                                     }
200                                 ]
201                             },
202                             footer : {
203                                 xtype: 'PagingToolbar',
204                                 xns: Roo,
205                                 displayInfo : true,
206                                 emptyMsg : "No Clients found",
207                                 pageSize : 25
208                             },
209                             colModel : [
210                                 {
211                                     xtype: 'ColumnModel',
212                                     xns: Roo.grid,
213                                     dataIndex : 'client_id',
214                                     header : 'Client ID',
215                                     width : 150,
216                                     renderer : function(v) { 
217                                         return String.format('{0}', v ? v : '');
218                                     },
219                                     editor : {
220                                         xtype: 'GridEditor',
221                                         xns: Roo.grid,
222                                         field : {
223                                             xtype: 'TextField',
224                                             xns: Roo.form,
225                                             allowBlank : false
226                                         }
227                                     }
228                                 },
229                                 {
230                                     xtype: 'ColumnModel',
231                                     xns: Roo.grid,
232                                     dataIndex : 'client_secret',
233                                     header : 'Client Secret',
234                                     width : 150,
235                                     renderer : function(v) { 
236                                         return String.format('{0}', v ? v : '');
237                                     },
238                                     editor : {
239                                         xtype: 'GridEditor',
240                                         xns: Roo.grid,
241                                         field : {
242                                             xtype: 'TextField',
243                                             xns: Roo.form,
244                                             allowBlank : false
245                                         }
246                                     }
247                                 },
248                                 {
249                                     xtype: 'ColumnModel',
250                                     xns: Roo.grid,
251                                     dataIndex : 'redirect_uri',
252                                     header : 'Redirect URI',
253                                     width : 150,
254                                     renderer : function(v) { 
255                                         return String.format('{0}', v ? v : '');
256                                     },
257                                     editor : {
258                                         xtype: 'GridEditor',
259                                         xns: Roo.grid,
260                                         field : {
261                                             xtype: 'TextField',
262                                             xns: Roo.form
263                                         }
264                                     }
265                                 }
266                             ]
267                         }
268                     }
269                 ],
270                 center : {
271                     xtype: 'LayoutRegion',
272                     xns: Roo,
273                     autoScroll : false,
274                     split : true
275                 }
276             }
277         };
278     }
279 });