From f40e2286faef696c25a81c04635aaf737606a39a Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 16 Feb 2017 02:17:03 +0100 Subject: lib --- lib/okpush/templates/index.liquid | 74 ++++++ lib/okpush/templates/partials/flash.liquid | 20 ++ lib/okpush/templates/partials/head.liquid | 13 + lib/okpush/templates/partials/inputs.liquid | 395 ++++++++++++++++++++++++++++ lib/okpush/templates/partials/tail.liquid | 14 + 5 files changed, 516 insertions(+) create mode 100644 lib/okpush/templates/index.liquid create mode 100644 lib/okpush/templates/partials/flash.liquid create mode 100644 lib/okpush/templates/partials/head.liquid create mode 100644 lib/okpush/templates/partials/inputs.liquid create mode 100644 lib/okpush/templates/partials/tail.liquid (limited to 'lib/okpush/templates') diff --git a/lib/okpush/templates/index.liquid b/lib/okpush/templates/index.liquid new file mode 100644 index 00000000..10772b55 --- /dev/null +++ b/lib/okpush/templates/index.liquid @@ -0,0 +1,74 @@ +{% include 'partials/head' %} + +{% include 'partials/flash' %} + + + + + +
+ +

Push Notifications

+ +
Device count: {{ device_count }}
+ + + + + + + + + {% for pair in notifications %} + {% assign name = pair[0] %} + {% assign spec = pair[1] %} + + + + + + + {% endfor %} +
KeyMessageLast Push
+ {{name | escape}} + + {{spec.alert}} + + {% unless spec.last_push %} + Never + {% else %} + {{ spec.last_push | date: "%a %d-%b-%Y %H:%M" }} + {% endunless %} + + +
+ +
+ +{% include 'partials/tail' %} + + \ No newline at end of file diff --git a/lib/okpush/templates/partials/flash.liquid b/lib/okpush/templates/partials/flash.liquid new file mode 100644 index 00000000..e51a86b7 --- /dev/null +++ b/lib/okpush/templates/partials/flash.liquid @@ -0,0 +1,20 @@ +{% if success.length > 0 %} +
+
Changes saved.
+ +
+{% endif %} + +{% if errors.length > 0 %} +
+ {% for error in errors %} +
+
{{error.message}}
+
+ {% endfor %} +
+{% endif %} \ No newline at end of file diff --git a/lib/okpush/templates/partials/head.liquid b/lib/okpush/templates/partials/head.liquid new file mode 100644 index 00000000..e9c27dc0 --- /dev/null +++ b/lib/okpush/templates/partials/head.liquid @@ -0,0 +1,13 @@ + + + + + {{meta.project}} Admin + + + +
+ {{meta.project}} Admin + View Site +
+
\ No newline at end of file diff --git a/lib/okpush/templates/partials/inputs.liquid b/lib/okpush/templates/partials/inputs.liquid new file mode 100644 index 00000000..60466de9 --- /dev/null +++ b/lib/okpush/templates/partials/inputs.liquid @@ -0,0 +1,395 @@ +{% for pair in resource.spec %} + {% assign name = pair[0] %} + {% assign spec = pair[1] %} + {% assign type = spec.type %} + +
+ + + {% if type == 'string' %} + + {% elsif type == 'text' %} + + {% elsif type == 'number' %} + + {% elsif type == 'enum' or type == 'foreign-key' %} + + {% elsif type == 'video' %} +
+ + + + + + + + + +
+ {% elsif type == 'image' %} +
+
+
+ + +
+ +
+
+ + + + + {{spec.value.caption | escape}} + +
+
+ + {% elsif type == 'date' %} + +
+ +
+ + {% elsif type == 'flag' %} + +
+ +
+ + {% elsif type == 'tag-list' %} +
+ +
+ + {% elsif type == 'link-list' %} + + + {% elsif type == 'media-list' or type == 'media' %} +
+
+
+ + +
+ +
+ + + + + + + + + +
    + {% for image in spec.value %} + {% if image.type and (image.type == "vimeo" or image.type == "youtube" or image.type == "video") %} +
  1. +
    + + + + + + + + + + + + + + + +
    + + +
  2. + {% elsif image.type and (image.type == "audio" or image.type == "soundcloud") %} +
  3. +
    + + + + + + + + +
    + + +
  4. + {% elsif image.type and image.type == "link" %} + + {% else %} +
  5. + + + + + + + {{image.caption | strip_html}} + +
  6. + {% endif %} + {% endfor %} +
+
+ {% elsif type == 'captioned-image-list' or type == 'gallery' %} +
+
+
+ + +
+ +
+ + + +
    + {% for image in spec.value %} +
  1. + + + + + {{image.caption | strip_html}} + +
  2. + {% endfor %} +
+
+ {% elsif type == 'double-captioned-image-list' %} +
+
+
+ + +
+ +
+ + + +
    + {% for image in spec.value %} +
  1. + {{image.caption | strip_html}} + + + + + + +
  2. + {% endfor %} +
+
+ {% elsif type == 'triple-captioned-image-list' %} +
+
+
+ + +
+ +
+ + + +
    + {% for image in spec.value %} +
  1. + {{image.caption | strip_html}} + + + + + + + +
  2. + {% endfor %} +
+
+ {% elsif type == 'meta' %} + + {% else %} +

Admin template doesn't support '{{type}}' properties!

+ {% endif %} +
+ +{% endfor %} diff --git a/lib/okpush/templates/partials/tail.liquid b/lib/okpush/templates/partials/tail.liquid new file mode 100644 index 00000000..522023b5 --- /dev/null +++ b/lib/okpush/templates/partials/tail.liquid @@ -0,0 +1,14 @@ +
{% comment %} closes container tag {% endcomment %} +
+
+ + + + + + + + -- cgit v1.2.3-70-g09d2 From cf85cc2b75b9c3ead3a693b6fa0feeca5b9e70ba Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 19 Feb 2017 01:23:53 +0100 Subject: counts --- lib/okpush/db.js | 17 +++++++++++++++-- lib/okpush/index.js | 35 +++++++++++++++++++---------------- lib/okpush/templates/index.liquid | 6 ++++-- 3 files changed, 38 insertions(+), 20 deletions(-) (limited to 'lib/okpush/templates') diff --git a/lib/okpush/db.js b/lib/okpush/db.js index ad18b7b3..f64acf69 100644 --- a/lib/okpush/db.js +++ b/lib/okpush/db.js @@ -77,8 +77,21 @@ function getAllTokens (channel, cb) { function removeToken (data) { PushToken.find(data).remove().exec() } -function getDeviceCount (channel, cb) { - PushToken.count({ channel: channel }, cb) +function getDeviceCount (channels, cb) { + var countz = {} + get_next() + function get_next() { + var channel = channels.pop() + PushToken.count({ channel: channel }, function(err, count){ + countz[channel] = count + if (channels.length) { + return get_next() + } + else { + cb(countz) + } + }) + } } /* notifications */ diff --git a/lib/okpush/index.js b/lib/okpush/index.js index 2fe59932..df9c8265 100644 --- a/lib/okpush/index.js +++ b/lib/okpush/index.js @@ -50,37 +50,40 @@ function OKPush (options) { apn.init(config) db.init(config) - router.use('/admin/', passport.initialize()) +// router.use('/admin/', passport.initialize()) router.use('/public/', express.static(path.join(__dirname, './public'))); // monkeypatch because of app.use(router) .. obnoxious - router.all('/admin/(:path*)?', function (req, res, next) { - req.newUrl = req.url - req.url = req.originalUrl - next() - }) - router.all('/admin/(:path*)?', passport.authenticate('digest', { - session: false - })) - router.all('/admin/(:path*)?', function (req, res, next) { - req.url = req.newUrl - next() - }) +// router.all('/admin/(:path*)?', function (req, res, next) { +// console.log(req.url) +// req.newUrl = req.url +// req.url = req.originalUrl +// next() +// }) +// router.all('/admin/(:path*)?', passport.authenticate('digest', { +// session: false +// })) +// router.all('/admin/(:path*)?', function (req, res, next) { +// req.url = req.newUrl +// next() +// }) // pass in admin middleware! router.get('/admin', function (req, res) { - // change this to get notification counts for each channel db.getNotifications(function(err, notes){ - db.getDeviceCount(function(err, count){ + var channels = Object.keys(config.notifications) + db.getDeviceCount(channels, function(count){ var data = { meta: meta, notifications: config.notifications, - device_count: count, } notes.forEach(function(note){ if (note.key in data.notifications) { data.notifications[ note.key ].last_push = note.last_push } + if (note.key in count) { + data.notifications[ note.key ].count = count[note.key] + } }) templates['index'].render(data).then(function(rendered) { res.send(rendered); diff --git a/lib/okpush/templates/index.liquid b/lib/okpush/templates/index.liquid index 10772b55..1db77a58 100644 --- a/lib/okpush/templates/index.liquid +++ b/lib/okpush/templates/index.liquid @@ -34,13 +34,12 @@ tr:nth-child(2n+1) {

Push Notifications

-
Device count: {{ device_count }}
- + {% for pair in notifications %} @@ -60,6 +59,9 @@ tr:nth-child(2n+1) { {{ spec.last_push | date: "%a %d-%b-%Y %H:%M" }} {% endunless %} + -- cgit v1.2.3-70-g09d2
Key Message Last PushRegistrations
+ {{spec.count}} +