mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-07-31 06:54:52 +00:00
Prepare notification form
This commit is contained in:
@ -133,6 +133,9 @@ val openapiScalaSettings = Seq(
|
|||||||
field.copy(typeDef = TypeDef("NerTag", Imports("docspell.common.NerTag")))
|
field.copy(typeDef = TypeDef("NerTag", Imports("docspell.common.NerTag")))
|
||||||
case "language" => field =>
|
case "language" => field =>
|
||||||
field.copy(typeDef = TypeDef("Language", Imports("docspell.common.Language")))
|
field.copy(typeDef = TypeDef("Language", Imports("docspell.common.Language")))
|
||||||
|
case "calevent" => field =>
|
||||||
|
field.copy(typeDef = TypeDef("CalEvent", Imports("com.github.eikek.calev.CalEvent",
|
||||||
|
"com.github.eikek.calev.circe.CalevCirceCodec._")))
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -149,6 +152,7 @@ val common = project.in(file("modules/common")).
|
|||||||
Dependencies.circe ++
|
Dependencies.circe ++
|
||||||
Dependencies.loggingApi ++
|
Dependencies.loggingApi ++
|
||||||
Dependencies.calevCore ++
|
Dependencies.calevCore ++
|
||||||
|
Dependencies.calevCirce ++
|
||||||
Dependencies.pureconfig.map(_ % "optional")
|
Dependencies.pureconfig.map(_ % "optional")
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -205,7 +209,8 @@ val store = project.in(file("modules/store")).
|
|||||||
Dependencies.loggingApi ++
|
Dependencies.loggingApi ++
|
||||||
Dependencies.emil ++
|
Dependencies.emil ++
|
||||||
Dependencies.emilDoobie ++
|
Dependencies.emilDoobie ++
|
||||||
Dependencies.calev
|
Dependencies.calevCore ++
|
||||||
|
Dependencies.calevFs2
|
||||||
).dependsOn(common)
|
).dependsOn(common)
|
||||||
|
|
||||||
val extract = project.in(file("modules/extract")).
|
val extract = project.in(file("modules/extract")).
|
||||||
|
@ -1560,9 +1560,96 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/BasicResult"
|
$ref: "#/components/schemas/BasicResult"
|
||||||
|
/sec/notification:
|
||||||
|
get:
|
||||||
|
tags: [ Notification ]
|
||||||
|
summary: Get current notification settings
|
||||||
|
description: |
|
||||||
|
Return the current notification settings of the authenticated
|
||||||
|
user. Users can be notified on due items via e-mail. This is
|
||||||
|
done by periodically querying items.
|
||||||
|
security:
|
||||||
|
- authTokenHeader: []
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Ok
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/NotificationData"
|
||||||
|
post:
|
||||||
|
tags: [ Notification ]
|
||||||
|
summary: Change current notification settings
|
||||||
|
description: |
|
||||||
|
Change the current notification settings of the authenticated
|
||||||
|
user.
|
||||||
|
security:
|
||||||
|
- authTokenHeader: []
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/NotificationSettings"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Ok
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/BasicResult"
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
|
NotificationSettings:
|
||||||
|
description: |
|
||||||
|
Settings for notifying about due items.
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
- enabled
|
||||||
|
- smtpConnection
|
||||||
|
- schedule
|
||||||
|
- remindDays
|
||||||
|
- tagsInclude
|
||||||
|
- tagsExclude
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
format: ident
|
||||||
|
enabled:
|
||||||
|
type: boolean
|
||||||
|
smtpConnection:
|
||||||
|
type: string
|
||||||
|
format: ident
|
||||||
|
schedule:
|
||||||
|
type: string
|
||||||
|
format: calevent
|
||||||
|
remindDays:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
tagsInclude:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: ident
|
||||||
|
tagsExclude:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: ident
|
||||||
|
NotificationData:
|
||||||
|
description: |
|
||||||
|
Data for the notification settings.
|
||||||
|
required:
|
||||||
|
- settings
|
||||||
|
properties:
|
||||||
|
settings:
|
||||||
|
$ref: "#/components/schemas/NotificationSettings"
|
||||||
|
nextRun:
|
||||||
|
type: integer
|
||||||
|
format: date-time
|
||||||
|
lastRun:
|
||||||
|
type: integer
|
||||||
|
format: date-time
|
||||||
SentMails:
|
SentMails:
|
||||||
description: |
|
description: |
|
||||||
A list of sent mails.
|
A list of sent mails.
|
||||||
|
42
modules/webapp/src/main/elm/Comp/NotificationForm.elm
Normal file
42
modules/webapp/src/main/elm/Comp/NotificationForm.elm
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
module Comp.NotificationForm exposing
|
||||||
|
( Model
|
||||||
|
, Msg
|
||||||
|
, init
|
||||||
|
, update
|
||||||
|
, view
|
||||||
|
)
|
||||||
|
|
||||||
|
import Api.Model.NotificationSettings exposing (NotificationSettings)
|
||||||
|
import Data.Flags exposing (Flags)
|
||||||
|
import Html exposing (..)
|
||||||
|
import Html.Attributes exposing (..)
|
||||||
|
|
||||||
|
|
||||||
|
type alias Model =
|
||||||
|
{ settings : NotificationSettings
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type Msg
|
||||||
|
= Submit
|
||||||
|
|
||||||
|
|
||||||
|
init : Model
|
||||||
|
init =
|
||||||
|
{ settings = Api.Model.NotificationSettings.empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
||||||
|
update flags msg model =
|
||||||
|
( model, Cmd.none )
|
||||||
|
|
||||||
|
|
||||||
|
view : Model -> Html Msg
|
||||||
|
view model =
|
||||||
|
div
|
||||||
|
[ classList
|
||||||
|
[ ( "ui form", True )
|
||||||
|
]
|
||||||
|
]
|
||||||
|
[]
|
@ -7,12 +7,14 @@ module Page.UserSettings.Data exposing
|
|||||||
|
|
||||||
import Comp.ChangePasswordForm
|
import Comp.ChangePasswordForm
|
||||||
import Comp.EmailSettingsManage
|
import Comp.EmailSettingsManage
|
||||||
|
import Comp.NotificationForm
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
{ currentTab : Maybe Tab
|
{ currentTab : Maybe Tab
|
||||||
, changePassModel : Comp.ChangePasswordForm.Model
|
, changePassModel : Comp.ChangePasswordForm.Model
|
||||||
, emailSettingsModel : Comp.EmailSettingsManage.Model
|
, emailSettingsModel : Comp.EmailSettingsManage.Model
|
||||||
|
, notificationModel : Comp.NotificationForm.Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -21,15 +23,18 @@ emptyModel =
|
|||||||
{ currentTab = Nothing
|
{ currentTab = Nothing
|
||||||
, changePassModel = Comp.ChangePasswordForm.emptyModel
|
, changePassModel = Comp.ChangePasswordForm.emptyModel
|
||||||
, emailSettingsModel = Comp.EmailSettingsManage.emptyModel
|
, emailSettingsModel = Comp.EmailSettingsManage.emptyModel
|
||||||
|
, notificationModel = Comp.NotificationForm.init
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type Tab
|
type Tab
|
||||||
= ChangePassTab
|
= ChangePassTab
|
||||||
| EmailSettingsTab
|
| EmailSettingsTab
|
||||||
|
| NotificationTab
|
||||||
|
|
||||||
|
|
||||||
type Msg
|
type Msg
|
||||||
= SetTab Tab
|
= SetTab Tab
|
||||||
| ChangePassMsg Comp.ChangePasswordForm.Msg
|
| ChangePassMsg Comp.ChangePasswordForm.Msg
|
||||||
| EmailSettingsMsg Comp.EmailSettingsManage.Msg
|
| EmailSettingsMsg Comp.EmailSettingsManage.Msg
|
||||||
|
| NotificationMsg Comp.NotificationForm.Msg
|
||||||
|
@ -2,6 +2,7 @@ module Page.UserSettings.Update exposing (update)
|
|||||||
|
|
||||||
import Comp.ChangePasswordForm
|
import Comp.ChangePasswordForm
|
||||||
import Comp.EmailSettingsManage
|
import Comp.EmailSettingsManage
|
||||||
|
import Comp.NotificationForm
|
||||||
import Data.Flags exposing (Flags)
|
import Data.Flags exposing (Flags)
|
||||||
import Page.UserSettings.Data exposing (..)
|
import Page.UserSettings.Data exposing (..)
|
||||||
|
|
||||||
@ -25,6 +26,10 @@ update flags msg model =
|
|||||||
|
|
||||||
ChangePassTab ->
|
ChangePassTab ->
|
||||||
( m, Cmd.none )
|
( m, Cmd.none )
|
||||||
|
|
||||||
|
NotificationTab ->
|
||||||
|
-- todo: get initial settings
|
||||||
|
( m, Cmd.none )
|
||||||
in
|
in
|
||||||
( m2, cmd )
|
( m2, cmd )
|
||||||
|
|
||||||
@ -41,3 +46,12 @@ update flags msg model =
|
|||||||
Comp.EmailSettingsManage.update flags m model.emailSettingsModel
|
Comp.EmailSettingsManage.update flags m model.emailSettingsModel
|
||||||
in
|
in
|
||||||
( { model | emailSettingsModel = m2 }, Cmd.map EmailSettingsMsg c2 )
|
( { model | emailSettingsModel = m2 }, Cmd.map EmailSettingsMsg c2 )
|
||||||
|
|
||||||
|
NotificationMsg lm ->
|
||||||
|
let
|
||||||
|
( m2, c2 ) =
|
||||||
|
Comp.NotificationForm.update flags lm model.notificationModel
|
||||||
|
in
|
||||||
|
( { model | notificationModel = m2 }
|
||||||
|
, Cmd.map NotificationMsg c2
|
||||||
|
)
|
||||||
|
@ -2,6 +2,7 @@ module Page.UserSettings.View exposing (view)
|
|||||||
|
|
||||||
import Comp.ChangePasswordForm
|
import Comp.ChangePasswordForm
|
||||||
import Comp.EmailSettingsManage
|
import Comp.EmailSettingsManage
|
||||||
|
import Comp.NotificationForm
|
||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Html.Events exposing (onClick)
|
import Html.Events exposing (onClick)
|
||||||
@ -18,22 +19,9 @@ view model =
|
|||||||
]
|
]
|
||||||
, div [ class "ui attached fluid segment" ]
|
, div [ class "ui attached fluid segment" ]
|
||||||
[ div [ class "ui fluid vertical secondary menu" ]
|
[ div [ class "ui fluid vertical secondary menu" ]
|
||||||
[ a
|
[ makeTab model ChangePassTab "Change Password" "user secret icon"
|
||||||
[ classActive (model.currentTab == Just ChangePassTab) "link icon item"
|
, makeTab model EmailSettingsTab "E-Mail Settings" "mail icon"
|
||||||
, onClick (SetTab ChangePassTab)
|
, makeTab model NotificationTab "Notifications" "bullhorn icon"
|
||||||
, href "#"
|
|
||||||
]
|
|
||||||
[ i [ class "user secret icon" ] []
|
|
||||||
, text "Change Password"
|
|
||||||
]
|
|
||||||
, a
|
|
||||||
[ classActive (model.currentTab == Just EmailSettingsTab) "link icon item"
|
|
||||||
, onClick (SetTab EmailSettingsTab)
|
|
||||||
, href "#"
|
|
||||||
]
|
|
||||||
[ i [ class "mail icon" ] []
|
|
||||||
, text "E-Mail Settings"
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -46,6 +34,9 @@ view model =
|
|||||||
Just EmailSettingsTab ->
|
Just EmailSettingsTab ->
|
||||||
viewEmailSettings model
|
viewEmailSettings model
|
||||||
|
|
||||||
|
Just NotificationTab ->
|
||||||
|
viewNotificationForm model
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
@ -53,6 +44,18 @@ view model =
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
makeTab : Model -> Tab -> String -> String -> Html Msg
|
||||||
|
makeTab model tab header icon =
|
||||||
|
a
|
||||||
|
[ classActive (model.currentTab == Just tab) "link icon item"
|
||||||
|
, onClick (SetTab tab)
|
||||||
|
, href "#"
|
||||||
|
]
|
||||||
|
[ i [ class icon ] []
|
||||||
|
, text header
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
viewEmailSettings : Model -> List (Html Msg)
|
viewEmailSettings : Model -> List (Html Msg)
|
||||||
viewEmailSettings model =
|
viewEmailSettings model =
|
||||||
[ h2 [ class "ui header" ]
|
[ h2 [ class "ui header" ]
|
||||||
@ -75,3 +78,15 @@ viewChangePassword model =
|
|||||||
]
|
]
|
||||||
, Html.map ChangePassMsg (Comp.ChangePasswordForm.view model.changePassModel)
|
, Html.map ChangePassMsg (Comp.ChangePasswordForm.view model.changePassModel)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
viewNotificationForm : Model -> List (Html Msg)
|
||||||
|
viewNotificationForm model =
|
||||||
|
[ h2 [ class "ui header" ]
|
||||||
|
[ i [ class "ui bullhorn icon" ] []
|
||||||
|
, div [ class "content" ]
|
||||||
|
[ text "Notification"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
, Html.map NotificationMsg (Comp.NotificationForm.view model.notificationModel)
|
||||||
|
]
|
||||||
|
@ -41,12 +41,14 @@ object Dependencies {
|
|||||||
|
|
||||||
|
|
||||||
val calevCore = Seq(
|
val calevCore = Seq(
|
||||||
"com.github.eikek" %% "calev-core" % CalevVersion,
|
"com.github.eikek" %% "calev-core" % CalevVersion
|
||||||
)
|
)
|
||||||
val calevFs2 = Seq(
|
val calevFs2 = Seq(
|
||||||
"com.github.eikek" %% "calev-fs2" % CalevVersion
|
"com.github.eikek" %% "calev-fs2" % CalevVersion
|
||||||
)
|
)
|
||||||
val calev = calevFs2 ++ calevCore
|
val calevCirce = Seq(
|
||||||
|
"com.github.eikek" %% "calev-circe" % CalevVersion
|
||||||
|
)
|
||||||
|
|
||||||
val jclOverSlf4j = Seq(
|
val jclOverSlf4j = Seq(
|
||||||
"org.slf4j" % "jcl-over-slf4j" % Slf4jVersion
|
"org.slf4j" % "jcl-over-slf4j" % Slf4jVersion
|
||||||
|
Reference in New Issue
Block a user