mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 10:28:27 +00:00
Add api functions for getting/setting client settings
This commit is contained in:
@ -37,6 +37,7 @@ module Api exposing
|
||||
, deleteUser
|
||||
, fileURL
|
||||
, getAttachmentMeta
|
||||
, getClientSettings
|
||||
, getCollective
|
||||
, getCollectiveSettings
|
||||
, getContacts
|
||||
@ -91,6 +92,7 @@ module Api exposing
|
||||
, removeTagsMultiple
|
||||
, reprocessItem
|
||||
, reprocessMultiple
|
||||
, saveClientSettings
|
||||
, sendMail
|
||||
, setAttachmentName
|
||||
, setCollectiveSettings
|
||||
@ -204,8 +206,10 @@ import Api.Model.VersionInfo exposing (VersionInfo)
|
||||
import Data.ContactType exposing (ContactType)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.Priority exposing (Priority)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import File exposing (File)
|
||||
import Http
|
||||
import Json.Decode as JsonDecode
|
||||
import Json.Encode as JsonEncode
|
||||
import Set exposing (Set)
|
||||
import Task
|
||||
@ -1981,6 +1985,44 @@ getItemProposals flags item receive =
|
||||
|
||||
|
||||
|
||||
--- Client Settings
|
||||
|
||||
|
||||
getClientSettings : Flags -> (Result Http.Error UiSettings -> msg) -> Cmd msg
|
||||
getClientSettings flags receive =
|
||||
let
|
||||
defaults =
|
||||
Data.UiSettings.defaults
|
||||
|
||||
decoder =
|
||||
JsonDecode.map (\s -> Data.UiSettings.merge s defaults)
|
||||
Data.UiSettings.storedUiSettingsDecoder
|
||||
in
|
||||
Http2.authGet
|
||||
{ url = flags.config.baseUrl ++ "/api/v1/sec/clientSettings/webClient"
|
||||
, account = getAccount flags
|
||||
, expect = Http.expectJson receive decoder
|
||||
}
|
||||
|
||||
|
||||
saveClientSettings : Flags -> UiSettings -> (Result Http.Error BasicResult -> msg) -> Cmd msg
|
||||
saveClientSettings flags settings receive =
|
||||
let
|
||||
storedSettings =
|
||||
Data.UiSettings.toStoredUiSettings settings
|
||||
|
||||
encode =
|
||||
Data.UiSettings.storedUiSettingsEncode storedSettings
|
||||
in
|
||||
Http2.authPut
|
||||
{ url = flags.config.baseUrl ++ "/api/v1/sec/clientSettings/webClient"
|
||||
, account = getAccount flags
|
||||
, body = Http.jsonBody encode
|
||||
, expect = Http.expectJson receive Api.Model.BasicResult.decoder
|
||||
}
|
||||
|
||||
|
||||
|
||||
--- Helper
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user