rails_db_admin 3.0.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/{public → app/assets}/images/icons/rails_db_admin/rails_db_admin_16x16.png +0 -0
  3. data/{public → app/assets}/images/icons/rails_db_admin/rails_db_admin_24x24.png +0 -0
  4. data/{public → app/assets}/images/icons/rails_db_admin/rails_db_admin_32x32.png +0 -0
  5. data/{public → app/assets}/images/icons/rails_db_admin/rails_db_admin_64x64.png +0 -0
  6. data/{public → app/assets}/images/icons/rails_db_admin/rails_db_admin_light_16x16.png +0 -0
  7. data/app/assets/images/splash/db_admin_splash.png +0 -0
  8. data/{public → app/assets}/images/splash/images/console-icon.png +0 -0
  9. data/{public → app/assets}/images/splash/images/data-model-icon.png +0 -0
  10. data/app/assets/javascripts/erp_app/desktop/applications/rails_db_admin/app.js +20 -0
  11. data/{public → app/assets}/javascripts/erp_app/desktop/applications/rails_db_admin/database_combo.js +1 -1
  12. data/{public → app/assets}/javascripts/erp_app/desktop/applications/rails_db_admin/module.js +227 -135
  13. data/{public → app/assets}/javascripts/erp_app/desktop/applications/rails_db_admin/queries_tree_menu.js +6 -6
  14. data/app/assets/javascripts/erp_app/desktop/applications/rails_db_admin/query_panel.js +383 -0
  15. data/{public → app/assets}/javascripts/erp_app/desktop/applications/rails_db_admin/readonly_table_data_grid.js +0 -0
  16. data/app/assets/javascripts/erp_app/desktop/applications/rails_db_admin/reports/ParamWindow.js +426 -0
  17. data/app/assets/javascripts/erp_app/desktop/applications/rails_db_admin/reports/ParamsManager.js +177 -0
  18. data/app/assets/javascripts/erp_app/desktop/applications/rails_db_admin/reports/RolesPanel.js +95 -0
  19. data/app/assets/javascripts/erp_app/desktop/applications/rails_db_admin/reports/SetDefaultWindow.js +244 -0
  20. data/app/assets/javascripts/erp_app/desktop/applications/rails_db_admin/reports/Settings.js +155 -0
  21. data/app/assets/javascripts/erp_app/desktop/applications/rails_db_admin/reports/TreePanel.js +391 -0
  22. data/app/assets/javascripts/erp_app/desktop/applications/rails_db_admin/splash_screen.js +163 -0
  23. data/{public → app/assets}/javascripts/erp_app/desktop/applications/rails_db_admin/tables_tree_menu.js +5 -3
  24. data/app/assets/javascripts/erp_app/shared/MultiOption.js +151 -0
  25. data/app/assets/javascripts/erp_app/shared/ReportsParams.js +289 -0
  26. data/app/assets/javascripts/erp_app/shared/rails_db_admin_shared.js +13 -0
  27. data/{public/stylesheets/erp_app/desktop/applications/rails_db_admin/rails_db_admin.css → app/assets/stylesheets/erp_app/shared/rails_db_admin_shared.css} +5 -10
  28. data/app/controllers/rails_db_admin/erp_app/desktop/base_controller.rb +7 -6
  29. data/app/controllers/rails_db_admin/erp_app/desktop/queries_controller.rb +88 -74
  30. data/app/controllers/rails_db_admin/erp_app/desktop/reports_controller.rb +361 -30
  31. data/app/controllers/rails_db_admin/reports/base_controller.rb +105 -22
  32. data/app/mailers/report_mailer.rb +15 -0
  33. data/app/models/report.rb +227 -14
  34. data/app/views/rails_db_admin/reports/base/error_report.erb +27 -0
  35. data/app/views/report_mailer/email_report.html.erb +255 -0
  36. data/config/routes.rb +2 -1
  37. data/db/data_migrations/20110816005525_rails_db_admin_application.rb +6 -14
  38. data/db/data_migrations/20151015093724_add_report_role_type.rb +15 -0
  39. data/db/migrate/20121210160131_add_reports.rb +2 -0
  40. data/db/migrate/20150926061259_add_meta_data_to_reports.rb +9 -0
  41. data/lib/rails_db_admin.rb +4 -2
  42. data/lib/rails_db_admin/engine.rb +12 -4
  43. data/lib/rails_db_admin/erp_string_parser.rb +26 -0
  44. data/lib/rails_db_admin/extensions/railties/action_view/helpers/report_helper.rb +167 -10
  45. data/lib/rails_db_admin/extjs/json_data_builder.rb +36 -20
  46. data/lib/rails_db_admin/query_params.rb +14 -0
  47. data/lib/rails_db_admin/query_support.rb +56 -46
  48. data/lib/rails_db_admin/services/report_helper.rb +241 -0
  49. data/lib/rails_db_admin/version.rb +1 -1
  50. metadata +41 -30
  51. data/app/assets/javascripts/rails_db_admin/application.js +0 -9
  52. data/app/assets/stylesheets/rails_db_admin/application.css +0 -7
  53. data/app/views/rails_db_admin/reports/base/show_report.erb +0 -11
  54. data/db/migrate/20131112013053_add_rails_db_admin_missing_indexes.rb +0 -17
  55. data/lib/rails_db_admin/report_support.rb +0 -52
  56. data/public/images/splash/splash.png +0 -0
  57. data/public/javascripts/erp_app/desktop/applications/rails_db_admin/query_panel.js +0 -223
  58. data/public/javascripts/erp_app/desktop/applications/rails_db_admin/report_panel.js +0 -78
  59. data/public/javascripts/erp_app/desktop/applications/rails_db_admin/reports_tree_panel.js +0 -237
  60. data/public/javascripts/erp_app/desktop/applications/rails_db_admin/splash_screen.js +0 -136
@@ -1,223 +0,0 @@
1
- Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel", {
2
- extend: "Ext.panel.Panel",
3
- alias: 'widget.railsdbadmin_querypanel',
4
-
5
- getSql: function () {
6
- return this.down('codemirror').getValue();
7
- },
8
-
9
- initComponent: function () {
10
- var self = this;
11
- var messageBox = null;
12
-
13
- var savedQueriesJsonStore = Ext.create('Ext.data.Store', {
14
- proxy: {
15
- type: 'ajax',
16
- url: '/rails_db_admin/erp_app/desktop/queries/saved_queries',
17
- reader: {
18
- type: 'json',
19
- root: 'data'
20
- }
21
- },
22
- fields: [
23
- {
24
- name: 'value'
25
- },
26
- {
27
- name: 'display'
28
- }
29
- ]
30
- });
31
-
32
- var tbarItems = [
33
- {
34
- text: 'Execute',
35
- iconCls: 'icon-playpause',
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();
42
-
43
- messageBox = Ext.Msg.wait('Status', 'Executing..');
44
-
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);
57
-
58
- if (response.success) {
59
- var columns = response.columns;
60
- var fields = response.fields;
61
- var data = response.data;
62
-
63
- if (!Ext.isEmpty(self.down('railsdbadmin_readonlytabledatagrid'))) {
64
- var jsonStore = new Ext.data.JsonStore({
65
- fields: fields,
66
- data: data
67
- });
68
-
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
- });
78
-
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
- }
88
-
89
- },
90
- failure: function () {
91
- messageBox.hide();
92
- Ext.Msg.alert('Status', 'Error loading grid');
93
- }
94
- });
95
- }
96
- }
97
- ];
98
-
99
- if (!this.initialConfig['hideSave']) {
100
- tbarItems.push({
101
- text: 'Save',
102
- iconCls: 'icon-save',
103
- handler: function () {
104
- var textarea = self.down('.codemirror');
105
- var save_window = new Ext.Window({
106
- layout: 'fit',
107
- width: 375,
108
- title: 'Save Query',
109
- height: 125,
110
- buttonAlign: 'center',
111
- closeAction: 'hide',
112
- plain: true,
113
- items: {
114
- xtype: 'form',
115
- frame: false,
116
- bodyStyle: 'padding:5px 5px 0',
117
- width: 500,
118
- items: [
119
- {
120
- xtype: 'combo',
121
- fieldLabel: 'Query Name',
122
- name: 'query_name',
123
- allowBlank: false,
124
- store: savedQueriesJsonStore,
125
- valueField: 'value',
126
- displayField: 'display',
127
- triggerAction: 'all',
128
- forceSelection: false,
129
- mode: 'remote'
130
- },
131
- {
132
- xtype: 'hidden',
133
- value: textarea.getValue(),
134
- name: 'query'
135
- },
136
- {
137
- xtype: 'hidden',
138
- value: self.module.getDatabase(),
139
- name: 'database'
140
- }
141
- ]
142
- },
143
- buttons: [
144
- {
145
- text: 'Save',
146
- handler: function (btn) {
147
- var fp = this.up('window').down('.form');
148
- if (fp.getForm().isValid()) {
149
- fp.getForm().submit({
150
- url: '/rails_db_admin/erp_app/desktop/queries/save_query',
151
- waitMsg: 'Saving Query...',
152
- success: function (fp, o) {
153
- Ext.Msg.alert('Success', 'Saved Query');
154
- var database = self.module.getDatabase();
155
- self.module.queriesTreePanel().store.setProxy({
156
- type: 'ajax',
157
- url: '/rails_db_admin/erp_app/desktop/queries/saved_queries_tree',
158
- extraParams: {
159
- database: database
160
- }
161
- });
162
- self.module.queriesTreePanel().store.load();
163
- btn.up('window').hide();
164
- }
165
- });
166
- }
167
- }
168
- },
169
- {
170
- text: 'Cancel',
171
- handler: function (btn) {
172
- btn.up('window').hide();
173
- }
174
- }
175
- ]
176
-
177
- }).show();
178
- }
179
- });
180
- }
181
-
182
- var codeMirrorPanel = {
183
- region: 'center',
184
- xtype: 'codemirror',
185
- mode: 'sql',
186
- split: true,
187
- tbarItems: tbarItems,
188
- sourceCode: this.initialConfig['sqlQuery'],
189
- disableSave: true
190
- };
191
-
192
- this.items = [codeMirrorPanel];
193
-
194
- if (!Ext.isEmpty(this.initialConfig['southRegion'])) {
195
- this.items.push(this.initialConfig['southRegion']);
196
- }
197
- else {
198
- this.items.push({
199
- layout: 'card',
200
- region: 'south',
201
- margins: '0 0 0 0',
202
- autoScroll: true,
203
- split: true,
204
- collapsible: true,
205
- collapseDirection: 'bottom',
206
- height: '50%',
207
- itemId: 'resultCardPanel',
208
- items: []
209
- })
210
- }
211
-
212
- this.callParent(arguments);
213
- },
214
-
215
- constructor: function (config) {
216
- config = Ext.applyIf({
217
- title: 'Query',
218
- layout: 'border',
219
- border: false
220
- }, config);
221
- this.callParent([config]);
222
- }
223
- });
@@ -1,78 +0,0 @@
1
- Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin.ReportPanel", {
2
- extend:"Ext.tab.Panel",
3
- alias:'widget.railsdbadmin_reportpanel',
4
-
5
- initComponent:function () {
6
- var me = this;
7
-
8
- var codeMirror = Ext.create("widget.codemirror", {
9
- title:'Template',
10
- disableSave:true,
11
- parser:'rb',
12
- sourceCode:me.initialConfig.template
13
- });
14
-
15
- var queryPanel = Ext.create('widget.railsdbadmin_querypanel',{
16
- title:'Query',
17
- hideSave:true,
18
- closable:false,
19
- module:me.initialConfig.module,
20
- sqlQuery:me.initialConfig.query
21
- });
22
-
23
- this.items = [queryPanel, codeMirror];
24
-
25
- this.tbar = {
26
- items:[
27
- {
28
- text:'Save Report',
29
- iconCls:'icon-save',
30
- handler:function(btn){
31
- var template, query = null;
32
-
33
- //need to show all tabs to make sure codemirror fully rendered.
34
- var tabPanel = btn.up('railsdbadmin_reportpanel');
35
- activeTab = tabPanel.getActiveTab();
36
- tabPanel.setActiveTab(1);
37
- tabPanel.setActiveTab(0);
38
- tabPanel.setActiveTab(activeTab);
39
-
40
- template = codeMirror.getValue();
41
- query = queryPanel.getSql();
42
-
43
- var waitMsg = Ext.Msg.wait("Saving Report...", "Status");
44
- Ext.Ajax.request({
45
- url:'/rails_db_admin/erp_app/desktop/reports/save',
46
- params:{
47
- id:me.initialConfig.reportId,
48
- template:template,
49
- query:query
50
- },
51
- success:function (responseObject) {
52
- waitMsg.close();
53
- var obj = Ext.decode(responseObject.responseText);
54
- if (!obj.success) {
55
- Ext.Msg.alert('Status', 'Error saving report');
56
- }
57
- },
58
- failure:function () {
59
- waitMsg.close();
60
- Ext.Msg.alert('Status', 'Error saving report');
61
- }
62
- });
63
- }
64
- },
65
- {
66
- text:'Execute Report',
67
- iconCls:'icon-playpause',
68
- handler:function(btn){
69
- var webNavigator = window.compassDesktop.getModule('web-navigator-win');
70
- webNavigator.createWindow('/reports/display/'+me.initialConfig.internalIdentifier);
71
- }
72
- }
73
- ]
74
- };
75
-
76
- this.callParent(arguments);
77
- }
78
- });
@@ -1,237 +0,0 @@
1
- Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin.ReportsTreePanel", {
2
- extend:"Ext.tree.TreePanel",
3
- alias:'widget.railsdbadmin_reportstreepanel',
4
-
5
- newReport:function () {
6
- var me = this;
7
-
8
- Ext.create("Ext.window.Window", {
9
- title:'New Report',
10
- plain:true,
11
- buttonAlign:'center',
12
- items:Ext.create('Ext.FormPanel', {
13
- labelWidth:110,
14
- frame:false,
15
- bodyStyle:'padding:5px 5px 0',
16
- url:'/rails_db_admin/erp_app/desktop/reports/create',
17
- defaults:{
18
- width:225
19
- },
20
- items:[
21
- {
22
- xtype:'textfield',
23
- fieldLabel:'Title',
24
- allowBlank:false,
25
- name:'name'
26
- },
27
- {
28
- xtype:'textfield',
29
- fieldLabel:'Unique Name',
30
- allowBlank:false,
31
- name:'internal_identifier'
32
- }
33
- ]
34
- }),
35
- buttons:[
36
- {
37
- text:'Submit',
38
- listeners:{
39
- 'click':function (button) {
40
- var window = button.up('window');
41
- var formPanel = window.down('form');
42
- formPanel.getForm().submit({
43
- waitMsg:'Creating Report...',
44
- success:function (form, action) {
45
- var obj = Ext.decode(action.response.responseText);
46
- if (obj.success) {
47
- button.up('window').close();
48
- me.getStore().load();
49
- }
50
- else {
51
- Ext.Msg.alert("Error", obj.msg);
52
- }
53
- },
54
- failure:function (form, action) {
55
- var obj = Ext.decode(action.response.responseText);
56
- if (obj.msg) {
57
- Ext.Msg.alert("Error", obj.msg);
58
- }
59
- else {
60
- Ext.Msg.alert("Error", "Error creating report.");
61
- }
62
- }
63
- });
64
- }
65
- }
66
- },
67
- {
68
- text:'Close',
69
- handler:function (btn) {
70
- btn.up('window').close();
71
- }
72
- }
73
- ]
74
- }).show();
75
- },
76
-
77
- deleteReport:function (id) {
78
- var me = this;
79
-
80
- Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this report?', function (btn) {
81
- if (btn === 'no') {
82
- return false;
83
- }
84
- else if (btn === 'yes') {
85
- Ext.Ajax.request({
86
- url:'/rails_db_admin/erp_app/desktop/reports/delete',
87
- params:{
88
- id:id
89
- },
90
- success:function (responseObject) {
91
- var obj = Ext.decode(responseObject.responseText);
92
- if (obj.success) {
93
- me.getStore().load();
94
- }
95
- else {
96
- Ext.Msg.alert('Status', 'Error deleting report');
97
- }
98
- },
99
- failure:function () {
100
- Ext.Msg.alert('Status', 'Error deleting report');
101
- }
102
- });
103
- }
104
- });
105
- },
106
-
107
- editReport:function (id) {
108
- var me = this;
109
-
110
- var waitMsg = Ext.Msg.wait("Loading report...", "Status");
111
- Ext.Ajax.request({
112
- url:'/rails_db_admin/erp_app/desktop/reports/edit',
113
- params:{
114
- id:id
115
- },
116
- success:function (responseObject) {
117
- waitMsg.close();
118
- var obj = Ext.decode(responseObject.responseText);
119
- if (obj.success) {
120
- me.initialConfig.module.editReport(obj.report);
121
- }
122
- else {
123
- Ext.Msg.alert('Status', 'Error deleting report');
124
- }
125
- },
126
- failure:function () {
127
- waitMsg.close();
128
- Ext.Msg.alert('Status', 'Error deleting report');
129
- }
130
- });
131
- },
132
-
133
- constructor:function (config) {
134
- var me = this;
135
-
136
- config = Ext.apply({
137
- title:'Reports',
138
- autoScroll:true,
139
- store:Ext.create('Ext.data.TreeStore', {
140
- proxy:{
141
- type:'ajax',
142
- url:'/rails_db_admin/erp_app/desktop/reports'
143
- },
144
- root:{
145
- text:'Reports',
146
- expanded:true,
147
- draggable:false,
148
- iconCls:'icon-reports'
149
- },
150
- fields:[
151
- {
152
- name:'text'
153
- }, {
154
- name:'iconCls'
155
- }, {
156
- name:'leaf'
157
- }, {
158
- name:'id'
159
- }, {
160
- name:'uniqueName'
161
- }
162
-
163
- ]
164
- }),
165
- animate:false,
166
- listeners:{
167
- 'itemclick':function (view, record, item, index, e) {
168
- e.stopEvent();
169
- if (record.data.leaf) {
170
- me.editReport(record.data.id);
171
- }
172
- },
173
- 'itemcontextmenu':function (view, record, item, index, e) {
174
- e.stopEvent();
175
- var contextMenu = null;
176
- if (record.data.leaf) {
177
- contextMenu = Ext.create('Ext.menu.Menu',{
178
- items:[
179
- {
180
- text:"Edit Report",
181
- iconCls:'icon-settings',
182
- listeners:{
183
- scope:record,
184
- 'click':function () {
185
- me.editReport(record.data.id);
186
- }
187
- }
188
- },
189
- {
190
- text:"Delete",
191
- iconCls:'icon-delete',
192
- listeners:{
193
- scope:record,
194
- 'click':function () {
195
- me.deleteReport(record.data.id);
196
- }
197
- }
198
- },
199
- {
200
- text:"Info",
201
- iconCls:'icon-info',
202
- listeners:{
203
- scope:record,
204
- 'click':function () {
205
- Ext.Msg.alert('Details', 'Title: '+record.data.text +
206
- '<br /> Unique Name: '+record.data.uniqueName
207
- );
208
- }
209
- }
210
- }
211
- ]
212
- });
213
- }
214
- else {
215
- contextMenu = Ext.create('Ext.menu.Menu',{
216
- items:[
217
- {
218
- text:"New Report",
219
- iconCls:'icon-document',
220
- listeners:{
221
- 'click':function () {
222
- me.newReport();
223
- }
224
- }
225
- }
226
- ]
227
- });
228
- }
229
- contextMenu.showAt(e.xy);
230
- }
231
- }
232
- }, config);
233
-
234
- this.callParent([config]);
235
- }
236
- });
237
-