mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-25 14:08:25 +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:
@ -13,10 +13,12 @@ module Page.UserSettings.Data exposing
|
||||
)
|
||||
|
||||
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)
|
||||
@ -28,10 +30,12 @@ type alias Model =
|
||||
, changePassModel : Comp.ChangePasswordForm.Model
|
||||
, emailSettingsModel : Comp.EmailSettingsManage.Model
|
||||
, imapSettingsModel : Comp.ImapSettingsManage.Model
|
||||
, notificationModel : Comp.NotificationManage.Model
|
||||
, notificationModel : Comp.DueItemsTaskManage.Model
|
||||
, scanMailboxModel : Comp.ScanMailboxManage.Model
|
||||
, uiSettingsModel : Comp.UiSettingsManage.Model
|
||||
, otpSetupModel : Comp.OtpSetup.Model
|
||||
, notificationHookModel : Comp.NotificationHookManage.Model
|
||||
, periodicQueryModel : Comp.PeriodicQueryTaskManage.Model
|
||||
}
|
||||
|
||||
|
||||
@ -43,19 +47,29 @@ init flags settings =
|
||||
|
||||
( otpm, otpc ) =
|
||||
Comp.OtpSetup.init flags
|
||||
|
||||
( nhm, nhc ) =
|
||||
Comp.NotificationHookManage.init flags
|
||||
|
||||
( pqm, pqc ) =
|
||||
Comp.PeriodicQueryTaskManage.init flags
|
||||
in
|
||||
( { currentTab = Just UiSettingsTab
|
||||
, changePassModel = Comp.ChangePasswordForm.emptyModel
|
||||
, emailSettingsModel = Comp.EmailSettingsManage.emptyModel
|
||||
, imapSettingsModel = Comp.ImapSettingsManage.emptyModel
|
||||
, notificationModel = Tuple.first (Comp.NotificationManage.init flags)
|
||||
, notificationModel = Tuple.first (Comp.DueItemsTaskManage.init flags)
|
||||
, scanMailboxModel = Tuple.first (Comp.ScanMailboxManage.init flags)
|
||||
, uiSettingsModel = um
|
||||
, otpSetupModel = otpm
|
||||
, notificationHookModel = nhm
|
||||
, periodicQueryModel = pqm
|
||||
}
|
||||
, Cmd.batch
|
||||
[ Cmd.map UiSettingsMsg uc
|
||||
, Cmd.map OtpSetupMsg otpc
|
||||
, Cmd.map NotificationHookMsg nhc
|
||||
, Cmd.map PeriodicQueryMsg pqc
|
||||
]
|
||||
)
|
||||
|
||||
@ -65,6 +79,9 @@ type Tab
|
||||
| EmailSettingsTab
|
||||
| ImapSettingsTab
|
||||
| NotificationTab
|
||||
| NotificationWebhookTab
|
||||
| NotificationQueriesTab
|
||||
| NotificationDueItemsTab
|
||||
| ScanMailboxTab
|
||||
| UiSettingsTab
|
||||
| OtpTab
|
||||
@ -74,10 +91,12 @@ type Msg
|
||||
= SetTab Tab
|
||||
| ChangePassMsg Comp.ChangePasswordForm.Msg
|
||||
| EmailSettingsMsg Comp.EmailSettingsManage.Msg
|
||||
| NotificationMsg Comp.NotificationManage.Msg
|
||||
| NotificationMsg Comp.DueItemsTaskManage.Msg
|
||||
| ImapSettingsMsg Comp.ImapSettingsManage.Msg
|
||||
| ScanMailboxMsg Comp.ScanMailboxManage.Msg
|
||||
| UiSettingsMsg Comp.UiSettingsManage.Msg
|
||||
| OtpSetupMsg Comp.OtpSetup.Msg
|
||||
| NotificationHookMsg Comp.NotificationHookManage.Msg
|
||||
| PeriodicQueryMsg Comp.PeriodicQueryTaskManage.Msg
|
||||
| UpdateSettings
|
||||
| ReceiveBrowserSettings StoredUiSettings
|
||||
|
@ -8,10 +8,12 @@
|
||||
module Page.UserSettings.Update exposing (UpdateResult, update)
|
||||
|
||||
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)
|
||||
@ -62,10 +64,32 @@ update flags settings msg model =
|
||||
UpdateResult m Cmd.none Sub.none Nothing
|
||||
|
||||
NotificationTab ->
|
||||
{ model = m
|
||||
, cmd = Cmd.none
|
||||
, sub = Sub.none
|
||||
, newSettings = Nothing
|
||||
}
|
||||
|
||||
NotificationWebhookTab ->
|
||||
{ model = m
|
||||
, cmd = Cmd.none
|
||||
, sub = Sub.none
|
||||
, newSettings = Nothing
|
||||
}
|
||||
|
||||
NotificationQueriesTab ->
|
||||
let
|
||||
initCmd =
|
||||
Cmd.map NotificationMsg
|
||||
(Tuple.second (Comp.NotificationManage.init flags))
|
||||
(Tuple.second (Comp.DueItemsTaskManage.init flags))
|
||||
in
|
||||
UpdateResult m initCmd Sub.none Nothing
|
||||
|
||||
NotificationDueItemsTab ->
|
||||
let
|
||||
initCmd =
|
||||
Cmd.map NotificationMsg
|
||||
(Tuple.second (Comp.DueItemsTaskManage.init flags))
|
||||
in
|
||||
UpdateResult m initCmd Sub.none Nothing
|
||||
|
||||
@ -119,7 +143,7 @@ update flags settings msg model =
|
||||
NotificationMsg lm ->
|
||||
let
|
||||
( m2, c2 ) =
|
||||
Comp.NotificationManage.update flags lm model.notificationModel
|
||||
Comp.DueItemsTaskManage.update flags lm model.notificationModel
|
||||
in
|
||||
{ model = { model | notificationModel = m2 }
|
||||
, cmd = Cmd.map NotificationMsg c2
|
||||
@ -160,6 +184,17 @@ update flags settings msg model =
|
||||
, newSettings = Nothing
|
||||
}
|
||||
|
||||
NotificationHookMsg lm ->
|
||||
let
|
||||
( hm, hc ) =
|
||||
Comp.NotificationHookManage.update flags lm model.notificationHookModel
|
||||
in
|
||||
{ model = { model | notificationHookModel = hm }
|
||||
, cmd = Cmd.map NotificationHookMsg hc
|
||||
, sub = Sub.none
|
||||
, newSettings = Nothing
|
||||
}
|
||||
|
||||
UpdateSettings ->
|
||||
update flags
|
||||
settings
|
||||
@ -172,3 +207,14 @@ update flags settings msg model =
|
||||
Comp.UiSettingsManage.ReceiveBrowserSettings sett
|
||||
in
|
||||
update flags settings (UiSettingsMsg lm) model
|
||||
|
||||
PeriodicQueryMsg lm ->
|
||||
let
|
||||
( pqm, pqc, pqs ) =
|
||||
Comp.PeriodicQueryTaskManage.update flags lm model.periodicQueryModel
|
||||
in
|
||||
{ model = { model | periodicQueryModel = pqm }
|
||||
, cmd = Cmd.map PeriodicQueryMsg pqc
|
||||
, sub = Sub.map PeriodicQueryMsg pqs
|
||||
, newSettings = Nothing
|
||||
}
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user