rails_db 0.9 → 0.9.9

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
  SHA1:
3
- metadata.gz: d99c898bfd1dfb091a63643e4340379cae66340d
4
- data.tar.gz: face242fcca9d97b3a6a771cea8cba9e9f0c1c61
3
+ metadata.gz: ee0ce0d6e3a70aa6c991f4dc375d28d219cb452a
4
+ data.tar.gz: 3fb59fa306290006d2e462abd6d88f0d10c3909c
5
5
  SHA512:
6
- metadata.gz: ff10955cb11ef2746442969ff36b008a90aa4b8399e715a5d162fc52068e9edc10f69fc34184335acd60f3c477617798fcc875ab78c60bfc75705d565f7b66d7
7
- data.tar.gz: 830e38745d4512024b766dca431fbcfd72b6813e5f11708a337381a0baab339558a07ef9d3f633846a5fe7ec269dcce89fe0d5b24e0002cf6da61c8ed177d6f1
6
+ metadata.gz: 90db375ee0998789dbc68d35c20518f63861d432cc7f93f646040e9f9b65fb3df386642f5a1e19a0fc4b5327d36304df3f87bb1a331515e589cd30941177d221
7
+ data.tar.gz: 5f5676c71b5c9b4439bd36b9e4edb5174348e1402c2bfc912cfc770113f662705bfa3510404e4c6a096ca068555ce5da966cfe931d492ac858e3a4196412d455
data/Gemfile CHANGED
@@ -10,6 +10,8 @@ gem 'codemirror-rails'
10
10
  gem 'terminal-table'
11
11
  gem 'axlsx_rails'
12
12
  gem 'simple_form'
13
+ gem 'ransack'
14
+ gem 'kaminari'
13
15
 
14
16
  group :assets do
15
17
  gem 'sass-rails'
data/Gemfile.lock CHANGED
@@ -1,13 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_db (0.9)
4
+ rails_db (0.9.9)
5
5
  axlsx_rails
6
6
  codemirror-rails
7
7
  font-awesome-rails
8
8
  jquery-rails
9
+ kaminari
9
10
  launchy
10
11
  rails (>= 3.1.0)
12
+ ransack
11
13
  sass
12
14
  sass-rails
13
15
  simple_form
@@ -76,6 +78,9 @@ GEM
76
78
  railties (>= 4.2.0)
77
79
  thor (>= 0.14, < 2.0)
78
80
  json (1.8.3)
81
+ kaminari (0.16.3)
82
+ actionpack (>= 3.0.0)
83
+ activesupport (>= 3.0.0)
79
84
  launchy (2.4.3)
80
85
  addressable (~> 2.3)
81
86
  loofah (2.0.3)
@@ -89,6 +94,8 @@ GEM
89
94
  nokogiri (1.6.6.2)
90
95
  mini_portile (~> 0.6.0)
91
96
  pg (0.18.3)
97
+ polyamorous (1.2.0)
98
+ activerecord (>= 3.0)
92
99
  rack (1.6.4)
93
100
  rack-test (0.6.3)
94
101
  rack (>= 1.0)
@@ -117,6 +124,12 @@ GEM
117
124
  rake (>= 0.8.7)
118
125
  thor (>= 0.18.1, < 2.0)
119
126
  rake (10.4.2)
127
+ ransack (1.7.0)
128
+ actionpack (>= 3.0)
129
+ activerecord (>= 3.0)
130
+ activesupport (>= 3.0)
131
+ i18n
132
+ polyamorous (~> 1.2)
120
133
  rubyzip (1.0.0)
121
134
  sass (3.4.19)
122
135
  sass-rails (5.0.4)
@@ -153,10 +166,12 @@ DEPENDENCIES
153
166
  codemirror-rails
154
167
  font-awesome-rails
155
168
  jquery-rails
169
+ kaminari
156
170
  mysql2 (<= 0.3.20)
157
171
  pg
158
172
  rails
159
173
  rails_db!
174
+ ransack
160
175
  sass
161
176
  sass-rails
162
177
  simple_form
@@ -24,6 +24,7 @@
24
24
  //= require codemirror/addons/hint/show-hint.js
25
25
  //= require codemirror/addons/hint/sql-hint.js
26
26
  //= require rails_db/show_hide_columns.js
27
+ //= require rails_db/search.js
27
28
 
28
29
  $(function(){
29
30
  $(document).foundation();
@@ -93,3 +94,18 @@ function init_sql_editor(mime, tables) {
93
94
  editor.setSize('100%', '300');
94
95
  editor.focus();
95
96
  };
97
+
98
+ function set_browser_url(url) {
99
+ if (typeof (history.pushState) != "undefined") {
100
+ window.history.pushState({"path": url}, '', url);
101
+ }
102
+ }
103
+
104
+ $(window).bind('popstate', function(event) {
105
+ if (typeof (history.pushState) != "undefined") {
106
+ var state = event.originalEvent.state;
107
+ if (state) {
108
+ window.location = state.path;
109
+ }
110
+ }
111
+ });
@@ -0,0 +1,19 @@
1
+ $(function() {
2
+ $('body').on('click', '.remove_fields', function(event) {
3
+ $(this).closest('.field').remove();
4
+ return event.preventDefault();
5
+ });
6
+
7
+ $('body').on('click', '.add_fields', function(event) {
8
+ var regexp, time;
9
+ time = new Date().getTime();
10
+ regexp = new RegExp($(this).data('id'), 'g');
11
+ $(this).before($(this).data('fields').replace(regexp, time));
12
+ return event.preventDefault();
13
+ });
14
+
15
+ $('body').on('click', '.search-link', function(event) {
16
+ $("#search_form").toggle();
17
+ return false;
18
+ });
19
+ });
@@ -1,7 +1,7 @@
1
1
  $(function(){
2
-
3
2
  $('body').on('click', '.settings-link', function() {
4
3
  $('.rails-db-settings').toggle();
4
+ return false;
5
5
  });
6
6
 
7
7
  $('body').on('click', '.column-name input', function() {
@@ -24,12 +24,14 @@ table {
24
24
  background-position: right center;
25
25
  }
26
26
 
27
- th .asc {
28
- background-image: asset-url('rails_db/up_arrow.gif');
29
- }
30
-
31
- th .desc {
32
- background-image: asset-url('rails_db/down_arrow.gif');
27
+ &.custom_sorting {
28
+ th .asc {
29
+ background-image: asset-url('rails_db/up_arrow.gif');
30
+ }
31
+
32
+ th .desc {
33
+ background-image: asset-url('rails_db/down_arrow.gif');
34
+ }
33
35
  }
34
36
 
35
37
  th, td {
@@ -96,3 +98,7 @@ table {
96
98
  padding-top: 8px;
97
99
  padding-left: 26px;
98
100
  }
101
+
102
+ .panel.no_bottom_padding {
103
+ padding-bottom: 0;
104
+ }
@@ -10,6 +10,7 @@
10
10
  *= require rails_db/pagination
11
11
  *= require rails_db/table
12
12
  *= require rails_db/forms
13
+ *= require rails_db/search
13
14
  *= require font-awesome
14
15
  */
15
16
 
@@ -0,0 +1,15 @@
1
+ #search_form {
2
+ select, input, button {
3
+ width: auto;
4
+ display: inline-block;
5
+ }
6
+ .sorting_options {
7
+ select {
8
+ margin-right: 5px;
9
+ }
10
+ }
11
+ }
12
+
13
+ #search_records {
14
+
15
+ }
@@ -1,6 +1,7 @@
1
1
  module RailsDb
2
2
  class ApplicationController < ActionController::Base
3
3
  helper :all
4
+ helper_method :per_page
4
5
 
5
6
  if Rails::VERSION::MAJOR >= 4
6
7
  before_action :verify_access
@@ -20,6 +21,10 @@ module RailsDb
20
21
  redirect_to('/', error: 'Access Denied', status: 401) unless result
21
22
  end
22
23
 
24
+ def per_page
25
+ params[:per_page] || session[:per_page]
26
+ end
27
+
23
28
  end
24
29
  end
25
30
 
@@ -1,7 +1,7 @@
1
1
  module RailsDb
2
2
  class TablesController < RailsDb::ApplicationController
3
3
  if Rails::VERSION::MAJOR >= 4
4
- before_action :find_table, only: [:show, :data, :csv, :truncate, :destroy, :edit, :update, :xlsx]
4
+ before_action :find_table, only: [:show, :data, :csv, :truncate, :destroy, :edit, :update, :xlsx, :search]
5
5
  else
6
6
  before_filter :find_table
7
7
  end
@@ -15,10 +15,16 @@ module RailsDb
15
15
 
16
16
  def data
17
17
  session[:per_page] = per_page
18
- @table = @table.paginate page: params[:page],
19
- sort_column: params[:sort_column],
20
- sort_order: params[:sort_order],
21
- per_page: per_page
18
+ @model = @table.as_model
19
+ @q = @model.ransack(params[:q])
20
+ @sql = @q.result.page(params[:page]).per(per_page).to_sql
21
+ @records = @q.result.page(params[:page]).per(per_page)
22
+ @q.build_condition if @q.conditions.empty?
23
+ @q.build_sort if @q.sorts.empty?
24
+ respond_to do |page|
25
+ page.html {}
26
+ page.js {}
27
+ end
22
28
  end
23
29
 
24
30
  def csv
@@ -35,10 +41,12 @@ module RailsDb
35
41
  end
36
42
 
37
43
  def destroy
38
- @table = @table.paginate page: params[:page],
39
- sort_column: params[:sort_column],
40
- sort_order: params[:sort_order],
41
- per_page: per_page
44
+ @model = @table.as_model
45
+ @q = @model.ransack(params[:q])
46
+ @sql = @q.result.page(params[:page]).per(per_page).to_sql
47
+ @records = @q.result.page(params[:page]).per(per_page)
48
+ @q.build_condition if @q.conditions.empty?
49
+ @q.build_sort if @q.sorts.empty?
42
50
  @table.delete(params[:pk_id])
43
51
  respond_to do |page|
44
52
  page.html { redirect_to action: :data, table_id: params[:table_id] }
@@ -77,9 +85,5 @@ module RailsDb
77
85
  @table ||= RailsDb::Table.new(params[:id] || params[:table_id])
78
86
  end
79
87
 
80
- def per_page
81
- params[:per_page] || session[:per_page]
82
- end
83
-
84
88
  end
85
89
  end
@@ -6,11 +6,20 @@ module RailsDb
6
6
  RailsDb::Database.accessible_tables
7
7
  end
8
8
 
9
+ def link_to_add_fields(name, f, type)
10
+ new_object = f.object.send "build_#{type}"
11
+ id = "new_#{type}"
12
+ fields = f.send("#{type}_fields", new_object, child_index: id) do |builder|
13
+ render(type.to_s + "_fields", f: builder)
14
+ end
15
+ link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")})
16
+ end
17
+
9
18
  def sidebar_classes
10
19
  if show_sidebar?
11
- 'large-3 pull-9 columns'
20
+ 'large-3 large-pull-9 columns'
12
21
  else
13
- 'large-3 pull-9 columns hide'
22
+ 'large-3 large-pull-9 columns hide'
14
23
  end
15
24
  end
16
25
 
@@ -15,13 +15,6 @@ module RailsDb
15
15
  end
16
16
  end
17
17
 
18
- def sortable(column, title = nil)
19
- title = titleize_column(column, title)
20
- css_class = (column == params[:sort_column]) ? "current #{params[:sort_order]}" : nil
21
- sort_order = (column == params[:sort_column] && params[:sort_order] == 'asc') ? 'desc' : 'asc'
22
- link_to title, params.merge({ action: :data, sort_column: column, sort_order: sort_order }), {remote: true, class: css_class }
23
- end
24
-
25
18
  def titleize_column(column, title = nil)
26
19
  column
27
20
  end
@@ -34,8 +27,7 @@ module RailsDb
34
27
  table_destroy_path(table,
35
28
  pk_id: record[table.primary_key],
36
29
  page: params[:page],
37
- sort_column: params[:sort_column],
38
- sort_order: params[:sort_order])
30
+ q: params[:q])
39
31
  end
40
32
 
41
33
  def table_pagination_path
@@ -55,5 +47,9 @@ module RailsDb
55
47
  column_is_checked?(table_name, column_name) ? 'display' : 'display:none'
56
48
  end
57
49
 
50
+ def search_form_class
51
+ params[:q].present? ? '' : 'hide'
52
+ end
53
+
58
54
  end
59
55
  end
@@ -3,13 +3,14 @@
3
3
  <br/>
4
4
  <br/>
5
5
 
6
- <p>Welcome, in Rails DB you can :</p>
6
+ <p>Welcome, in Rails DB you can:</p>
7
7
 
8
8
  <ul>
9
9
  <li>use command line tools `railsdb` and `runsql` to run app and sql for your apps.</li>
10
10
  <li>view content and schema of DB tables (including indexes)</li>
11
11
  <li>edit content</li>
12
12
  <li>sort content of DB tables</li>
13
+ <li>filters support</li>
13
14
  <li>execute SQL queries</li>
14
15
  <li>enjoy autocomplete for your SQL queries</li>
15
16
  <li>filter tables for easier navigation</li>
@@ -5,7 +5,7 @@
5
5
  <ul class="side-nav tables" id='rails_db_tables'>
6
6
  <% rails_db_tables.each do |table| %>
7
7
  <li>
8
- <%= link_to table_data_path(table, sidebar: true), remote: true, class: "sidebar_table sidebar_table_#{table}" do %>
8
+ <%= link_to table_data_path(table), remote: true, class: "sidebar_table sidebar_table_#{table}" do %>
9
9
  <%= fa_icon 'table'%>
10
10
  <%= table %>
11
11
  <% end %>
@@ -0,0 +1,10 @@
1
+ <div class="field">
2
+ <%= f.attribute_fields do |a| %>
3
+ <%= a.attribute_select associations: [:category] %>
4
+ <% end %>
5
+ <%= f.predicate_select %>
6
+ <%= f.value_fields do |v| %>
7
+ <%= v.text_field :value %>
8
+ <% end %>
9
+ <%= link_to raw("#{fa_icon 'minus'} remove"), '#', class: "remove_fields" %>
10
+ </div>
@@ -18,21 +18,38 @@
18
18
  <a href="#" data-options="align: bottom" data-dropdown="drop"><%= fa_icon 'th-large' %> Functions</a>
19
19
  </dd>
20
20
  <dd class="right"><%= link_to raw("#{fa_icon('cogs')} Settings"), '#', :class => 'settings-link', :table_name => "#{@table.name}" %></dd>
21
+ <dd class="right"><%= link_to raw("#{fa_icon('search')} Search"), '#', :class => 'search-link' %></dd>
21
22
  </dl>
22
23
  <div class="clearfix"></div>
23
24
 
24
-
25
25
  <ul id="drop" class="f-dropdown" data-dropdown-content>
26
26
  <li><%= link_to raw("#{fa_icon('trash-o')} Truncate Table"), table_truncate_path(@table), data: {confirm: 'Are you sure?'} %></li>
27
27
  </ul>
28
28
 
29
29
  <ul id="download-files" class="f-dropdown" data-dropdown-content>
30
- <li><%= link_to raw("#{fa_icon('file-text-o')} Export to CSV"), table_csv_path(@table) %></li>
31
- <li><%= link_to raw("#{fa_icon('file-excel-o')} Export to Excel"), table_xlsx_path(@table, format: 'xls') %></li>
30
+ <li><%= link_to raw("#{fa_icon('file-text-o')} Export table to CSV"), table_csv_path(@table) %></li>
31
+ <li><%= link_to raw("#{fa_icon('file-excel-o')} Export table to Excel"), table_xlsx_path(@table, format: 'xls') %></li>
32
32
  </ul>
33
33
 
34
34
  <div class='scrollable'>
35
- <div class='rails-db-settings' style="display:none">
35
+ <%= search_form_for @q, url: table_data_path(@table), method: :get, remote: true, html: { id: 'search_form', class: search_form_class } do |f| %>
36
+ <div class='panel no_bottom_padding'>
37
+ <h6>Search</h6>
38
+ <%= f.condition_fields do |c| %>
39
+ <%= render "condition_fields", f: c %>
40
+ <% end %>
41
+ <p><%= link_to_add_fields raw("#{fa_icon 'plus'} Add Conditions"), f, :condition %></p>
42
+ <div class="field sorting_options">
43
+ Sort:
44
+ <%= f.sort_fields do |s| %>
45
+ <%= s.sort_select %>
46
+ <% end %>
47
+ </div>
48
+ <div class="actions"><%= f.submit "Search", class: 'button small' %></div>
49
+ </div>
50
+ <% end %>
51
+
52
+ <div class='rails-db-settings panel no_bottom_padding' style="display:none">
36
53
  <h6>Settings</h6>
37
54
  <% @table.columns.each do |column| %>
38
55
  <label class='column-name'>
@@ -40,47 +57,42 @@
40
57
  <%= column.name %>
41
58
  </label>
42
59
  <% end %>
60
+ <div class='clearfix'></div>
43
61
  </div>
44
62
 
45
- <table>
63
+ <table id="search_records" class='table'>
46
64
  <thead>
47
65
  <tr>
48
- <% if @table.primary_key.present? %>
49
- <th class='delete_td'></th>
50
- <th class='edit_td'></th>
66
+ <% if @table.primary_key %>
67
+ <th colspan="2">Actions</th>
51
68
  <% end %>
52
- <% @table.columns.each do |column| %>
53
- <th class="column_<%= column.name %>" style=<%= display_style_column(@table.name, column.name) %>>
54
- <%= sortable column.name %>
69
+ <% @model.column_names.each do |column| %>
70
+ <th class="column_<%= column %>" style="<%= display_style_column(@table.name, column)%>">
71
+ <%= sort_link(@q, column) %>
55
72
  </th>
56
73
  <% end %>
57
74
  </tr>
58
75
  </thead>
59
-
60
- <% n = 0 %>
61
-
62
76
  <tbody>
63
- <% @table.data.each do |record| %>
77
+ <% @records.each do |record| %>
64
78
  <tr class="row_<%= record[@table.primary_key] %>">
65
79
  <%= render 'row', record: record %>
66
80
  </tr>
67
81
  <% end %>
68
- <% n += 1 %>
69
- <% if @table.data.total_entries == 0 %>
70
- <tr>
71
- <% if @table.primary_key.present? %>
72
- <td></td>
73
- <% end %>
74
- <td>No Records</td>
75
- </tr>
82
+
83
+ <% if @records.none? %>
84
+ <td>No Records</td>
76
85
  <% end %>
77
86
  </tbody>
78
87
 
79
- <% if n > 10 %>
88
+ <% if @records.size > 10 %>
80
89
  <tfoot>
81
90
  <tr>
82
- <% @table.columns.each do |column| %>
83
- <th><%= sortable column.name %></th>
91
+ <% if @table.primary_key %>
92
+ <th colspan="2">Actions</th>
93
+ <% end %>
94
+ <% @model.column_names.each do |column| %>
95
+ <th> <%= sort_link(@q, column) %> </th>
84
96
  <% end %>
85
97
  </tr>
86
98
  </tfoot>
@@ -89,20 +101,19 @@
89
101
  </div>
90
102
 
91
103
  <p>
92
- <span class="radius success label">Total: <%= pluralize @table.data.total_entries, 'record' %></span>
93
- <span class="radius info label">Time: <%= @table.data.time %> seconds</span>
104
+ <span class="radius success label">Total: <%= pluralize @records.total_count, 'record' %></span>
94
105
  </p>
95
106
 
96
- <% if @table.data.total_entries > 0 %>
107
+ <% if @records.total_count > 10 %>
97
108
  <div class='left'>
98
109
  <%= form_tag table_pagination_path, method: :get, remote: true do %>
99
- <%= select_tag :per_page, options_for_select([10, 15, 20, 50, 100, 200, 500], @table.data.per_page), class: 'per_page_pagination_select' %>
110
+ <%= select_tag :per_page, options_for_select([10, 15, 20, 50, 100, 200, 500], per_page), class: 'per_page_pagination_select' %>
100
111
  <% end %>
101
112
  </div>
102
113
 
103
114
  <div class='left per_page_pagination'>
104
- <%= paginate_table_entries @table.data %>
115
+ <%= paginate @records, remote: true %>
105
116
  </div>
106
117
  <% end %>
107
118
 
108
- <div class='clear'></div>
119
+ <div class='clear'></div>
@@ -0,0 +1,76 @@
1
+ <% title "'#{@table.name}'"%>
2
+
3
+ <h2>Table: <%= @table.name %></h2>
4
+
5
+ <div class='clear'></div>
6
+
7
+ <hr/>
8
+
9
+ <dl class="sub-nav">
10
+ <dd><%= render '/rails_db/shared/exp_col' %></dd>
11
+ <dd class="active"><%= link_to raw("#{fa_icon('table')} Records"), table_data_path(@table), remote: true %></dd>
12
+ <dd><%= link_to raw("#{fa_icon('tasks')} Schema"), table_path(@table), remote: true %></dd>
13
+ <dd><%= select_top_from_table(@table.name) %></dd>
14
+ <dd>
15
+ <a href="#" data-options="align: bottom" data-dropdown="download-files"><%= fa_icon 'download' %> Export</a>
16
+ </dd>
17
+ <dd>
18
+ <a href="#" data-options="align: bottom" data-dropdown="drop"><%= fa_icon 'th-large' %> Functions</a>
19
+ </dd>
20
+ <dd class="right"><%= link_to raw("#{fa_icon('cogs')} Settings"), '#', :class => 'settings-link', :table_name => "#{@table.name}" %></dd>
21
+ <dd class="right"><%= link_to raw("#{fa_icon('search')} Search"), '#', :class => 'search-link' %></dd>
22
+ </dl>
23
+ <div class="clearfix"></div>
24
+
25
+ <ul id="drop" class="f-dropdown" data-dropdown-content>
26
+ <li><%= link_to raw("#{fa_icon('trash-o')} Truncate Table"), table_truncate_path(@table), data: {confirm: 'Are you sure?'} %></li>
27
+ </ul>
28
+
29
+ <ul id="download-files" class="f-dropdown" data-dropdown-content>
30
+ <li><%= link_to raw("#{fa_icon('file-text-o')} Export to CSV"), table_csv_path(@table) %></li>
31
+ <li><%= link_to raw("#{fa_icon('file-excel-o')} Export to Excel"), table_xlsx_path(@table, format: 'xls') %></li>
32
+ </ul>
33
+
34
+ <%= search_form_for @q, url: table_search_path(@table), method: :get, remote: true, html: { id: 'search_form', class: search_form_class } do |f| %>
35
+ <%= f.condition_fields do |c| %>
36
+ <%= render "condition_fields", f: c %>
37
+ <% end %>
38
+ <p><%= link_to_add_fields raw("#{fa_icon 'plus'} Add Conditions"), f, :condition %></p>
39
+ <div class="field sorting_options">
40
+ Sort:
41
+ <%= f.sort_fields do |s| %>
42
+ <%= s.sort_select %>
43
+ <% end %>
44
+ </div>
45
+ <div class="actions"><%= f.submit "Search", class: 'button small' %></div>
46
+ <% end %>
47
+
48
+ <div class='scrollable'>
49
+ <table id="search_records" class='table'>
50
+ <thead>
51
+ <tr>
52
+ <% if @table.primary_key %>
53
+ <th colspan="2">Actions</th>
54
+ <% end %>
55
+ <% @model.column_names.each do |column| %>
56
+ <th> <%= sort_link(@q, column) %> </th>
57
+ <% end %>
58
+ </tr>
59
+ </thead>
60
+ <tbody>
61
+ <% @records.each do |record| %>
62
+ <tr class="row_<%= record[@table.primary_key] %>">
63
+ <%= render 'row', record: record %>
64
+ </tr>
65
+ <% end %>
66
+
67
+ <% if @records.none? %>
68
+ <td>No Records</td>
69
+ <% end %>
70
+ </tbody>
71
+ </table>
72
+ </div>
73
+
74
+ <p>
75
+ <%= paginate @records, remote: true %>
76
+ </p>
@@ -9,12 +9,19 @@
9
9
  <dd><%= link_to raw("#{fa_icon('table')} Records"), table_data_path(@table), remote: true %></dd>
10
10
  <dd class="active"><%= link_to raw("#{fa_icon('tasks')} Schema"), table_path(@table), remote: true %></dd>
11
11
  <dd><%= select_top_from_table(@table.name) %></dd>
12
- <dd><%= link_to raw("#{fa_icon('file-excel-o')} Export"), table_csv_path(@table) %></dd>
12
+ <dd>
13
+ <a href="#" data-options="align: bottom" data-dropdown="download-files"><%= fa_icon 'download' %> Export</a>
14
+ </dd>
13
15
  <dd>
14
16
  <a href="#" data-options="align: bottom" data-dropdown="drop"><%= fa_icon 'th-large' %> Functions</a>
15
17
  </dd>
16
18
  </dl>
17
19
 
20
+ <ul id="download-files" class="f-dropdown" data-dropdown-content>
21
+ <li><%= link_to raw("#{fa_icon('file-text-o')} Export table to CSV"), table_csv_path(@table) %></li>
22
+ <li><%= link_to raw("#{fa_icon('file-excel-o')} Export table to Excel"), table_xlsx_path(@table, format: 'xls') %></li>
23
+ </ul>
24
+
18
25
  <ul id="drop" class="f-dropdown" data-dropdown-content>
19
26
  <li><%= link_to raw("#{fa_icon('trash-o')} Truncate Table"), table_truncate_path(@table), remote: true, confirm: 'Are you sure?', data: {confirm: 'Are you sure?'} %></a></li>
20
27
  </ul>
@@ -9,4 +9,6 @@ stickyFooter();
9
9
 
10
10
  $(document).foundation('reflow');
11
11
 
12
- $(document).scrollTop(0);
12
+ $(document).scrollTop(0);
13
+
14
+ set_browser_url('<%= url_for(params) %>');
@@ -10,3 +10,5 @@ stickyFooter();
10
10
  $(document).foundation('reflow');
11
11
 
12
12
  $(document).scrollTop(0);
13
+
14
+ set_browser_url('<%= url_for(params) %>');
data/lib/rails_db.rb CHANGED
@@ -8,6 +8,8 @@ require 'terminal-table'
8
8
  require 'csv'
9
9
  require 'axlsx_rails'
10
10
  require 'simple_form'
11
+ require 'ransack'
12
+ require 'kaminari'
11
13
 
12
14
  module RailsDb
13
15
  # Custom require relative that work with older rubies also
@@ -1,3 +1,5 @@
1
+ require 'active_model'
2
+
1
3
  module RailsDb
2
4
 
3
5
  class Table
@@ -45,7 +47,12 @@ module RailsDb
45
47
  end
46
48
 
47
49
  def create_model(table_name, &block)
48
- klass = Class.new(ActiveRecord::Base) {self.table_name = table_name}
50
+ klass = Class.new(ActiveRecord::Base) do
51
+ def self.model_name
52
+ ActiveModel::Name.new(self, nil, table_name)
53
+ end
54
+ self.table_name = table_name
55
+ end
49
56
  klass.class_eval(&block) if block_given?
50
57
  klass
51
58
  end
@@ -1,3 +1,3 @@
1
1
  module RailsDb
2
- VERSION = "0.9"
2
+ VERSION = "0.9.9"
3
3
  end
data/rails_db.gemspec CHANGED
@@ -17,16 +17,18 @@ Gem::Specification.new do |s|
17
17
 
18
18
  s.executables = ["railsdb", "rails_db", 'runsql']
19
19
 
20
- s.add_dependency "rails", ">= 3.1.0"
21
- s.add_dependency "font-awesome-rails"
22
- s.add_dependency "sass"
23
- s.add_dependency "sass-rails"
24
- s.add_dependency "jquery-rails"
20
+ s.add_dependency 'rails', ">= 3.1.0"
21
+ s.add_dependency 'font-awesome-rails'
22
+ s.add_dependency 'sass'
23
+ s.add_dependency 'sass-rails'
24
+ s.add_dependency 'jquery-rails'
25
25
  s.add_dependency 'codemirror-rails'
26
26
  s.add_dependency 'launchy'
27
27
  s.add_dependency 'terminal-table'
28
28
  s.add_dependency 'axlsx_rails'
29
29
  s.add_dependency 'simple_form'
30
+ s.add_dependency 'ransack'
31
+ s.add_dependency 'kaminari'
30
32
 
31
33
  s.add_development_dependency "sqlite3"
32
34
  s.add_development_dependency "mysql2", '<= 0.3.20'
Binary file
Binary file
@@ -1 +1 @@
1
- 62164
1
+ 91954
@@ -1,5 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+
4
+
3
5
  gem 'rails'
4
6
  gem 'sass'
5
7
  gem 'jquery-rails'
@@ -8,6 +10,8 @@ gem 'codemirror-rails'
8
10
  gem 'terminal-table'
9
11
  gem 'axlsx_rails'
10
12
  gem 'simple_form'
13
+ gem 'ransack'
14
+ gem 'kaminari'
11
15
 
12
16
  group :assets do
13
17
  gem 'sass-rails'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_db
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.9'
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-24 00:00:00.000000000 Z
11
+ date: 2015-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -150,6 +150,34 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: ransack
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: kaminari
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
153
181
  - !ruby/object:Gem::Dependency
154
182
  name: sqlite3
155
183
  requirement: !ruby/object:Gem::Requirement
@@ -235,6 +263,7 @@ files:
235
263
  - app/assets/javascripts/rails_db/foundation/foundation.tooltip.js
236
264
  - app/assets/javascripts/rails_db/foundation/foundation.topbar.js
237
265
  - app/assets/javascripts/rails_db/jquery.cookie.js
266
+ - app/assets/javascripts/rails_db/search.js
238
267
  - app/assets/javascripts/rails_db/show_hide_columns.js
239
268
  - app/assets/javascripts/rails_db/sticky.js
240
269
  - app/assets/javascripts/rails_db/vendor/fastclick.js
@@ -250,6 +279,7 @@ files:
250
279
  - app/assets/stylesheets/rails_db/foundation_and_overrides.css.scss
251
280
  - app/assets/stylesheets/rails_db/normalize.css
252
281
  - app/assets/stylesheets/rails_db/pagination.css.scss
282
+ - app/assets/stylesheets/rails_db/search.css.scss
253
283
  - app/assets/stylesheets/rails_db/sidebar.css.scss
254
284
  - app/assets/stylesheets/rails_db/table.css.scss
255
285
  - app/controllers/rails_db/application_controller.rb
@@ -278,9 +308,11 @@ files:
278
308
  - app/views/rails_db/sql/import.html.erb
279
309
  - app/views/rails_db/sql/index.html.erb
280
310
  - app/views/rails_db/sql/xls.xls.axlsx
311
+ - app/views/rails_db/tables/_condition_fields.html.erb
281
312
  - app/views/rails_db/tables/_data.html.erb
282
313
  - app/views/rails_db/tables/_edit.html.erb
283
314
  - app/views/rails_db/tables/_row.html.erb
315
+ - app/views/rails_db/tables/_search.html.erb
284
316
  - app/views/rails_db/tables/_show.html.erb
285
317
  - app/views/rails_db/tables/data.html.erb
286
318
  - app/views/rails_db/tables/data.js.erb