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:
eikek
2021-11-22 00:22:51 +01:00
parent 93a828720c
commit 4ffc8d1f14
175 changed files with 13041 additions and 599 deletions

View File

@ -8,10 +8,12 @@
module Page.UserSettings.View2 exposing (viewContent, viewSidebar)
import Comp.ChangePasswordForm
import Comp.DueItemsTaskManage
import Comp.EmailSettingsManage
import Comp.ImapSettingsManage
import Comp.NotificationManage
import Comp.NotificationHookManage
import Comp.OtpSetup
import Comp.PeriodicQueryTaskManage
import Comp.ScanMailboxManage
import Comp.UiSettingsManage
import Data.Flags exposing (Flags)
@ -27,6 +29,24 @@ import Styles as S
viewSidebar : Texts -> Bool -> Flags -> UiSettings -> Model -> Html Msg
viewSidebar texts visible _ _ model =
let
isNotificationTab =
case model.currentTab of
Just NotificationTab ->
True
Just NotificationQueriesTab ->
True
Just NotificationWebhookTab ->
True
Just NotificationDueItemsTab ->
True
_ ->
False
in
div
[ id "sidebar"
, class S.sidebar
@ -50,16 +70,56 @@ viewSidebar texts visible _ _ model =
[ class "ml-3" ]
[ text texts.uiSettings ]
]
, a
[ href "#"
, onClick (SetTab NotificationTab)
, menuEntryActive model NotificationTab
, class S.sidebarLink
]
[ i [ class "fa fa-bullhorn" ] []
, span
[ class "ml-3" ]
[ text texts.notifications ]
, div []
[ a
[ href "#"
, onClick (SetTab NotificationTab)
, menuEntryActive model NotificationTab
, class S.sidebarLink
]
[ i [ class "fa fa-bullhorn" ] []
, span
[ class "ml-3" ]
[ text texts.notifications ]
]
, div
[ class "ml-5 flex flex-col"
, classList [ ( "hidden", not isNotificationTab ) ]
]
[ a
[ href "#"
, onClick (SetTab NotificationWebhookTab)
, menuEntryActive model NotificationWebhookTab
, class S.sidebarLink
]
[ i [ class "fa fa-bell" ] []
, span
[ class "ml-3" ]
[ text texts.webhooks ]
]
, a
[ href "#"
, onClick (SetTab NotificationDueItemsTab)
, menuEntryActive model NotificationDueItemsTab
, class S.sidebarLink
]
[ i [ class "fa fa-history" ] []
, span
[ class "ml-3" ]
[ text texts.dueItems ]
]
, a
[ href "#"
, onClick (SetTab NotificationQueriesTab)
, menuEntryActive model NotificationQueriesTab
, class S.sidebarLink
]
[ i [ class "fa fa-history" ] []
, span
[ class "ml-3" ]
[ text texts.genericQueries ]
]
]
]
, a
[ href "#"
@ -134,7 +194,16 @@ viewContent texts flags settings model =
viewEmailSettings texts settings model
Just NotificationTab ->
viewNotificationManage texts settings model
viewNotificationInfo texts settings model
Just NotificationWebhookTab ->
viewNotificationHooks texts settings model
Just NotificationQueriesTab ->
viewNotificationQueries texts settings model
Just NotificationDueItemsTab ->
viewNotificationDueItems texts settings model
Just ImapSettingsTab ->
viewImapSettings texts settings model
@ -268,8 +337,8 @@ viewImapSettings texts settings model =
]
viewNotificationManage : Texts -> UiSettings -> Model -> List (Html Msg)
viewNotificationManage texts settings model =
viewNotificationInfo : Texts -> UiSettings -> Model -> List (Html Msg)
viewNotificationInfo texts settings model =
[ h2
[ class S.header1
, class "inline-flex items-center"
@ -279,20 +348,119 @@ viewNotificationManage texts settings model =
[ text texts.notifications
]
]
, p [ class "opacity-80 text-lg mb-3" ]
[ text texts.notificationInfoText
, Markdown.toHtml [ class "opacity-80 text-lg max-w-prose mb-3 markdown-preview" ] texts.notificationInfoText
, div [ class "mt-2" ]
[ ul [ class "list-none ml-8" ]
[ li [ class "py-2" ]
[ a
[ href "#"
, onClick (SetTab NotificationWebhookTab)
, class S.link
]
[ i [ class "fa fa-bell" ] []
, span
[ class "ml-3" ]
[ text texts.webhooks ]
]
, div [ class "ml-3 text-sm opacity-50" ]
[ text texts.webhookInfoText
]
]
, li [ class "py-2" ]
[ a
[ href "#"
, onClick (SetTab NotificationDueItemsTab)
, class S.link
]
[ i [ class "fa fa-history" ] []
, span
[ class "ml-3" ]
[ text texts.dueItems ]
]
, div [ class "ml-3 text-sm opacity-50" ]
[ text texts.dueItemsInfoText
]
]
, li [ class "py-2" ]
[ a
[ href "#"
, onClick (SetTab NotificationQueriesTab)
, class S.link
]
[ i [ class "fa fa-history" ] []
, span
[ class "ml-3" ]
[ text texts.genericQueries ]
]
, div [ class "ml-3 text-sm opacity-50" ]
[ text texts.periodicQueryInfoText
]
]
]
]
, p [ class "opacity-80 text-lg mb-3" ]
[ Markdown.toHtml [] texts.notificationRemindDaysInfo
]
viewNotificationDueItems : Texts -> UiSettings -> Model -> List (Html Msg)
viewNotificationDueItems texts settings model =
[ h2
[ class S.header1
, class "inline-flex items-center"
]
[ i [ class "fa fa-history" ] []
, div [ class "ml-3" ]
[ text texts.dueItems
]
]
, Markdown.toHtml [ class "opacity-80 text-lg mb-3 markdown-preview" ] texts.dueItemsInfoText
, Html.map NotificationMsg
(Comp.NotificationManage.view2 texts.notificationManage
(Comp.DueItemsTaskManage.view2 texts.notificationManage
settings
model.notificationModel
)
]
viewNotificationQueries : Texts -> UiSettings -> Model -> List (Html Msg)
viewNotificationQueries texts settings model =
[ h2
[ class S.header1
, class "inline-flex items-center"
]
[ i [ class "fa fa-history" ] []
, div [ class "ml-3" ]
[ text texts.genericQueries
]
]
, Markdown.toHtml [ class "opacity-80 text-lg mb-3 markdown-preview" ] texts.periodicQueryInfoText
, Html.map PeriodicQueryMsg
(Comp.PeriodicQueryTaskManage.view texts.periodicQueryTask
settings
model.periodicQueryModel
)
]
viewNotificationHooks : Texts -> UiSettings -> Model -> List (Html Msg)
viewNotificationHooks texts settings model =
[ h2
[ class S.header1
, class "inline-flex items-center"
]
[ i [ class "fa fa-bell" ] []
, div [ class "ml-3" ]
[ text texts.webhooks
]
]
, Markdown.toHtml [ class "opacity-80 text-lg mb-3 markdown-preview" ] texts.webhookInfoText
, Html.map NotificationHookMsg
(Comp.NotificationHookManage.view texts.notificationHookManage
settings
model.notificationHookModel
)
]
viewScanMailboxManage : Texts -> Flags -> UiSettings -> Model -> List (Html Msg)
viewScanMailboxManage texts flags settings model =
[ h2