mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-04 06:05:59 +00:00
Add new search-index route to web-ui
This commit is contained in:
parent
d5c9923a6d
commit
6846f2f46e
@ -45,6 +45,7 @@ module Api exposing
|
|||||||
, getTags
|
, getTags
|
||||||
, getUsers
|
, getUsers
|
||||||
, itemDetail
|
, itemDetail
|
||||||
|
, itemIndexSearch
|
||||||
, itemSearch
|
, itemSearch
|
||||||
, login
|
, login
|
||||||
, loginSession
|
, loginSession
|
||||||
@ -104,6 +105,7 @@ import Api.Model.ImapSettings exposing (ImapSettings)
|
|||||||
import Api.Model.ImapSettingsList exposing (ImapSettingsList)
|
import Api.Model.ImapSettingsList exposing (ImapSettingsList)
|
||||||
import Api.Model.InviteResult exposing (InviteResult)
|
import Api.Model.InviteResult exposing (InviteResult)
|
||||||
import Api.Model.ItemDetail exposing (ItemDetail)
|
import Api.Model.ItemDetail exposing (ItemDetail)
|
||||||
|
import Api.Model.ItemFtsSearch exposing (ItemFtsSearch)
|
||||||
import Api.Model.ItemInsights exposing (ItemInsights)
|
import Api.Model.ItemInsights exposing (ItemInsights)
|
||||||
import Api.Model.ItemLightList exposing (ItemLightList)
|
import Api.Model.ItemLightList exposing (ItemLightList)
|
||||||
import Api.Model.ItemProposals exposing (ItemProposals)
|
import Api.Model.ItemProposals exposing (ItemProposals)
|
||||||
@ -1092,6 +1094,20 @@ moveAttachmentBefore flags itemId data receive =
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
itemIndexSearch :
|
||||||
|
Flags
|
||||||
|
-> ItemFtsSearch
|
||||||
|
-> (Result Http.Error ItemLightList -> msg)
|
||||||
|
-> Cmd msg
|
||||||
|
itemIndexSearch flags query receive =
|
||||||
|
Http2.authPost
|
||||||
|
{ url = flags.config.baseUrl ++ "/api/v1/sec/item/searchIndex"
|
||||||
|
, account = getAccount flags
|
||||||
|
, body = Http.jsonBody (Api.Model.ItemFtsSearch.encode query)
|
||||||
|
, expect = Http.expectJson receive Api.Model.ItemLightList.decoder
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
itemSearch : Flags -> ItemSearch -> (Result Http.Error ItemLightList -> msg) -> Cmd msg
|
itemSearch : Flags -> ItemSearch -> (Result Http.Error ItemLightList -> msg) -> Cmd msg
|
||||||
itemSearch flags search receive =
|
itemSearch flags search receive =
|
||||||
Http2.authPost
|
Http2.authPost
|
||||||
|
@ -3,6 +3,7 @@ module Page.Home.Data exposing
|
|||||||
, Msg(..)
|
, Msg(..)
|
||||||
, SearchType(..)
|
, SearchType(..)
|
||||||
, ViewMode(..)
|
, ViewMode(..)
|
||||||
|
, defaultSearchType
|
||||||
, doSearchCmd
|
, doSearchCmd
|
||||||
, init
|
, init
|
||||||
, itemNav
|
, itemNav
|
||||||
@ -35,6 +36,7 @@ type alias Model =
|
|||||||
, throttle : Throttle Msg
|
, throttle : Throttle Msg
|
||||||
, searchTypeDropdown : Comp.FixedDropdown.Model SearchType
|
, searchTypeDropdown : Comp.FixedDropdown.Model SearchType
|
||||||
, searchType : SearchType
|
, searchType : SearchType
|
||||||
|
, contentOnlySearch : Maybe String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -47,13 +49,6 @@ init flags =
|
|||||||
|
|
||||||
else
|
else
|
||||||
[ BasicSearch ]
|
[ BasicSearch ]
|
||||||
|
|
||||||
defaultSearchType =
|
|
||||||
if flags.config.fullTextSearchEnabled then
|
|
||||||
ContentSearch
|
|
||||||
|
|
||||||
else
|
|
||||||
BasicSearch
|
|
||||||
in
|
in
|
||||||
{ searchMenuModel = Comp.SearchMenu.init
|
{ searchMenuModel = Comp.SearchMenu.init
|
||||||
, itemListModel = Comp.ItemCardList.init
|
, itemListModel = Comp.ItemCardList.init
|
||||||
@ -67,10 +62,20 @@ init flags =
|
|||||||
, searchTypeDropdown =
|
, searchTypeDropdown =
|
||||||
Comp.FixedDropdown.initMap searchTypeString
|
Comp.FixedDropdown.initMap searchTypeString
|
||||||
searchTypeOptions
|
searchTypeOptions
|
||||||
, searchType = defaultSearchType
|
, searchType = defaultSearchType flags
|
||||||
|
, contentOnlySearch = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
defaultSearchType : Flags -> SearchType
|
||||||
|
defaultSearchType flags =
|
||||||
|
if flags.config.fullTextSearchEnabled then
|
||||||
|
ContentSearch
|
||||||
|
|
||||||
|
else
|
||||||
|
BasicSearch
|
||||||
|
|
||||||
|
|
||||||
type Msg
|
type Msg
|
||||||
= Init
|
= Init
|
||||||
| SearchMenuMsg Comp.SearchMenu.Msg
|
| SearchMenuMsg Comp.SearchMenu.Msg
|
||||||
@ -85,6 +90,7 @@ type Msg
|
|||||||
| SetBasicSearch String
|
| SetBasicSearch String
|
||||||
| SearchTypeMsg (Comp.FixedDropdown.Msg SearchType)
|
| SearchTypeMsg (Comp.FixedDropdown.Msg SearchType)
|
||||||
| KeyUpMsg (Maybe KeyCode)
|
| KeyUpMsg (Maybe KeyCode)
|
||||||
|
| SetContentOnly String
|
||||||
|
|
||||||
|
|
||||||
type SearchType
|
type SearchType
|
||||||
@ -127,6 +133,19 @@ itemNav id model =
|
|||||||
|
|
||||||
doSearchCmd : Flags -> UiSettings -> Int -> Model -> Cmd Msg
|
doSearchCmd : Flags -> UiSettings -> Int -> Model -> Cmd Msg
|
||||||
doSearchCmd flags settings offset model =
|
doSearchCmd flags settings offset model =
|
||||||
|
case model.searchType of
|
||||||
|
BasicSearch ->
|
||||||
|
doSearchDefaultCmd flags settings offset model
|
||||||
|
|
||||||
|
ContentSearch ->
|
||||||
|
doSearchDefaultCmd flags settings offset model
|
||||||
|
|
||||||
|
ContentOnlySearch ->
|
||||||
|
doSearchIndexCmd flags settings offset model
|
||||||
|
|
||||||
|
|
||||||
|
doSearchDefaultCmd : Flags -> UiSettings -> Int -> Model -> Cmd Msg
|
||||||
|
doSearchDefaultCmd flags settings offset model =
|
||||||
let
|
let
|
||||||
smask =
|
smask =
|
||||||
Comp.SearchMenu.getItemSearch model.searchMenuModel
|
Comp.SearchMenu.getItemSearch model.searchMenuModel
|
||||||
@ -144,6 +163,27 @@ doSearchCmd flags settings offset model =
|
|||||||
Api.itemSearch flags mask ItemSearchAddResp
|
Api.itemSearch flags mask ItemSearchAddResp
|
||||||
|
|
||||||
|
|
||||||
|
doSearchIndexCmd : Flags -> UiSettings -> Int -> Model -> Cmd Msg
|
||||||
|
doSearchIndexCmd flags settings offset model =
|
||||||
|
case model.contentOnlySearch of
|
||||||
|
Just q ->
|
||||||
|
let
|
||||||
|
mask =
|
||||||
|
{ query = q
|
||||||
|
, limit = settings.itemSearchPageSize
|
||||||
|
, offset = offset
|
||||||
|
}
|
||||||
|
in
|
||||||
|
if offset == 0 then
|
||||||
|
Api.itemIndexSearch flags mask ItemSearchResp
|
||||||
|
|
||||||
|
else
|
||||||
|
Api.itemIndexSearch flags mask ItemSearchAddResp
|
||||||
|
|
||||||
|
Nothing ->
|
||||||
|
Cmd.none
|
||||||
|
|
||||||
|
|
||||||
resultsBelowLimit : UiSettings -> Model -> Bool
|
resultsBelowLimit : UiSettings -> Model -> Bool
|
||||||
resultsBelowLimit settings model =
|
resultsBelowLimit settings model =
|
||||||
let
|
let
|
||||||
|
@ -11,6 +11,7 @@ import Page.Home.Data exposing (..)
|
|||||||
import Throttle
|
import Throttle
|
||||||
import Time
|
import Time
|
||||||
import Util.Html exposing (KeyCode(..))
|
import Util.Html exposing (KeyCode(..))
|
||||||
|
import Util.Maybe
|
||||||
import Util.Update
|
import Util.Update
|
||||||
|
|
||||||
|
|
||||||
@ -27,7 +28,10 @@ update key flags settings msg model =
|
|||||||
ResetSearch ->
|
ResetSearch ->
|
||||||
let
|
let
|
||||||
nm =
|
nm =
|
||||||
{ model | searchOffset = 0 }
|
{ model
|
||||||
|
| searchOffset = 0
|
||||||
|
, searchType = defaultSearchType flags
|
||||||
|
}
|
||||||
in
|
in
|
||||||
update key flags settings (SearchMenuMsg Comp.SearchMenu.ResetForm) nm
|
update key flags settings (SearchMenuMsg Comp.SearchMenu.ResetForm) nm
|
||||||
|
|
||||||
@ -161,10 +165,16 @@ update key flags settings msg model =
|
|||||||
SearchMenuMsg (Comp.SearchMenu.SetFulltext str)
|
SearchMenuMsg (Comp.SearchMenu.SetFulltext str)
|
||||||
|
|
||||||
ContentOnlySearch ->
|
ContentOnlySearch ->
|
||||||
Debug.todo "implement"
|
SetContentOnly str
|
||||||
in
|
in
|
||||||
update key flags settings smMsg model
|
update key flags settings smMsg model
|
||||||
|
|
||||||
|
SetContentOnly str ->
|
||||||
|
withSub
|
||||||
|
( { model | contentOnlySearch = Util.Maybe.fromString str }
|
||||||
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
SearchTypeMsg lm ->
|
SearchTypeMsg lm ->
|
||||||
let
|
let
|
||||||
( sm, mv ) =
|
( sm, mv ) =
|
||||||
|
@ -134,7 +134,7 @@ viewSearchBar flags model =
|
|||||||
model.searchMenuModel.fulltextModel
|
model.searchMenuModel.fulltextModel
|
||||||
|
|
||||||
ContentOnlySearch ->
|
ContentOnlySearch ->
|
||||||
Debug.todo "implement"
|
model.contentOnlySearch
|
||||||
|
|
||||||
searchTypeClass =
|
searchTypeClass =
|
||||||
if flags.config.fullTextSearchEnabled then
|
if flags.config.fullTextSearchEnabled then
|
||||||
@ -211,6 +211,6 @@ hasMoreSearch model =
|
|||||||
{ is | fullText = Nothing }
|
{ is | fullText = Nothing }
|
||||||
|
|
||||||
ContentOnlySearch ->
|
ContentOnlySearch ->
|
||||||
Debug.todo "implement"
|
Api.Model.ItemSearch.empty
|
||||||
in
|
in
|
||||||
is_ /= Api.Model.ItemSearch.empty
|
is_ /= Api.Model.ItemSearch.empty
|
||||||
|
Loading…
x
Reference in New Issue
Block a user