-
Notifications
You must be signed in to change notification settings - Fork 0
/
orionDashboard_XP.js
231 lines (203 loc) · 5.53 KB
/
orionDashboard_XP.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/**
* @property orion
* @where {client}
* @public
* @return {Object}
*
* Declares the orion namespace
*/
orion = orion;
/**
* @property orion.dashboard
* @where {client}
* @public
* @return {Object}
*
* Declares the orion.dashboard namespace and Object.
*/
orion.dashboard = {};
/**
* @property orion.dashboard._widgets
* @where {client}
* @public
* @return {[Object]}
*
* Declares the orion.dashboard._widgets array. Which is an array
* of objects that are
*/
orion.dashboard._widgets = [];
/**
* @method orion.dashboard.registerWidget
* @where {client}
* @public
* @param {Object} data An object that contains the data to be passed to the template
* @return {Object} Returns an object with data for the widet.
*
* Registers the widget and passes the data along to the declared template.
* Template must be defined within the Passed argument otherwise it will default
* to the default widget template.
*/
orion.dashboard.registerWidget = function(data) {
check(data, Object);
if (data.template === undefined || data.template == 'default') {
data.template = ReactiveTemplates.get('orionDashboardWidget');
}
return orion.dashboard._widgets.push(data);
};
/**
* @property ReactiveTemplates.helpers
* @where {client}
* @public
* @return {undefined}
*
* Pulls all widgets from the orion.dashboard._widgets array and passes them
* along to the declared template.
*/
if (Meteor.isClient) {
ReactiveTemplates.helpers('orionDashboard', {
widgets: function() {
return orion.dashboard._widgets;
},
count: function() {
return Counter.get(this);
}
});
/**
* @property ReactiveTemplates.onCreated('orionDashboardWidget')
* @where {client}
* @public
* @return {undefined}
*
* Subscribes to the publication passed to the widget.
*/
ReactiveTemplates.onCreated('orionDashboardWidget', function() {
var data = this.data
this.subscribe(data.publication);
});
ReactiveTemplates.helpers('orionDashboardWidget', {
/**
* @method getCount
* @public
* @param {String} count The count passed to through registerWidget
* @return {Number} Returns the total counts from the publication.
*
* Returns the total count of records based on the Counter
* passed through the registerWidget function.
*/
getCount: function(count) {
return Counts.get(count);
}
});
}
/**
* @method Options.init
* @where {client|server}
* @private
* @return {Boolean} Returns Boolean True or False
*
* Optional setting allowing or denying the dashboard link to display
* in the admin panel.
*/
//Options.init('showDashboardTab', true);
/**
* @where {client|server}
* @private
* @return {Boolean}
*
* If the showDashboard option is set to true, the home route will be
* set to the dashboard path. This option can be overwritten by
* setting the adminHomeRoute explicitly
*/
//if (Options.get('showDashboardTab') == true) {
// Options.set('adminHomeRoute', 'orionDashboard');
//}
/**
* @where {client|server}
* @private
* @return {String}
*
* Set's the dashboard template and defines the default template.
* See ReactiveTemplates documentation for how to override the default
* dashboard template. This typically is not neeed.
*/
ReactiveTemplates.request('orionDashboard', 'orion_dashboard_bootstrap');
if (_.has(Package, 'orionjs:materialize')) {
ReactiveTemplates.set('orionDashboard', 'orion_dashboard_materialize');
}
/**
* @method ReactiveTemplates.request
* @where {client|server}
* @private
* @return {String}
*
* Set's the Dashboard Widget template and defines the default template.
* See ReactiveTemplates documentation for informatation on how to override the
* default widget. NOTE: this is not the same as registering a new widget.
*/
ReactiveTemplates.request('orionDashboardWidget', 'orion_dashboard_default_widget_bootstrap');
if (_.has(Package, 'orionjs:materialize')) {
ReactiveTemplates.set('orionDashboardWidget', 'orion_dashboard_default_widget_materialize');
}
/**
* @method Roles.registerAction
* @where {client|server}
* @private
* @return {Boolean}
*
* Registers the orionDashboard action to the Roles package.
* This allows us to ensure the user has the proper permissions to
* make changes to the dashboard.
*/
Roles.registerAction('orionDashboard', true);
/**
* @method RouterLayer.route
* @where {client}
* @private
* @return {Object}
*
* Registers the route for the dashboard. By Default this route is always
* registered as a subpath of /admin/
*/
/*
RouterLayer.route('/admin/dashboard', {
layout: 'layout',
template: 'orionDashboard',
name: 'orionDashboard',
reactiveTemplates: true
});
*/
/**
* @method orion.accounts.addProtectedRoute
* @where {client}
* @private
* @return {String}
*
* Adds a protected route to orionDashboard ensuring that the user must be
* logged in to navigate to this path.
*/
orion.accounts.addProtectedRoute('orionDashboard');
if (Meteor.isClient) {
/**
* @method orion.links.add
* @where {client}
* @public
* @return {Object}
*
* Adds the orion dashboard link to the admin panel.
* Note that the showDashboardTab Option defines whether
* the ordering of the link.
*/
Tracker.autorun(function() {
/*
var index = Options.get('showDashboardTab') ? 1 : undefined;
orion.links.add({
index: index,
identifier: 'orion-dashboard',
title: 'Dashboard',
routeName: 'orionDashboard',
activeRouteRegex: 'orionDashboard',
permission: 'orionDashboard',
parent: 'ajustes_template'
});*/
});
}