Skip to content

Commit 362a64d

Browse files
committed
Merge branch 'admin' into develop
2 parents 1aaa8f1 + 2872b83 commit 362a64d

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

.meteor/packages

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,4 @@ emails
8484
modules
8585
service-messages
8686
meteorhacks:aggregate
87+
admin

packages/admin/README.md

Whitespace-only changes.

packages/admin/package.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Package.describe({
2+
name: 'admin',
3+
version: '0.0.1',
4+
summary: 'admin api endpoints',
5+
git: '',
6+
documentation: 'README.md',
7+
})
8+
9+
Package.onUse(function(api) {
10+
api.versionsFrom('1.2.1')
11+
api.use([
12+
'ecmascript',
13+
'tmeasday:publish-counts',
14+
'check',
15+
'mongo',
16+
], 'server')
17+
api.addFiles('server/publish.js', 'server')
18+
})

packages/admin/server/publish.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* global userIsInRole, Counts, ReportItems */
2+
3+
function pub (name, fn) {
4+
Meteor.publish(`admin_${name}`, function () {
5+
if (this.userId == null || !userIsInRole(this.userId, 'admin')) {
6+
this.ready()
7+
return undefined
8+
}
9+
return fn.apply(this, arguments)
10+
})
11+
}
12+
13+
pub('userCount', function () {
14+
Counts.publish(
15+
this,
16+
'userCount',
17+
Meteor.users.find({})
18+
)
19+
})
20+
21+
pub('loggedIn', function () {
22+
Counts.publish(
23+
this,
24+
'loggedInUsersCount',
25+
Meteor.users.find({ 'status.online': true })
26+
)
27+
})
28+
29+
pub('reportItems', function (all = false) {
30+
let query = {}
31+
if (!all) {
32+
query = {
33+
resolvedInfo: { $exists: false },
34+
}
35+
}
36+
return ReportItems.find(query)
37+
})

0 commit comments

Comments
 (0)