Files
docspell/modules/webapp/src/main/elm/Comp/PeriodicQueryTaskList.elm
eikek 4ffc8d1f14 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.
2021-12-11 18:57:32 +01:00

103 lines
2.4 KiB
Elm

{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Comp.PeriodicQueryTaskList exposing
( Action(..)
, Model
, Msg
, init
, update
, view2
)
import Comp.Basic as B
import Data.ChannelType
import Data.NotificationChannel
import Data.PeriodicQuerySettings exposing (PeriodicQuerySettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Messages.Comp.PeriodicQueryTaskList exposing (Texts)
import Styles as S
import Util.Html
type alias Model =
{}
type Msg
= EditSettings PeriodicQuerySettings
type Action
= NoAction
| EditAction PeriodicQuerySettings
init : Model
init =
{}
update : Msg -> Model -> ( Model, Action )
update msg model =
case msg of
EditSettings settings ->
( model, EditAction settings )
--- View2
view2 : Texts -> Model -> List PeriodicQuerySettings -> Html Msg
view2 texts _ items =
div []
[ table [ class S.tableMain ]
[ thead []
[ tr []
[ th [ class "" ] []
, th [ class "text-center mr-2" ]
[ i [ class "fa fa-check" ] []
]
, th [ class "text-left " ] [ text texts.summary ]
, th [ class "text-left hidden sm:table-cell mr-2" ]
[ text texts.schedule ]
, th [ class "text-left mr-2" ]
[ text texts.connection ]
]
]
, tbody []
(List.map (viewItem2 texts) items)
]
]
viewItem2 : Texts -> PeriodicQuerySettings -> Html Msg
viewItem2 texts item =
tr []
[ B.editLinkTableCell texts.basics.edit (EditSettings item)
, td [ class "w-px whitespace-nowrap px-2 text-center" ]
[ Util.Html.checkbox2 item.enabled
]
, td [ class "text-left" ]
[ Maybe.withDefault "" item.summary
|> text
]
, td [ class "text-left hidden sm:table-cell mr-2" ]
[ code [ class "font-mono text-sm" ]
[ text item.schedule
]
]
, td [ class "text-left py-4 md:py-2" ]
[ Data.NotificationChannel.channelType item.channel
|> Maybe.map Data.ChannelType.asString
|> Maybe.withDefault "-"
|> text
]
]