rails_db_admin 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,205 +1,211 @@
1
- Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel",{
2
- extend:"Ext.Panel",
3
- alias:'widget.railsdbadmin_querypanel',
4
- gridContainer : null,
5
- initComponent: function() {
6
- var self = this;
7
- var messageBox = null;
1
+ Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel", {
2
+ extend:"Ext.panel.Panel",
3
+ alias:'widget.railsdbadmin_querypanel',
4
+ initComponent:function () {
5
+ var self = this;
6
+ var messageBox = null;
8
7
 
9
- var savedQueriesJsonStore = Ext.create('Ext.data.Store', {
10
- proxy: {
11
- type: 'ajax',
12
- url: '/rails_db_admin/erp_app/desktop/queries/saved_queries',
13
- reader: {
14
- type: 'json',
15
- root: 'data'
16
- }
17
- },
18
- fields:[
19
- {
20
- name:'value'
21
- },
22
- {
23
- name:'display'
24
- }
25
- ]
26
- });
8
+ var savedQueriesJsonStore = Ext.create('Ext.data.Store', {
9
+ proxy:{
10
+ type:'ajax',
11
+ url:'/rails_db_admin/erp_app/desktop/queries/saved_queries',
12
+ reader:{
13
+ type:'json',
14
+ root:'data'
15
+ }
16
+ },
17
+ fields:[
18
+ {
19
+ name:'value'
20
+ },
21
+ {
22
+ name:'display'
23
+ }
24
+ ]
25
+ });
27
26
 
28
- var tableGridContainer = new Ext.Panel({
29
- layout:'card',
30
- region : 'center',
31
- margins : '0 0 0 0',
32
- autoScroll:true,
33
- items:[]
34
- });
27
+ var codeMirrorPanel = {
28
+ height:250,
29
+ region:'north',
30
+ xtype:'codemirror',
31
+ parser:'sql',
32
+ tbarItems:[
33
+ {
34
+ text:'Execute',
35
+ iconCls:'icon-settings',
36
+ handler:function (button) {
37
+ var textarea = self.query('.codemirror')[0];
38
+ var sql = textarea.getValue();
39
+ var selected_sql = textarea.getSelection();
40
+ var cursor_pos = textarea.getCursor().line;
41
+ var database = self.module.getDatabase();
35
42
 
36
- this.gridContainer = tableGridContainer;
37
-
38
- var codeMirrorPanel = new Ext.Panel({
39
- height:250,
40
- region:'north',
41
- margins : '0 0 0 0',
42
- frame:false,
43
- border:false,
44
- autoScroll:true,
45
- layout:'fit',
46
- items:[
47
- {
48
- xtype:'codemirror',
49
- parser:'sql',
50
- sourceCode:this.initialConfig['sqlQuery'],
51
- disableSave:true
52
- }
53
- ]
54
-
55
- });
56
-
57
- this.tbar = {
58
- items:[{
59
- text: 'Execute',
60
- iconCls: 'icon-settings',
61
- handler: function(button) {
62
- var textarea = self.query('.codemirror')[0];
63
- var sql = textarea.getValue();
64
- var selected_sql = textarea.getSelection();
65
- var cursor_pos = textarea.getCursor().line;
66
- var database = self.module.getDatabase();
67
-
68
- messageBox = Ext.Msg.wait('Status', 'Executing..');
43
+ messageBox = Ext.Msg.wait('Status', 'Executing..');
69
44
 
70
- Ext.Ajax.request({
71
- url: '/rails_db_admin/erp_app/desktop/queries/execute_query',
72
- params:{
73
- sql:sql,
74
- database:database,
75
- cursor_pos: cursor_pos,
76
- selected_sql : selected_sql
77
- },
78
- method:'post',
79
- success: function(responseObject) {
45
+ Ext.Ajax.request({
46
+ url:'/rails_db_admin/erp_app/desktop/queries/execute_query',
47
+ params:{
48
+ sql:sql,
49
+ database:database,
50
+ cursor_pos:cursor_pos,
51
+ selected_sql:selected_sql
52
+ },
53
+ method:'post',
54
+ success:function (responseObject) {
55
+ messageBox.hide();
56
+ var response = Ext.decode(responseObject.responseText);
80
57
 
81
- messageBox.hide();
82
- var response = Ext.decode(responseObject.responseText);
58
+ if (response.success) {
59
+ var columns = response.columns;
60
+ var fields = response.fields;
61
+ var data = response.data;
83
62
 
84
- if(response.success)
85
- {
86
- var columns = response.columns;
87
- var fields = response.fields;
88
- var data = response.data;
63
+ if(!Ext.isEmpty(self.down('railsdbadmin_readonlytabledatagrid'))){
64
+ var jsonStore = new Ext.data.JsonStore({
65
+ fields:fields,
66
+ data:data
67
+ });
89
68
 
90
- var grid = new Compass.ErpApp.Desktop.Applications.RailsDbAdmin.ReadOnlyTableDataGrid({
91
- columns:columns,
92
- fields:fields,
93
- data:data
94
- });
69
+ self.down('railsdbadmin_readonlytabledatagrid').reconfigure(jsonStore, columns);
70
+ }
71
+ else{
72
+ var readOnlyDataGrid = Ext.create('Compass.ErpApp.Desktop.Applications.RailsDbAdmin.ReadOnlyTableDataGrid',{
73
+ layout:'fit',
74
+ columns:columns,
75
+ fields:fields,
76
+ data:data
77
+ });
95
78
 
96
- tableGridContainer.removeAll(true);
97
- tableGridContainer.add(grid);
98
- tableGridContainer.getLayout().setActiveItem(0);
99
- }
100
- else
101
- {
102
- Ext.Msg.alert("Error", response.exception);
103
- }
79
+ var cardPanel = self.down('#resultCardPanel');
80
+ cardPanel.removeAll(true);
81
+ cardPanel.add(readOnlyDataGrid);
82
+ cardPanel.getLayout().setActiveItem(readOnlyDataGrid);
83
+ }
84
+ }
85
+ else {
86
+ Ext.Msg.alert("Error", response.exception);
87
+ }
104
88
 
105
- },
106
- failure: function() {
107
- messageBox.hide();
108
- Ext.Msg.alert('Status', 'Error loading grid');
109
- }
110
- });
111
- }
112
- },
113
- {
114
- text: 'Save',
115
- iconCls: 'icon-save',
116
- handler:function(){
117
- var textarea = self.query('.codemirror')[0];
118
- var save_window = new Ext.Window({
119
- layout:'fit',
120
- width:375,
121
- title:'Save Query',
122
- height:125,
123
- buttonAlign:'center',
124
- closeAction:'hide',
125
- plain: true,
126
- items: new Ext.FormPanel({
127
- frame:false,
128
- bodyStyle:'padding:5px 5px 0',
129
- width: 500,
130
- items: [{
131
- xtype: 'combo',
132
- fieldLabel: 'Query Name',
133
- name: 'query_name',
134
- allowBlank:false,
135
- store:savedQueriesJsonStore,
136
- valueField:'value',
137
- displayField:'display',
138
- triggerAction:'all',
139
- forceSelection:false,
140
- mode:'remote'
141
- },
142
- {
143
- xtype: 'hidden',
144
- value: textarea.getValue(),
145
- name: 'query'
146
- },
147
- {
148
- xtype: 'hidden',
149
- value: self.module.getDatabase(),
150
- name: 'database'
151
- }]
152
- }),
153
- buttons: [{
154
- text: 'Save',
155
- handler: function(){
156
- var fp = this.findParentByType('window').query('.form')[0];
157
- if(fp.getForm().isValid()){
158
- fp.getForm().submit({
159
- url: '/rails_db_admin/erp_app/desktop/queries/save_query',
160
- waitMsg: 'Saving Query...',
161
- success: function(fp, o){
162
- Ext.Msg.alert('Success', 'Saved Query');
163
- var database = self.module.getDatabase();
164
- self.module.queriesTreePanel().store.setProxy({
165
- type: 'ajax',
166
- url: '/rails_db_admin/erp_app/desktop/queries/saved_queries_tree',
167
- extraParams:{
168
- database:database
169
- }
170
- });
171
- self.module.queriesTreePanel().store.load();
172
- save_window.hide();
89
+ },
90
+ failure:function () {
91
+ messageBox.hide();
92
+ Ext.Msg.alert('Status', 'Error loading grid');
93
+ }
94
+ });
95
+ }
96
+ },
97
+ {
98
+ text:'Save',
99
+ iconCls:'icon-save',
100
+ handler:function () {
101
+ var textarea = self.down('.codemirror');
102
+ var save_window = new Ext.Window({
103
+ layout:'fit',
104
+ width:375,
105
+ title:'Save Query',
106
+ height:125,
107
+ buttonAlign:'center',
108
+ closeAction:'hide',
109
+ plain:true,
110
+ items:new Ext.FormPanel({
111
+ frame:false,
112
+ bodyStyle:'padding:5px 5px 0',
113
+ width:500,
114
+ items:[
115
+ {
116
+ xtype:'combo',
117
+ fieldLabel:'Query Name',
118
+ name:'query_name',
119
+ allowBlank:false,
120
+ store:savedQueriesJsonStore,
121
+ valueField:'value',
122
+ displayField:'display',
123
+ triggerAction:'all',
124
+ forceSelection:false,
125
+ mode:'remote'
126
+ },
127
+ {
128
+ xtype:'hidden',
129
+ value:textarea.getValue(),
130
+ name:'query'
131
+ },
132
+ {
133
+ xtype:'hidden',
134
+ value:self.module.getDatabase(),
135
+ name:'database'
136
+ }
137
+ ]
138
+ }),
139
+ buttons:[
140
+ {
141
+ text:'Save',
142
+ handler:function () {
143
+ var fp = this.up('window').down('.form');
144
+ if (fp.getForm().isValid()) {
145
+ fp.getForm().submit({
146
+ url:'/rails_db_admin/erp_app/desktop/queries/save_query',
147
+ waitMsg:'Saving Query...',
148
+ success:function (fp, o) {
149
+ Ext.Msg.alert('Success', 'Saved Query');
150
+ var database = self.module.getDatabase();
151
+ self.module.queriesTreePanel().store.setProxy({
152
+ type:'ajax',
153
+ url:'/rails_db_admin/erp_app/desktop/queries/saved_queries_tree',
154
+ extraParams:{
155
+ database:database
156
+ }
157
+ });
158
+ self.module.queriesTreePanel().store.load();
159
+ save_window.hide();
160
+ }
161
+ });
162
+ }
163
+ }
164
+ },
165
+ {
166
+ text:'Cancel',
167
+ handler:function () {
168
+ save_window.hide();
169
+ }
170
+ }
171
+ ]
172
+
173
+ });
174
+ save_window.show();
173
175
  }
174
- });
175
176
  }
176
- }
177
- },{
178
- text: 'Cancel',
179
- handler: function(){
180
- save_window.hide();
181
- }
182
- }]
183
-
184
- });
185
- save_window.show();
177
+ ],
178
+ sourceCode:this.initialConfig['sqlQuery'],
179
+ disableSave:true
180
+ };
181
+
182
+ this.items = [codeMirrorPanel];
183
+
184
+ if(!Ext.isEmpty(this.initialConfig['southRegion'])){
185
+ this.items.push(this.initialConfig['southRegion']);
186
+ }
187
+ else{
188
+ this.items.push({
189
+ layout:'card',
190
+ region:'center',
191
+ margins:'0 0 0 0',
192
+ autoScroll:true,
193
+ itemId:'resultCardPanel',
194
+ items:[]
195
+ })
186
196
  }
187
- }]
188
- };
189
197
 
190
- this.items = [codeMirrorPanel, tableGridContainer];
191
- this.callParent(arguments);
192
- },
198
+ this.callParent(arguments);
199
+ },
200
+
201
+ constructor:function (config) {
202
+ config = Ext.apply({
203
+ title:'Query',
204
+ layout:'border',
205
+ closable:true,
206
+ border:false
207
+ }, config);
208
+ this.callParent([config]);
209
+ }
193
210
 
194
- constructor : function(config) {
195
- config = Ext.apply({
196
- title:'Query',
197
- layout:'border',
198
- autoScroll:true,
199
- closable: true,
200
- border:false
201
- }, config);
202
- this.callParent([config]);
203
- }
204
-
205
211
  });
@@ -5,15 +5,12 @@ Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin.ReadOnlyTableDataGr
5
5
  var jsonStore = new Ext.data.JsonStore({
6
6
  fields:config.fields,
7
7
  data:config.data
8
- })
8
+ });
9
9
 
10
10
  config = Ext.apply({
11
11
  store:jsonStore,
12
- layout:'fit',
13
- frame: false,
14
- closable: true,
15
12
  autoScroll:true,
16
- region:'center',
13
+ height:'100%',
17
14
  loadMask:true
18
15
  }, config);
19
16