easy_reports 0.0.25 → 0.0.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/easy_reports/dashboard/dashboard_content.css +2 -13
- data/app/controllers/easy_reports/databases_controller.rb +53 -0
- data/app/controllers/easy_reports/reports_controller.rb +11 -10
- data/app/forms/easy_reports/report_form.rb +22 -0
- data/app/helpers/easy_reports/databases_helper.rb +4 -0
- data/app/models/easy_reports/database.rb +11 -0
- data/app/models/easy_reports/report.rb +2 -0
- data/app/services/easy_reports/database_mediator.rb +11 -12
- data/app/views/easy_reports/dashboard/show.html.slim +8 -8
- data/app/views/easy_reports/{database_configs → databases}/_form.html.slim +6 -6
- data/app/views/easy_reports/databases/edit.html.slim +8 -0
- data/app/views/easy_reports/databases/index.html.slim +35 -0
- data/app/views/easy_reports/databases/new.html.slim +5 -0
- data/app/views/easy_reports/databases/show.html.slim +27 -0
- data/app/views/easy_reports/reports/_form.html.slim +15 -13
- data/app/views/layouts/easy_reports/application.html.slim +2 -2
- data/app/views/shared/_header.html.slim +3 -20
- data/config/initializers/simple_form.rb +145 -0
- data/config/initializers/simple_form_bootstrap.rb +45 -0
- data/config/locales/simple_form.en.yml +26 -0
- data/config/routes.rb +2 -2
- data/db/migrate/{20141213173509_create_easy_reports_database_configs.rb → 20141213173509_create_easy_reports_databases.rb} +3 -3
- data/db/migrate/20150131195101_add_config_id_to_reports.rb +5 -0
- data/easy_reports.gemspec +9 -5
- data/lib/easy_reports.rb +8 -5
- data/lib/easy_reports/version.rb +1 -1
- data/lib/templates/erb/scaffold/_form.html.erb +13 -0
- data/test/dummy/Gemfile.lock +5 -1
- data/test/dummy/db/migrate/{20141214161417_create_easy_reports_reports.easy_reports.rb → 20150131203555_create_easy_reports_reports.easy_reports.rb} +1 -1
- data/test/dummy/db/migrate/{20141214161418_create_easy_reports_database_configs.easy_reports.rb → 20150131203556_create_easy_reports_databases.easy_reports.rb} +4 -4
- data/test/dummy/db/migrate/20150131203557_add_config_id_to_reports.easy_reports.rb +6 -0
- data/test/dummy/db/schema.rb +4 -3
- metadata +58 -26
- data/app/assets/stylesheets/easy_reports/dashboard/sidebar.css +0 -10
- data/app/controllers/easy_reports/database_configs_controller.rb +0 -53
- data/app/helpers/easy_reports/database_configs_helper.rb +0 -4
- data/app/models/easy_reports/database_config.rb +0 -4
- data/app/views/easy_reports/database_configs/edit.html.slim +0 -8
- data/app/views/easy_reports/database_configs/index.html.slim +0 -35
- data/app/views/easy_reports/database_configs/new.html.slim +0 -5
- data/app/views/easy_reports/database_configs/show.html.slim +0 -27
- data/app/views/shared/_sidebar.html.slim +0 -90
- data/test/controllers/easy_reports/database_configs_controller_test.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 746d45a01ec80bcf9507b683b27cb6211be5d688
|
4
|
+
data.tar.gz: 13c690001188fa46cf8153f4d0f48a7aa5812f9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e5bc837d0399f510324485ad5e83ee39fa982452d0e2ab474770c82c27d59c5f9b8269d3621af1e712cee6ec92d0d1fb47be3e63a1838b5e8a750fedd6e90c8
|
7
|
+
data.tar.gz: 36263b604e022d66262232ac81ff1e5cea544fe2cbc4f46ebbda132e2b8a913811a277ce96925ed34e02e29701fa06deaae63df8b2371d3cb54e855647a6e4bc
|
@@ -1,9 +1,3 @@
|
|
1
|
-
/*!
|
2
|
-
* Start Bootstrap - SB Admin 2 Bootstrap Admin Theme (http://startbootstrap.com)
|
3
|
-
* Code licensed under the Apache License v2.0.
|
4
|
-
* For details, see http://www.apache.org/licenses/LICENSE-2.0.
|
5
|
-
*/
|
6
|
-
|
7
1
|
body {
|
8
2
|
background-color: #f8f8f8;
|
9
3
|
}
|
@@ -18,13 +12,8 @@ body {
|
|
18
12
|
background-color: #fff;
|
19
13
|
}
|
20
14
|
|
21
|
-
|
22
|
-
|
23
|
-
position: inherit;
|
24
|
-
margin: 0 0 0 250px;
|
25
|
-
padding: 0 30px;
|
26
|
-
border-left: 1px solid #e7e7e7;
|
27
|
-
}
|
15
|
+
.navbar.navbar-default {
|
16
|
+
margin-bottom: 0;
|
28
17
|
}
|
29
18
|
|
30
19
|
.navbar-top-links {
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require_dependency "easy_reports/application_controller"
|
2
|
+
|
3
|
+
module EasyReports
|
4
|
+
class DatabasesController < ApplicationController
|
5
|
+
before_action :set_database, only: [:show, :edit, :update, :destroy]
|
6
|
+
|
7
|
+
def index
|
8
|
+
@databases = Database.all
|
9
|
+
end
|
10
|
+
|
11
|
+
def show
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
@database = Database.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def edit
|
19
|
+
end
|
20
|
+
|
21
|
+
def create
|
22
|
+
@database = Database.new(database_params)
|
23
|
+
|
24
|
+
if @database.save
|
25
|
+
redirect_to @database, notice: 'Database was successfully created.'
|
26
|
+
else
|
27
|
+
render :new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def update
|
32
|
+
if @database.update(database_params)
|
33
|
+
redirect_to @database, notice: 'Database was successfully updated.'
|
34
|
+
else
|
35
|
+
render :edit
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy
|
40
|
+
@database.destroy
|
41
|
+
redirect_to databases_url, notice: 'Database was successfully destroyed.'
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def set_database
|
46
|
+
@database = Database.find(params[:id])
|
47
|
+
end
|
48
|
+
|
49
|
+
def database_params
|
50
|
+
params.require(:database).permit(:adapter, :encoding, :pool, :username, :password, :host, :name, :port)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -11,26 +11,27 @@ module EasyReports
|
|
11
11
|
@table_list = database_mediator.tables
|
12
12
|
end
|
13
13
|
|
14
|
-
def show
|
15
|
-
end
|
16
|
-
|
17
14
|
def new
|
18
|
-
@
|
19
|
-
end
|
20
|
-
|
21
|
-
def edit
|
15
|
+
@report_form = ReportForm.new
|
22
16
|
end
|
23
17
|
|
24
18
|
def create
|
25
|
-
@
|
19
|
+
@report_form = ReportForm.new(report_params)
|
26
20
|
|
27
|
-
if @
|
28
|
-
redirect_to @
|
21
|
+
if @report_form.save
|
22
|
+
redirect_to @report_form, notice: 'Report was successfully created.'
|
29
23
|
else
|
30
24
|
render :new
|
31
25
|
end
|
32
26
|
end
|
33
27
|
|
28
|
+
|
29
|
+
def show
|
30
|
+
end
|
31
|
+
|
32
|
+
def edit
|
33
|
+
end
|
34
|
+
|
34
35
|
def update
|
35
36
|
if @report.update(report_params)
|
36
37
|
redirect_to @report, notice: 'Report was successfully updated.'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module EasyReports
|
2
|
+
class ReportForm
|
3
|
+
include ActiveModel::Model
|
4
|
+
|
5
|
+
attr_accessor :report
|
6
|
+
|
7
|
+
delegate :database,
|
8
|
+
:title,
|
9
|
+
:description,
|
10
|
+
to: :report
|
11
|
+
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@report = Report.new
|
15
|
+
# @mediator = EasyReports::DatabaseMediator.new(params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def database_list
|
19
|
+
EasyReports::Database.all
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -2,35 +2,34 @@ module EasyReports
|
|
2
2
|
class DatabaseMediator
|
3
3
|
class DatabaseNotFoundError < StandardError; end
|
4
4
|
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :connection, :db
|
6
6
|
|
7
|
-
delegate :adapter, :username, :password, :host, :port, :
|
8
|
-
|
7
|
+
delegate :adapter, :username, :password, :host, :port, :name,
|
8
|
+
to: :db
|
9
9
|
|
10
|
-
def initialize
|
11
|
-
@
|
12
|
-
@
|
10
|
+
def initialize(database_id)
|
11
|
+
@db = set_database(database_id)
|
12
|
+
@connection = establish_connection
|
13
13
|
rescue => e
|
14
14
|
Rails.logger.info "#{e.message}"
|
15
15
|
raise DatabaseNotFoundError
|
16
16
|
end
|
17
17
|
|
18
18
|
def tables
|
19
|
-
|
19
|
+
connection.tables
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
|
-
def
|
25
|
-
EasyReports::
|
24
|
+
def set_database(id)
|
25
|
+
EasyReports::Database.find(id)
|
26
26
|
end
|
27
27
|
|
28
28
|
def establish_connection
|
29
29
|
::Sequel.connect(
|
30
|
-
"#{adapter}://#{username}:#{password}@#{host}:#{port}/#{
|
31
|
-
:max_connections =>
|
30
|
+
"#{adapter}://#{username}:#{password}@#{host}:#{port}/#{name}",
|
31
|
+
:max_connections => db.pool,
|
32
32
|
:logger => Logger.new('log/db.log'))
|
33
33
|
end
|
34
|
-
|
35
34
|
end
|
36
35
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#page-wrapper style=("min-height: 200px;")
|
1
|
+
#page-wrapper style=("min-height: 200px;")
|
2
2
|
.row
|
3
3
|
.col-lg-12
|
4
4
|
h1.page-header Dashboard
|
@@ -13,13 +13,13 @@
|
|
13
13
|
i.fa.fa-comments.fa-5x
|
14
14
|
.col-xs-9.text-right
|
15
15
|
.huge 26
|
16
|
-
div
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
div View Reports
|
17
|
+
= link_to new_report_path do
|
18
|
+
.panel-footer
|
19
|
+
span.pull-left Create report
|
20
|
+
span.pull-right
|
21
|
+
i.fa.fa-arrow-circle-right
|
22
|
+
.clearfix
|
23
23
|
.col-lg-3.col-md-6
|
24
24
|
.panel.panel-green
|
25
25
|
.panel-heading
|
@@ -1,9 +1,9 @@
|
|
1
|
-
= form_for @
|
2
|
-
- if @
|
1
|
+
= form_for @database do |f|
|
2
|
+
- if @database.errors.any?
|
3
3
|
#error_explanation
|
4
|
-
h2 = "#{pluralize(@
|
4
|
+
h2 = "#{pluralize(@database.errors.count, "error")} prohibited this database from being saved:"
|
5
5
|
ul
|
6
|
-
- @
|
6
|
+
- @database.errors.full_messages.each do |message|
|
7
7
|
li = message
|
8
8
|
|
9
9
|
.field
|
@@ -28,6 +28,6 @@
|
|
28
28
|
= f.label :port
|
29
29
|
= f.text_field :port
|
30
30
|
.field
|
31
|
-
= f.label :
|
32
|
-
= f.text_field :
|
31
|
+
= f.label :name
|
32
|
+
= f.text_field :name
|
33
33
|
.actions = f.submit 'Save'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
h1 Listing databases
|
2
|
+
|
3
|
+
table
|
4
|
+
thead
|
5
|
+
tr
|
6
|
+
th Adapter
|
7
|
+
th Encoding
|
8
|
+
th Pool
|
9
|
+
th Username
|
10
|
+
th Password
|
11
|
+
th Host
|
12
|
+
th Port
|
13
|
+
th Name
|
14
|
+
th
|
15
|
+
th
|
16
|
+
th
|
17
|
+
|
18
|
+
tbody
|
19
|
+
- @databases.each do |database|
|
20
|
+
tr
|
21
|
+
td = database.adapter
|
22
|
+
td = database.encoding
|
23
|
+
td = database.pool
|
24
|
+
td = database.username
|
25
|
+
td = database.password
|
26
|
+
td = database.host
|
27
|
+
td = database.port
|
28
|
+
td = database.name
|
29
|
+
td = link_to 'Show', database
|
30
|
+
td = link_to 'Edit', edit_database_path(database)
|
31
|
+
td = link_to 'Destroy', database, data: {:confirm => 'Are you sure?'}, :method => :delete
|
32
|
+
|
33
|
+
br
|
34
|
+
|
35
|
+
= link_to 'New Database config', new_database_path
|
@@ -0,0 +1,27 @@
|
|
1
|
+
p#notice = notice
|
2
|
+
|
3
|
+
p
|
4
|
+
strong Adapter:
|
5
|
+
= @database.adapter
|
6
|
+
p
|
7
|
+
strong Encoding:
|
8
|
+
= @database.encoding
|
9
|
+
p
|
10
|
+
strong Pool:
|
11
|
+
= @database.pool
|
12
|
+
p
|
13
|
+
strong Username:
|
14
|
+
= @database.username
|
15
|
+
p
|
16
|
+
strong Password:
|
17
|
+
= @database.password
|
18
|
+
p
|
19
|
+
strong Host:
|
20
|
+
= @database.host
|
21
|
+
p
|
22
|
+
strong Database:
|
23
|
+
= @database.name
|
24
|
+
|
25
|
+
= link_to 'Edit', edit_database_path(@database)
|
26
|
+
'|
|
27
|
+
= link_to 'Back', databases_path
|
@@ -1,17 +1,19 @@
|
|
1
|
-
=
|
2
|
-
- if @
|
1
|
+
= simple_form_for @report_form, url: reports_path, html: { multipart: true } do |f|
|
2
|
+
- if @report_form.errors.any?
|
3
3
|
#error_explanation
|
4
|
-
h2 = "#{pluralize(@
|
4
|
+
h2 = "#{pluralize(@report_form.errors.count, "error")} prohibited this report from being saved:"
|
5
5
|
ul
|
6
|
-
- @
|
6
|
+
- @report_form.errors.full_messages.each do |message|
|
7
7
|
li = message
|
8
8
|
|
9
|
-
.
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
= f.label
|
16
|
-
= f.
|
17
|
-
|
9
|
+
.form-inputs
|
10
|
+
/* = f.association :database, label: 'database config', input_html: { class: 'selectpicker' } */
|
11
|
+
= f.simple_fields_for :database, @report_form.database do |f_database|
|
12
|
+
= f_database.input :name, as: :select, collection: @report_form.database_list, label: 'Database config', input_html: { class: 'selectpicker' }
|
13
|
+
= f_database.input :name, as: :select, collection: @report_form.database_list, label: 'Database config', input_html: { class: 'selectpicker' }
|
14
|
+
/* = f.input :table_ids, label: 'table list', input_html: { class: 'selectpicker' } */
|
15
|
+
= f.input :title, label: 'title'
|
16
|
+
= f.input :description, as: :text, label: 'description'
|
17
|
+
|
18
|
+
.actions
|
19
|
+
= f.button :submit
|
@@ -2,21 +2,11 @@ nav.navbar.navbar-default
|
|
2
2
|
.container-fluid
|
3
3
|
/! Brand and toggle get grouped for better mobile display
|
4
4
|
.navbar-header
|
5
|
-
|
6
|
-
|
7
|
-
span.icon-bar
|
8
|
-
span.icon-bar
|
9
|
-
span.icon-bar
|
10
|
-
a.navbar-brand href="#" Easy Reports
|
5
|
+
= link_to 'Easy Reports', root_path, class: 'navbar-brand'
|
6
|
+
|
11
7
|
/! Collect the nav links, forms, and other content for toggling
|
12
|
-
#
|
8
|
+
#easy_reports_navbat.collapse.navbar-collapse
|
13
9
|
ul.nav.navbar-nav
|
14
|
-
li.active
|
15
|
-
a href="#"
|
16
|
-
| Link
|
17
|
-
span.sr-only (current)
|
18
|
-
li
|
19
|
-
a href="#" Link
|
20
10
|
li.dropdown
|
21
11
|
a.dropdown-toggle aria-expanded="false" data-toggle="dropdown" href="#" role="button"
|
22
12
|
| Dropdown
|
@@ -34,10 +24,6 @@ nav.navbar.navbar-default
|
|
34
24
|
li.divider
|
35
25
|
li
|
36
26
|
a href="#" One more separated link
|
37
|
-
form.navbar-form.navbar-left role="search"
|
38
|
-
.form-group
|
39
|
-
input.form-control placeholder="Search" type="text" /
|
40
|
-
button.btn.btn-default type="submit" Submit
|
41
27
|
ul.nav.navbar-nav.navbar-right
|
42
28
|
li
|
43
29
|
a href="#" Link
|
@@ -55,6 +41,3 @@ nav.navbar.navbar-default
|
|
55
41
|
li.divider
|
56
42
|
li
|
57
43
|
a href="#" Separated link
|
58
|
-
/! /.navbar-collapse
|
59
|
-
/! /.container-fluid
|
60
|
-
|