db_admin 0.1.0 → 0.1.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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -14
  3. data/lib/db_admin.rb +4 -0
  4. data/lib/views/_table.erb +19 -8
  5. metadata +14 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97e0c34215973f91a6e3526db876d8f66fc780acfd00aaac943b761d1b3616ff
4
- data.tar.gz: 1a274611cf882bc84beb574e800a2e1f57d896c6392adba22389290a38c0541e
3
+ metadata.gz: f6088beb0959e56e8da0a7da89afc2777b51787c858fa3dfbbc1cb28000c2863
4
+ data.tar.gz: ed3c59335703f4c9f73791729f78036336a4bceec777293a5cfd1ffde5adc4ea
5
5
  SHA512:
6
- metadata.gz: 16fa22a4045863a22bf00ebfbc6bbee13a7073c7dc1cad96bb7f009972e64431bd83a1eb42e6f6cd4832cb7dc00df15bbf7b8a4ec5bfc79fe664be4c465917cf
7
- data.tar.gz: de5d6460a10df571c2a75db5bdc059f3cf8098e1b3267cdb2cee3c40f9a3092b214a253491f491ae82d651cc15e3c52994ac6e7c0152696b5482ef21a9ee41f3
6
+ metadata.gz: 0d52e3976234eb2944119fc22c75a16dc611e811eacd66c0bceb0cd9bdec5b6b7310f2396614e490fc6bc6d39ad079bb15159a2eafb4363abfc8fcab32b15f64
7
+ data.tar.gz: 0a031caf04fe329413fed852de84aa9be4ee27fb748a15c8b0bfc817c4336dfc508192f94fd436507cb853951236fd7661d0038989389a6b163d5b3bca3058cc
data/README.md CHANGED
@@ -1,33 +1,47 @@
1
1
  ## Ruby Database Admin
2
- A Sequel and Sinatra project.
2
+ A gem based on [Sinatra](https://github.com/sinatra/sinatra) and [Sequel](https://github.com/jeremyevans/sequel).
3
3
 
4
4
  You can use it to manage multiple databases at the same time.
5
5
 
6
- Here are some Demo pictures.
6
+ Rails user can also use it because it is just a gem. Here are some demo pictures.
7
7
 
8
- ![Demo home](./public/demo_home.png)
8
+ ![Demo home](./lib/public/demo_home.png)
9
9
 
10
- ![Demo operations](./public/demo_oprations.png)
10
+ ![Demo operations](./lib/public/demo_oprations.png)
11
11
 
12
- ![Demo hover](./public/demo_hover.png)
12
+ ![Demo hover](./lib/public/demo_hover.png)
13
13
 
14
14
  ## Installation
15
15
  ~~~bash
16
16
  $ gem install db_admin
17
17
  ~~~
18
- Or add `gem 'db_admin'` to `Gemfile` and run `$ bundle install`.
19
-
20
- Make sure you have installed database driver gem. E.g: in `Gemfile`
18
+ Or add `gem 'db_admin'` to `Gemfile`, then `$ bundle install`.
21
19
  ~~~ruby
22
- gem 'sqlite3' # SQLite
23
- gem 'pg' # PostgreSQL
24
- gem 'mysql2' # MySQL
20
+ group :development do
21
+ # A Web UI for database admin. Run `$ db_admin` and then
22
+ # visit http://localhost:4567
23
+ gem 'db_admin'
24
+ end
25
25
  ~~~
26
26
 
27
+ Make sure you have installed database driver gem.
28
+
29
+ E.g: `gem install pg`, `gem install sqlite3` or `gem install mysql2`, etc.
30
+
27
31
  ~~~bash
28
- $ db_admin # Run this command will start a sinatra Web.
32
+ $ db_admin # Run this command to start a Sinatra Web.
29
33
  ~~~
30
34
  Visit [http://localhost:4567](http://localhost:4567/)
31
35
 
32
- ## Contributing
33
- Improving ruby-db-admin, please clone and pull requests! We love you do it.
36
+ ## Customizing
37
+ If you want to change some code for your own purpose, please
38
+ ~~~bash
39
+ $ git clone git@github.com:gazeldx/db_admin.git
40
+ $ ruby db_admin/lib/db_admin.rb # Then visit http://localhost:4567
41
+ ~~~
42
+
43
+ ### Debugging
44
+ Uncomment the below line in `db_admin/lib/db_admin.rb` to auto-reload changed files.
45
+ ~~~ruby
46
+ require 'sinatra/reloader' if development? # `gem install sinatra-reloader` first.
47
+ ~~~
data/lib/db_admin.rb CHANGED
@@ -3,6 +3,10 @@ require 'sequel'
3
3
  require 'json'
4
4
 
5
5
  class RubyDatabaseAdmin < Sinatra::Base
6
+ # require 'sinatra/reloader' if development? # `gem install sinatra-reloader` first if you want to debug this project by auto-reloading changed files.
7
+
8
+ use Rack::MethodOverride
9
+
6
10
  DBs = []
7
11
  DB = nil
8
12
 
data/lib/views/_table.erb CHANGED
@@ -12,11 +12,12 @@
12
12
 
13
13
  <tbody>
14
14
  <% @dataset.each_with_index do |row, row_num| %>
15
- <tr id='tr<%= row_num %>' onmouseover='show_delete_button.call(this)' onmouseout='hide_delete_button.call(this)'>
15
+ <tr id='tr<%= row_num %>' onmouseover='show_operate_buttons.call(this)' onmouseout='hide_operate_buttons.call(this)'>
16
16
  <% @dataset.columns.each_with_index do |column, column_num| %>
17
17
  <% if column_num == 0 && row[:id] %>
18
- <td width='40px' id='<%= row[:id] %>'>
18
+ <td width='50px' id='<%= row[:id] %>'>
19
19
  <a href='#_' onclick='delete_this_row.call(this)' style='display: none' title='Delete this row' data-url=<%= "/tables/#{params[:table_name]}/delete_one/#{row[:id]}" %>>Del</a>
20
+ <a href='#_' onclick='edit_this_row.call(this)' style='display: none' title='Edit this row'>Edit</a>
20
21
  </td>
21
22
  <% end %>
22
23
 
@@ -37,12 +38,22 @@
37
38
 
38
39
  <script>
39
40
  $('.table').on('dblclick', 'span', function() {
40
- $(this).closest('td').find('span').hide();
41
- $(this).closest('td').find(':text').show();
42
- $(this).closest('td').find(':text').select();
43
- $(this).closest('td').find('a').show();
41
+ show_column_editer($(this).closest('td'));
44
42
  });
45
43
 
44
+ function edit_this_row() {
45
+ $(this).closest('tr').find('td').each(function () {
46
+ show_column_editer($(this));
47
+ });
48
+ }
49
+
50
+ function show_column_editer(td) {
51
+ td.find('span').hide();
52
+ td.find(':text').show();
53
+ td.find(':text').select();
54
+ td.find('a').show();
55
+ }
56
+
46
57
  function save_this_data() {
47
58
  $.ajax({
48
59
  url: $(this).attr('data-url'),
@@ -74,11 +85,11 @@
74
85
  });
75
86
  }
76
87
 
77
- function show_delete_button() {
88
+ function show_operate_buttons() {
78
89
  $(this).find('td:first a').show();
79
90
  }
80
91
 
81
- function hide_delete_button() {
92
+ function hide_operate_buttons() {
82
93
  $(this).find('td:first a').hide();
83
94
  }
84
95
 
metadata CHANGED
@@ -1,47 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lane Zhang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-29 00:00:00.000000000 Z
11
+ date: 2019-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sequel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '5.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
41
- description: 'A Web to manage databases. Support PostgerSQL, MySQL, SQLite, Oracle,
42
- MS-SQL, SQLAnywhere, DB2, Access, etc.
43
-
44
- '
40
+ version: '5.0'
41
+ description: A Web UI to manage databases. Support PostgreSQL, MySQL, SQLite, Oracle,
42
+ MS-SQL, etc.
45
43
  email: zjloveztt@gmail.com
46
44
  executables:
47
45
  - db_admin
@@ -70,7 +68,7 @@ files:
70
68
  - lib/views/layout_index.erb
71
69
  - lib/views/select_sql.erb
72
70
  - lib/views/table.erb
73
- homepage: https://github.com/gazeldx/ruby-db-admin
71
+ homepage: https://github.com/gazeldx/db_admin
74
72
  licenses:
75
73
  - MIT
76
74
  metadata: {}
@@ -92,5 +90,5 @@ requirements: []
92
90
  rubygems_version: 3.0.1
93
91
  signing_key:
94
92
  specification_version: 4
95
- summary: A Web for database admin!
93
+ summary: A Web UI for database admin!
96
94
  test_files: []