Add notification sending functionality.
This commit is contained in:
parent
00ba3a6ac0
commit
3e7d12b6e4
11
src/Scylla/Notification.elm
Normal file
11
src/Scylla/Notification.elm
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
port module Scylla.Notification exposing (..)
|
||||||
|
import Scylla.Model exposing (..)
|
||||||
|
import Json.Decode
|
||||||
|
|
||||||
|
type alias Notification =
|
||||||
|
{ name : String
|
||||||
|
, text : String
|
||||||
|
}
|
||||||
|
|
||||||
|
port sendNotificationPort : Notification -> Cmd msg
|
||||||
|
port onNotificationClockPort : (Json.Decode.Value -> msg) -> Sub msg
|
12
static/js/notifications.js
Normal file
12
static/js/notifications.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
if("Notification" in window) {
|
||||||
|
Notification.requestPermission();
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupNotificationPorts(app) {
|
||||||
|
app.ports.sendNotificationPort.subscribe(function(data) {
|
||||||
|
var options = {
|
||||||
|
"body" : data.text
|
||||||
|
}
|
||||||
|
new Notification(data.name, options)
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user