Pman.Tab.BuilderDatabase.bjs
[Pman.Builder] / Pman.Tab.BuilderDatabase.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5
6
7 // register the module first
8 Pman.on('beforeload', function()
9 {
10     Pman.register({
11         part :  ["Builder","Database"],
12         modKey : '999-Pman.Tab.BuilderDatabase',
13         module : Pman.Tab.BuilderDatabase,
14         region : 'center',
15         parent : Pman.Tab.Builder,
16         name : "Pman.Tab.BuilderDatabase",
17         disabled : false, 
18         permname: '' 
19     });
20 });
21
22 Pman.Tab.BuilderDatabase = new Roo.util.Observable({
23
24     panel : false,
25     disabled : false,
26     parentLayout:  false,
27
28     add : function(parentLayout, region)
29     {
30
31         var _this = this;
32         this.parentLayout = parentLayout;
33
34         this.panel = parentLayout.addxtype({
35             xtype: 'NestedLayoutPanel',
36             xns: Roo,
37             region : 'center',
38             title : "Manage Database",
39             layout : {
40                 xtype: 'BorderLayout',
41                 xns: Roo,
42                 items : [
43                     {
44                         xtype: 'TreePanel',
45                         xns: Roo,
46                         listeners : {
47                             render : function (_self)
48                             {
49                                _this.treepanel = _self;
50                             }
51                         },
52                         region : 'west',
53                         toolbar : {
54                             xtype: 'Toolbar',
55                             xns: Roo,
56                             items : [
57                                 {
58                                     xtype: 'SplitButton',
59                                     xns: Roo.Toolbar,
60                                     listeners : {
61                                         click : function (_self, e)
62                                         {
63                                          _this.treepanel.tree.root.reload();
64                                         }
65                                     },
66                                     text : "Refresh/Manage Tables",
67                                     menu : {
68                                         xtype: 'Menu',
69                                         xns: Roo.menu,
70                                         items : [
71                                             {
72                                                 xtype: 'Item',
73                                                 xns: Roo.menu,
74                                                 text : "Add Table/Container"
75                                             },
76                                             {
77                                                 xtype: 'Separator',
78                                                 xns: Roo.menu
79                                             },
80                                             {
81                                                 xtype: 'Item',
82                                                 xns: Roo.menu,
83                                                 listeners : {
84                                                     click : function (_self, e)
85                                                     {
86                                                         new Pman.Request({
87                                                             method: 'GET',
88                                                             url: baseURL + '/Roo/Builder_tables.php',
89                                                             params : {
90                                                                  _sync : 1
91                                                             }
92                                                         });
93                                                             
94                                                     }
95                                                 },
96                                                 text : "Sync Tables"
97                                             }
98                                         ]
99                                     }
100                                 }
101                             ]
102                         },
103                         tree : {
104                             xtype: 'TreePanel',
105                             xns: Roo.tree,
106                             ddGroup : 'dbtree',
107                             enableDrag : true,
108                             enableDrop : true,
109                             rootVisible : false,
110                             renderer : function(n) {
111                                 n.attributes.leaf = n.attributes.name.length ? true : false;
112                             
113                                 return String.format('<B>{0}</B><i>{1}</i>',
114                                     n.attributes.name,
115                                     n.attributes.desc
116                                 );
117                                 
118                             },
119                             loader : {
120                                 xtype: 'TreeLoader',
121                                 xns: Roo.tree,
122                                 queryParam : 'parent_id',
123                                 requestMethod : 'GET',
124                                 root : 'data',
125                                 baseParams : { _tree: 1, 'sort': 'name', dir: 'ASC' },
126                                 dataUrl : baseURL + '/Roo/Builder_tables.php'
127                             },
128                             root : {
129                                 xtype: 'AsyncTreeNode',
130                                 xns: Roo.tree,
131                                 text : "TOP LEVEL"
132                             }
133                         }
134                     },
135                     {
136                         xtype: 'GridPanel',
137                         xns: Roo,
138                         listeners : {
139                             activate : function() {
140                                 _this.panel = this;
141                                 if (_this.grid) {
142                                     _this.grid.footer.onClick('first');
143                                 }
144                             }
145                         },
146                         background : true,
147                         fitContainer : true,
148                         fitToframe : true,
149                         region : 'center',
150                         tableName : 'Tables',
151                         title : "Tables",
152                         grid : {
153                             xtype: 'Grid',
154                             xns: Roo.grid,
155                             listeners : {
156                                 render : function() 
157                                 {
158                                     _this.grid = this; 
159                                     //_this.dialog = Pman.Dialog.FILL_IN
160                                     if (_this.panel.active) {
161                                        this.footer.onClick('first');
162                                     }
163                                 },
164                                 rowdblclick : function (_self, rowIndex, e)
165                                 {
166                                     if (!_this.dialog) return;
167                                     _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
168                                         _this.grid.footer.onClick('first');
169                                     }); 
170                                 }
171                             },
172                             autoExpandColumn : 'table',
173                             loadMask : true,
174                             dataSource : {
175                                 xtype: 'Store',
176                                 xns: Roo.data,
177                                 remoteSort : true,
178                                 sortInfo : { field : 'filename', direction: 'ASC' },
179                                 proxy : {
180                                     xtype: 'HttpProxy',
181                                     xns: Roo.data,
182                                     method : 'GET',
183                                     url : baseURL + '/Builder/ERM.php'
184                                 },
185                                 reader : {
186                                     xtype: 'JsonReader',
187                                     xns: Roo.data,
188                                     totalProperty : 'total',
189                                     root : 'data',
190                                     id : 'id',
191                                     fields : [
192                                         {
193                                             'name': 'id',
194                                             'type': 'int'
195                                         },
196                                         {
197                                             'name': 'filename',
198                                             'type': 'string'
199                                         },
200                                         {
201                                             'name': 'ontable',
202                                             'type': 'string'
203                                         },
204                                         {
205                                             'name': 'onid',
206                                             'type': 'int'
207                                         },
208                                         {
209                                             'name': 'mimetype',
210                                             'type': 'string'
211                                         },
212                                         {
213                                             'name': 'width',
214                                             'type': 'int'
215                                         },
216                                         {
217                                             'name': 'height',
218                                             'type': 'int'
219                                         },
220                                         {
221                                             'name': 'filesize',
222                                             'type': 'int'
223                                         },
224                                         {
225                                             'name': 'displayorder',
226                                             'type': 'int'
227                                         },
228                                         {
229                                             'name': 'language',
230                                             'type': 'string'
231                                         },
232                                         {
233                                             'name': 'parent_image_id',
234                                             'type': 'int'
235                                         },
236                                         {
237                                             'name': 'created',
238                                             'type': 'date',
239                                             'dateFormat': 'Y-m-d'
240                                         },
241                                         {
242                                             'name': 'imgtype',
243                                             'type': 'string'
244                                         },
245                                         {
246                                             'name': 'linkurl',
247                                             'type': 'string'
248                                         },
249                                         {
250                                             'name': 'descript',
251                                             'type': 'string'
252                                         },
253                                         {
254                                             'name': 'title',
255                                             'type': 'string'
256                                         },
257                                         {
258                                             'name': 'credit',
259                                             'type': 'string'
260                                         },
261                                         {
262                                             'name': 'source',
263                                             'type': 'string'
264                                         },
265                                         {
266                                             'name': 'parent_image_id_id',
267                                             'type': 'int'
268                                         },
269                                         {
270                                             'name': 'parent_image_id_filename',
271                                             'type': 'string'
272                                         },
273                                         {
274                                             'name': 'parent_image_id_ontable',
275                                             'type': 'string'
276                                         },
277                                         {
278                                             'name': 'parent_image_id_onid',
279                                             'type': 'int'
280                                         },
281                                         {
282                                             'name': 'parent_image_id_mimetype',
283                                             'type': 'string'
284                                         },
285                                         {
286                                             'name': 'parent_image_id_width',
287                                             'type': 'int'
288                                         },
289                                         {
290                                             'name': 'parent_image_id_height',
291                                             'type': 'int'
292                                         },
293                                         {
294                                             'name': 'parent_image_id_filesize',
295                                             'type': 'int'
296                                         },
297                                         {
298                                             'name': 'parent_image_id_displayorder',
299                                             'type': 'int'
300                                         },
301                                         {
302                                             'name': 'parent_image_id_language',
303                                             'type': 'string'
304                                         },
305                                         {
306                                             'name': 'parent_image_id_parent_image_id',
307                                             'type': 'int'
308                                         },
309                                         {
310                                             'name': 'parent_image_id_created',
311                                             'type': 'date'
312                                         },
313                                         {
314                                             'name': 'parent_image_id_imgtype',
315                                             'type': 'string'
316                                         },
317                                         {
318                                             'name': 'parent_image_id_linkurl',
319                                             'type': 'string'
320                                         },
321                                         {
322                                             'name': 'parent_image_id_descript',
323                                             'type': 'string'
324                                         },
325                                         {
326                                             'name': 'parent_image_id_title',
327                                             'type': 'string'
328                                         },
329                                         {
330                                             'name': 'parent_image_id_credit',
331                                             'type': 'string'
332                                         },
333                                         {
334                                             'name': 'parent_image_id_source',
335                                             'type': 'string'
336                                         }
337                                     ]
338                                 }
339                             },
340                             footer : {
341                                 xtype: 'PagingToolbar',
342                                 xns: Roo,
343                                 pageSize : 25,
344                                 displayInfo : true,
345                                 displayMsg : "Displaying Images{0} - {1} of {2}",
346                                 emptyMsg : "No Images found"
347                             },
348                             toolbar : {
349                                 xtype: 'Toolbar',
350                                 xns: Roo,
351                                 items : [
352                                     {
353                                         xtype: 'Button',
354                                         xns: Roo.Toolbar,
355                                         listeners : {
356                                             click : function()
357                                             {
358                                                 Roo.MessageBox.alert("Updating", "Updating the cache");
359                                                 new Pman.Request({
360                                                     url : baseURL + '/Core/RefreshDatabaseCache',
361                                                     method : 'GET',
362                                                     success : function() {
363                                                         Roo.MessageBox.hide();
364                                                     }
365                                                 });
366                                             }
367                                         },
368                                         cls : 'x-btn-text-icon',
369                                         text : "Refresh Schema",
370                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
371                                     }
372                                 ]
373                             },
374                             colModel : [
375                                 {
376                                     xtype: 'ColumnModel',
377                                     xns: Roo.grid,
378                                     dataIndex : 'table',
379                                     header : 'Table',
380                                     width : 200,
381                                     renderer : function(v) { return String.format('{0}', v); }
382                                 }
383                             ]
384                         }
385                     }
386                 ],
387                 west : {
388                     xtype: 'LayoutRegion',
389                     xns: Roo,
390                     split : true,
391                     width : 150
392                 },
393                 center : {
394                     xtype: 'LayoutRegion',
395                     xns: Roo
396                 }
397             }
398         });
399         this.layout = this.panel.layout;
400
401     }
402 });