summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-09-21 01:34:58 +0200
committerJules Laplace <julescarbon@gmail.com>2017-09-21 01:34:58 +0200
commite6c2b28c9824cae592c59c4838d12ae98fb27f9e (patch)
treea30e9419a4b5d6e1c0ffab09c1549a16600fd790 /lib
parent6196c6d19a8fb8f7a008eba455a54c8e5b1f2160 (diff)
form for custom push notifications
Diffstat (limited to 'lib')
-rw-r--r--lib/okpush/public/push.js21
-rw-r--r--lib/okpush/templates/index.liquid15
-rw-r--r--lib/okpush/templates/new.liquid45
3 files changed, 70 insertions, 11 deletions
diff --git a/lib/okpush/public/push.js b/lib/okpush/public/push.js
index e75fc7f4..06588327 100644
--- a/lib/okpush/public/push.js
+++ b/lib/okpush/public/push.js
@@ -27,6 +27,27 @@ $(function(){
}
})
})
+
+ $('#custom').submit(function(e){
+ e.preventDefault()
+ var message = $("#message").val().trim()
+ var dest = $("#dest").val()
+ var msg = "This will send this push notification to everyone. Click OK to confirm.\n\n" + message
+ if (! confirm(msg)) return
+
+ $.ajax({
+ type: "POST",
+ url: "/_services/push/custom",
+ data: {
+ message: message,
+ dest: dest,
+ },
+ success: function(){
+ alert("Push notification sent.")
+ }
+ })
+
+ })
})
function capitalize (string) {
diff --git a/lib/okpush/templates/index.liquid b/lib/okpush/templates/index.liquid
index 124fb4ee..ec639646 100644
--- a/lib/okpush/templates/index.liquid
+++ b/lib/okpush/templates/index.liquid
@@ -11,9 +11,6 @@ th {
th:nth-child(2) {
min-width: 300px;
}
-th:nth-child(3) {
- min-width: 170px;
-}
table,tr,th,td {
margin: 0;
padding: 0;
@@ -33,12 +30,15 @@ tr:nth-child(2n+1) {
<section class="main resource">
<h2>Push Notifications</h2>
+
+ <p>
+ <a href="/_services/push/new">Send custom push notification</a>
+ </p>
<table class="notifications" cellpadding="0" cellspacing="0">
<tr>
<th>Key</th>
<th>Message</th>
- <th>Last Push</th>
<th>Tokens</th>
<th></th>
</tr>
@@ -52,13 +52,6 @@ tr:nth-child(2n+1) {
<td>
{{spec.alert}}
</td>
- <td class="notification-date">
- {% unless spec.last_push %}
- Never
- {% else %}
- {{ spec.last_push | date: "%a %d-%b-%Y %H:%M" }}
- {% endunless %}
- </td>
<td>
{{spec.count}}
</td>
diff --git a/lib/okpush/templates/new.liquid b/lib/okpush/templates/new.liquid
new file mode 100644
index 00000000..0393535c
--- /dev/null
+++ b/lib/okpush/templates/new.liquid
@@ -0,0 +1,45 @@
+{% include 'partials/head' %}
+
+{% include 'partials/flash' %}
+
+<style>
+</style>
+
+<nav class="resource-nav">
+ <a href="/admin/" class="btn">Back</a>
+</nav>
+
+<section class="main resource">
+
+ <h2>Custom Push Notification</h2>
+
+ <form id='custom'>
+
+ <div>
+ <label for='message'>Message</label>
+ <input type='text' name='message' id='message'>
+ </div>
+
+ <div>
+ <label for='dest'>Destination</label>
+ <select id='dest' name='dest'>
+ <option>/</option>
+ <option selected>/store</option>
+ <option>/hub</option>
+ <option>/story</option>
+ <option>/archive</option>
+ </select>
+ (will open after push is tapped)
+ </div>
+
+ <div>
+ <input type='submit' value='Send Push Notification'>
+ </div>
+
+ </form>
+
+</section>
+
+{% include 'partials/tail' %}
+
+<script src="public/push.js"></script> \ No newline at end of file