rails_admin_mydash 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8b80695c22eabd86345a42ea0e130d8a35ea8229
4
+ data.tar.gz: d33f858d6af0c8644cd47c3f8e1106966129091d
5
+ SHA512:
6
+ metadata.gz: 6da0af2be9493626eb6c032bc00989104b9c3427183d9d8bd55b689e52f1d8727d8c3729287b492aa53809f5960d1474b2fe7666eccc176034046d29f4b0087d
7
+ data.tar.gz: 4f180ab2b8b46d270ae3dd980312e7ec28a0588cc990c17a0255a02ae4416db2949a956e7ce361c22125b33d9b77ce83b8d34c1782a7382826949227ac4c4e97
@@ -0,0 +1,20 @@
1
+ Copyright 2017
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,15 @@
1
+ # RailsAdminMydash
2
+
3
+ A rails_admin alternative dashboard.
4
+
5
+ Show the last 3 records for each model instead of the standard progress bar animation count.
6
+
7
+ ## Installation
8
+
9
+ - Add the gem to Gemfile (after *rails_admin* gem): `gem 'rails_admin_mydash'`
10
+
11
+ - Execute `bundle`
12
+
13
+ ## Contributors
14
+
15
+ - [Mattia Roccoberton](http://blocknot.es) - creator, maintainer
@@ -0,0 +1,24 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'RailsAdminMydash'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+ load 'rails/tasks/statistics.rake'
20
+
21
+
22
+
23
+ require 'bundler/gem_tasks'
24
+
@@ -0,0 +1,36 @@
1
+ / TODO: show admin notes ?
2
+ / TODO: show audit ?
3
+
4
+ - if @abstract_models
5
+ %table.table.table-condensed.table-striped.dashboard-table
6
+ %thead
7
+ %tr
8
+ %th.shrink.model-name= t 'admin.table_headers.model_name'
9
+ %th.shrink.records= t 'admin.table_headers.records'
10
+ %th.last-records= t 'admin.table_headers.last_records'
11
+ %th.shrink.controls
12
+ %tbody
13
+ - @abstract_models.each do |abstract_model|
14
+ - if authorized? :index, abstract_model
15
+ - index_path = index_path(model_name: abstract_model.to_param)
16
+ - row_class = "#{cycle("odd", "even")}#{" link" if index_path} #{abstract_model.param_key}_links"
17
+ %tr{class: row_class, :"data-link" => index_path}
18
+ %td.c1
19
+ %span.show= link_to capitalize_first_letter(abstract_model.config.label_plural), index_path, class: 'pjax'
20
+ %td.c2
21
+ - if @count[abstract_model.model.name]
22
+ = @count[abstract_model.model.name]
23
+ %td.c3
24
+ - if @last_rows[abstract_model.model.name]
25
+ %div.last-records-list
26
+ - @last_rows[abstract_model.model.name].each do |row|
27
+ - if row.respond_to?( :name ) && ( show_action = action(:show, abstract_model, row) )
28
+ %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')
29
+ %td.c4.links
30
+ %ul.inline.list-inline= menu_for :collection, abstract_model, nil, true
31
+
32
+ / - if @auditing_adapter && authorized?(:history_index)
33
+ / #block-tables.block
34
+ / .content
35
+ / %h2= t("admin.actions.history_index.menu")
36
+ / = render partial: 'rails_admin/main/dashboard_history'
@@ -0,0 +1,5 @@
1
+ require 'rails_admin_mydash/engine'
2
+ require 'rails_admin_mydash/config/actions/dashboard'
3
+
4
+ module RailsAdminMydash
5
+ end
@@ -0,0 +1,97 @@
1
+ RailsAdmin::Config::Actions::Dashboard.class_eval do
2
+ RailsAdmin::Config::Actions.register(self)
3
+
4
+ register_instance_option :root? do
5
+ true
6
+ end
7
+
8
+ register_instance_option :breadcrumb_parent do
9
+ nil
10
+ end
11
+
12
+ register_instance_option :controller do
13
+ proc do
14
+ # @history = @auditing_adapter && @auditing_adapter.latest || []
15
+ @count = {}
16
+ @last_rows = {}
17
+ @abstract_models = RailsAdmin::Config.visible_models(controller: self).collect(&:abstract_model)
18
+ @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)
22
+ end
23
+ render @action.template_name, status: @status_code || :ok
24
+ end
25
+ end
26
+
27
+ register_instance_option :route_fragment do
28
+ ''
29
+ end
30
+
31
+ register_instance_option :link_icon do
32
+ 'icon-home'
33
+ end
34
+
35
+ register_instance_option :statistics? do
36
+ true
37
+ end
38
+
39
+ ## Static
40
+ # class << self
41
+ # end
42
+ end
43
+
44
+ ## Original action:
45
+ #
46
+ # module RailsAdmin
47
+ # module Config
48
+ # module Actions
49
+ # class Dashboard < RailsAdmin::Config::Actions::Base
50
+ # RailsAdmin::Config::Actions.register(self)
51
+
52
+ # register_instance_option :root? do
53
+ # true
54
+ # end
55
+
56
+ # register_instance_option :breadcrumb_parent do
57
+ # nil
58
+ # end
59
+
60
+ # register_instance_option :controller do
61
+ # proc do
62
+ # puts ">>>>>>>>>>>>>>>>>>>>>"
63
+ # @history = @auditing_adapter && @auditing_adapter.latest || []
64
+ # if @action.statistics?
65
+ # @abstract_models = RailsAdmin::Config.visible_models(controller: self).collect(&:abstract_model)
66
+
67
+ # @most_recent_created = {}
68
+ # @count = {}
69
+ # @max = 0
70
+ # @abstract_models.each do |t|
71
+ # scope = @authorization_adapter && @authorization_adapter.query(:index, t)
72
+ # current_count = t.count({}, scope)
73
+ # @max = current_count > @max ? current_count : @max
74
+ # @count[t.model.name] = current_count
75
+ # next unless t.properties.detect { |c| c.name == :created_at }
76
+ # @most_recent_created[t.model.name] = t.model.last.try(:created_at)
77
+ # end
78
+ # end
79
+ # render @action.template_name, status: @status_code || :ok
80
+ # end
81
+ # end
82
+
83
+ # register_instance_option :route_fragment do
84
+ # ''
85
+ # end
86
+
87
+ # register_instance_option :link_icon do
88
+ # 'icon-home'
89
+ # end
90
+
91
+ # register_instance_option :statistics? do
92
+ # true
93
+ # end
94
+ # end
95
+ # end
96
+ # end
97
+ # end
@@ -0,0 +1,4 @@
1
+ module RailsAdminMydash
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module RailsAdminMydash
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_admin_mydash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mattia Roccoberton
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Custom Dashboard for RailsAdmin
14
+ email:
15
+ - mat@blocknot.es
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - MIT-LICENSE
21
+ - README.md
22
+ - Rakefile
23
+ - app/views/rails_admin/main/dashboard.html.haml
24
+ - lib/rails_admin_mydash.rb
25
+ - lib/rails_admin_mydash/config/actions/dashboard.rb
26
+ - lib/rails_admin_mydash/engine.rb
27
+ - lib/rails_admin_mydash/version.rb
28
+ homepage: http://blocknot.es/blocknotes/rails_admin_mydash
29
+ licenses:
30
+ - MIT
31
+ metadata: {}
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubyforge_project:
48
+ rubygems_version: 2.6.8
49
+ signing_key:
50
+ specification_version: 4
51
+ summary: RailsAdmin Mydash
52
+ test_files: []