mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Allow a collective to disable the integration endpoint
This commit is contained in:
@ -8,7 +8,7 @@ module Page.CollectiveSettings.Data exposing
|
||||
import Api.Model.BasicResult exposing (BasicResult)
|
||||
import Api.Model.CollectiveSettings exposing (CollectiveSettings)
|
||||
import Api.Model.ItemInsights exposing (ItemInsights)
|
||||
import Comp.Settings
|
||||
import Comp.CollectiveSettingsForm
|
||||
import Comp.SourceManage
|
||||
import Comp.UserManage
|
||||
import Http
|
||||
@ -18,7 +18,7 @@ type alias Model =
|
||||
{ currentTab : Maybe Tab
|
||||
, sourceModel : Comp.SourceManage.Model
|
||||
, userModel : Comp.UserManage.Model
|
||||
, settingsModel : Comp.Settings.Model
|
||||
, settingsModel : Comp.CollectiveSettingsForm.Model
|
||||
, insights : ItemInsights
|
||||
, submitResult : Maybe BasicResult
|
||||
}
|
||||
@ -29,7 +29,7 @@ emptyModel =
|
||||
{ currentTab = Just InsightsTab
|
||||
, sourceModel = Comp.SourceManage.emptyModel
|
||||
, userModel = Comp.UserManage.emptyModel
|
||||
, settingsModel = Comp.Settings.init Api.Model.CollectiveSettings.empty
|
||||
, settingsModel = Comp.CollectiveSettingsForm.init Api.Model.CollectiveSettings.empty
|
||||
, insights = Api.Model.ItemInsights.empty
|
||||
, submitResult = Nothing
|
||||
}
|
||||
@ -46,7 +46,7 @@ type Msg
|
||||
= SetTab Tab
|
||||
| SourceMsg Comp.SourceManage.Msg
|
||||
| UserMsg Comp.UserManage.Msg
|
||||
| SettingsMsg Comp.Settings.Msg
|
||||
| SettingsFormMsg Comp.CollectiveSettingsForm.Msg
|
||||
| Init
|
||||
| GetInsightsResp (Result Http.Error ItemInsights)
|
||||
| CollectiveSettingsResp (Result Http.Error CollectiveSettings)
|
||||
|
@ -2,7 +2,7 @@ module Page.CollectiveSettings.Update exposing (update)
|
||||
|
||||
import Api
|
||||
import Api.Model.BasicResult exposing (BasicResult)
|
||||
import Comp.Settings
|
||||
import Comp.CollectiveSettingsForm
|
||||
import Comp.SourceManage
|
||||
import Comp.UserManage
|
||||
import Data.Flags exposing (Flags)
|
||||
@ -45,10 +45,10 @@ update flags msg model =
|
||||
in
|
||||
( { model | userModel = m2 }, Cmd.map UserMsg c2 )
|
||||
|
||||
SettingsMsg m ->
|
||||
SettingsFormMsg m ->
|
||||
let
|
||||
( m2, c2, msett ) =
|
||||
Comp.Settings.update flags m model.settingsModel
|
||||
Comp.CollectiveSettingsForm.update flags m model.settingsModel
|
||||
|
||||
cmd =
|
||||
case msett of
|
||||
@ -58,7 +58,9 @@ update flags msg model =
|
||||
Just sett ->
|
||||
Api.setCollectiveSettings flags sett SubmitResp
|
||||
in
|
||||
( { model | settingsModel = m2, submitResult = Nothing }, Cmd.batch [ cmd, Cmd.map SettingsMsg c2 ] )
|
||||
( { model | settingsModel = m2, submitResult = Nothing }
|
||||
, Cmd.batch [ cmd, Cmd.map SettingsFormMsg c2 ]
|
||||
)
|
||||
|
||||
Init ->
|
||||
( { model | submitResult = Nothing }
|
||||
@ -75,7 +77,7 @@ update flags msg model =
|
||||
( model, Cmd.none )
|
||||
|
||||
CollectiveSettingsResp (Ok data) ->
|
||||
( { model | settingsModel = Comp.Settings.init data }, Cmd.none )
|
||||
( { model | settingsModel = Comp.CollectiveSettingsForm.init data }, Cmd.none )
|
||||
|
||||
CollectiveSettingsResp (Err _) ->
|
||||
( model, Cmd.none )
|
||||
|
@ -1,7 +1,7 @@
|
||||
module Page.CollectiveSettings.View exposing (view)
|
||||
|
||||
import Api.Model.NameCount exposing (NameCount)
|
||||
import Comp.Settings
|
||||
import Comp.CollectiveSettingsForm
|
||||
import Comp.SourceManage
|
||||
import Comp.UserManage
|
||||
import Data.Flags exposing (Flags)
|
||||
@ -41,8 +41,8 @@ view flags model =
|
||||
[ classActive (model.currentTab == Just SettingsTab) "link icon item"
|
||||
, onClick (SetTab SettingsTab)
|
||||
]
|
||||
[ i [ class "language icon" ] []
|
||||
, text "Document Language"
|
||||
[ i [ class "cog icon" ] []
|
||||
, text "Settings"
|
||||
]
|
||||
, div
|
||||
[ classActive (model.currentTab == Just UserTab) "link icon item"
|
||||
@ -67,7 +67,7 @@ view flags model =
|
||||
viewInsights model
|
||||
|
||||
Just SettingsTab ->
|
||||
viewSettings model
|
||||
viewSettings flags model
|
||||
|
||||
Nothing ->
|
||||
[]
|
||||
@ -176,42 +176,25 @@ viewUsers model =
|
||||
]
|
||||
|
||||
|
||||
viewSettings : Model -> List (Html Msg)
|
||||
viewSettings model =
|
||||
[ div [ class "ui grid" ]
|
||||
[ div [ class "row" ]
|
||||
[ div [ class "sixteen wide colum" ]
|
||||
[ h2 [ class "ui header" ]
|
||||
[ i [ class "ui language icon" ] []
|
||||
, div [ class "content" ]
|
||||
[ text "Document Language"
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
, div [ class "row" ]
|
||||
[ div [ class "six wide column" ]
|
||||
[ div [ class "ui basic segment" ]
|
||||
[ text "The language of your documents. This helps text recognition (OCR) and text analysis."
|
||||
]
|
||||
]
|
||||
]
|
||||
, div [ class "row" ]
|
||||
[ div [ class "six wide column" ]
|
||||
[ Html.map SettingsMsg (Comp.Settings.view model.settingsModel)
|
||||
, div
|
||||
[ classList
|
||||
[ ( "ui message", True )
|
||||
, ( "hidden", Util.Maybe.isEmpty model.submitResult )
|
||||
, ( "success", Maybe.map .success model.submitResult |> Maybe.withDefault False )
|
||||
, ( "error", Maybe.map .success model.submitResult |> Maybe.map not |> Maybe.withDefault False )
|
||||
]
|
||||
]
|
||||
[ Maybe.map .message model.submitResult
|
||||
|> Maybe.withDefault ""
|
||||
|> text
|
||||
]
|
||||
]
|
||||
viewSettings : Flags -> Model -> List (Html Msg)
|
||||
viewSettings flags model =
|
||||
[ h2 [ class "ui header" ]
|
||||
[ i [ class "cog icon" ] []
|
||||
, text "Settings"
|
||||
]
|
||||
, div [ class "ui segment" ]
|
||||
[ Html.map SettingsFormMsg (Comp.CollectiveSettingsForm.view flags model.settingsModel)
|
||||
]
|
||||
, div
|
||||
[ classList
|
||||
[ ( "ui message", True )
|
||||
, ( "hidden", Util.Maybe.isEmpty model.submitResult )
|
||||
, ( "success", Maybe.map .success model.submitResult |> Maybe.withDefault False )
|
||||
, ( "error", Maybe.map .success model.submitResult |> Maybe.map not |> Maybe.withDefault False )
|
||||
]
|
||||
]
|
||||
[ Maybe.map .message model.submitResult
|
||||
|> Maybe.withDefault ""
|
||||
|> text
|
||||
]
|
||||
]
|
||||
|
Reference in New Issue
Block a user