easy_reports 0.0.22 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +21 -21
  3. data/Gemfile +19 -19
  4. data/MIT-LICENSE +20 -20
  5. data/README.md +31 -31
  6. data/Rakefile +10 -10
  7. data/app/assets/javascripts/application.js +10 -10
  8. data/app/assets/javascripts/bootstrap.js +3 -3
  9. data/app/assets/javascripts/easy_reports/application.js +17 -16
  10. data/app/assets/javascripts/easy_reports/database_configs.js +2 -2
  11. data/app/assets/javascripts/easy_reports/reports.js +2 -2
  12. data/app/assets/stylesheets/application.css +8 -8
  13. data/app/assets/stylesheets/easy_reports/application.css +17 -16
  14. data/app/assets/stylesheets/easy_reports/bootstrap_and_overrides.css.less +29 -29
  15. data/app/assets/stylesheets/easy_reports/dashboard/dashboard_content.css +0 -0
  16. data/app/assets/stylesheets/easy_reports/dashboard/sidebar.css +135 -0
  17. data/app/assets/stylesheets/easy_reports/database_configs.css +4 -4
  18. data/app/assets/stylesheets/easy_reports/reports.css +4 -4
  19. data/app/controllers/easy_reports/application_controller.rb +4 -4
  20. data/app/controllers/easy_reports/dashboard_controller.rb +17 -0
  21. data/app/controllers/easy_reports/database_configs_controller.rb +53 -53
  22. data/app/controllers/easy_reports/reports_controller.rb +56 -57
  23. data/app/helpers/easy_reports/application_helper.rb +4 -4
  24. data/app/helpers/easy_reports/database_configs_helper.rb +4 -4
  25. data/app/helpers/easy_reports/reports_helper.rb +4 -4
  26. data/app/models/easy_reports/database_config.rb +4 -4
  27. data/app/models/easy_reports/report.rb +4 -4
  28. data/app/services/easy_reports/database_mediator.rb +36 -18
  29. data/app/views/easy_reports/dashboard/show.html.slim +3 -0
  30. data/app/views/easy_reports/database_configs/_form.html.slim +33 -33
  31. data/app/views/easy_reports/database_configs/edit.html.slim +8 -8
  32. data/app/views/easy_reports/database_configs/index.html.slim +35 -35
  33. data/app/views/easy_reports/database_configs/new.html.slim +5 -5
  34. data/app/views/easy_reports/database_configs/show.html.slim +27 -27
  35. data/app/views/easy_reports/reports/_form.html.slim +17 -15
  36. data/app/views/easy_reports/reports/edit.html.slim +8 -8
  37. data/app/views/easy_reports/reports/index.html.slim +26 -26
  38. data/app/views/easy_reports/reports/new.html.slim +5 -5
  39. data/app/views/easy_reports/reports/show.html.slim +12 -12
  40. data/app/views/layouts/easy_reports/application.html.slim +15 -0
  41. data/app/views/shared/_header.html.slim +60 -0
  42. data/app/views/shared/_sidebar.html.slim +58 -0
  43. data/bin/rails +12 -12
  44. data/config/locales/en.bootstrap.yml +23 -23
  45. data/config/routes.rb +8 -8
  46. data/db/migrate/20141207141745_create_easy_reports_reports.rb +10 -10
  47. data/db/migrate/20141213173509_create_easy_reports_database_configs.rb +16 -16
  48. data/easy_reports.gemspec +36 -35
  49. data/lib/easy_reports.rb +13 -11
  50. data/lib/easy_reports/engine.rb +5 -5
  51. data/lib/easy_reports/version.rb +3 -3
  52. data/lib/tasks/easy_reports_tasks.rake +4 -4
  53. data/test/controllers/easy_reports/database_configs_controller_test.rb +51 -51
  54. data/test/controllers/easy_reports/reports_controller_test.rb +51 -51
  55. data/test/dummy/Gemfile +16 -16
  56. data/test/dummy/Gemfile.lock +129 -129
  57. data/test/dummy/Rakefile +6 -6
  58. data/test/dummy/app/assets/javascripts/application.js +13 -13
  59. data/test/dummy/app/assets/javascripts/bootstrap.js +4 -4
  60. data/test/dummy/app/assets/stylesheets/application.css +15 -15
  61. data/test/dummy/app/assets/stylesheets/bootstrap_and_overrides.css.less +29 -29
  62. data/test/dummy/app/controllers/application_controller.rb +5 -5
  63. data/test/dummy/app/helpers/application_helper.rb +2 -2
  64. data/test/dummy/app/views/layouts/application.html.erb +14 -14
  65. data/test/dummy/bin/bundle +3 -3
  66. data/test/dummy/bin/rails +4 -4
  67. data/test/dummy/bin/rake +4 -4
  68. data/test/dummy/config.ru +4 -4
  69. data/test/dummy/config/application.rb +23 -23
  70. data/test/dummy/config/boot.rb +5 -5
  71. data/test/dummy/config/database.yml +25 -25
  72. data/test/dummy/config/environment.rb +5 -5
  73. data/test/dummy/config/environments/development.rb +37 -37
  74. data/test/dummy/config/environments/production.rb +82 -82
  75. data/test/dummy/config/environments/test.rb +39 -39
  76. data/test/dummy/config/initializers/assets.rb +8 -8
  77. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -7
  78. data/test/dummy/config/initializers/cookies_serializer.rb +2 -2
  79. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -4
  80. data/test/dummy/config/initializers/inflections.rb +16 -16
  81. data/test/dummy/config/initializers/mime_types.rb +4 -4
  82. data/test/dummy/config/initializers/session_store.rb +3 -3
  83. data/test/dummy/config/initializers/wrap_parameters.rb +14 -14
  84. data/test/dummy/config/locales/en.bootstrap.yml +23 -23
  85. data/test/dummy/config/locales/en.yml +23 -23
  86. data/test/dummy/config/routes.rb +4 -4
  87. data/test/dummy/config/secrets.yml +22 -22
  88. data/test/dummy/db/migrate/20141214161417_create_easy_reports_reports.easy_reports.rb +11 -11
  89. data/test/dummy/db/migrate/20141214161418_create_easy_reports_database_configs.easy_reports.rb +17 -17
  90. data/test/dummy/public/404.html +67 -67
  91. data/test/dummy/public/422.html +67 -67
  92. data/test/dummy/public/500.html +66 -66
  93. data/test/fixtures/easy_reports/database_configs.yml +19 -19
  94. data/test/fixtures/easy_reports/reports.yml +9 -9
  95. data/test/helpers/easy_reports/database_configs_helper_test.rb +6 -6
  96. data/test/helpers/easy_reports/reports_helper_test.rb +6 -6
  97. data/test/models/easy_reports/database_config_test.rb +9 -9
  98. data/test/models/easy_reports/report_test.rb +9 -9
  99. metadata +24 -5
  100. data/app/assets/stylesheets/scaffold.css +0 -56
  101. data/app/views/layouts/easy_reports/application.html.erb +0 -14
@@ -1,4 +1,4 @@
1
- /*
2
- Place all the styles related to the matching controller here.
3
- They will automatically be included in application.css.
4
- */
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -1,4 +1,4 @@
1
- /*
2
- Place all the styles related to the matching controller here.
3
- They will automatically be included in application.css.
4
- */
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -1,4 +1,4 @@
1
- module EasyReports
2
- class ApplicationController < ActionController::Base
3
- end
4
- end
1
+ module EasyReports
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,17 @@
1
+ require_dependency "easy_reports/application_controller"
2
+
3
+ module EasyReports
4
+ class DashboardController < ApplicationController
5
+
6
+ def show
7
+ load_dashboard
8
+ end
9
+
10
+ private
11
+
12
+ def load_dashboard
13
+
14
+ end
15
+ end
16
+ end
17
+
@@ -1,53 +1,53 @@
1
- require_dependency "easy_reports/application_controller"
2
-
3
- module EasyReports
4
- class DatabaseConfigsController < ApplicationController
5
- before_action :set_database_config, only: [:show, :edit, :update, :destroy]
6
-
7
- def index
8
- @database_configs = DatabaseConfig.all
9
- end
10
-
11
- def show
12
- end
13
-
14
- def new
15
- @database_config = DatabaseConfig.new
16
- end
17
-
18
- def edit
19
- end
20
-
21
- def create
22
- @database_config = DatabaseConfig.new(database_config_params)
23
-
24
- if @database_config.save
25
- redirect_to @database_config, notice: 'Database config was successfully created.'
26
- else
27
- render :new
28
- end
29
- end
30
-
31
- def update
32
- if @database_config.update(database_config_params)
33
- redirect_to @database_config, notice: 'Database config was successfully updated.'
34
- else
35
- render :edit
36
- end
37
- end
38
-
39
- def destroy
40
- @database_config.destroy
41
- redirect_to database_configs_url, notice: 'Database config was successfully destroyed.'
42
- end
43
-
44
- private
45
- def set_database_config
46
- @database_config = DatabaseConfig.find(params[:id])
47
- end
48
-
49
- def database_config_params
50
- params.require(:database_config).permit(:adapter, :encoding, :pool, :username, :password, :host, :database_name, :port)
51
- end
52
- end
53
- end
1
+ require_dependency "easy_reports/application_controller"
2
+
3
+ module EasyReports
4
+ class DatabaseConfigsController < ApplicationController
5
+ before_action :set_database_config, only: [:show, :edit, :update, :destroy]
6
+
7
+ def index
8
+ @database_configs = DatabaseConfig.all
9
+ end
10
+
11
+ def show
12
+ end
13
+
14
+ def new
15
+ @database_config = DatabaseConfig.new
16
+ end
17
+
18
+ def edit
19
+ end
20
+
21
+ def create
22
+ @database_config = DatabaseConfig.new(database_config_params)
23
+
24
+ if @database_config.save
25
+ redirect_to @database_config, notice: 'Database config was successfully created.'
26
+ else
27
+ render :new
28
+ end
29
+ end
30
+
31
+ def update
32
+ if @database_config.update(database_config_params)
33
+ redirect_to @database_config, notice: 'Database config was successfully updated.'
34
+ else
35
+ render :edit
36
+ end
37
+ end
38
+
39
+ def destroy
40
+ @database_config.destroy
41
+ redirect_to database_configs_url, notice: 'Database config was successfully destroyed.'
42
+ end
43
+
44
+ private
45
+ def set_database_config
46
+ @database_config = DatabaseConfig.find(params[:id])
47
+ end
48
+
49
+ def database_config_params
50
+ params.require(:database_config).permit(:adapter, :encoding, :pool, :username, :password, :host, :database_name, :port)
51
+ end
52
+ end
53
+ end
@@ -1,57 +1,56 @@
1
- require_dependency "easy_reports/application_controller"
2
-
3
- module EasyReports
4
- class ReportsController < ApplicationController
5
- before_action :set_report, only: [:show, :edit, :update, :destroy]
6
-
7
- def index
8
- @reports = Report.all
9
-
10
- # TODO: remove into service
11
- database_mediator = EasyReports::DatabaseMediator.new
12
- @table_list = database_mediator.tables
13
- end
14
-
15
- def show
16
- end
17
-
18
- def new
19
- @report = Report.new
20
- end
21
-
22
- def edit
23
- end
24
-
25
- def create
26
- @report = Report.new(report_params)
27
-
28
- if @report.save
29
- redirect_to @report, notice: 'Report was successfully created.'
30
- else
31
- render :new
32
- end
33
- end
34
-
35
- def update
36
- if @report.update(report_params)
37
- redirect_to @report, notice: 'Report was successfully updated.'
38
- else
39
- render :edit
40
- end
41
- end
42
-
43
- def destroy
44
- @report.destroy
45
- redirect_to reports_url, notice: 'Report was successfully destroyed.'
46
- end
47
-
48
- private
49
- def set_report
50
- @report = Report.find(params[:id])
51
- end
52
-
53
- def report_params
54
- params.require(:report).permit(:title, :description)
55
- end
56
- end
57
- end
1
+ require_dependency "easy_reports/application_controller"
2
+
3
+ module EasyReports
4
+ class ReportsController < ApplicationController
5
+ before_action :set_report, only: [:show, :edit, :update, :destroy]
6
+
7
+ def index
8
+ @reports = Report.all
9
+
10
+ database_mediator = EasyReports::DatabaseMediator.new
11
+ @table_list = database_mediator.tables
12
+ end
13
+
14
+ def show
15
+ end
16
+
17
+ def new
18
+ @report = Report.new
19
+ end
20
+
21
+ def edit
22
+ end
23
+
24
+ def create
25
+ @report = Report.new(report_params)
26
+
27
+ if @report.save
28
+ redirect_to @report, notice: 'Report was successfully created.'
29
+ else
30
+ render :new
31
+ end
32
+ end
33
+
34
+ def update
35
+ if @report.update(report_params)
36
+ redirect_to @report, notice: 'Report was successfully updated.'
37
+ else
38
+ render :edit
39
+ end
40
+ end
41
+
42
+ def destroy
43
+ @report.destroy
44
+ redirect_to reports_url, notice: 'Report was successfully destroyed.'
45
+ end
46
+
47
+ private
48
+ def set_report
49
+ @report = Report.find(params[:id])
50
+ end
51
+
52
+ def report_params
53
+ params.require(:report).permit(:title, :description)
54
+ end
55
+ end
56
+ end
@@ -1,4 +1,4 @@
1
- module EasyReports
2
- module ApplicationHelper
3
- end
4
- end
1
+ module EasyReports
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -1,4 +1,4 @@
1
- module EasyReports
2
- module DatabaseConfigsHelper
3
- end
4
- end
1
+ module EasyReports
2
+ module DatabaseConfigsHelper
3
+ end
4
+ end
@@ -1,4 +1,4 @@
1
- module EasyReports
2
- module ReportsHelper
3
- end
4
- end
1
+ module EasyReports
2
+ module ReportsHelper
3
+ end
4
+ end
@@ -1,4 +1,4 @@
1
- module EasyReports
2
- class DatabaseConfig < ActiveRecord::Base
3
- end
4
- end
1
+ module EasyReports
2
+ class DatabaseConfig < ActiveRecord::Base
3
+ end
4
+ end
@@ -1,4 +1,4 @@
1
- module EasyReports
2
- class Report < ActiveRecord::Base
3
- end
4
- end
1
+ module EasyReports
2
+ class Report < ActiveRecord::Base
3
+ end
4
+ end
@@ -1,18 +1,36 @@
1
- module EasyReports
2
- class DatabaseMediator
3
-
4
- attr_reader :db
5
-
6
- def initialize
7
- db_config = EasyReports::DatabaseConfig.last
8
-
9
- @db = ::Sequel.connect(
10
- "#{db_config.adapter}://#{db_config.username}:#{db_config.password}@#{db_config.host}:#{db_config.port}/#{db_config.database_name}",
11
- :max_connections => db_config.pool, :logger => Logger.new('log/db.log'))
12
- end
13
-
14
- def tables
15
- db.tables
16
- end
17
- end
18
- end
1
+ module EasyReports
2
+ class DatabaseMediator
3
+ class DatabaseNotFoundError < StandardError; end
4
+
5
+ attr_reader :db, :db_config
6
+
7
+ delegate :adapter, :username, :password, :host, :port, :database_name,
8
+ to: :db_config
9
+
10
+ def initialize
11
+ @db_config = load_database_config
12
+ @db = establish_connection
13
+ rescue => e
14
+ Rails.logger.info "#{e.message}"
15
+ raise DatabaseNotFoundError
16
+ end
17
+
18
+ def tables
19
+ db.tables
20
+ end
21
+
22
+ private
23
+
24
+ def load_database_config
25
+ EasyReports::DatabaseConfig.find(params[:db_id])
26
+ end
27
+
28
+ def establish_connection
29
+ ::Sequel.connect(
30
+ "#{adapter}://#{username}:#{password}@#{host}:#{port}/#{database_name}",
31
+ :max_connections => db_config.pool,
32
+ :logger => Logger.new('log/db.log'))
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ .col-lg-12
2
+ h1.page-header Dashboard
3
+
@@ -1,33 +1,33 @@
1
- = form_for @database_config do |f|
2
- - if @database_config.errors.any?
3
- #error_explanation
4
- h2 = "#{pluralize(@database_config.errors.count, "error")} prohibited this database_config from being saved:"
5
- ul
6
- - @database_config.errors.full_messages.each do |message|
7
- li = message
8
-
9
- .field
10
- = f.label :adapter
11
- = f.text_field :adapter
12
- .field
13
- = f.label :encoding
14
- = f.text_field :encoding
15
- .field
16
- = f.label :pool
17
- = f.text_field :pool
18
- .field
19
- = f.label :username
20
- = f.text_field :username
21
- .field
22
- = f.label :password
23
- = f.text_field :password
24
- .field
25
- = f.label :host
26
- = f.text_field :host
27
- .field
28
- = f.label :port
29
- = f.text_field :port
30
- .field
31
- = f.label :database_name
32
- = f.text_field :database_name
33
- .actions = f.submit 'Save'
1
+ = form_for @database_config do |f|
2
+ - if @database_config.errors.any?
3
+ #error_explanation
4
+ h2 = "#{pluralize(@database_config.errors.count, "error")} prohibited this database_config from being saved:"
5
+ ul
6
+ - @database_config.errors.full_messages.each do |message|
7
+ li = message
8
+
9
+ .field
10
+ = f.label :adapter
11
+ = f.text_field :adapter
12
+ .field
13
+ = f.label :encoding
14
+ = f.text_field :encoding
15
+ .field
16
+ = f.label :pool
17
+ = f.text_field :pool
18
+ .field
19
+ = f.label :username
20
+ = f.text_field :username
21
+ .field
22
+ = f.label :password
23
+ = f.text_field :password
24
+ .field
25
+ = f.label :host
26
+ = f.text_field :host
27
+ .field
28
+ = f.label :port
29
+ = f.text_field :port
30
+ .field
31
+ = f.label :database_name
32
+ = f.text_field :database_name
33
+ .actions = f.submit 'Save'