mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 19:08:26 +00:00
Add support for more generic notification
This is a start to have different kinds of notifications. It is possible to be notified via e-mail, matrix or gotify. It also extends the current "periodic query" for due items by allowing notification over different channels. A "generic periodic query" variant is added as well.
This commit is contained in:
117
modules/webapp/src/main/elm/Comp/NotificationGotifyForm.elm
Normal file
117
modules/webapp/src/main/elm/Comp/NotificationGotifyForm.elm
Normal file
@ -0,0 +1,117 @@
|
||||
{-
|
||||
Copyright 2020 Eike K. & Contributors
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-}
|
||||
|
||||
|
||||
module Comp.NotificationGotifyForm exposing (Model, Msg, init, initWith, update, view)
|
||||
|
||||
import Api.Model.NotificationGotify exposing (NotificationGotify)
|
||||
import Comp.Basic as B
|
||||
import Data.NotificationChannel
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onInput)
|
||||
import Messages.Comp.NotificationGotifyForm exposing (Texts)
|
||||
import Styles as S
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ hook : NotificationGotify
|
||||
}
|
||||
|
||||
|
||||
init : Model
|
||||
init =
|
||||
{ hook = Data.NotificationChannel.setTypeGotify Api.Model.NotificationGotify.empty
|
||||
}
|
||||
|
||||
|
||||
initWith : NotificationGotify -> Model
|
||||
initWith hook =
|
||||
{ hook = Data.NotificationChannel.setTypeGotify hook
|
||||
}
|
||||
|
||||
|
||||
type Msg
|
||||
= SetUrl String
|
||||
| SetAppKey String
|
||||
|
||||
|
||||
|
||||
--- Update
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Maybe NotificationGotify )
|
||||
update msg model =
|
||||
let
|
||||
newHook =
|
||||
updateHook msg model.hook
|
||||
in
|
||||
( { model | hook = newHook }, check newHook )
|
||||
|
||||
|
||||
check : NotificationGotify -> Maybe NotificationGotify
|
||||
check hook =
|
||||
Just hook
|
||||
|
||||
|
||||
updateHook : Msg -> NotificationGotify -> NotificationGotify
|
||||
updateHook msg hook =
|
||||
case msg of
|
||||
SetUrl s ->
|
||||
{ hook | url = s }
|
||||
|
||||
SetAppKey s ->
|
||||
{ hook | appKey = s }
|
||||
|
||||
|
||||
|
||||
--- View
|
||||
|
||||
|
||||
view : Texts -> Model -> Html Msg
|
||||
view texts model =
|
||||
div []
|
||||
[ div
|
||||
[ class "mb-2"
|
||||
]
|
||||
[ label
|
||||
[ for "gotifyurl"
|
||||
, class S.inputLabel
|
||||
]
|
||||
[ text texts.gotifyUrl
|
||||
, B.inputRequired
|
||||
]
|
||||
, input
|
||||
[ type_ "text"
|
||||
, onInput SetUrl
|
||||
, placeholder texts.gotifyUrl
|
||||
, value model.hook.url
|
||||
, name "gotifyurl"
|
||||
, class S.textInput
|
||||
]
|
||||
[]
|
||||
]
|
||||
, div
|
||||
[ class "mb-2"
|
||||
]
|
||||
[ label
|
||||
[ for "appkey"
|
||||
, class S.inputLabel
|
||||
]
|
||||
[ text texts.appKey
|
||||
, B.inputRequired
|
||||
]
|
||||
, input
|
||||
[ type_ "text"
|
||||
, onInput SetAppKey
|
||||
, placeholder texts.appKey
|
||||
, value model.hook.appKey
|
||||
, name "appkey"
|
||||
, class S.textInput
|
||||
]
|
||||
[]
|
||||
]
|
||||
]
|
Reference in New Issue
Block a user