rails_admin_mydash 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 839d3ed157454dbdd9f5a5a0688a0c4749ba3eeb
4
- data.tar.gz: 59d0dde27c0e3bb9545cfc1aa014b4198a1915f8
3
+ metadata.gz: b67b99bbf01affa133bba7810b3acf636cf4bd31
4
+ data.tar.gz: a6a54c5e092385610db8b80e610f5d7d8b59617f
5
5
  SHA512:
6
- metadata.gz: 2ef35867dcaea3ac2e49461a72ad708d23b03af08bd22592819a619e396d0a12c3a1cb3a230f0b504d8c9e15b3673e3e1f33af032a311d048d6b3becad23b1e4
7
- data.tar.gz: f80438352e1a0ced6fed4d0df0436f9b32cab8b2fb4914bd18d44438a2ca2cfd834b92122be78956d61c37ae3e13fce4f1539999f787e123a3931b1a4f6a4a9f
6
+ metadata.gz: 919e091bf8e8e5cddc4eb636ae0ef4b1837a4e6043dcc9c5433b8353ca84f55b748ba246dac749c2bf2bdeae23f7b857e5ab0895a17a2208ab2fb752cdcb5214
7
+ data.tar.gz: 06012d90886d783d6a0e7ae24411849063c74d9a5a82691667508caba30242430c7e24b9de60441506448a133cba5f13b933fa2c1158c1531baf324e43a6d593
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # RailsAdminMydash [![Gem Version](https://badge.fury.io/rb/rails_admin_mydash.svg)](https://badge.fury.io/rb/rails_admin_mydash)
2
2
 
3
- A rails_admin alternative dashboard.
3
+ A rails_admin alternative dashboard. It overrides the default dashboard component.
4
4
 
5
5
  Features:
6
6
 
@@ -8,13 +8,15 @@ Features:
8
8
 
9
9
  - show optionally admin notices (to show informations to the users)
10
10
 
11
- - auditing / history table
11
+ - show auditing / history table if enabled
12
12
 
13
- - disabled default progress bars with statistics (minor performance improvement)
13
+ - hid breadcrump and nav tabs on the dashboard
14
+
15
+ - disable counters progress bars (minor performance improvement)
14
16
 
15
17
  ## Installation
16
18
 
17
- - Add the gem to Gemfile (after *rails_admin* gem): `gem 'rails_admin_mydash'`
19
+ - Add the gem to Gemfile (**after** rails_admin gem): `gem 'rails_admin_mydash'`
18
20
 
19
21
  - Execute `bundle`
20
22
 
@@ -37,6 +39,14 @@ end
37
39
 
38
40
  - Add some messages: `AdminNotice.new( message: 'Just a test', published: true ).save`
39
41
 
42
+ ## Options
43
+
44
+ - *admin_notices* [String]: model to use to show admin messages
45
+
46
+ - *last_records* [Integer]: number of records to show per model
47
+
48
+ - *models* [String array]: list of models to show (es. `['Category', 'Post', 'Tag']`)
49
+
40
50
  ## Notes
41
51
 
42
52
  - For each record to show a *name* field or method is used
@@ -1,43 +1,47 @@
1
- - if @admin_notices
2
- %div.panel.panel-info
3
- %div.panel-heading
4
- %h3.panel-title= t 'admin.dashboard.notices'
5
- / %div.panel-body
6
- %table.table
7
- - @admin_notices.each do |notice|
8
- %tr
9
- %td= notice.message
10
-
11
- - if @abstract_models
12
- %table.table.table-condensed.table-striped.dashboard-table
13
- %thead
14
- %tr
15
- %th.shrink.model-name= t 'admin.table_headers.model_name'
16
- %th.shrink.records= t 'admin.table_headers.records'
17
- %th.last-records= t 'admin.table_headers.last_records'
18
- %th.shrink.controls
19
- %tbody
20
- - @abstract_models.each do |abstract_model|
21
- - if authorized? :index, abstract_model
22
- - index_path = index_path(model_name: abstract_model.to_param)
23
- - row_class = "#{cycle("odd", "even")}#{" link" if index_path} #{abstract_model.param_key}_links"
24
- %tr{class: row_class, :"data-link" => index_path}
25
- %td.c1
26
- %span.show= link_to capitalize_first_letter(abstract_model.config.label_plural), index_path, class: 'pjax'
27
- %td.c2
28
- - if @count[abstract_model.model.name]
29
- = @count[abstract_model.model.name]
30
- %td.c3
31
- - if @last_rows[abstract_model.model.name]
32
- %div.last-records-list
33
- - @last_rows[abstract_model.model.name].each do |row|
34
- - if row.respond_to?( :name ) && ( show_action = action(:show, abstract_model, row) )
35
- %div.last-records-item= link_to(row.name, url_for(action: show_action.action_name, model_name: abstract_model.to_param, id: row.id), class: 'pjax')
36
- %td.c4.links
37
- %ul.inline.list-inline= menu_for :collection, abstract_model, nil, true
1
+ :css
2
+ .content > .breadcrumb { display: none; }
3
+ .content > .nav-tabs { display: none; }
4
+ td.c2 { text-align: center; }
38
5
 
39
- - if @auditing_adapter && authorized?(:history_index)
40
- #block-tables.block
41
- .content
42
- %h2= t("admin.actions.history_index.menu")
43
- = render partial: 'mydashboard_history'
6
+ %div#mydash
7
+ - if @admin_notices
8
+ %div.panel.panel-info
9
+ %div.panel-heading
10
+ %h3.panel-title= t 'admin.dashboard.notices'
11
+ / %div.panel-body
12
+ %table.table
13
+ - @admin_notices.each do |notice|
14
+ %tr
15
+ %td= notice.message
16
+ - if @abstract_models
17
+ %table.table.table-condensed.table-striped.dashboard-table
18
+ %thead
19
+ %tr
20
+ %th.shrink.model-name= t 'admin.table_headers.model_name'
21
+ %th.shrink.records= t 'admin.table_headers.records'
22
+ %th.last-records= t 'admin.table_headers.last_records'
23
+ %th.shrink.controls
24
+ %tbody
25
+ - @abstract_models.each do |abstract_model|
26
+ - if authorized? :index, abstract_model
27
+ - index_path = index_path(model_name: abstract_model.to_param)
28
+ - row_class = "#{cycle("odd", "even")}#{" link" if index_path} #{abstract_model.param_key}_links"
29
+ %tr{class: row_class, :"data-link" => index_path}
30
+ %td.c1
31
+ %span.show= link_to capitalize_first_letter(abstract_model.config.label_plural), index_path, class: 'pjax'
32
+ %td.c2
33
+ - if @count[abstract_model.model.name]
34
+ = @count[abstract_model.model.name]
35
+ %td.c3
36
+ - if @last_rows[abstract_model.model.name]
37
+ %div.last-records-list
38
+ - @last_rows[abstract_model.model.name].each do |row|
39
+ - if row.respond_to?( :name ) && ( show_action = action(:show, abstract_model, row) )
40
+ %div.last-records-item= link_to(row.name, url_for(action: show_action.action_name, model_name: abstract_model.to_param, id: row.id), class: 'pjax')
41
+ %td.c4.links
42
+ %ul.inline.list-inline= menu_for :collection, abstract_model, nil, true
43
+ - if @auditing_adapter && authorized?(:history_index)
44
+ #block-tables.block
45
+ .content
46
+ %h2= t("admin.actions.history_index.menu")
47
+ = render partial: 'mydashboard_history'
@@ -1,6 +1,8 @@
1
1
  RailsAdmin::Config::Actions::Dashboard.class_eval do
2
2
  RailsAdmin::Config::Actions.register(self)
3
3
 
4
+ MAX_NOTICES = 10
5
+
4
6
  register_instance_option :root? do
5
7
  true
6
8
  end
@@ -14,13 +16,16 @@ RailsAdmin::Config::Actions::Dashboard.class_eval do
14
16
  @history = @auditing_adapter && @auditing_adapter.latest || []
15
17
  @count = {}
16
18
  @last_rows = {}
17
- @abstract_models = RailsAdmin::Config.visible_models(controller: self).collect(&:abstract_model)
19
+ @abstract_models = RailsAdmin::Config.visible_models( controller: self ).collect( &:abstract_model )
20
+ if @action.models
21
+ @abstract_models.keep_if { |model| @action.models.include? model.to_s }
22
+ end
18
23
  @abstract_models.each do |t|
19
- scope = @authorization_adapter && @authorization_adapter.query(:index, t)
20
- @count[t.model.name] = t.count({}, scope)
21
- @last_rows[t.model.name] = t.all({ limit: 3, sort: t.model.primary_key, sort_reverse: false }, scope)
24
+ scope = @authorization_adapter && @authorization_adapter.query( :index, t )
25
+ @count[t.model.name] = t.count( {}, scope )
26
+ @last_rows[t.model.name] = t.all( { limit: @action.last_records, sort: t.model.primary_key, sort_reverse: false }, scope )
22
27
  end
23
- @admin_notices = @action.admin_notices.constantize.where( published: true ).order( id: :desc ).limit( 10 ) if @action.admin_notices
28
+ @admin_notices = @action.admin_notices.constantize.where( published: true ).order( id: :desc ).limit( MAX_NOTICES ) if @action.admin_notices
24
29
  render @action.template_name, status: @status_code || :ok
25
30
  end
26
31
  end
@@ -33,11 +38,21 @@ RailsAdmin::Config::Actions::Dashboard.class_eval do
33
38
  'icon-home'
34
39
  end
35
40
 
36
- register_instance_option :statistics? do
37
- true
41
+ # Options
42
+
43
+ register_instance_option :statistics? do # for compatibility
44
+ false
38
45
  end
39
46
 
40
47
  register_instance_option :admin_notices do
41
48
  false
42
49
  end
50
+
51
+ register_instance_option :last_records do
52
+ 3
53
+ end
54
+
55
+ register_instance_option :models do
56
+ nil
57
+ end
43
58
  end
@@ -1,3 +1,3 @@
1
1
  module RailsAdminMydash
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_mydash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattia Roccoberton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-31 00:00:00.000000000 Z
11
+ date: 2017-02-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: An alternative dashboard for rails_admin
14
14
  email: