rails_db_admin 2.1.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/controllers/rails_db_admin/erp_app/desktop/base_controller.rb +6 -4
- data/app/controllers/rails_db_admin/erp_app/desktop/queries_controller.rb +1 -1
- data/db/migrate/20131112013053_add_rails_db_admin_missing_indexes.rb +17 -0
- data/lib/rails_db_admin.rb +0 -1
- data/lib/rails_db_admin/engine.rb +1 -1
- data/lib/rails_db_admin/extjs/json_column_builder.rb +53 -43
- data/lib/rails_db_admin/table_support.rb +24 -15
- data/lib/rails_db_admin/version.rb +7 -3
- data/public/images/icons/rails_db_admin/rails_db_admin_16x16.png +0 -0
- data/public/images/icons/rails_db_admin/rails_db_admin_64x64.png +0 -0
- data/public/images/icons/rails_db_admin/rails_db_admin_light_16x16.png +0 -0
- data/public/images/splash/images/console-icon.png +0 -0
- data/public/images/splash/images/data-model-icon.png +0 -0
- data/public/images/splash/splash.png +0 -0
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/database_combo.js +28 -25
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/module.js +276 -215
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/queries_tree_menu.js +3 -3
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/query_panel.js +100 -97
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/readonly_table_data_grid.js +22 -18
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/report_panel.js +1 -1
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/reports_tree_panel.js +2 -2
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/splash_screen.js +136 -0
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/tables_tree_menu.js +25 -10
- data/public/stylesheets/erp_app/desktop/applications/rails_db_admin/rails_db_admin.css +4 -0
- metadata +44 -44
- data/app/helpers/rails_db_admin/application_helper.rb +0 -4
- data/public/images/icons/rails_db_admin/rails_db_admin_48x48.png +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3585669877d1680f37b6daf89d11effe18c6f4ed
|
4
|
+
data.tar.gz: 17cecfddcfb176df82f5e8f2957f018b8189aa4c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fa9a5af45478f74855a41a557c6bf59fe4f54b064e480e18d56be5852db33a95d16d718eb4bbe2eed24d1ca8e7f56007165ddadc509b86b9be306dc9a61b478d
|
7
|
+
data.tar.gz: f19151aeec5d273e695e3cf61ce77d63b67510a268f4e3b7e55fa08e6366493d1a7b9286da095bc29e6467d7a3466b9153e58b8e8247454f3252fe65674fc408
|
@@ -26,20 +26,22 @@ module RailsDbAdmin
|
|
26
26
|
tables << {:name => table, :display => table} unless table.blank?
|
27
27
|
end
|
28
28
|
|
29
|
-
tables = tables.select
|
29
|
+
tables = tables.select do |table|
|
30
|
+
(table[:name] =~ Regexp.new("^#{params[:name]}.", Regexp::IGNORECASE)) || table[:name] == params[:name]
|
31
|
+
end
|
30
32
|
tables.sort! { |a, b| a[:name].downcase <=> b[:name].downcase }
|
31
33
|
|
32
34
|
tables.each do |table|
|
33
35
|
result_hash << {:isTable => true,
|
34
|
-
:text => table[:display],
|
35
36
|
:id => table[:display],
|
36
|
-
:
|
37
|
+
:text => table[:display],
|
38
|
+
:iconCls => 'icon-db-table',
|
37
39
|
:leaf => false}
|
38
40
|
end
|
39
41
|
else
|
40
42
|
columns = @database_connection_class.connection.columns(params[:node])
|
41
43
|
columns.each do |column|
|
42
|
-
result_hash << {:text => "#{column.name} : #{column.type}", :iconCls => 'icon-
|
44
|
+
result_hash << {:text => "#{column.name} : #{column.type}", :iconCls => 'icon-db-column', :leaf => true}
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
@@ -37,7 +37,7 @@ module RailsDbAdmin
|
|
37
37
|
queries = []
|
38
38
|
|
39
39
|
queries = names.collect do |name|
|
40
|
-
{:text => name, :id => name, :iconCls => 'icon-
|
40
|
+
{:text => name, :id => name, :iconCls => 'icon-sql', :leaf => true}
|
41
41
|
end unless names.empty?
|
42
42
|
|
43
43
|
render :json => queries
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class AddRailsDbAdminMissingIndexes < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
|
4
|
+
if indexes(:reports).select {|index| index.name == 'reports_internal_identifier_idx'}.empty?
|
5
|
+
add_index :reports, :internal_identifier, :name => 'reports_internal_identifier_idx'
|
6
|
+
end
|
7
|
+
|
8
|
+
end
|
9
|
+
|
10
|
+
def down
|
11
|
+
|
12
|
+
unless indexes(:reports).select {|index| index.name == 'reports_internal_identifier_idx'}.empty?
|
13
|
+
remove_index :reports, :internal_identifier
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/lib/rails_db_admin.rb
CHANGED
@@ -5,7 +5,7 @@ module RailsDbAdmin
|
|
5
5
|
config.rails_db_admin = RailsDbAdmin::Config
|
6
6
|
|
7
7
|
initializer "rails_db_admin.merge_public" do |app|
|
8
|
-
app.middleware.insert_before Rack::
|
8
|
+
app.middleware.insert_before Rack::Runtime, ::ActionDispatch::Static, "#{root}/public"
|
9
9
|
end
|
10
10
|
|
11
11
|
ErpBaseErpSvcs.register_as_compass_ae_engine(config, self)
|
@@ -13,9 +13,9 @@ module RailsDbAdmin
|
|
13
13
|
end
|
14
14
|
if add_fake_id
|
15
15
|
grid_columns << {:header => "fake_id",
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
:type => "number",
|
17
|
+
:dataIndex => "fake_id",
|
18
|
+
:hidden => true}
|
19
19
|
end
|
20
20
|
grid_columns
|
21
21
|
end
|
@@ -34,10 +34,10 @@ module RailsDbAdmin
|
|
34
34
|
|
35
35
|
def self.build_readonly_column(column_name)
|
36
36
|
{
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
:header => column_name,
|
38
|
+
:type => 'string',
|
39
|
+
:dataIndex => column_name,
|
40
|
+
:width => 150
|
41
41
|
}
|
42
42
|
end
|
43
43
|
|
@@ -46,21 +46,21 @@ module RailsDbAdmin
|
|
46
46
|
|
47
47
|
def self.build_boolean_column(column_name)
|
48
48
|
{
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
49
|
+
:header => column_name,
|
50
|
+
:type => 'boolean',
|
51
|
+
:dataIndex => column_name,
|
52
|
+
:width => 150,
|
53
|
+
:editor => {:xtype => 'booleancolumneditor'},
|
54
|
+
:renderer => NonEscapeJsonString.new("Compass.ErpApp.Desktop.Applications.RailsDbAdmin.renderBooleanColumn")
|
55
55
|
}
|
56
56
|
end
|
57
57
|
|
58
58
|
def self.build_date_column(column_name)
|
59
59
|
hash = {
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
:header => column_name,
|
61
|
+
:type => 'date',
|
62
|
+
:dataIndex => column_name,
|
63
|
+
:width => 150,
|
64
64
|
}
|
65
65
|
hash[:editor] = {:xtype => 'textfield'} if (column_name != "created_at" && column_name != "updated_at")
|
66
66
|
|
@@ -69,10 +69,10 @@ module RailsDbAdmin
|
|
69
69
|
|
70
70
|
def self.build_datetime_column(column_name)
|
71
71
|
hash = {
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
:header => column_name,
|
73
|
+
:type => 'date',
|
74
|
+
:dataIndex => column_name,
|
75
|
+
:width => 150,
|
76
76
|
}
|
77
77
|
hash[:editor] = {:xtype => 'textfield'} if (column_name != "created_at" && column_name != "updated_at")
|
78
78
|
|
@@ -81,30 +81,30 @@ module RailsDbAdmin
|
|
81
81
|
|
82
82
|
def self.build_string_column(column_name)
|
83
83
|
{
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
84
|
+
:header => column_name,
|
85
|
+
:type => 'string',
|
86
|
+
:dataIndex => column_name,
|
87
|
+
:width => 150,
|
88
|
+
:editor => {:xtype => 'textfield'}
|
89
89
|
}
|
90
90
|
end
|
91
91
|
|
92
92
|
def self.build_text_column(column_name)
|
93
93
|
{
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
94
|
+
:header => column_name,
|
95
|
+
:type => 'string',
|
96
|
+
:dataIndex => column_name,
|
97
|
+
:width => 150,
|
98
|
+
:editor => {:xtype => 'textarea'}
|
99
99
|
}
|
100
100
|
end
|
101
101
|
|
102
102
|
def self.build_integer_column(column_name)
|
103
103
|
hash = {
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
104
|
+
:header => column_name,
|
105
|
+
:type => 'number',
|
106
|
+
:dataIndex => column_name,
|
107
|
+
:width => 150,
|
108
108
|
}
|
109
109
|
hash[:editor] = {:xtype => 'textfield'} if column_name != "id"
|
110
110
|
|
@@ -113,10 +113,10 @@ module RailsDbAdmin
|
|
113
113
|
|
114
114
|
def self.build_decimal_column(column_name)
|
115
115
|
hash = {
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
116
|
+
:header => column_name,
|
117
|
+
:type => 'float',
|
118
|
+
:dataIndex => column_name,
|
119
|
+
:width => 150,
|
120
120
|
}
|
121
121
|
hash[:editor] = {:xtype => 'textfield'} if column_name != "id"
|
122
122
|
|
@@ -125,15 +125,25 @@ module RailsDbAdmin
|
|
125
125
|
|
126
126
|
def self.build_float_column(column_name)
|
127
127
|
hash = {
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
128
|
+
:header => column_name,
|
129
|
+
:type => 'float',
|
130
|
+
:dataIndex => column_name,
|
131
|
+
:width => 150,
|
132
132
|
}
|
133
133
|
hash[:editor] = {:xtype => 'textfield'} if column_name != "id"
|
134
134
|
|
135
135
|
hash
|
136
136
|
end
|
137
|
+
|
138
|
+
def self.build_hstore_column(column_name)
|
139
|
+
{
|
140
|
+
:header => column_name,
|
141
|
+
:type => 'string',
|
142
|
+
:dataIndex => column_name,
|
143
|
+
:width => 150
|
144
|
+
}
|
145
|
+
end
|
146
|
+
|
137
147
|
end
|
138
148
|
end
|
139
149
|
end
|
@@ -2,7 +2,7 @@ module RailsDbAdmin
|
|
2
2
|
class TableSupport
|
3
3
|
|
4
4
|
def initialize(database_connection_class)
|
5
|
-
|
5
|
+
@connection = database_connection_class.connection
|
6
6
|
end
|
7
7
|
|
8
8
|
def columns(table)
|
@@ -25,7 +25,7 @@ module RailsDbAdmin
|
|
25
25
|
data[0].delete('fake_id')
|
26
26
|
data[1].delete('fake_id')
|
27
27
|
data.map! do |item|
|
28
|
-
item.each do |k,v|
|
28
|
+
item.each do |k, v|
|
29
29
|
item[k] = v.to_s
|
30
30
|
end
|
31
31
|
item
|
@@ -72,27 +72,27 @@ module RailsDbAdmin
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def primary_key(table)
|
75
|
-
[@connection.primary_key(table),nil]
|
75
|
+
[@connection.primary_key(table), nil]
|
76
76
|
end
|
77
77
|
|
78
78
|
def primary_key?(table)
|
79
79
|
@connection.supports_primary_key? && !@connection.primary_key(table).nil?
|
80
80
|
end
|
81
81
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
82
|
+
|
83
|
+
def table_contains_column(table, column_name)
|
84
|
+
|
85
|
+
column_names = columns(table).map { |column| column.name.to_sym }
|
86
|
+
|
87
|
+
column_names.include?(column_name)
|
88
|
+
end
|
89
|
+
|
90
90
|
def clean_nulls!(table, data)
|
91
91
|
if data.class == Array
|
92
|
-
data.each {|x| clean_nulls!(table, x)}
|
92
|
+
data.each { |x| clean_nulls!(table, x) }
|
93
93
|
end
|
94
94
|
|
95
|
-
data.collect do |k,v|
|
95
|
+
data.collect do |k, v|
|
96
96
|
if v == "" || v == 0
|
97
97
|
column = columns(table).collect do |x|
|
98
98
|
if (x.name == k)
|
@@ -117,7 +117,16 @@ module RailsDbAdmin
|
|
117
117
|
# records << record
|
118
118
|
|
119
119
|
# simplifying the above with to_hash.symbolize_keys
|
120
|
-
|
120
|
+
row_data = row.to_hash.symbolize_keys
|
121
|
+
|
122
|
+
# any hashes need to be converted to json strings
|
123
|
+
row_data.each do |k, v|
|
124
|
+
if v.is_a?(Hash)
|
125
|
+
row_data[k] = v.to_json
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
records << row_data
|
121
130
|
end
|
122
131
|
|
123
132
|
records.reverse
|
@@ -128,7 +137,7 @@ module RailsDbAdmin
|
|
128
137
|
#calls
|
129
138
|
def self.arel_attr data, arel_table
|
130
139
|
cln_hsh = {}
|
131
|
-
data.each do |k,v|
|
140
|
+
data.each do |k, v|
|
132
141
|
cln_hsh[arel_table[k.to_sym]] = v
|
133
142
|
end
|
134
143
|
cln_hsh
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,27 +1,26 @@
|
|
1
|
-
Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin.DatabaseComboBox",{
|
2
|
-
extend:"Ext.form.field.ComboBox",
|
3
|
-
alias:'widget.railsdbadmin_databasecombo',
|
4
|
-
initComponent: function() {
|
1
|
+
Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin.DatabaseComboBox", {
|
2
|
+
extend: "Ext.form.field.ComboBox",
|
3
|
+
alias: 'widget.railsdbadmin_databasecombo',
|
4
|
+
initComponent: function () {
|
5
5
|
|
6
|
-
var databaseJsonStore =
|
7
|
-
timeout:60000,
|
6
|
+
var databaseJsonStore = Ext.create('Ext.data.Store', {
|
7
|
+
timeout: 60000,
|
8
8
|
proxy: {
|
9
9
|
type: 'ajax',
|
10
|
-
url
|
10
|
+
url: '/rails_db_admin/erp_app/desktop/base/databases',
|
11
11
|
reader: {
|
12
12
|
type: 'json',
|
13
13
|
root: 'databases'
|
14
14
|
}
|
15
15
|
},
|
16
|
-
fields: [
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}]
|
16
|
+
fields: [
|
17
|
+
'value',
|
18
|
+
'display'
|
19
|
+
]
|
21
20
|
});
|
22
21
|
|
23
22
|
var me = this;
|
24
|
-
databaseJsonStore.on('load', function(store) {
|
23
|
+
databaseJsonStore.on('load', function (store) {
|
25
24
|
me.setValue(store.first().get('value'));
|
26
25
|
});
|
27
26
|
|
@@ -29,25 +28,29 @@ Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin.DatabaseComboBox",{
|
|
29
28
|
this.callParent(arguments);
|
30
29
|
},
|
31
30
|
|
32
|
-
constructor
|
31
|
+
constructor: function (config) {
|
33
32
|
config = Ext.apply({
|
34
|
-
id:'databaseCombo',
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
id: 'databaseCombo',
|
34
|
+
fieldStyle: {
|
35
|
+
borderRadius: '0px !important'
|
36
|
+
},
|
37
|
+
valueField: 'value',
|
38
|
+
displayField: 'display',
|
39
|
+
triggerAction: 'all',
|
40
|
+
editable: false,
|
41
|
+
forceSelection: true,
|
40
42
|
queryMode: 'local',
|
41
|
-
listeners:{
|
42
|
-
'select':function(combo, record, index){
|
43
|
-
|
44
|
-
|
43
|
+
listeners: {
|
44
|
+
'select': function (combo, record, index) {
|
45
|
+
// switch databases
|
46
|
+
combo.initialConfig.module.connectToDatatbase();
|
45
47
|
},
|
46
|
-
render:function(combo){
|
48
|
+
render: function (combo) {
|
47
49
|
combo.getStore().load();
|
48
50
|
}
|
49
51
|
}
|
50
52
|
}, config);
|
53
|
+
|
51
54
|
this.callParent([config]);
|
52
55
|
}
|
53
56
|
});
|
@@ -1,102 +1,113 @@
|
|
1
1
|
Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin", {
|
2
|
-
extend:"Ext.ux.desktop.Module",
|
3
|
-
id:'rails_db_admin-win',
|
2
|
+
extend: "Ext.ux.desktop.Module",
|
3
|
+
id: 'rails_db_admin-win',
|
4
4
|
|
5
|
-
|
6
|
-
return this.
|
5
|
+
getWindow: function () {
|
6
|
+
return this.app.getDesktop().getWindow('rails_db_admin');
|
7
7
|
},
|
8
8
|
|
9
|
-
|
10
|
-
this.
|
9
|
+
queriesTreePanel: function () {
|
10
|
+
return this.accordion.down('.railsdbadmin_queriestreemenu');
|
11
11
|
},
|
12
12
|
|
13
|
-
|
14
|
-
this.
|
13
|
+
setWindowStatus: function (status) {
|
14
|
+
this.getWindow().setStatus(status);
|
15
15
|
},
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
clearWindowStatus: function () {
|
18
|
+
this.getWindow().clearStatus();
|
19
|
+
},
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
proxy:{
|
42
|
-
type:'rest',
|
43
|
-
url:'/rails_db_admin/erp_app/desktop/base/table_data/' + table,
|
44
|
-
//private var to store the previous model in an
|
45
|
-
//update operation
|
46
|
-
oldModel:null,
|
47
|
-
setOldModel:function (old_model) {
|
48
|
-
this.oldModel = old_model.copy();
|
49
|
-
},
|
50
|
-
update:function (operation, callback, scope) {
|
51
|
-
operation.records.push(this.oldModel);
|
52
|
-
Ext.data.proxy.Rest.superclass.update.call(this, operation, callback, scope);
|
53
|
-
},
|
54
|
-
reader:{
|
55
|
-
type:'json',
|
56
|
-
successProperty:'success',
|
57
|
-
root:'data',
|
58
|
-
messageProperty:'message'
|
21
|
+
getTableData: function (table) {
|
22
|
+
var self = this,
|
23
|
+
id = 'ext-' + table + '-data';
|
24
|
+
|
25
|
+
var grid = self.container.down('#' + id);
|
26
|
+
|
27
|
+
if (Ext.isEmpty(grid)) {
|
28
|
+
grid = Ext.create('Compass.ErpApp.Shared.DynamicEditableGridLoaderPanel', {
|
29
|
+
id: id,
|
30
|
+
title: table,
|
31
|
+
setupUrl: '/rails_db_admin/erp_app/desktop/base/setup_table_grid/' + table,
|
32
|
+
dataUrl: '/rails_db_admin/erp_app/desktop/base/table_data/' + table,
|
33
|
+
editable: true,
|
34
|
+
page: true,
|
35
|
+
pageSize: 25,
|
36
|
+
displayMsg: 'Displaying {0} - {1} of {2}',
|
37
|
+
emptyMsg: 'Empty',
|
38
|
+
loadErrorMessage: 'Tables Without Ids Can Not Be Edited',
|
39
|
+
closable: true,
|
40
|
+
params: {
|
41
|
+
database: self.getDatabase()
|
59
42
|
},
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
43
|
+
grid_listeners: {
|
44
|
+
validateedit: {
|
45
|
+
fn: function (editor, e) {
|
46
|
+
this.store.proxy.setOldModel(e.record);
|
47
|
+
}
|
48
|
+
}
|
64
49
|
},
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
50
|
+
proxy: {
|
51
|
+
type: 'rest',
|
52
|
+
url: '/rails_db_admin/erp_app/desktop/base/table_data/' + table,
|
53
|
+
//private var to store the previous model in an
|
54
|
+
//update operation
|
55
|
+
oldModel: null,
|
56
|
+
setOldModel: function (old_model) {
|
57
|
+
this.oldModel = old_model.copy();
|
58
|
+
},
|
59
|
+
update: function (operation, callback, scope) {
|
60
|
+
operation.records.push(this.oldModel);
|
61
|
+
Ext.data.proxy.Rest.superclass.update.call(this, operation, callback, scope);
|
62
|
+
},
|
63
|
+
reader: {
|
64
|
+
type: 'json',
|
65
|
+
successProperty: 'success',
|
66
|
+
root: 'data',
|
67
|
+
messageProperty: 'message'
|
68
|
+
},
|
69
|
+
writer: {
|
70
|
+
type: 'json',
|
71
|
+
writeAllFields: true,
|
72
|
+
root: 'data'
|
73
|
+
},
|
74
|
+
listeners: {
|
75
|
+
exception: function (proxy, response, operation) {
|
76
|
+
var msg;
|
77
|
+
if (operation.getError() === undefined) {
|
78
|
+
var responseObject = Ext.JSON.decode(response.responseText);
|
79
|
+
msg = responseObject.exception;
|
80
|
+
} else {
|
81
|
+
msg = operation.getError();
|
82
|
+
}
|
83
|
+
Ext.MessageBox.show({
|
84
|
+
title: 'REMOTE EXCEPTION',
|
85
|
+
msg: msg,
|
86
|
+
icon: Ext.MessageBox.ERROR,
|
87
|
+
buttons: Ext.Msg.OK
|
88
|
+
});
|
73
89
|
}
|
74
|
-
Ext.MessageBox.show({
|
75
|
-
title:'REMOTE EXCEPTION',
|
76
|
-
msg:msg,
|
77
|
-
icon:Ext.MessageBox.ERROR,
|
78
|
-
buttons:Ext.Msg.OK
|
79
|
-
});
|
80
90
|
}
|
81
91
|
}
|
82
|
-
}
|
83
|
-
});
|
92
|
+
});
|
84
93
|
|
85
|
-
|
86
|
-
|
94
|
+
self.container.add(grid);
|
95
|
+
}
|
96
|
+
|
97
|
+
self.container.setActiveTab(grid);
|
87
98
|
},
|
88
99
|
|
89
|
-
selectTopFifty:function (table) {
|
100
|
+
selectTopFifty: function (table) {
|
90
101
|
this.setWindowStatus('Selecting Top 50 from ' + table + '...');
|
91
102
|
var self = this;
|
92
103
|
|
93
104
|
Ext.Ajax.request({
|
94
|
-
url:'/rails_db_admin/erp_app/desktop/queries/select_top_fifty/' + table,
|
95
|
-
timeout:60000,
|
96
|
-
params:{
|
97
|
-
database:self.getDatabase()
|
105
|
+
url: '/rails_db_admin/erp_app/desktop/queries/select_top_fifty/' + table,
|
106
|
+
timeout: 60000,
|
107
|
+
params: {
|
108
|
+
database: self.getDatabase()
|
98
109
|
},
|
99
|
-
success:function (responseObject) {
|
110
|
+
success: function (responseObject) {
|
100
111
|
self.clearWindowStatus();
|
101
112
|
var response = Ext.decode(responseObject.responseText);
|
102
113
|
var sql = response.sql;
|
@@ -105,17 +116,21 @@ Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin", {
|
|
105
116
|
var data = response.data;
|
106
117
|
|
107
118
|
var readOnlyDataGrid = Ext.create('Compass.ErpApp.Desktop.Applications.RailsDbAdmin.ReadOnlyTableDataGrid', {
|
108
|
-
region:'
|
109
|
-
|
110
|
-
|
111
|
-
|
119
|
+
region: 'south',
|
120
|
+
split: true,
|
121
|
+
columns: columns,
|
122
|
+
fields: fields,
|
123
|
+
data: data,
|
124
|
+
collapseDirection: 'bottom',
|
125
|
+
height: '50%',
|
126
|
+
collapsible: true
|
112
127
|
});
|
113
128
|
|
114
129
|
var queryPanel = Ext.create('Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel', {
|
115
|
-
module:self,
|
116
|
-
closable:true,
|
117
|
-
sqlQuery:sql,
|
118
|
-
southRegion:readOnlyDataGrid
|
130
|
+
module: self,
|
131
|
+
closable: true,
|
132
|
+
sqlQuery: sql,
|
133
|
+
southRegion: readOnlyDataGrid
|
119
134
|
});
|
120
135
|
|
121
136
|
self.container.add(queryPanel);
|
@@ -124,51 +139,60 @@ Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin", {
|
|
124
139
|
//queryPanel.gridContainer.add(readOnlyDataGrid);
|
125
140
|
//queryPanel.gridContainer.getLayout().setActiveItem(0);
|
126
141
|
},
|
127
|
-
failure:function () {
|
142
|
+
failure: function () {
|
128
143
|
self.clearWindowStatus();
|
129
144
|
Ext.Msg.alert('Status', 'Error loading grid');
|
130
145
|
}
|
131
146
|
});
|
132
147
|
},
|
133
148
|
|
134
|
-
|
149
|
+
|
150
|
+
addConsolePanel: function () {
|
151
|
+
this.container.add({
|
152
|
+
xtype: 'compass_ae_console_panel',
|
153
|
+
module: this
|
154
|
+
});
|
155
|
+
this.container.setActiveTab(this.container.items.length - 1);
|
156
|
+
|
157
|
+
},
|
158
|
+
|
159
|
+
addNewQueryTab: function () {
|
135
160
|
this.container.add({
|
136
|
-
xtype:'railsdbadmin_querypanel',
|
137
|
-
module:this
|
161
|
+
xtype: 'railsdbadmin_querypanel',
|
162
|
+
module: this
|
138
163
|
});
|
139
164
|
this.container.setActiveTab(this.container.items.length - 1);
|
140
165
|
},
|
141
166
|
|
142
|
-
connectToDatatbase:function () {
|
167
|
+
connectToDatatbase: function () {
|
143
168
|
var database = this.getDatabase();
|
144
169
|
var tablestreePanelStore = this.accordion.down('.railsdbadmin_tablestreemenu').store;
|
145
170
|
var queriesTreePanelStore = this.accordion.down('.railsdbadmin_queriestreemenu').store;
|
146
171
|
|
147
172
|
tablestreePanelStore.setProxy({
|
148
|
-
type:'ajax',
|
149
|
-
url:'/rails_db_admin/erp_app/desktop/base/tables',
|
150
|
-
extraParams:{
|
151
|
-
database:database
|
173
|
+
type: 'ajax',
|
174
|
+
url: '/rails_db_admin/erp_app/desktop/base/tables',
|
175
|
+
extraParams: {
|
176
|
+
database: database
|
152
177
|
}
|
153
178
|
});
|
154
179
|
tablestreePanelStore.load();
|
155
180
|
|
156
181
|
queriesTreePanelStore.setProxy({
|
157
|
-
type:'ajax',
|
158
|
-
url:'/rails_db_admin/erp_app/desktop/queries/saved_queries_tree',
|
159
|
-
extraParams:{
|
160
|
-
database:database
|
182
|
+
type: 'ajax',
|
183
|
+
url: '/rails_db_admin/erp_app/desktop/queries/saved_queries_tree',
|
184
|
+
extraParams: {
|
185
|
+
database: database
|
161
186
|
}
|
162
187
|
});
|
163
188
|
queriesTreePanelStore.load();
|
164
189
|
},
|
165
190
|
|
166
|
-
getDatabase:function () {
|
167
|
-
|
168
|
-
return database;
|
191
|
+
getDatabase: function () {
|
192
|
+
return Ext.getCmp('databaseCombo').getValue();
|
169
193
|
},
|
170
194
|
|
171
|
-
deleteQuery:function (queryName) {
|
195
|
+
deleteQuery: function (queryName) {
|
172
196
|
var self = this;
|
173
197
|
Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this query?', function (btn) {
|
174
198
|
if (btn === 'no') {
|
@@ -178,22 +202,22 @@ Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin", {
|
|
178
202
|
self.setWindowStatus('Deleting ' + queryName + '...');
|
179
203
|
var database = self.getDatabase();
|
180
204
|
Ext.Ajax.request({
|
181
|
-
url:'/rails_db_admin/erp_app/desktop/queries/delete_query/',
|
182
|
-
params:{
|
183
|
-
database:database,
|
184
|
-
query_name:queryName
|
205
|
+
url: '/rails_db_admin/erp_app/desktop/queries/delete_query/',
|
206
|
+
params: {
|
207
|
+
database: database,
|
208
|
+
query_name: queryName
|
185
209
|
},
|
186
|
-
success:function (responseObject) {
|
210
|
+
success: function (responseObject) {
|
187
211
|
self.clearWindowStatus();
|
188
212
|
var response = Ext.decode(responseObject.responseText);
|
189
213
|
if (response.success) {
|
190
214
|
Ext.Msg.alert('Error', 'Query deleted');
|
191
215
|
var queriesTreePanelStore = self.accordion.down('.railsdbadmin_queriestreemenu').store;
|
192
216
|
queriesTreePanelStore.setProxy({
|
193
|
-
type:'ajax',
|
194
|
-
url:'/rails_db_admin/erp_app/desktop/queries/saved_queries_tree',
|
195
|
-
extraParams:{
|
196
|
-
database:database
|
217
|
+
type: 'ajax',
|
218
|
+
url: '/rails_db_admin/erp_app/desktop/queries/saved_queries_tree',
|
219
|
+
extraParams: {
|
220
|
+
database: database
|
197
221
|
}
|
198
222
|
});
|
199
223
|
queriesTreePanelStore.load();
|
@@ -203,7 +227,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin", {
|
|
203
227
|
}
|
204
228
|
|
205
229
|
},
|
206
|
-
failure:function () {
|
230
|
+
failure: function () {
|
207
231
|
self.clearWindowStatus();
|
208
232
|
Ext.Msg.alert('Status', 'Error deleting query');
|
209
233
|
}
|
@@ -212,17 +236,17 @@ Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin", {
|
|
212
236
|
});
|
213
237
|
},
|
214
238
|
|
215
|
-
displayAndExecuteQuery:function (queryName) {
|
239
|
+
displayAndExecuteQuery: function (queryName) {
|
216
240
|
this.setWindowStatus('Executing ' + queryName + '...');
|
217
241
|
var self = this;
|
218
242
|
var database = this.getDatabase();
|
219
243
|
Ext.Ajax.request({
|
220
|
-
url:'/rails_db_admin/erp_app/desktop/queries/open_and_execute_query/',
|
221
|
-
params:{
|
222
|
-
database:database,
|
223
|
-
query_name:queryName
|
244
|
+
url: '/rails_db_admin/erp_app/desktop/queries/open_and_execute_query/',
|
245
|
+
params: {
|
246
|
+
database: database,
|
247
|
+
query_name: queryName
|
224
248
|
},
|
225
|
-
success:function (responseObject) {
|
249
|
+
success: function (responseObject) {
|
226
250
|
var response = Ext.decode(responseObject.responseText);
|
227
251
|
var query = response.query;
|
228
252
|
|
@@ -235,17 +259,20 @@ Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin", {
|
|
235
259
|
var data = response.data;
|
236
260
|
|
237
261
|
var readOnlyDataGrid = Ext.create('Compass.ErpApp.Desktop.Applications.RailsDbAdmin.ReadOnlyTableDataGrid', {
|
238
|
-
region:'
|
239
|
-
columns:columns,
|
240
|
-
fields:fields,
|
241
|
-
data:data
|
262
|
+
region: 'south',
|
263
|
+
columns: columns,
|
264
|
+
fields: fields,
|
265
|
+
data: data,
|
266
|
+
collapseDirection: 'bottom',
|
267
|
+
height: '50%',
|
268
|
+
collapsible: true
|
242
269
|
});
|
243
270
|
|
244
|
-
|
245
|
-
module:self,
|
246
|
-
sqlQuery:query,
|
247
|
-
southRegion:readOnlyDataGrid,
|
248
|
-
closable:true
|
271
|
+
queryPanel = Ext.create('Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel', {
|
272
|
+
module: self,
|
273
|
+
sqlQuery: query,
|
274
|
+
southRegion: readOnlyDataGrid,
|
275
|
+
closable: true
|
249
276
|
});
|
250
277
|
|
251
278
|
self.container.add(queryPanel);
|
@@ -254,9 +281,9 @@ Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin", {
|
|
254
281
|
else {
|
255
282
|
Ext.Msg.alert('Error', response.exception);
|
256
283
|
queryPanel = Ext.create('Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel', {
|
257
|
-
module:self,
|
258
|
-
closable:true,
|
259
|
-
sqlQuery:query
|
284
|
+
module: self,
|
285
|
+
closable: true,
|
286
|
+
sqlQuery: query
|
260
287
|
});
|
261
288
|
|
262
289
|
self.container.add(queryPanel);
|
@@ -264,7 +291,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin", {
|
|
264
291
|
}
|
265
292
|
|
266
293
|
},
|
267
|
-
failure:function () {
|
294
|
+
failure: function () {
|
268
295
|
self.clearWindowStatus();
|
269
296
|
Ext.Msg.alert('Status', 'Error loading query');
|
270
297
|
}
|
@@ -273,44 +300,45 @@ Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin", {
|
|
273
300
|
|
274
301
|
//************ Reporting ************************************************
|
275
302
|
|
276
|
-
editReport
|
303
|
+
editReport: function (reportObj) {
|
277
304
|
var me = this;
|
278
305
|
|
279
306
|
me.container.add({
|
280
|
-
title:reportObj.title,
|
281
|
-
xtype:'railsdbadmin_reportpanel',
|
282
|
-
module:me,
|
283
|
-
query:reportObj.query,
|
284
|
-
reportId:reportObj.id,
|
285
|
-
template:reportObj.template,
|
286
|
-
internalIdentifier:reportObj.internalIdentifier,
|
287
|
-
closable:true
|
307
|
+
title: reportObj.title,
|
308
|
+
xtype: 'railsdbadmin_reportpanel',
|
309
|
+
module: me,
|
310
|
+
query: reportObj.query,
|
311
|
+
reportId: reportObj.id,
|
312
|
+
template: reportObj.template,
|
313
|
+
internalIdentifier: reportObj.internalIdentifier,
|
314
|
+
closable: true
|
288
315
|
});
|
289
316
|
me.container.setActiveTab(me.container.items.length - 1);
|
290
317
|
},
|
291
318
|
|
292
319
|
//***********************************************************************
|
293
320
|
|
294
|
-
init:function () {
|
321
|
+
init: function () {
|
295
322
|
this.launcher = {
|
296
|
-
text:'
|
297
|
-
iconCls:'icon-rails_db_admin',
|
298
|
-
handler:this.createWindow,
|
299
|
-
scope:this
|
323
|
+
text: 'Database Tools',
|
324
|
+
iconCls: 'icon-rails_db_admin',
|
325
|
+
handler: this.createWindow,
|
326
|
+
scope: this
|
327
|
+
|
300
328
|
};
|
301
329
|
},
|
302
330
|
|
303
|
-
displayQuery:function (queryName) {
|
331
|
+
displayQuery: function (queryName) {
|
304
332
|
this.setWindowStatus('Retrieving ' + queryName + '...');
|
305
333
|
var self = this;
|
306
334
|
var database = this.getDatabase();
|
307
335
|
Ext.Ajax.request({
|
308
|
-
url:'/rails_db_admin/erp_app/desktop/queries/open_query/',
|
309
|
-
params:{
|
310
|
-
database:database,
|
311
|
-
query_name:queryName
|
336
|
+
url: '/rails_db_admin/erp_app/desktop/queries/open_query/',
|
337
|
+
params: {
|
338
|
+
database: database,
|
339
|
+
query_name: queryName
|
312
340
|
},
|
313
|
-
success:function (responseObject) {
|
341
|
+
success: function (responseObject) {
|
314
342
|
var response = Ext.decode(responseObject.responseText);
|
315
343
|
var query = response.query;
|
316
344
|
|
@@ -320,9 +348,9 @@ Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin", {
|
|
320
348
|
self.clearWindowStatus();
|
321
349
|
|
322
350
|
queryPanel = Ext.create('Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel', {
|
323
|
-
module:self,
|
324
|
-
closable:true,
|
325
|
-
sqlQuery:query
|
351
|
+
module: self,
|
352
|
+
closable: true,
|
353
|
+
sqlQuery: query
|
326
354
|
});
|
327
355
|
|
328
356
|
self.container.add(queryPanel);
|
@@ -331,9 +359,9 @@ Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin", {
|
|
331
359
|
else {
|
332
360
|
Ext.Msg.alert('Error', response.exception);
|
333
361
|
queryPanel = Ext.create('Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel', {
|
334
|
-
module:self,
|
335
|
-
closable:true,
|
336
|
-
sqlQuery:query
|
362
|
+
module: self,
|
363
|
+
closable: true,
|
364
|
+
sqlQuery: query
|
337
365
|
});
|
338
366
|
|
339
367
|
self.container.add(queryPanel);
|
@@ -341,100 +369,133 @@ Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin", {
|
|
341
369
|
}
|
342
370
|
|
343
371
|
},
|
344
|
-
failure:function () {
|
372
|
+
failure: function () {
|
345
373
|
self.clearWindowStatus();
|
346
374
|
Ext.Msg.alert('Status', 'Error loading query');
|
347
375
|
}
|
348
376
|
});
|
349
377
|
},
|
350
378
|
|
351
|
-
|
379
|
+
|
380
|
+
openIframeInTab: function (title, url) {
|
381
|
+
var self = this;
|
382
|
+
|
383
|
+
var item = Ext.create('Ext.panel.Panel', {
|
384
|
+
iframeId: 'tutorials_iframe',
|
385
|
+
closable: true,
|
386
|
+
layout: 'fit',
|
387
|
+
title: title,
|
388
|
+
html: '<iframe id="themes_iframe" height="100%" width="100%" frameBorder="0" src="' + url + '"></iframe>'
|
389
|
+
});
|
390
|
+
|
391
|
+
self.container.add(item);
|
392
|
+
self.container.setActiveTab(item);
|
393
|
+
},
|
394
|
+
|
395
|
+
createWindow: function () {
|
396
|
+
|
352
397
|
var self = this;
|
353
398
|
var desktop = this.app.getDesktop();
|
354
399
|
var win = desktop.getWindow('rails_db_admin');
|
355
400
|
if (!win) {
|
356
401
|
this.container = Ext.create('Ext.tab.Panel', {
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
402
|
+
itemId: 'centerRegion',
|
403
|
+
region: 'center',
|
404
|
+
margins: '0 0 0 0',
|
405
|
+
border: false,
|
406
|
+
minsize: 300
|
361
407
|
});
|
362
408
|
|
363
409
|
this.accordion = Ext.create('Ext.panel.Panel', {
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
410
|
+
dockedItems: [
|
411
|
+
{
|
412
|
+
xtype: 'toolbar',
|
413
|
+
dock: 'top',
|
414
|
+
items: [
|
415
|
+
{
|
416
|
+
text: 'Database:'
|
417
|
+
},
|
418
|
+
{
|
419
|
+
xtype: 'railsdbadmin_databasecombo',
|
420
|
+
module: self
|
421
|
+
}
|
422
|
+
]
|
423
|
+
}
|
424
|
+
],
|
425
|
+
ui: 'rounded-panel',
|
426
|
+
region: 'west',
|
427
|
+
margins: '0 0 0 0',
|
428
|
+
cmargins: '0 0 0 0',
|
429
|
+
width: 300,
|
430
|
+
collapsible: true,
|
431
|
+
header: false,
|
432
|
+
split: true,
|
433
|
+
layout: 'accordion',
|
434
|
+
items: [
|
435
|
+
{
|
436
|
+
xtype: 'railsdbadmin_tablestreemenu',
|
437
|
+
module: this
|
438
|
+
},
|
439
|
+
{
|
440
|
+
xtype: 'railsdbadmin_queriestreemenu',
|
441
|
+
module: this
|
442
|
+
},
|
371
443
|
{
|
372
|
-
xtype:'
|
373
|
-
module:this
|
374
|
-
}, {
|
375
|
-
xtype:'railsdbadmin_queriestreemenu',
|
376
|
-
module:this
|
377
|
-
}, {
|
378
|
-
xtype:'railsdbadmin_reportstreepanel',
|
379
|
-
module:this
|
444
|
+
xtype: 'railsdbadmin_reportstreepanel',
|
445
|
+
module: this
|
380
446
|
}
|
381
447
|
]
|
382
448
|
});
|
383
449
|
|
384
450
|
win = desktop.createWindow({
|
385
|
-
id:'rails_db_admin',
|
386
|
-
title:'RailsDBAdmin',
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
iconCls:'icon-rails_db_admin',
|
391
|
-
shim:false,
|
392
|
-
animCollapse:false,
|
393
|
-
constrainHeader:true,
|
394
|
-
layout:'border',
|
395
|
-
|
396
|
-
items:[
|
397
|
-
{
|
398
|
-
text:'Database:'
|
399
|
-
},
|
400
|
-
{
|
401
|
-
xtype:'railsdbadmin_databasecombo',
|
402
|
-
module:self
|
403
|
-
}
|
404
|
-
]
|
405
|
-
},
|
406
|
-
items:[this.accordion, this.container]
|
451
|
+
id: 'rails_db_admin',
|
452
|
+
title: 'RailsDBAdmin',
|
453
|
+
width: 1200,
|
454
|
+
height: 550,
|
455
|
+
maximized: true,
|
456
|
+
iconCls: 'icon-rails_db_admin-light',
|
457
|
+
shim: false,
|
458
|
+
animCollapse: false,
|
459
|
+
constrainHeader: true,
|
460
|
+
layout: 'border',
|
461
|
+
items: [this.accordion, this.container]
|
407
462
|
});
|
408
463
|
|
409
|
-
|
464
|
+
win.addListener('render', function (win) {
|
465
|
+
win.down('#centerRegion').add({
|
466
|
+
xtype: 'railsdbadmin_splash_screen',
|
467
|
+
module: self,
|
468
|
+
closable: true
|
469
|
+
});
|
470
|
+
|
471
|
+
win.down('#centerRegion').setActiveTab(win.down('#centerRegion').items.length - 1);
|
472
|
+
});
|
410
473
|
}
|
411
474
|
win.show();
|
412
475
|
}
|
413
476
|
});
|
414
477
|
|
415
478
|
Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin.BooleanEditor", {
|
416
|
-
extend:"Ext.form.ComboBox",
|
417
|
-
alias:'widget.booleancolumneditor',
|
418
|
-
initComponent:function () {
|
419
|
-
|
420
|
-
fields:['display', 'value'],
|
421
|
-
data:[
|
479
|
+
extend: "Ext.form.ComboBox",
|
480
|
+
alias: 'widget.booleancolumneditor',
|
481
|
+
initComponent: function () {
|
482
|
+
this.store = Ext.create('Ext.data.ArrayStore', {
|
483
|
+
fields: ['display', 'value'],
|
484
|
+
data: [
|
422
485
|
['False', '0'],
|
423
486
|
['True', '1']
|
424
487
|
]
|
425
488
|
});
|
426
489
|
|
427
|
-
this.store = trueFalseStore;
|
428
|
-
|
429
490
|
this.callParent(arguments);
|
430
491
|
},
|
431
|
-
constructor:function (config) {
|
492
|
+
constructor: function (config) {
|
432
493
|
config = Ext.apply({
|
433
|
-
valueField:'value',
|
434
|
-
displayField:'display',
|
435
|
-
triggerAction:'all',
|
436
|
-
forceSelection:true,
|
437
|
-
mode:'local'
|
494
|
+
valueField: 'value',
|
495
|
+
displayField: 'display',
|
496
|
+
triggerAction: 'all',
|
497
|
+
forceSelection: true,
|
498
|
+
mode: 'local'
|
438
499
|
}, config);
|
439
500
|
|
440
501
|
this.callParent([config]);
|