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