simple_drilldown 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +5 -5
  2. data/{LICENSE.txt → MIT-LICENSE} +1 -3
  3. data/README.md +15 -16
  4. data/Rakefile +32 -0
  5. data/app/assets/config/simple_drilldown_manifest.js +1 -0
  6. data/app/assets/stylesheets/simple_drilldown/application.css +121 -0
  7. data/app/controllers/simple_drilldown/application_controller.rb +7 -0
  8. data/app/helpers/simple_drilldown/application_helper.rb +6 -0
  9. data/app/jobs/simple_drilldown/application_job.rb +6 -0
  10. data/app/mailers/simple_drilldown/application_mailer.rb +8 -0
  11. data/app/models/simple_drilldown/application_record.rb +7 -0
  12. data/app/views/drilldown/_chart.html.erb +57 -0
  13. data/app/views/drilldown/_excel_record_list.builder +7 -0
  14. data/app/views/drilldown/_excel_row.builder +24 -0
  15. data/app/views/drilldown/_excel_row_header.builder +10 -0
  16. data/app/views/drilldown/_excel_styles.builder +69 -0
  17. data/app/views/drilldown/_excel_summary_row.builder +16 -0
  18. data/app/views/drilldown/_excel_summary_total_row.builder +14 -0
  19. data/app/views/drilldown/_field.html.erb +39 -0
  20. data/app/views/drilldown/_fields.html.erb +12 -0
  21. data/app/views/drilldown/_filter.html.erb +20 -0
  22. data/app/views/drilldown/_record_list.html.erb +12 -0
  23. data/app/views/drilldown/_row.html.erb +13 -0
  24. data/app/views/drilldown/_row_header.html.erb +8 -0
  25. data/app/views/drilldown/_summary_row.html.erb +18 -0
  26. data/app/views/drilldown/_summary_table.html.erb +12 -0
  27. data/app/views/drilldown/_summary_total_row.html.erb +4 -0
  28. data/app/views/drilldown/_tab_buttons.html.erb +5 -0
  29. data/app/views/drilldown/data_0.builder +10 -0
  30. data/app/views/drilldown/data_1.builder +11 -0
  31. data/app/views/drilldown/data_2.builder +37 -0
  32. data/app/views/drilldown/data_3.builder +37 -0
  33. data/app/views/drilldown/excel_export.builder +42 -0
  34. data/app/views/drilldown/excel_export_transactions.builder +90 -0
  35. data/app/views/drilldown/html_export.html.erb +6 -0
  36. data/app/views/drilldown/index.html.erb +107 -0
  37. data/app/views/drilldown/print.html.erb +18 -0
  38. data/app/views/layouts/simple_drilldown/application.html.erb +15 -0
  39. data/config/locales/en.yml +23 -0
  40. data/config/locales/nb.yml +20 -0
  41. data/config/routes.rb +4 -0
  42. data/lib/generators/drilldown_controller/USAGE +8 -0
  43. data/lib/generators/drilldown_controller/drilldown_controller_generator.rb +8 -0
  44. data/lib/generators/drilldown_controller/templates/drilldown_controller.rb.erb +41 -0
  45. data/lib/simple_drilldown.rb +3 -3
  46. data/lib/simple_drilldown/drilldown_controller.rb +389 -274
  47. data/lib/simple_drilldown/drilldown_helper.rb +68 -0
  48. data/lib/simple_drilldown/engine.rb +11 -0
  49. data/lib/simple_drilldown/search.rb +12 -1
  50. data/lib/simple_drilldown/version.rb +1 -1
  51. data/lib/tasks/simple_drilldown_tasks.rake +5 -0
  52. metadata +85 -34
  53. data/.document +0 -5
  54. data/.gitignore +0 -22
  55. data/Gemfile +0 -3
  56. data/Gemfile.lock +0 -89
  57. data/README.rdoc +0 -19
  58. data/lib/sample_drilldown_controller.rb +0 -95
  59. data/lib/simple_drilldown/simple_drilldown_helper.rb +0 -66
  60. data/simple_drilldown.gemspec +0 -24
  61. data/test/helper.rb +0 -18
  62. data/test/test_simple_drilldown.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f142583337003129a4ed401d134a3e64700aedef
4
- data.tar.gz: 03d966c4128c1868e45a43520af87039f16ff726
2
+ SHA256:
3
+ metadata.gz: 69ddf461c2a4468488cbc463a59aa94229bb26f85e248e712da54545865c669e
4
+ data.tar.gz: 33af8b7b6cf86b22c17e4db5193b3c0cc8db3e228f2dfbc2a376f5b0e534b2fa
5
5
  SHA512:
6
- metadata.gz: 28ec3095cfa04d823bb11849cea7c9d3945c000dfdc9ca2c91aa9613cb293beb163332c7a1e7a59a9318ecdab755a737d0ac3bf75c36718d57c895cafd471028
7
- data.tar.gz: a0a9f7c8fc5bb058e864b21c29d8e264efc93195887a1c9106be68be33a169e35930de105c59ae264ac07d2a0ef7501d9e76d5827856243a90d96e362d616a3d
6
+ metadata.gz: 1adc008b5dd8e53570735de90939ed33ad7e4e0f16067c177c60bb05ff6b189097f4c2057376fcfb99bc931b05579189f276167b204397aee46f990830362913
7
+ data.tar.gz: f45aa0e99c1df10b9a6ce8dfb0f2782e3535f80c75294b7c0c2a7e0396b532cef6f626e7859c6e1f9d2455e2f6858e40197dee458c77659e53756832d31f5819
@@ -1,6 +1,4 @@
1
- Copyright (c) 2011-2013 Datek Wireless AS
2
-
3
- MIT License
1
+ Copyright 2020 Uwe Kubosch
4
2
 
5
3
  Permission is hereby granted, free of charge, to any person obtaining
6
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,29 +1,28 @@
1
1
  # SimpleDrilldown
2
+ Short description and motivation.
2
3
 
3
- TODO: Write a gem description
4
+ ## Usage
5
+ How to use my plugin.
4
6
 
5
7
  ## Installation
6
-
7
8
  Add this line to your application's Gemfile:
8
9
 
9
- gem 'simple_drilldown'
10
+ ```ruby
11
+ gem 'simple_drilldown'
12
+ ```
10
13
 
11
14
  And then execute:
12
-
13
- $ bundle
15
+ ```bash
16
+ $ bundle
17
+ ```
14
18
 
15
19
  Or install it yourself as:
16
-
17
- $ gem install simple_drilldown
18
-
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
20
+ ```bash
21
+ $ gem install simple_drilldown
22
+ ```
22
23
 
23
24
  ## Contributing
25
+ Contribution directions go here.
24
26
 
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
10
+ load 'rails/tasks/engine.rake'
11
+ load 'rails/tasks/statistics.rake'
12
+
1
13
  require 'bundler/gem_tasks'
14
+ require 'rake/testtask'
15
+
16
+ Rake::TestTask.new(:test) do |t|
17
+ t.libs << 'test'
18
+ t.pattern = 'test/**/*_test.rb'
19
+ t.verbose = false
20
+ end
21
+
22
+ task default: :test
23
+
24
+ require 'rubocop/rake_task'
25
+ RuboCop::RakeTask.new
26
+
27
+ namespace :test do
28
+ desc 'Run Rubocop and all tests'
29
+ task full: %i[rubocop:auto_correct test]
30
+
31
+ desc 'Run all tests except system tests'
32
+ task quick: :test
33
+ end
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/simple_drilldown .css
@@ -0,0 +1,121 @@
1
+ table {
2
+ border: none;
3
+ }
4
+
5
+ th {
6
+ border: 1px solid #dfded2;
7
+ padding: 2px;
8
+ font-size: 10pt;
9
+ font-weight: bold;
10
+ background-color: #dddddd;
11
+ text-align: center;
12
+ }
13
+
14
+ th.header {
15
+ font-weight: bold;
16
+ text-align: center;
17
+ }
18
+
19
+ td {
20
+ border: 1px solid #dfded2;
21
+ padding: 2px;
22
+ font-size: 10px;
23
+ }
24
+
25
+ td.numeric {
26
+ text-align: right;
27
+ }
28
+
29
+ tr.sum {
30
+ text-align: right;
31
+ border-top: 2px solid black;
32
+ }
33
+
34
+ tr.summary {
35
+ background-color: #eeeeee;
36
+ font-weight: bold;
37
+ }
38
+
39
+ tr.credit_record {
40
+ color: orange;
41
+ }
42
+
43
+ tr.deleted {
44
+ background-color: #ffff88;
45
+ }
46
+
47
+ tr.reading {
48
+ background-color: #fffff0;
49
+ font-weight: bold;
50
+ }
51
+
52
+ tr.context_record {
53
+ background-color: #eeeeee;
54
+ }
55
+
56
+ table.border_table {
57
+ border: 2px solid black;
58
+ border-spacing: 1em;
59
+ border-collapse: collapse;
60
+ }
61
+
62
+ table.border_table td {
63
+ border: 1px solid #dfded2;
64
+ border-bottom-width: 0;
65
+ }
66
+
67
+ table.border_table th {
68
+ border: 2px solid black;
69
+ }
70
+
71
+ #stock_report tr.month th {
72
+ border-bottom: 0;
73
+ }
74
+
75
+ table.border_table tr.year td {
76
+ border-top: 0;
77
+ }
78
+
79
+ table.border_table tr.year th {
80
+ border-top: 0;
81
+ }
82
+
83
+ form.search {
84
+ padding: 0;
85
+ }
86
+
87
+ form.search label, form.search .label {
88
+ min-width: inherit;
89
+ font-size: inherit;
90
+ }
91
+
92
+ table#search th {
93
+ border: 0;
94
+ }
95
+
96
+ table#search td {
97
+ border: 0;
98
+ }
99
+
100
+ table#drill_down_layout > tbody > tr > td {
101
+ border: none;
102
+ font-size: 13px
103
+ }
104
+
105
+ table#drill_down_layout td {
106
+ padding: 2px;
107
+ margin: 0;
108
+ line-height: 18px
109
+ }
110
+
111
+ table#drill_down_layout table{
112
+ border: none;
113
+ }
114
+
115
+ table#drill_down_layout {
116
+ border: none;
117
+ }
118
+
119
+ table#search_fields td {
120
+ border: none;
121
+ }
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleDrilldown
4
+ class ApplicationController < ActionController::Base
5
+ protect_from_forgery with: :exception
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleDrilldown
4
+ module ApplicationHelper
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleDrilldown
4
+ class ApplicationJob < ActiveJob::Base
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleDrilldown
4
+ class ApplicationMailer < ActionMailer::Base
5
+ default from: 'from@example.com'
6
+ layout 'mailer'
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleDrilldown
4
+ class ApplicationRecord < ActiveRecord::Base
5
+ self.abstract_class = true
6
+ end
7
+ end
@@ -0,0 +1,57 @@
1
+ <%
2
+ # The xml is obtained as a string from builder template.
3
+ str_xml = render :file => "drilldown/data_#{@dimensions.size}"
4
+ str_xml = str_xml.gsub("\n", "").gsub("\r", "").gsub("&amp;", "&").gsub("'", "").html_safe
5
+
6
+ type = nil
7
+ case @search.display_type
8
+ when SimpleDrilldown::Search::DisplayType::PIE
9
+ type = 'Pie3D'
10
+ when SimpleDrilldown::Search::DisplayType::BAR
11
+ type = (@search.dimensions && @search.dimensions.size >= 2) ? 'MSCombi3D' : 'Column2D'
12
+ when SimpleDrilldown::Search::DisplayType::LINE
13
+ type = (@search.dimensions && @search.dimensions.size >= 2) ? 'MSLine' : 'Line'
14
+ end
15
+ if type %>
16
+ <div id="chartdiv" align="center">Chart will load here</div>
17
+ <script type="text/javascript">
18
+ var chart = new FusionCharts("<%= asset_path(type + '.swf') %>", "ChartId_Election", "650", "400", "0", "1");
19
+ chart.setXMLData('<%= str_xml %>');
20
+ chart.render("chartdiv");
21
+ </script>
22
+ <% else %>
23
+ <div id="drilldown_area">
24
+ <h2><%= caption %></h2>
25
+ <h3><%= subcaption %></h3>
26
+ <br/>
27
+ </div>
28
+ <% end %>
29
+ <div id="drilldown_search_area" style="margin-left: auto; margin-right: auto; text-align: center">
30
+ <% (0..2).each do |i| %>
31
+ <%
32
+ options = [['', '']]
33
+ options << [@dimensions[i][:pretty_name], @dimensions[i][:url_param_name]] if @dimensions[i]
34
+ options += @remaining_dimensions.keys.map { |name| [@dimension_defs[name][:pretty_name], name] }
35
+ %>
36
+ <%= t(i == 0 ? :group_by : :then_by) %>:
37
+ <%= form.select 'dimensions', options, {:selected => @search.dimensions && @search.dimensions[i]},
38
+ {:onChange => 'form.submit()', :name => 'search[dimensions][]', :id => "search_dimensions_#{i}"}
39
+ %>
40
+ <% end %>
41
+ <br/>
42
+ <%= t :chart_type %>:
43
+ <%= form.radio_button 'display_type', SimpleDrilldown::Search::DisplayType::BAR, {:onChange => 'form.submit()'} %>
44
+ <%= form.label :display_type_bar, t(:bar) %>
45
+ <%= form.radio_button 'display_type', SimpleDrilldown::Search::DisplayType::PIE, {:disabled => @search.dimensions.size >= 2, :onChange => 'form.submit()'} %>
46
+ <%= form.label :display_type_pie, t(:pie) %>
47
+ <%= form.radio_button 'display_type', SimpleDrilldown::Search::DisplayType::LINE, {:onChange => 'form.submit()'} %>
48
+ <%= form.label :display_type_line, t(:line) %>
49
+ <%= form.radio_button 'display_type', SimpleDrilldown::Search::DisplayType::NONE, {:onChange => 'form.submit()'} %>
50
+ <%= form.label :display_type_none, t(:none) %>
51
+
52
+ <%= form.check_box :order_by_value, {:onChange => 'form.submit()'} %>
53
+ <%= form.label :order_by_value, t(:order_by_value) %>
54
+
55
+ <%= form.check_box :list, {:onChange => 'form.submit()'} %>
56
+ <%= form.label :list, t(:list) %>
57
+ </div>
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ xml << render(partial: '/drilldown/excel_row_header')
4
+
5
+ result[:transactions].each do |t|
6
+ xml << render(partial: '/drilldown/excel_row', locals: { transaction: t, previous_transaction: nil, errors: [], error_row: false, meter1_errors: false })
7
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ xml.Row do
4
+ padding_cells = @dimensions.empty? ? 1 : @dimensions.size
5
+ 1.upto(padding_cells - 1) { |_n| xml.Cell('ss:StyleID' => 'Outer') }
6
+
7
+ @search.fields.each_with_index do |field, i|
8
+ if field == 'time'
9
+ value = (transaction.respond_to?(:completed_at) ? transaction.completed_at : transaction.created_at).localtime.strftime('%Y-%m-%d %H:%M')
10
+ else
11
+ value = if @transaction_fields_map[field.to_sym][:attr_method]
12
+ @transaction_fields_map[field.to_sym][:attr_method].call(transaction)
13
+ else
14
+ transaction.send(field)
15
+ end
16
+ end
17
+
18
+ field_def = @transaction_fields_map[field.to_sym]
19
+
20
+ xml.Cell('ss:Index' => (padding_cells + i).to_s) do
21
+ xml.Data value, 'ss:Type' => 'String'
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ xml.Row do
4
+ padding_cells = @dimensions.empty? ? 1 : @dimensions.size
5
+ 1.upto(padding_cells - 1) { |_n| xml.Cell('ss:StyleID' => 'Outer') }
6
+
7
+ @search.fields.each_with_index do |field, i|
8
+ xml.Cell('ss:Index' => (padding_cells + i).to_s) { xml.Data t(field), 'ss:Type' => 'String' }
9
+ end
10
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ xml.Styles do
4
+ xml.Style 'ss:ID' => 'Default', 'ss:Name' => 'Normal' do
5
+ xml.Alignment 'ss:Vertical' => 'Center'
6
+ xml.Borders
7
+ xml.Font 'ss:FontName' => 'Calibri', 'x:Family' => 'Swiss', 'ss:Size' => '11', 'ss:Color' => '#000000'
8
+ xml.Interior
9
+ xml.NumberFormat
10
+ xml.Protection
11
+ end
12
+ xml.Style 'ss:ID' => 'MainTitle' do
13
+ xml.Alignment 'ss:Horizontal' => 'Center', 'ss:Vertical' => 'Bottom'
14
+ xml.Font 'ss:Size' => '14', 'ss:Bold' => '1'
15
+ end
16
+ xml.Style 'ss:ID' => 'SubTitle' do
17
+ xml.Alignment 'ss:Horizontal' => 'Center', 'ss:Vertical' => 'Bottom'
18
+ xml.Font 'ss:Size' => '12', 'ss:Bold' => '1'
19
+ end
20
+ xml.Style 'ss:ID' => 'Heading' do
21
+ xml.Font 'ss:Bold' => '1'
22
+ xml.Alignment 'ss:Horizontal' => 'Center', 'ss:Vertical' => 'Bottom'
23
+ end
24
+ xml.Style 'ss:ID' => 'DimensionHeading' do
25
+ xml.Font 'ss:Bold' => '1'
26
+ end
27
+ xml.Style 'ss:ID' => 'StandardNumberFormat' do
28
+ xml.NumberFormat 'ss:Format' => 'Standard'
29
+ end
30
+ xml.Style 'ss:ID' => 'ThreeDecimalNumberFormat' do
31
+ xml.NumberFormat 'ss:Format' => '0.000'
32
+ end
33
+ xml.Style 'ss:ID' => 'NoDecimalNumberFormat' do
34
+ xml.NumberFormat 'ss:Format' => "\#,\#\#0"
35
+ end
36
+ xml.Style 'ss:ID' => 'Percent' do
37
+ xml.NumberFormat 'ss:Format' => '0%'
38
+ end
39
+ xml.Style 'ss:ID' => 'Sum' do
40
+ xml.Borders do
41
+ %w[Top Left Right].each do |pos|
42
+ xml.Border 'ss:Position' => pos
43
+ end
44
+ xml.Border 'ss:Position' => 'Bottom', 'ss:Weight' => '1'
45
+ end
46
+ xml.Interior 'ss:Color' => '#dedede', 'ss:Pattern' => 'Solid'
47
+ xml.NumberFormat 'ss:Format' => "\#,\#\#0"
48
+ end
49
+ xml.Style 'ss:ID' => 'Outer' do
50
+ end
51
+ xml.Style 'ss:ID' => 'ShortDate' do
52
+ xml.NumberFormat 'ss:Format' => 'Short Date'
53
+ end
54
+ xml.Style 'ss:ID' => 'NormalDate' do
55
+ xml.NumberFormat 'ss:Format' => 'Long Date'
56
+ end
57
+ xml.Style 'ss:ID' => 'DateOnlyFormat' do
58
+ xml.NumberFormat 'ss:Format' => 'd/m/yyyy;@'
59
+ end
60
+ xml.Style 'ss:ID' => 'TimeOnlyFormat' do
61
+ xml.NumberFormat 'ss:Format' => 'hh:mm;@'
62
+ end
63
+ xml.Style 'ss:ID' => 'LongDate' do
64
+ xml.NumberFormat 'ss:Format' => 'dd/mm/yyyy\\ hh:mm:ss'
65
+ end
66
+ xml.Style 'ss:ID' => 'VerticalCenter' do
67
+ xml.Alignment 'ss:Vertical' => 'Center'
68
+ end
69
+ end