db-gui 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +8 -2
- data/VERSION +1 -1
- data/app/db_gui/model/db.rb +49 -9
- data/app/db_gui/view/db_command_form.rb +24 -3
- data/app/db_gui/view/db_config_form.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 75e15d34f7435b0c8d0d66b67cc8138b7935c88dad827a9ed2cc3575e9a83b00
|
|
4
|
+
data.tar.gz: 7f19a38c51c2e91423e7c95d7aa631410208f3a9134e6e011c916b827949e6ba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef5768eb5582be26fb0d2c3089c33bc6d905982981978361713ec764134952d0a0abb246494a6a5c17fe1cd27cff176acb3a719e0e547b5e28e59e6b43e4f4aa
|
|
7
|
+
data.tar.gz: a77221ceb7131f2c0d14b28e1ec3465f740f9c678e0e9936579766019efd9abca519ba0132c609f1a2acbe116ddbc49270df5008c67c1a061335bfbe53d0a39a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
- Remember all DB commands in a history dropdown
|
|
6
|
+
- Remove currently selected DB command from DB command history dropdown
|
|
7
|
+
- Clear DB command history dropdown
|
|
8
|
+
|
|
3
9
|
## 0.3.0
|
|
4
10
|
|
|
5
11
|
- Support the ability to save/load multiple databases (DB configs)
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# DB GUI (Database Graphical User Interface) 0.
|
|
1
|
+
# DB GUI (Database Graphical User Interface) 0.4.0
|
|
2
2
|
## [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 /> Glimmer DSL for LibUI Application](https://github.com/AndyObtiva/glimmer-dsl-libui)
|
|
3
3
|
[](http://badge.fury.io/rb/db-gui)
|
|
4
4
|
|
|
@@ -8,11 +8,15 @@ It currently supports PostgreSQL as a start, with the potential of supporting ma
|
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
11
15
|
## Setup
|
|
12
16
|
|
|
13
17
|
Run:
|
|
14
18
|
```
|
|
15
|
-
gem install db-gui -v0.
|
|
19
|
+
gem install db-gui -v0.4.0
|
|
16
20
|
```
|
|
17
21
|
|
|
18
22
|
## Usage
|
|
@@ -26,6 +30,8 @@ Or, run one of the aliases: `db-ui` / `dbgui` / `db-gui`
|
|
|
26
30
|
|
|
27
31
|
Note that it stores the last connection details under `~/.db_gui`, and will auto-connect using that configuration on startup for extra convenience (in the future, there is the potential to support multiple connection configurations).
|
|
28
32
|
|
|
33
|
+
It remembers DB command history in a dropdown above the DB command text area.
|
|
34
|
+
|
|
29
35
|
### Menu Items
|
|
30
36
|
|
|
31
37
|
**Edit -> Copy Table**
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.4.0
|
data/app/db_gui/model/db.rb
CHANGED
|
@@ -10,17 +10,19 @@ class DbGui
|
|
|
10
10
|
REGEX_ROW_COUNT = /^\((\d+) row/
|
|
11
11
|
ERROR_PREFIX = 'ERROR:'
|
|
12
12
|
NEW_LINE = OS.windows? ? "\r\n" : "\n"
|
|
13
|
+
DB_COMMAND_TIMEOUT_DEFAULT = 300
|
|
13
14
|
|
|
14
15
|
attr_accessor :deleteable
|
|
15
16
|
alias deleteable? deleteable
|
|
16
17
|
attr_accessor :connected
|
|
17
18
|
alias connected? connected
|
|
18
19
|
attr_accessor :db_command_result
|
|
20
|
+
attr_accessor :db_commands
|
|
19
21
|
attr_accessor :db_command
|
|
20
22
|
attr_accessor :db_command_result_selection
|
|
21
23
|
|
|
22
24
|
def initialize
|
|
23
|
-
|
|
25
|
+
load_db_commands
|
|
24
26
|
reset
|
|
25
27
|
to_h.keys.each do |attribute|
|
|
26
28
|
Glimmer::DataBinding::Observer.proc do |value|
|
|
@@ -37,8 +39,17 @@ class DbGui
|
|
|
37
39
|
self.username = nil
|
|
38
40
|
self.password = nil
|
|
39
41
|
self.db_command_result = ''
|
|
40
|
-
self.db_command_timeout ||= ENV.fetch('DB_COMMAND_TIMEOUT_IN_MILLISECONDS',
|
|
42
|
+
self.db_command_timeout ||= ENV.fetch('DB_COMMAND_TIMEOUT_IN_MILLISECONDS', DB_COMMAND_TIMEOUT_DEFAULT).to_i
|
|
41
43
|
self.db_command_result_selection = 0
|
|
44
|
+
self.db_commands ||= ['']
|
|
45
|
+
self.db_command ||= ''
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def db_commands
|
|
49
|
+
if @db_commands == []
|
|
50
|
+
@db_commands = ['']
|
|
51
|
+
end
|
|
52
|
+
@db_commands
|
|
42
53
|
end
|
|
43
54
|
|
|
44
55
|
def new?
|
|
@@ -98,8 +109,23 @@ class DbGui
|
|
|
98
109
|
end
|
|
99
110
|
|
|
100
111
|
def run_db_command
|
|
112
|
+
reset_db_command_timeout
|
|
101
113
|
run_io_command(db_command)
|
|
102
|
-
|
|
114
|
+
save_db_commands
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def clear_db_commands
|
|
118
|
+
self.db_commands = ['']
|
|
119
|
+
self.db_command = ''
|
|
120
|
+
save_db_commands(add_current: false)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def remove_db_command
|
|
124
|
+
current_db_command = db_command
|
|
125
|
+
self.db_commands = self.db_commands - [current_db_command.to_s.strip]
|
|
126
|
+
self.db_command = ''
|
|
127
|
+
self.db_command = self.db_commands.last || ''
|
|
128
|
+
save_db_commands(add_current: false)
|
|
103
129
|
end
|
|
104
130
|
|
|
105
131
|
def db_command_result_count
|
|
@@ -182,16 +208,30 @@ class DbGui
|
|
|
182
208
|
@line = nil
|
|
183
209
|
end
|
|
184
210
|
|
|
185
|
-
def
|
|
186
|
-
|
|
187
|
-
|
|
211
|
+
def reset_db_command_timeout
|
|
212
|
+
self.db_command_timeout = DB_COMMAND_TIMEOUT_DEFAULT
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def save_db_commands(add_current: true)
|
|
216
|
+
return if db_command_result_error?
|
|
217
|
+
new_command = db_command.to_s.strip
|
|
218
|
+
self.db_commands ||= []
|
|
219
|
+
db_command_exists_in_db_commands = db_commands.find { |command| new_command == command.to_s.strip }
|
|
220
|
+
if add_current && !db_command_exists_in_db_commands
|
|
221
|
+
new_db_commands = db_commands + [new_command]
|
|
222
|
+
self.db_commands = new_db_commands.reject { |command| command.to_s.strip.empty? }
|
|
223
|
+
end
|
|
224
|
+
self.db_command = ''
|
|
225
|
+
self.db_command = new_command
|
|
226
|
+
db_commands_file_content = YAML.dump(db_command:, db_commands:)
|
|
188
227
|
File.write(FILE_DB_COMMANDS, db_commands_file_content)
|
|
189
228
|
end
|
|
190
229
|
|
|
191
|
-
def
|
|
230
|
+
def load_db_commands
|
|
192
231
|
db_commands_file_content = File.read(FILE_DB_COMMANDS)
|
|
193
|
-
|
|
194
|
-
self.
|
|
232
|
+
db_commands_config = YAML.load(db_commands_file_content)
|
|
233
|
+
self.db_commands = db_commands_config[:db_commands]
|
|
234
|
+
self.db_command = db_commands_config[:db_command]
|
|
195
235
|
rescue => e
|
|
196
236
|
puts "No database commands stored yet. #{e.message}"
|
|
197
237
|
end
|
|
@@ -11,19 +11,40 @@ class DbGui
|
|
|
11
11
|
|
|
12
12
|
body {
|
|
13
13
|
vertical_box {
|
|
14
|
+
horizontal_box {
|
|
15
|
+
stretchy false
|
|
16
|
+
combobox {
|
|
17
|
+
items <= [db_presenter, 'selected_db.db_commands']
|
|
18
|
+
selected_item <=> [db_presenter, 'selected_db.db_command']
|
|
19
|
+
enabled <= [db_presenter, 'selected_db.db_commands', on_read: -> (value) { value != [''] }]
|
|
20
|
+
}
|
|
21
|
+
button('Remove') {
|
|
22
|
+
stretchy false
|
|
23
|
+
on_clicked do
|
|
24
|
+
db_presenter.selected_db.remove_db_command
|
|
25
|
+
end
|
|
26
|
+
}
|
|
27
|
+
button('Clear') {
|
|
28
|
+
stretchy false
|
|
29
|
+
on_clicked do
|
|
30
|
+
db_presenter.selected_db.clear_db_commands
|
|
31
|
+
end
|
|
32
|
+
}
|
|
33
|
+
}
|
|
14
34
|
non_wrapping_multiline_entry {
|
|
15
35
|
text <=> [db_presenter, 'selected_db.db_command']
|
|
16
36
|
}
|
|
17
|
-
|
|
18
37
|
horizontal_box {
|
|
19
38
|
stretchy false
|
|
20
39
|
|
|
21
40
|
button('Run') {
|
|
41
|
+
enabled <= [db_presenter, 'selected_db.db_command', on_read: -> (command) { !command.to_s.strip.empty? }]
|
|
42
|
+
|
|
22
43
|
on_clicked do
|
|
23
44
|
db_presenter.selected_db.run_db_command
|
|
24
45
|
end
|
|
25
46
|
}
|
|
26
|
-
|
|
47
|
+
|
|
27
48
|
label('Timeout (msec): ') {
|
|
28
49
|
stretchy false
|
|
29
50
|
}
|
|
@@ -32,7 +53,7 @@ class DbGui
|
|
|
32
53
|
value <=> [db_presenter, 'selected_db.db_command_timeout', on_read: :to_i]
|
|
33
54
|
}
|
|
34
55
|
|
|
35
|
-
label('
|
|
56
|
+
label('Rows: ') {
|
|
36
57
|
stretchy false
|
|
37
58
|
}
|
|
38
59
|
label {
|