db-gui 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c47f16e87bb120e67c9ded08af1613226f997239310973d9c35f2cde6b7620ae
4
- data.tar.gz: ea3c1ae5858376c27dd9817cedc213bf0fd16eb696e9a817e0efeb0af84a7ef7
3
+ metadata.gz: fa4ce5de9be304c9f5638048111e9571854f2dfc66feecfd0e37f8ba4261ae82
4
+ data.tar.gz: 5806bf4a1514e28cee22c5ea2b5716f8c1e0fa0ffec32ca0072f62daef06cc1a
5
5
  SHA512:
6
- metadata.gz: 1f3ea785cfa0e94155628a7df1b278bd3b86840e50f009fa26401910958f6de524b1ebdd9713eada1ba9b6e4047fa9e529d06b2da1563576935491236e5aee31
7
- data.tar.gz: c5bda179f9fef7c91bc82532ace7ca4b1ce17fd0bb426fb3ab37cd19cf296f6e98f8b57c6391e713c0092ae040bd2432976766a174e27c0895894005fe7489ef
6
+ metadata.gz: 4d1b50280d1e23630beb85e7c6fae71716b51b8024cce27f38b2ea1c2cf137cd5d1fa619cadf07fc76ec465faabe587abece721ec0643cee84450c21a53cc4f2
7
+ data.tar.gz: a70bb46bf0016aec98b5bea7cb702161987aefa79914e4eafd4f89978536943e3c530bc22a548a6625ebd3c16639f9cbbea0f5d8037b2c286cf7d7cdd407f4ba
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.2
4
+
5
+ - Support displaying DB command results in a table instead of a non_wrapping_multiline_entry
6
+ - Ensure connecting to DB disables DB configuration fields
7
+ - Make DB command timeout configurable via Timeout field (in milliseconds)
8
+ - Make DB command timeout configurable via ENV var DB_COMMAND_TIMEOUT_IN_MILLISECONDS (default is 300 milliseconds)
9
+
3
10
  ## 0.0.1
4
11
 
5
12
  - DB GUI for PostgreSQL database with support for running SQL queries and seeing their result as text
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # DB GUI (Database Graphical User Interface) 0.0.1
1
+ # DB GUI (Database Graphical User Interface) 0.0.2
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
- [![Gem Version](https://badge.fury.io/rb/glimmer_snake.svg)](http://badge.fury.io/rb/glimmer_snake)
3
+ [![Gem Version](https://badge.fury.io/rb/db-gui.svg)](http://badge.fury.io/rb/db-gui)
4
4
 
5
5
 
6
6
  This is a database graphical user interface that enables interaction with relational SQL database data.
@@ -13,7 +13,7 @@ It currently supports PostgreSQL as a start, with the potential of supporting ma
13
13
 
14
14
  Run:
15
15
  ```
16
- gem install db-gui -v0.0.1
16
+ gem install db-gui -v0.0.2
17
17
  ```
18
18
 
19
19
  ## Usage
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -10,10 +10,12 @@ class DbGui
10
10
  alias connected? connected
11
11
  attr_accessor :db_command_result
12
12
  attr_accessor :db_command
13
+ attr_accessor :db_command_timeout
13
14
 
14
15
  def initialize
15
16
  self.port = 5432 # PostgreSQL default port
16
17
  self.db_command_result = ''
18
+ self.db_command_timeout = (ENV['DB_COMMAND_TIMEOUT_IN_MILLISECONDS'] || 300).to_i
17
19
  load_db_config
18
20
  connect if to_a.none? {|value| value.nil? || (value.respond_to?(:empty?) && value.empty?) }
19
21
  end
@@ -86,7 +88,7 @@ class DbGui
86
88
 
87
89
  def io_gets
88
90
  # TODO figure out a way of knowing the end of input without timing out
89
- Timeout.timeout(3) { io.gets }
91
+ Timeout.timeout(db_command_timeout/1000.0) { io.gets }
90
92
  rescue
91
93
  @io = nil
92
94
  nil
@@ -13,12 +13,22 @@ class DbGui
13
13
  text <=> [db_config, :db_command]
14
14
  }
15
15
 
16
- button('Run') {
16
+ horizontal_box {
17
17
  stretchy false
18
-
19
- on_clicked do
20
- db_config.run_db_command
21
- end
18
+
19
+ button('Run') {
20
+ on_clicked do
21
+ db_config.run_db_command
22
+ end
23
+ }
24
+
25
+ label('Timeout (msec): ') {
26
+ stretchy false
27
+ }
28
+ spinbox(0, 60000) {
29
+ stretchy false
30
+ value <=> [db_config, :db_command_timeout]
31
+ }
22
32
  }
23
33
  }
24
34
  }
@@ -0,0 +1,40 @@
1
+ require 'db_gui/model/db_config'
2
+
3
+ class DbGui
4
+ module View
5
+ class DbCommandResultTable
6
+ include Glimmer::LibUI::CustomControl
7
+
8
+ option :db_config
9
+
10
+ body {
11
+ vertical_box {
12
+ content(db_config, :db_command_result) {
13
+ db_command_result_lines = db_config.db_command_result.lines
14
+ db_command_result_lines.pop if db_command_result_lines.last == "\n"
15
+ if db_command_result_lines.any?
16
+ headers = db_command_result_lines.first.split('|').map(&:strip)
17
+ count_footer = db_command_result_lines.last
18
+ count_footer_match = count_footer.match(/^\((\d+) row/)
19
+ if count_footer_match
20
+ rows = db_command_result_lines[2..-2].map {|row| row.split('|').map(&:strip) }
21
+ table {
22
+ headers.each do |header|
23
+ text_column(header)
24
+ end
25
+
26
+ cell_rows rows
27
+ }
28
+ else
29
+ label('No data')
30
+ end
31
+ else
32
+ label('No data')
33
+ end
34
+ }
35
+ }
36
+ }
37
+ end
38
+ end
39
+ end
40
+
@@ -13,26 +13,31 @@ class DbGui
13
13
  entry {
14
14
  label 'Host:'
15
15
  text <=> [db_config, :host]
16
+ enabled <= [db_config, :connected, on_read: :!]
16
17
  }
17
18
 
18
19
  spinbox(0, 1_000_000) {
19
20
  label 'Port:'
20
21
  value <=> [db_config, :port]
22
+ enabled <= [db_config, :connected, on_read: :!]
21
23
  }
22
24
 
23
25
  entry {
24
26
  label 'Database Name:'
25
27
  text <=> [db_config, :dbname]
28
+ enabled <= [db_config, :connected, on_read: :!]
26
29
  }
27
30
 
28
31
  entry {
29
32
  label 'Username:'
30
33
  text <=> [db_config, :username]
34
+ enabled <= [db_config, :connected, on_read: :!]
31
35
  }
32
36
 
33
37
  password_entry {
34
38
  label 'Password:'
35
39
  text <=> [db_config, :password]
40
+ enabled <= [db_config, :connected, on_read: :!]
36
41
  }
37
42
  }
38
43
 
@@ -2,6 +2,7 @@ require 'db_gui/presenter/db_gui_presenter'
2
2
 
3
3
  require 'db_gui/view/db_config_form'
4
4
  require 'db_gui/view/db_command_form'
5
+ require 'db_gui/view/db_command_result_table'
5
6
 
6
7
  class DbGui
7
8
  module View
@@ -29,9 +30,7 @@ class DbGui
29
30
 
30
31
  db_command_form(db_config: presenter.db_config)
31
32
 
32
- non_wrapping_multiline_entry {
33
- text <=> [presenter.db_config, :db_command_result, on_write: ->(value) {presenter.db_config.db_command_result}]
34
- }
33
+ db_command_result_table(db_config: presenter.db_config)
35
34
  }
36
35
  }
37
36
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db-gui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
@@ -66,7 +66,8 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: Db Gui
69
+ description: DB GUI (Database Graphical User Interface) - Enables Interaction with
70
+ Relational SQL Databases
70
71
  email: andy.am@gmail.com
71
72
  executables:
72
73
  - db-gui
@@ -88,6 +89,7 @@ files:
88
89
  - app/db_gui/model/db_config.rb
89
90
  - app/db_gui/presenter/db_gui_presenter.rb
90
91
  - app/db_gui/view/db_command_form.rb
92
+ - app/db_gui/view/db_command_result_table.rb
91
93
  - app/db_gui/view/db_config_form.rb
92
94
  - app/db_gui/view/db_gui_application.rb
93
95
  - bin/db-gui
@@ -120,5 +122,5 @@ requirements: []
120
122
  rubygems_version: 3.4.10
121
123
  signing_key:
122
124
  specification_version: 4
123
- summary: Db Gui
125
+ summary: DB GUI
124
126
  test_files: []