mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-04 22:25:58 +00:00
Allow a collective to re-index their data
If something goes wrong, this might be necessary.
This commit is contained in:
parent
c81b92af6d
commit
4a41168bbb
@ -78,6 +78,7 @@ module Api exposing
|
|||||||
, setUnconfirmed
|
, setUnconfirmed
|
||||||
, startOnceNotifyDueItems
|
, startOnceNotifyDueItems
|
||||||
, startOnceScanMailbox
|
, startOnceScanMailbox
|
||||||
|
, startReIndex
|
||||||
, submitNotifyDueItems
|
, submitNotifyDueItems
|
||||||
, updateNotifyDueItems
|
, updateNotifyDueItems
|
||||||
, updateScanMailbox
|
, updateScanMailbox
|
||||||
@ -149,6 +150,20 @@ import Util.Http as Http2
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Full-Text
|
||||||
|
|
||||||
|
|
||||||
|
startReIndex : Flags -> (Result Http.Error BasicResult -> msg) -> Cmd msg
|
||||||
|
startReIndex flags receive =
|
||||||
|
Http2.authPost
|
||||||
|
{ url = flags.config.baseUrl ++ "/api/v1/sec/fts/reIndex"
|
||||||
|
, account = getAccount flags
|
||||||
|
, body = Http.emptyBody
|
||||||
|
, expect = Http.expectJson receive Api.Model.BasicResult.decoder
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Scan Mailboxes
|
--- Scan Mailboxes
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ module Comp.CollectiveSettingsForm exposing
|
|||||||
, view
|
, view
|
||||||
)
|
)
|
||||||
|
|
||||||
|
import Api
|
||||||
|
import Api.Model.BasicResult exposing (BasicResult)
|
||||||
import Api.Model.CollectiveSettings exposing (CollectiveSettings)
|
import Api.Model.CollectiveSettings exposing (CollectiveSettings)
|
||||||
import Comp.Dropdown
|
import Comp.Dropdown
|
||||||
import Data.Flags exposing (Flags)
|
import Data.Flags exposing (Flags)
|
||||||
@ -14,13 +16,17 @@ import Data.Language exposing (Language)
|
|||||||
import Data.UiSettings exposing (UiSettings)
|
import Data.UiSettings exposing (UiSettings)
|
||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Html.Events exposing (onCheck)
|
import Html.Events exposing (onCheck, onClick, onInput)
|
||||||
|
import Http
|
||||||
|
import Util.Http
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
{ langModel : Comp.Dropdown.Model Language
|
{ langModel : Comp.Dropdown.Model Language
|
||||||
, intEnabled : Bool
|
, intEnabled : Bool
|
||||||
, initSettings : CollectiveSettings
|
, initSettings : CollectiveSettings
|
||||||
|
, fullTextConfirmText : String
|
||||||
|
, fullTextReIndexResult : Maybe BasicResult
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -44,6 +50,8 @@ init settings =
|
|||||||
}
|
}
|
||||||
, intEnabled = settings.integrationEnabled
|
, intEnabled = settings.integrationEnabled
|
||||||
, initSettings = settings
|
, initSettings = settings
|
||||||
|
, fullTextConfirmText = ""
|
||||||
|
, fullTextReIndexResult = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -61,10 +69,13 @@ getSettings model =
|
|||||||
type Msg
|
type Msg
|
||||||
= LangDropdownMsg (Comp.Dropdown.Msg Language)
|
= LangDropdownMsg (Comp.Dropdown.Msg Language)
|
||||||
| ToggleIntegrationEndpoint
|
| ToggleIntegrationEndpoint
|
||||||
|
| SetFullTextConfirm String
|
||||||
|
| TriggerReIndex
|
||||||
|
| TriggerReIndexResult (Result Http.Error BasicResult)
|
||||||
|
|
||||||
|
|
||||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg, Maybe CollectiveSettings )
|
update : Flags -> Msg -> Model -> ( Model, Cmd Msg, Maybe CollectiveSettings )
|
||||||
update _ msg model =
|
update flags msg model =
|
||||||
case msg of
|
case msg of
|
||||||
LangDropdownMsg m ->
|
LangDropdownMsg m ->
|
||||||
let
|
let
|
||||||
@ -90,17 +101,70 @@ update _ msg model =
|
|||||||
in
|
in
|
||||||
( nextModel, Cmd.none, Just (getSettings nextModel) )
|
( nextModel, Cmd.none, Just (getSettings nextModel) )
|
||||||
|
|
||||||
|
SetFullTextConfirm str ->
|
||||||
|
( { model | fullTextConfirmText = str }, Cmd.none, Nothing )
|
||||||
|
|
||||||
|
TriggerReIndex ->
|
||||||
|
case String.toLower model.fullTextConfirmText of
|
||||||
|
"ok" ->
|
||||||
|
( { model | fullTextReIndexResult = Nothing }
|
||||||
|
, Api.startReIndex flags TriggerReIndexResult
|
||||||
|
, Nothing
|
||||||
|
)
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
( { model
|
||||||
|
| fullTextReIndexResult =
|
||||||
|
Just
|
||||||
|
(BasicResult False <|
|
||||||
|
"Please type OK in the field if you really "
|
||||||
|
++ "want to start re-indexing your data."
|
||||||
|
)
|
||||||
|
}
|
||||||
|
, Cmd.none
|
||||||
|
, Nothing
|
||||||
|
)
|
||||||
|
|
||||||
|
TriggerReIndexResult (Ok br) ->
|
||||||
|
( { model | fullTextReIndexResult = Just br }, Cmd.none, Nothing )
|
||||||
|
|
||||||
|
TriggerReIndexResult (Err err) ->
|
||||||
|
( { model
|
||||||
|
| fullTextReIndexResult =
|
||||||
|
Just (BasicResult False (Util.Http.errorToString err))
|
||||||
|
}
|
||||||
|
, Cmd.none
|
||||||
|
, Nothing
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
view : Flags -> UiSettings -> Model -> Html Msg
|
view : Flags -> UiSettings -> Model -> Html Msg
|
||||||
view flags settings model =
|
view flags settings model =
|
||||||
div [ class "ui form" ]
|
div
|
||||||
[ div [ class "field" ]
|
[ classList
|
||||||
|
[ ( "ui form", True )
|
||||||
|
, ( "error", Maybe.map .success model.fullTextReIndexResult == Just False )
|
||||||
|
, ( "success", Maybe.map .success model.fullTextReIndexResult == Just True )
|
||||||
|
]
|
||||||
|
]
|
||||||
|
[ h3 [ class "ui dividing header" ]
|
||||||
|
[ text "Document Language"
|
||||||
|
]
|
||||||
|
, div [ class "field" ]
|
||||||
[ label [] [ text "Document Language" ]
|
[ label [] [ text "Document Language" ]
|
||||||
, Html.map LangDropdownMsg (Comp.Dropdown.view settings model.langModel)
|
, Html.map LangDropdownMsg (Comp.Dropdown.view settings model.langModel)
|
||||||
, span [ class "small-info" ]
|
, span [ class "small-info" ]
|
||||||
[ text "The language of your documents. This helps text recognition (OCR) and text analysis."
|
[ text "The language of your documents. This helps text recognition (OCR) and text analysis."
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
, h3
|
||||||
|
[ classList
|
||||||
|
[ ( "ui dividing header", True )
|
||||||
|
, ( "invisible hidden", not flags.config.integrationEnabled )
|
||||||
|
]
|
||||||
|
]
|
||||||
|
[ text "Integration Endpoint"
|
||||||
|
]
|
||||||
, div
|
, div
|
||||||
[ classList
|
[ classList
|
||||||
[ ( "field", True )
|
[ ( "field", True )
|
||||||
@ -121,4 +185,50 @@ view flags settings model =
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
, h3
|
||||||
|
[ classList
|
||||||
|
[ ( "ui dividing header", True )
|
||||||
|
, ( "invisible hidden", not flags.config.fullTextSearchEnabled )
|
||||||
|
]
|
||||||
|
]
|
||||||
|
[ text "Full-Text Search"
|
||||||
|
]
|
||||||
|
, div
|
||||||
|
[ classList
|
||||||
|
[ ( "inline field", True )
|
||||||
|
, ( "invisible hidden", not flags.config.fullTextSearchEnabled )
|
||||||
|
]
|
||||||
|
]
|
||||||
|
[ div [ class "ui action input" ]
|
||||||
|
[ input
|
||||||
|
[ type_ "text"
|
||||||
|
, value model.fullTextConfirmText
|
||||||
|
, onInput SetFullTextConfirm
|
||||||
|
]
|
||||||
|
[]
|
||||||
|
, button
|
||||||
|
[ class "ui primary right labeled icon button"
|
||||||
|
, onClick TriggerReIndex
|
||||||
|
]
|
||||||
|
[ i [ class "refresh icon" ] []
|
||||||
|
, text "Re-Index All Data"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
, div [ class "small-info" ]
|
||||||
|
[ text "This starts a task that clears the full-text index and re-indexes all your data again."
|
||||||
|
, text "You must type OK before clicking the button to avoid accidental re-indexing."
|
||||||
|
]
|
||||||
|
, div
|
||||||
|
[ classList
|
||||||
|
[ ( "ui message", True )
|
||||||
|
, ( "error", Maybe.map .success model.fullTextReIndexResult == Just False )
|
||||||
|
, ( "success", Maybe.map .success model.fullTextReIndexResult == Just True )
|
||||||
|
, ( "hidden invisible", model.fullTextReIndexResult == Nothing )
|
||||||
|
]
|
||||||
|
]
|
||||||
|
[ Maybe.map .message model.fullTextReIndexResult
|
||||||
|
|> Maybe.withDefault ""
|
||||||
|
|> text
|
||||||
|
]
|
||||||
|
]
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user