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.
- data/app/controllers/rails_db_admin/erp_app/desktop/base_controller.rb +3 -0
- data/lib/rails_db_admin/version.rb +1 -1
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/database_combo.js +4 -3
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/module.js +401 -405
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/query_panel.js +196 -190
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/readonly_table_data_grid.js +2 -5
- data/spec/controllers/rails_db_admin/erp_app/desktop/base_controller_spec.rb +50 -70
- data/spec/controllers/rails_db_admin/erp_app/desktop/queries_controller_spec.rb +15 -17
- metadata +7 -7
@@ -1,205 +1,211 @@
|
|
1
|
-
Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel",{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
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
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
-
|
82
|
-
|
58
|
+
if (response.success) {
|
59
|
+
var columns = response.columns;
|
60
|
+
var fields = response.fields;
|
61
|
+
var data = response.data;
|
83
62
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
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
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
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
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
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
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
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
|
-
|
191
|
-
|
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
|
});
|
data/public/javascripts/erp_app/desktop/applications/rails_db_admin/readonly_table_data_grid.js
CHANGED
@@ -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
|
-
|
13
|
+
height:'100%',
|
17
14
|
loadMask:true
|
18
15
|
}, config);
|
19
16
|
|