rails_data 0.0.1
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 +7 -0
- data/LICENSE +165 -0
- data/README.md +41 -0
- data/Rakefile +37 -0
- data/app/assets/config/rails_data_manifest.js +1 -0
- data/app/assets/javascripts/channels/done.js +10 -0
- data/app/assets/javascripts/controllers/the_data_admin/data_lists/edit.js +1 -0
- data/app/assets/javascripts/controllers/the_data_admin/data_lists/new.js +1 -0
- data/app/assets/javascripts/controllers/the_data_admin/table_lists/index.js +10 -0
- data/app/channels/done_channel.rb +7 -0
- data/app/channels/rails_data_connection.rb +29 -0
- data/app/controllers/rails_data_admin/base_controller.rb +3 -0
- data/app/controllers/rails_data_admin/data_lists_controller.rb +75 -0
- data/app/controllers/rails_data_admin/data_records_controller.rb +71 -0
- data/app/controllers/rails_data_admin/record_lists_controller.rb +105 -0
- data/app/controllers/rails_data_admin/table_lists_controller.rb +115 -0
- data/app/helpers/data_records_helper.rb +2 -0
- data/app/helpers/rails_data_helper.rb +21 -0
- data/app/jobs/table_job.rb +11 -0
- data/app/mailers/report_finish_mailer.rb +17 -0
- data/app/models/rails_data/concerns/data_cache_service.rb +26 -0
- data/app/models/rails_data/concerns/data_export_helper.rb +55 -0
- data/app/models/rails_data/concerns/data_import_helper.rb +40 -0
- data/app/models/rails_data/concerns/data_import_service.rb +35 -0
- data/app/models/rails_data/data_list.rb +47 -0
- data/app/models/rails_data/data_lists/data_export.rb +11 -0
- data/app/models/rails_data/data_lists/data_import.rb +11 -0
- data/app/models/rails_data/data_lists/data_record.rb +18 -0
- data/app/models/rails_data/export_services/csv_export_service.rb +24 -0
- data/app/models/rails_data/export_services/pdf_export_service.rb +74 -0
- data/app/models/rails_data/export_services/xlsx_export_service.rb +51 -0
- data/app/models/rails_data/record_list.rb +69 -0
- data/app/models/rails_data/table_item.rb +5 -0
- data/app/models/rails_data/table_list.rb +47 -0
- data/app/pdfs/concerns/pdf_page_helper.rb +37 -0
- data/app/pdfs/concerns/pdf_table_helper.rb +107 -0
- data/app/pdfs/concerns/pdf_text_helper.rb +18 -0
- data/app/pdfs/rails_data_pdf.rb +32 -0
- data/app/views/rails_data_admin/base/_nav.html.erb +9 -0
- data/app/views/rails_data_admin/data_lists/_item_form.html.erb +15 -0
- data/app/views/rails_data_admin/data_lists/add_item.js.erb +4 -0
- data/app/views/rails_data_admin/data_lists/edit.html.erb +33 -0
- data/app/views/rails_data_admin/data_lists/index.html.erb +43 -0
- data/app/views/rails_data_admin/data_lists/new.html.erb +17 -0
- data/app/views/rails_data_admin/data_lists/remove_item.js.erb +1 -0
- data/app/views/rails_data_admin/data_lists/reportable.html.erb +31 -0
- data/app/views/rails_data_admin/data_lists/show.html.erb +20 -0
- data/app/views/rails_data_admin/data_records/_item_form.html.erb +15 -0
- data/app/views/rails_data_admin/data_records/add_item.js.erb +4 -0
- data/app/views/rails_data_admin/data_records/edit.html.erb +33 -0
- data/app/views/rails_data_admin/data_records/index.html.erb +57 -0
- data/app/views/rails_data_admin/data_records/new.html.erb +16 -0
- data/app/views/rails_data_admin/data_records/remove_item.js.erb +1 -0
- data/app/views/rails_data_admin/data_records/reportable.html.erb +31 -0
- data/app/views/rails_data_admin/data_records/show.html.erb +20 -0
- data/app/views/rails_data_admin/record_lists/_edit_columns.html.erb +19 -0
- data/app/views/rails_data_admin/record_lists/_edit_table.erb +44 -0
- data/app/views/rails_data_admin/record_lists/_index.html.erb +22 -0
- data/app/views/rails_data_admin/record_lists/_search_form.html.erb +9 -0
- data/app/views/rails_data_admin/record_lists/_show.html.erb +16 -0
- data/app/views/rails_data_admin/record_lists/_table.html.erb +12 -0
- data/app/views/rails_data_admin/record_lists/edit.html.erb +19 -0
- data/app/views/rails_data_admin/record_lists/edit_columns.html.erb +30 -0
- data/app/views/rails_data_admin/record_lists/edit_columns.js.erb +9 -0
- data/app/views/rails_data_admin/record_lists/find.js.erb +8 -0
- data/app/views/rails_data_admin/record_lists/index.html.erb +52 -0
- data/app/views/rails_data_admin/record_lists/new.html.erb +19 -0
- data/app/views/rails_data_admin/record_lists/show.html.erb +19 -0
- data/app/views/rails_data_admin/record_lists/show.js.erb +8 -0
- data/app/views/rails_data_admin/record_lists/update_columns.js.erb +8 -0
- data/app/views/rails_data_admin/table_lists/_import.html.erb +17 -0
- data/app/views/rails_data_admin/table_lists/_index.html.erb +22 -0
- data/app/views/rails_data_admin/table_lists/_process.html.erb +5 -0
- data/app/views/rails_data_admin/table_lists/_show.html.erb +10 -0
- data/app/views/rails_data_admin/table_lists/_table.html.erb +38 -0
- data/app/views/rails_data_admin/table_lists/create_import.js.erb +8 -0
- data/app/views/rails_data_admin/table_lists/edit.html.erb +19 -0
- data/app/views/rails_data_admin/table_lists/find.js.erb +2 -0
- data/app/views/rails_data_admin/table_lists/index.html.erb +55 -0
- data/app/views/rails_data_admin/table_lists/new.html.erb +19 -0
- data/app/views/rails_data_admin/table_lists/new_import.js.erb +30 -0
- data/app/views/rails_data_admin/table_lists/run.js.erb +10 -0
- data/app/views/rails_data_admin/table_lists/show.html.erb +11 -0
- data/app/views/report_finish_mailer/finish_notify.text.erb +5 -0
- data/config/initializers/the_data.rb +4 -0
- data/config/locales/en.yml +10 -0
- data/config/locales/zh.yml +10 -0
- data/config/routes.rb +35 -0
- data/db/migrate/20150618053929_create_report_lists.rb +51 -0
- data/lib/rails_data/config.rb +23 -0
- data/lib/rails_data/engine.rb +18 -0
- data/lib/rails_data/export.rb +52 -0
- data/lib/rails_data/import.rb +42 -0
- data/lib/rails_data/record.rb +42 -0
- data/lib/rails_data/version.rb +3 -0
- data/lib/rails_data.rb +5 -0
- data/test/controllers/data_records_controller_test.rb +48 -0
- data/test/controllers/rails_data_admin/report_lists_controller_test.rb +49 -0
- data/test/controllers/rails_data_admin/table_lists_controller_test.rb +49 -0
- data/test/factories/combines.rb +7 -0
- data/test/factories/report_lists.rb +14 -0
- data/test/factories/table_items.rb +6 -0
- data/test/factories/table_lists.rb +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/models/data_list_test.rb +10 -0
- data/test/system/data_records_test.rb +41 -0
- data/test/test_helper.rb +21 -0
- data/test/the_data_test.rb +7 -0
- metadata +247 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<div class="ui segment breadcrumb">
|
|
2
|
+
<%= link_to 'Back', data_record_record_lists_path(@data_record), class: 'section' %>
|
|
3
|
+
<div class="divider"> / </div>
|
|
4
|
+
<div class="active section">Edit</div>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div class="ui segment">
|
|
8
|
+
<%= default_form_with model: @record_list, url: data_record_record_list_path(@data_record) do |f| %>
|
|
9
|
+
<% @record_list.parameters.each do |k, v| %>
|
|
10
|
+
<div class="inline fields">
|
|
11
|
+
<label class="six wide field"><%= k.to_s.titleize %>:</label>
|
|
12
|
+
<div class="six wide field">
|
|
13
|
+
<%= text_field_tag :"record_list[parameters][#{k}]", v, as: @data_record.parameters[k].to_sym %>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
<% end %>
|
|
17
|
+
<%= f.submit %>
|
|
18
|
+
<% end %>
|
|
19
|
+
</div>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<div class="ui segment breadcrumb">
|
|
2
|
+
<%= link_to 'Back', data_record_record_lists_path(@data_record), class: 'section' %>
|
|
3
|
+
<div class="divider"> / </div>
|
|
4
|
+
<div class="active section">Edit</div>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div class="ui segment">
|
|
8
|
+
<%= default_form_with url: columns_data_record_record_list_path(@data_record), method: :patch do |f| %>
|
|
9
|
+
<% @record_list.columns.each do |k, v| %>
|
|
10
|
+
<% if TheData.config.mapping[@data_record.columns[k.to_sym].to_sym][:input] == 'array' %>
|
|
11
|
+
<div class="inline fields">
|
|
12
|
+
<label class="six wide field"><%= k.to_s.titleize %>:</label>
|
|
13
|
+
<% v.each_with_index do |_value, _index| %>
|
|
14
|
+
<% _value.each do |_k, _v| %>
|
|
15
|
+
<%= text_field_tag "columns[#{k}][][#{_k}]", _v %>
|
|
16
|
+
<% end %>
|
|
17
|
+
<% end %>
|
|
18
|
+
</div>
|
|
19
|
+
<% else %>
|
|
20
|
+
<div class="inline fields">
|
|
21
|
+
<label class="six wide field"><%= k.to_s.titleize %>:</label>
|
|
22
|
+
<div class="six wide field">
|
|
23
|
+
<%= text_field_tag :"columns[#{k}]", v, as: @data_record.columns[k.to_sym] %>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
<% end %>
|
|
27
|
+
<% end %>
|
|
28
|
+
<%= f.submit %>
|
|
29
|
+
<% end %>
|
|
30
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
if ($('.ui.modals').length === 0) {
|
|
2
|
+
$('body').append('<%= j(render 'edit_columns') %>');
|
|
3
|
+
} else {
|
|
4
|
+
$('.ui.modals').html('<%= j(render 'edit_columns') %>');
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
$('.ui.modal').modal('setting', {autofocus: false}).modal('show');
|
|
9
|
+
$('#columns_main').dropdown();
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<ul class="ui segment breadcrumb">
|
|
2
|
+
<li class="section"><%= link_to 'back', data_records_path %></li>
|
|
3
|
+
<li class="divider">/</li>
|
|
4
|
+
<li class="section">Table lists</li>
|
|
5
|
+
</ul>
|
|
6
|
+
|
|
7
|
+
<div class="ui top attached borderless menu">
|
|
8
|
+
<div class="item header">Table List</div>
|
|
9
|
+
<div class="right menu">
|
|
10
|
+
<div class="item">
|
|
11
|
+
<%= link_to '新建', new_data_record_record_list_path(@data_record), class: 'ui teal button' %>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div class="ui attached segment">
|
|
17
|
+
<%= render 'search_form' %>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<table class="ui bottom attached table">
|
|
21
|
+
<thead>
|
|
22
|
+
<tr>
|
|
23
|
+
<th class="one wide">ID</th>
|
|
24
|
+
<th class="two wide">Parameters</th>
|
|
25
|
+
<th>Columns</th>
|
|
26
|
+
<th>Export</th>
|
|
27
|
+
<th class="three wide"></th>
|
|
28
|
+
</tr>
|
|
29
|
+
</thead>
|
|
30
|
+
|
|
31
|
+
<tbody>
|
|
32
|
+
<% @record_lists.each do |record_list| %>
|
|
33
|
+
<tr>
|
|
34
|
+
<td><%= record_list.id %></td>
|
|
35
|
+
<td><%= simple_format_hash(record_list.parameters) %></td>
|
|
36
|
+
<td><%= simple_format_hash(record_list.columns) %></td>
|
|
37
|
+
<td class="ui labels">
|
|
38
|
+
<%= link_to 'pdf', data_record_record_list_path(@data_record, record_list, format: 'pdf'), target: '_blank', class: 'ui label' %>
|
|
39
|
+
</td>
|
|
40
|
+
<td class="ui labels">
|
|
41
|
+
<%= link_to '运行', run_data_record_record_list_path(@data_record, record_list), method: :patch, remote: true, data: { confirm: 'Are you sure?' }, class: 'ui blue label' %>
|
|
42
|
+
<%= link_to '预览', find_data_record_record_lists_path(@data_record.data_table, record_list.parameters), remote: true, class: 'ui blue label' %>
|
|
43
|
+
<%= link_to '修改', columns_data_record_record_list_path(@data_record, record_list), remote: true, class: 'ui blue label' %>
|
|
44
|
+
<%= link_to 'edit', edit_data_record_record_list_path(@data_record, record_list), class: 'ui yellow label' %>
|
|
45
|
+
<%= link_to 'destroy', data_record_record_list_path(@data_record, record_list), method: :delete, data: { confirm: 'Are you sure?' }, class: 'ui red label' %>
|
|
46
|
+
</td>
|
|
47
|
+
</tr>
|
|
48
|
+
<% end %>
|
|
49
|
+
</tbody>
|
|
50
|
+
</table>
|
|
51
|
+
|
|
52
|
+
<%= paginate @record_lists %>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<div class="ui segment breadcrumb">
|
|
2
|
+
<%= link_to 'Back', data_record_record_lists_path(@data_record), class: 'section' %>
|
|
3
|
+
<div class="divider"> /</div>
|
|
4
|
+
<div class="active section">New</div>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div class="ui segment">
|
|
8
|
+
<%= default_form_with model: @record_list, url: data_record_record_lists_path, locale: true do |f| %>
|
|
9
|
+
<% @data_record.parameters.each do |k, v| %>
|
|
10
|
+
<div class="inline fields">
|
|
11
|
+
<label class="six wide field"><%= k.to_s.titleize %>:</label>
|
|
12
|
+
<div class="six wide field">
|
|
13
|
+
<%= text_field_tag :"record_list[parameters][#{k}]", nil, as: @data_record.parameters[k] %>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
<% end %>
|
|
17
|
+
<%= f.submit %>
|
|
18
|
+
<% end %>
|
|
19
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<ul class="ui segment breadcrumb">
|
|
2
|
+
<li class="section"><%= link_to 'Data List', data_records_path %></li>
|
|
3
|
+
<li class="divider">/</li>
|
|
4
|
+
<li class="section"><%= link_to 'Table List', data_record_record_lists_path(@data_record) %></li>
|
|
5
|
+
</ul>
|
|
6
|
+
|
|
7
|
+
<div class="ui top attached menu borderless">
|
|
8
|
+
<div class="item"><strong>Preview</strong></div>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div class="ui top attached menu borderless">
|
|
12
|
+
<div class="item"><strong>TableID:<%= @record_list.id %></strong></div>
|
|
13
|
+
<div class="right menu">
|
|
14
|
+
<%= link_to 'download Csv', data_record_record_list_path(@data_record, @record_list, format: 'csv'), class: 'item ui button' %>
|
|
15
|
+
<%= link_to 'download Xlsx', data_record_record_list_path(@data_record, @record_list, format: 'xlsx'), class: 'item ui blue button' %>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<%= render 'table' %>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<div class="ui modal">
|
|
2
|
+
<i class="close icon"></i>
|
|
3
|
+
<div class="ui header blue">
|
|
4
|
+
Import
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div class="content">
|
|
8
|
+
<%= form_with model: @table_list, url: import_data_list_table_lists_path(@data_list), local: true, id: 'import_table' do |f| %>
|
|
9
|
+
<%= f.file_field :file %>
|
|
10
|
+
<%= f.submit %>
|
|
11
|
+
<% end %>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<table class="table table-striped">
|
|
2
|
+
<thead>
|
|
3
|
+
<tr>
|
|
4
|
+
<th>ID</th>
|
|
5
|
+
<th colspan="4"></th>
|
|
6
|
+
</tr>
|
|
7
|
+
</thead>
|
|
8
|
+
|
|
9
|
+
<tbody>
|
|
10
|
+
<% @table_lists.each do |table_list| %>
|
|
11
|
+
<tr>
|
|
12
|
+
<td><%= table_list.id %></td>
|
|
13
|
+
<td><%= link_to 'Download Csv', report_list_table_list_path(@report_list, table_list, format: 'csv') %></td>
|
|
14
|
+
<td><%= link_to 'Download Pdf', report_list_table_list_path(@report_list, table_list, format: 'pdf') %></td>
|
|
15
|
+
<td><%= link_to 'Download row Pdf', row_report_list_table_list_path(@report_list, table_list, format: 'pdf') %></td>
|
|
16
|
+
<td><%= link_to 'destroy', report_list_table_list_path(@report_list, table_list), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
|
17
|
+
</tr>
|
|
18
|
+
<% end %>
|
|
19
|
+
</tbody>
|
|
20
|
+
</table>
|
|
21
|
+
|
|
22
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<div class="ui top attached menu borderless">
|
|
2
|
+
<div class="header item">TableID:<%= @table_list.id %></div>
|
|
3
|
+
<div class="right menu">
|
|
4
|
+
<%= link_to 'Migrate', migrate_data_list_table_list_path(@data_list, @table_list), method: :patch, class: 'item ui button' if @table_list.data_list.is_a?(DataImport) %>
|
|
5
|
+
<%= link_to 'download Csv', data_list_table_list_path(@data_list, @table_list, format: 'csv'), class: 'item ui button' %>
|
|
6
|
+
<%= link_to 'download Xlsx', data_list_table_list_path(@data_list, @table_list, format: 'xlsx'), class: 'item ui blue button' %>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<table class="ui celled red bottom attached fixed table">
|
|
11
|
+
<thead>
|
|
12
|
+
<tr>
|
|
13
|
+
<% @table_list.headers.each do |header| %>
|
|
14
|
+
<th><%= header %></th>
|
|
15
|
+
<% end %>
|
|
16
|
+
</tr>
|
|
17
|
+
</thead>
|
|
18
|
+
|
|
19
|
+
<tbody>
|
|
20
|
+
<% @table_items.limit(100).each do |item| %>
|
|
21
|
+
<tr>
|
|
22
|
+
<% item.fields.each do |field| %>
|
|
23
|
+
<td><pre><%= field %></pre></td>
|
|
24
|
+
<% end %>
|
|
25
|
+
</tr>
|
|
26
|
+
<% end %>
|
|
27
|
+
</tbody>
|
|
28
|
+
|
|
29
|
+
<tfoot>
|
|
30
|
+
<tr>
|
|
31
|
+
<% @table_list.footers.each do |footer| %>
|
|
32
|
+
<th><%= footer %></th>
|
|
33
|
+
<% end %>
|
|
34
|
+
</tr>
|
|
35
|
+
</tfoot>
|
|
36
|
+
</table>
|
|
37
|
+
|
|
38
|
+
<%= paginate @table_items, remote: remote %>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<div class="ui segment breadcrumb">
|
|
2
|
+
<%= link_to 'Back', data_list_table_lists_path(@data_list), class: 'section' %>
|
|
3
|
+
<div class="divider"> / </div>
|
|
4
|
+
<div class="active section">Edit</div>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div class="ui segment">
|
|
8
|
+
<%= default_form_with model: @table_list, url: data_list_table_list_path, locale: true do |f| %>
|
|
9
|
+
<% @table_list.parameters.each do |k, v| %>
|
|
10
|
+
<div class="inline fields">
|
|
11
|
+
<label class="six wide field"><%= k.to_s.titleize %>:</label>
|
|
12
|
+
<div class="six wide field">
|
|
13
|
+
<%= text_field_tag :"table_list[parameters][#{k}]", v, type: TheData.config.mapping[@data_list.parameters[k].to_sym][:input] %>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
<% end %>
|
|
17
|
+
<%= f.submit %>
|
|
18
|
+
<% end %>
|
|
19
|
+
</div>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<ul class="ui segment breadcrumb">
|
|
2
|
+
<li class="section"><%= link_to 'back', data_lists_path(type: @data_list.type) %></li>
|
|
3
|
+
<li class="divider">/</li>
|
|
4
|
+
<li class="section">Table lists</li>
|
|
5
|
+
</ul>
|
|
6
|
+
|
|
7
|
+
<div class="ui top attached menu borderless">
|
|
8
|
+
<div class="item"><strong>Table List</strong></div>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div class="ui segment top attached">
|
|
12
|
+
<% if @data_list.type == 'DataImport' %>
|
|
13
|
+
<%= link_to 'Import', import_data_list_table_lists_path(@data_list), class: 'ui blue button', remote: true %>
|
|
14
|
+
<% else %>
|
|
15
|
+
<%= link_to 'New', new_data_list_table_list_path(@data_list), class: 'ui teal button' %>
|
|
16
|
+
<% end %>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<table class="ui bottom attached table">
|
|
20
|
+
<thead>
|
|
21
|
+
<tr>
|
|
22
|
+
<th class="one wide">ID</th>
|
|
23
|
+
<th class="two wide">Parameters</th>
|
|
24
|
+
<th class="eight wide">Headers</th>
|
|
25
|
+
<th class="one wide"><%= TableList.human_attribute_name(:timestamp) %></th>
|
|
26
|
+
<th class="one wide">Done</th>
|
|
27
|
+
<th class="three wide"></th>
|
|
28
|
+
</tr>
|
|
29
|
+
</thead>
|
|
30
|
+
|
|
31
|
+
<tbody>
|
|
32
|
+
<% @table_lists.each do |table_list| %>
|
|
33
|
+
<tr>
|
|
34
|
+
<td><%= table_list.id %></td>
|
|
35
|
+
<td><%= simple_format_hash(table_list.parameters) %></td>
|
|
36
|
+
<td><%= table_list.headers.to_csv %></td>
|
|
37
|
+
<td><%= table_list.timestamp %></td>
|
|
38
|
+
<td id="done_<%= table_list.id %>">
|
|
39
|
+
<% if table_list.done %>
|
|
40
|
+
<i class="green checkmark icon"></i>
|
|
41
|
+
<% else %>
|
|
42
|
+
<i class="grey remove icon"></i>
|
|
43
|
+
<% end %>
|
|
44
|
+
</td>
|
|
45
|
+
<td class="ui labels">
|
|
46
|
+
<%= link_to 'Run', run_data_list_table_list_path(@data_list, table_list), method: :patch, remote: true, data: { confirm: 'Are you sure?' }, class: 'ui blue label' %>
|
|
47
|
+
<%= link_to 'xlsx', xlsx_data_list_table_list_path(@data_list, table_list, format: 'xlsx'), class: 'ui yellow label' %>
|
|
48
|
+
<%= link_to 'Preview', data_list_table_list_path(@data_list, table_list), class: 'ui blue label' %>
|
|
49
|
+
<%= link_to 'Edit', edit_data_list_table_list_path(@data_list, table_list), class: 'ui yellow label' %>
|
|
50
|
+
<%= link_to 'Destroy', data_list_table_list_path(@data_list, table_list), method: :delete, data: { confirm: 'Are you sure?' }, class: 'ui red label' %>
|
|
51
|
+
</td>
|
|
52
|
+
</tr>
|
|
53
|
+
<% end %>
|
|
54
|
+
</tbody>
|
|
55
|
+
</table>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<div class="ui segment breadcrumb">
|
|
2
|
+
<%= link_to 'Back', data_list_table_lists_path(@data_list), class: 'section' %>
|
|
3
|
+
<div class="divider"> / </div>
|
|
4
|
+
<div class="active section">New</div>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div class="ui segment">
|
|
8
|
+
<%= form_with model: @table_list, url: data_list_table_lists_path, local: true do |f| %>
|
|
9
|
+
<% @data_list.parameters.each do |k, v| %>
|
|
10
|
+
<div class="inline fields">
|
|
11
|
+
<label class="six wide field"><%= k.to_s.titleize %>:</label>
|
|
12
|
+
<div class="six wide field">
|
|
13
|
+
<%= text_field_tag :"table_list[parameters][#{k}]", nil, type: TheData.config.mapping[v.to_sym][:input] %>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
<% end %>
|
|
17
|
+
<%= f.submit %>
|
|
18
|
+
<% end %>
|
|
19
|
+
</div>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
if ($('.ui.modals').length === 0) {
|
|
2
|
+
$('body').append('<%= j(render 'import') %>');
|
|
3
|
+
} else {
|
|
4
|
+
$('.ui.modals').html('<%= j(render 'import') %>');
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
$('.ui.modal').modal('setting', {autofocus: false}).modal('show');
|
|
8
|
+
|
|
9
|
+
$('#import_table').submit(function(event) {
|
|
10
|
+
event.preventDefault();
|
|
11
|
+
var form = document.querySelector('#import_table')
|
|
12
|
+
|
|
13
|
+
fetch('<%= import_data_list_table_lists_path(@data_list) %>', {
|
|
14
|
+
method: 'POST',
|
|
15
|
+
credentials: 'same-origin',
|
|
16
|
+
headers: {
|
|
17
|
+
Accept: 'application/javascript'
|
|
18
|
+
},
|
|
19
|
+
body: new FormData(form)
|
|
20
|
+
}).then(function(response) {
|
|
21
|
+
return response.text()
|
|
22
|
+
}).then(function(response) {
|
|
23
|
+
var script = document.createElement('script');
|
|
24
|
+
script.text = response;
|
|
25
|
+
document.head.appendChild(script).parentNode.removeChild(script);
|
|
26
|
+
}).catch(function(ex) {
|
|
27
|
+
console.log('parsing failed', ex)
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<ul class="ui segment breadcrumb">
|
|
2
|
+
<li class="section"><%= link_to 'Data List', data_lists_path %></li>
|
|
3
|
+
<li class="divider">/</li>
|
|
4
|
+
<li class="section"><%= link_to 'Table List', data_list_table_lists_path(@data_list) %></li>
|
|
5
|
+
</ul>
|
|
6
|
+
|
|
7
|
+
<div class="ui top attached menu borderless">
|
|
8
|
+
<div class="item"><strong>Preview</strong></div>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<%= render partial: 'table', locals: { remote: false } %>
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Rails.application.routes.draw do
|
|
2
|
+
|
|
3
|
+
scope module: 'rails_data_admin' do
|
|
4
|
+
resources :data_lists do
|
|
5
|
+
get :add_item, on: :collection
|
|
6
|
+
get :remove_item, on: :collection
|
|
7
|
+
put :update_publish, on: :member
|
|
8
|
+
patch :rebuild, on: :member
|
|
9
|
+
resources :table_lists do
|
|
10
|
+
get :find, on: :collection
|
|
11
|
+
get :direct, on: :collection
|
|
12
|
+
get 'import' => :new_import, on: :collection
|
|
13
|
+
post 'import' => :create_import, on: :collection
|
|
14
|
+
get :row, on: :member
|
|
15
|
+
patch :run, on: :member
|
|
16
|
+
get :xlsx, on: :member
|
|
17
|
+
patch :migrate, on: :member
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
resources :data_records do
|
|
22
|
+
get :add_item, on: :collection
|
|
23
|
+
get :remove_item, on: :collection
|
|
24
|
+
patch :rebuild, on: :member
|
|
25
|
+
resources :record_lists do
|
|
26
|
+
get :find, on: :collection
|
|
27
|
+
get :row, on: :member
|
|
28
|
+
patch :run, on: :member
|
|
29
|
+
get 'columns' => :edit_columns, on: :member
|
|
30
|
+
patch 'columns' => :update_columns, on: :member
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
class CreateReportLists < ActiveRecord::Migration
|
|
2
|
+
|
|
3
|
+
def change
|
|
4
|
+
|
|
5
|
+
create_table :data_lists do |t|
|
|
6
|
+
t.string :title
|
|
7
|
+
t.string :comment, limit: 4096
|
|
8
|
+
t.string :type
|
|
9
|
+
t.string :parameters, limit: 1024
|
|
10
|
+
t.string :columns, limit: 1024
|
|
11
|
+
t.string :data_table
|
|
12
|
+
t.string :export_excel
|
|
13
|
+
t.string :export_pdf
|
|
14
|
+
t.timestamps
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
create_table :table_lists do |t|
|
|
18
|
+
t.references :data_list
|
|
19
|
+
t.string :headers, limit: 4096
|
|
20
|
+
t.string :footers, limit: 4096
|
|
21
|
+
t.integer :table_items_count, default: 0
|
|
22
|
+
t.string :parameters, limit: 1024
|
|
23
|
+
t.string :timestamp
|
|
24
|
+
t.boolean :done
|
|
25
|
+
t.boolean :published
|
|
26
|
+
t.timestamps
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
create_table :table_items do |t|
|
|
30
|
+
t.references :table_list
|
|
31
|
+
t.string :fields, limit: 4096
|
|
32
|
+
t.timestamps
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
create_table :record_lists do |t|
|
|
36
|
+
t.references :data_list
|
|
37
|
+
t.string :columns, limit: 4096
|
|
38
|
+
t.string :parameters, limit: 1024
|
|
39
|
+
t.boolean :done
|
|
40
|
+
t.timestamps
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
create_table :record_items do |t|
|
|
44
|
+
t.references :record_list
|
|
45
|
+
t.string :fields, limit: 10240
|
|
46
|
+
t.timestamps
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'active_support/configurable'
|
|
2
|
+
|
|
3
|
+
module RailsData
|
|
4
|
+
# Config
|
|
5
|
+
# Configure the standard CSV default options
|
|
6
|
+
# as well the option to output the header row
|
|
7
|
+
|
|
8
|
+
include ActiveSupport::Configurable
|
|
9
|
+
|
|
10
|
+
configure do |config|
|
|
11
|
+
config.mapping = ActiveSupport::OrderedOptions.new
|
|
12
|
+
|
|
13
|
+
config.inflector = :titleize
|
|
14
|
+
config.method_name = :report
|
|
15
|
+
config.admin_class = 'Admin::BaseController'
|
|
16
|
+
config.mapping.date = { input: 'date', output: 'to_date' }
|
|
17
|
+
config.mapping.integer = { input: 'number', output: 'to_i' }
|
|
18
|
+
config.mapping.string = { input: 'text', output: 'to_s' }
|
|
19
|
+
config.mapping.text = { input: 'textarea', output: 'to_s' }
|
|
20
|
+
config.mapping.array = { input: 'array', output: 'to_s' }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module RailsData
|
|
2
|
+
class Engine < ::Rails::Engine
|
|
3
|
+
|
|
4
|
+
config.eager_load_paths += Dir[
|
|
5
|
+
"#{config.root}/app/models/rails_data",
|
|
6
|
+
"#{config.root}/app/models/rails_data/concerns",
|
|
7
|
+
"#{config.root}/app/models/rails_data/data_lists",
|
|
8
|
+
"#{config.root}/app/models/rails_data/export_services"
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
initializer 'rails_data.assets.precompile' do |app|
|
|
12
|
+
app.config.assets.precompile += ['rails_data_manifest.js']
|
|
13
|
+
Mime::Type.register 'application/xlsx', :xlsx
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|