rails_admin_mydash 0.1.6 → 0.1.8
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4e2fbef2752b495ea75283d3859c5cd1d559034
|
4
|
+
data.tar.gz: 6c0aed6ea36fdb41af371cd7acab87cb281f52a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2a971bb5a0fda8ba30d76f6bc0e6ab9653d41e97a9eb202ebb6fb19d14f586e3f6f995ec23f24b8c9521af92f0eee226aa71113e1f06f81f85bc5ed30fb1711
|
7
|
+
data.tar.gz: ec4b39eba036a12f63c1f932bc1b03ab7405703e26023e740e8bf96ce4a589c3a0b228fbc9915a3d3799ea988631699c15cc50013116c52bef1aa3d1bb413c09
|
data/README.md
CHANGED
@@ -4,15 +4,17 @@ A rails_admin alternative dashboard. It overrides the default dashboard componen
|
|
4
4
|
|
5
5
|
Features:
|
6
6
|
|
7
|
-
-
|
7
|
+
- last 3 records for each model (useful to reach the last items easily)
|
8
8
|
|
9
|
-
-
|
9
|
+
- Google Analytics data if enabled
|
10
10
|
|
11
|
-
-
|
11
|
+
- admin notices if enabled (to show informations to the users)
|
12
12
|
|
13
|
-
-
|
13
|
+
- auditing / history table if enabled
|
14
14
|
|
15
|
-
-
|
15
|
+
- no breadcrump and nav tabs on the dashboard
|
16
|
+
|
17
|
+
- no counters progress bars (minor performance improvement)
|
16
18
|
|
17
19
|
## Installation
|
18
20
|
|
@@ -20,6 +22,35 @@ Features:
|
|
20
22
|
|
21
23
|
- Execute `bundle`
|
22
24
|
|
25
|
+
## Google Analytics
|
26
|
+
|
27
|
+
- To enable Google Analytics follow this guide: [Google Analytics Embed API](https://developers.google.com/analytics/devguides/reporting/embed/v1/getting-started)
|
28
|
+
|
29
|
+
- Set the options in rails_admin config:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
# In config.actions block:
|
33
|
+
dashboard do
|
34
|
+
ga_key 'XXX.apps.googleusercontent.com'
|
35
|
+
ga_chart_id 'ga:YYYYYYYYY'
|
36
|
+
ga_start_date '60daysAgo'
|
37
|
+
ga_end_date '30daysAgo'
|
38
|
+
ga_metrics 'ga:sessions,ga:pageviews'
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
Options:
|
43
|
+
|
44
|
+
- ga_key: required - CLIENT_ID parameter (obtained from [Google API Client Libraries](https://developers.google.com/api-client-library/javascript/start/start-js#Setup) - [ID client OAuth 2.0](https://console.developers.google.com/apis/credentials))
|
45
|
+
|
46
|
+
- ga_chart_id: optional - chart to show, if not specified the selector is shown
|
47
|
+
|
48
|
+
- ga_start_date: optional - starting date, default: '30daysAgo'
|
49
|
+
|
50
|
+
- ga_end_date: optional - ending date, default: 'yesterday'
|
51
|
+
|
52
|
+
- ga_metrics: optional - type of data to show, default: 'ga:sessions'
|
53
|
+
|
23
54
|
## Admin notices
|
24
55
|
|
25
56
|
- Create and apply a migration:
|
@@ -0,0 +1,78 @@
|
|
1
|
+
:css
|
2
|
+
#ga-auth-button { color: #888; font-style: italic; text-align: center; }
|
3
|
+
#ga-timeline { overflow-x: scroll; }
|
4
|
+
#ga-timeline .gapi-analytics-data-chart > div > div { margin: 0 auto; }
|
5
|
+
#ga-view-selector table { margin: 5px auto 0 auto; }
|
6
|
+
|
7
|
+
.panel.panel-info
|
8
|
+
.panel-heading
|
9
|
+
%h3.panel-title= t 'admin.dashboard.google_analytics'
|
10
|
+
.panel-body
|
11
|
+
%section#ga-auth-button
|
12
|
+
%section#ga-view-selector
|
13
|
+
%section#ga-timeline
|
14
|
+
|
15
|
+
:javascript
|
16
|
+
var gapi_init = false;
|
17
|
+
if( !$('#gapi-script').length ) {
|
18
|
+
// Include once
|
19
|
+
(function(w,d,s,g,js,fjs){
|
20
|
+
g=w.gapi||(w.gapi={});g.analytics={q:[],ready:function(cb){this.q.push(cb)}};
|
21
|
+
js=d.createElement(s);fjs=d.getElementsByTagName(s)[0];
|
22
|
+
js.id='gapi-script';
|
23
|
+
js.src='https://apis.google.com/js/platform.js';
|
24
|
+
fjs.parentNode.insertBefore(js,fjs);js.onload=function(){g.load('analytics')};
|
25
|
+
}(window,document,'script'));
|
26
|
+
gapi_init = true;
|
27
|
+
}
|
28
|
+
|
29
|
+
:javascript
|
30
|
+
var timeline;
|
31
|
+
var ga_chart_id = '#{@action.ga_chart_id}';
|
32
|
+
var ga_metrics = '#{@action.ga_metrics ? @action.ga_metrics : "ga:sessions"}';
|
33
|
+
var ga_start_date = '#{@action.ga_start_date ? @action.ga_start_date : "30daysAgo"}';
|
34
|
+
var ga_end_date = '#{@action.ga_end_date ? @action.ga_end_date : "yesterday"}';
|
35
|
+
var ga_client_id = '#{@action.ga_key}';
|
36
|
+
gapi.analytics.ready(function() {
|
37
|
+
// >> Create the view selector.
|
38
|
+
if( !ga_chart_id ) {
|
39
|
+
var viewSelector = new gapi.analytics.ViewSelector({
|
40
|
+
container: 'ga-view-selector'
|
41
|
+
});
|
42
|
+
viewSelector.on( 'change', function( ids ) {
|
43
|
+
// console.log( ids );
|
44
|
+
timeline.set( { query: { ids: ids } } ).execute();
|
45
|
+
});
|
46
|
+
}
|
47
|
+
// >> Create the timeline chart.
|
48
|
+
timeline = new gapi.analytics.googleCharts.DataChart({
|
49
|
+
reportType: 'ga',
|
50
|
+
query: {
|
51
|
+
'dimensions': 'ga:date',
|
52
|
+
'metrics': ga_metrics,
|
53
|
+
'start-date': ga_start_date,
|
54
|
+
'end-date': ga_end_date,
|
55
|
+
},
|
56
|
+
chart: {
|
57
|
+
type: 'LINE',
|
58
|
+
container: 'ga-timeline'
|
59
|
+
}
|
60
|
+
});
|
61
|
+
if( gapi_init ) {
|
62
|
+
// >> Authorize the user.
|
63
|
+
gapi.analytics.auth.authorize({
|
64
|
+
container: 'ga-auth-button',
|
65
|
+
clientid: ga_client_id,
|
66
|
+
});
|
67
|
+
// >> Hook up the components to work together.
|
68
|
+
gapi.analytics.auth.on('success', function(response) {
|
69
|
+
if( ga_chart_id ) timeline.set( { query: { ids: ga_chart_id } } ).execute();
|
70
|
+
else viewSelector.execute();
|
71
|
+
$('#ga-auth-button').fadeOut( 500 );
|
72
|
+
});
|
73
|
+
}
|
74
|
+
else {
|
75
|
+
if( ga_chart_id ) timeline.set( { query: { ids: ga_chart_id } } ).execute();
|
76
|
+
else viewSelector.execute();
|
77
|
+
}
|
78
|
+
});
|
@@ -4,42 +4,50 @@
|
|
4
4
|
td.c2 { text-align: center; }
|
5
5
|
|
6
6
|
%div#mydash
|
7
|
-
|
7
|
+
.row
|
8
|
+
- if @action.ga_key
|
9
|
+
%div{class:@action.ga_key ? 'col-md-7' : 'col-md-12'}
|
10
|
+
= render partial: 'analytics_embed'
|
11
|
+
- if @admin_notices && @admin_notices.any?
|
12
|
+
%div{class:@action.ga_key ? 'col-md-5' : 'col-md-12'}
|
13
|
+
%div.panel.panel-info
|
14
|
+
%div.panel-heading
|
15
|
+
%h3.panel-title= t 'admin.dashboard.notices'
|
16
|
+
/ %div.panel-body
|
17
|
+
%table.table
|
18
|
+
- @admin_notices.each do |notice|
|
19
|
+
%tr
|
20
|
+
%td= notice.message
|
21
|
+
- if @abstract_models
|
8
22
|
%div.panel.panel-info
|
9
23
|
%div.panel-heading
|
10
|
-
%h3.panel-title= t 'admin.dashboard.
|
11
|
-
|
12
|
-
|
13
|
-
- @admin_notices.each do |notice|
|
24
|
+
%h3.panel-title= t 'admin.dashboard.records'
|
25
|
+
%table.table.table-condensed.table-striped.dashboard-table
|
26
|
+
%thead
|
14
27
|
%tr
|
15
|
-
%
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
%
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
%
|
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
|
28
|
+
%th.shrink.model-name= t 'admin.table_headers.model_name'
|
29
|
+
%th.shrink.records= t 'admin.table_headers.records'
|
30
|
+
%th.last-records= t 'admin.table_headers.last_records'
|
31
|
+
%th.shrink.controls
|
32
|
+
%tbody
|
33
|
+
- @abstract_models.each do |abstract_model|
|
34
|
+
- if authorized? :index, abstract_model
|
35
|
+
- index_path = index_path(model_name: abstract_model.to_param)
|
36
|
+
- row_class = "#{cycle("odd", "even")}#{" link" if index_path} #{abstract_model.param_key}_links"
|
37
|
+
%tr{class: row_class, :"data-link" => index_path}
|
38
|
+
%td.c1
|
39
|
+
%span.show= link_to capitalize_first_letter(abstract_model.config.label_plural), index_path, class: 'pjax'
|
40
|
+
%td.c2
|
41
|
+
- if @count[abstract_model.model.name]
|
42
|
+
= @count[abstract_model.model.name]
|
43
|
+
%td.c3
|
44
|
+
- if @last_rows[abstract_model.model.name]
|
45
|
+
%div.last-records-list
|
46
|
+
- @last_rows[abstract_model.model.name].each do |row|
|
47
|
+
- if row.respond_to?( :name ) && ( show_action = action(:show, abstract_model, row) )
|
48
|
+
%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')
|
49
|
+
%td.c4.links
|
50
|
+
%ul.inline.list-inline= menu_for :collection, abstract_model, nil, true
|
43
51
|
- if @auditing_adapter && authorized?(:history_index)
|
44
52
|
#block-tables.block
|
45
53
|
.content
|
@@ -48,6 +48,26 @@ RailsAdmin::Config::Actions::Dashboard.class_eval do
|
|
48
48
|
false
|
49
49
|
end
|
50
50
|
|
51
|
+
register_instance_option :ga_chart_id do
|
52
|
+
nil
|
53
|
+
end
|
54
|
+
|
55
|
+
register_instance_option :ga_end_date do
|
56
|
+
'yesterday'
|
57
|
+
end
|
58
|
+
|
59
|
+
register_instance_option :ga_key do
|
60
|
+
nil
|
61
|
+
end
|
62
|
+
|
63
|
+
register_instance_option :ga_metrics do
|
64
|
+
'ga:sessions'
|
65
|
+
end
|
66
|
+
|
67
|
+
register_instance_option :ga_start_date do
|
68
|
+
'30daysAgo'
|
69
|
+
end
|
70
|
+
|
51
71
|
register_instance_option :last_records do
|
52
72
|
3
|
53
73
|
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
|
+
version: 0.1.8
|
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-02-
|
11
|
+
date: 2017-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: An alternative dashboard for rails_admin
|
14
14
|
email:
|
@@ -20,6 +20,7 @@ files:
|
|
20
20
|
- MIT-LICENSE
|
21
21
|
- README.md
|
22
22
|
- Rakefile
|
23
|
+
- app/views/rails_admin/main/_analytics_embed.html.haml
|
23
24
|
- app/views/rails_admin/main/_mydashboard_history.html.haml
|
24
25
|
- app/views/rails_admin/main/dashboard.html.haml
|
25
26
|
- lib/rails_admin_mydash.rb
|