mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Use search stats to populate search menu
This commit is contained in:
@ -114,6 +114,7 @@ module Api exposing
|
||||
, restoreItem
|
||||
, saveClientSettings
|
||||
, searchShare
|
||||
, searchShareStats
|
||||
, sendMail
|
||||
, setAttachmentName
|
||||
, setCollectiveSettings
|
||||
@ -2283,13 +2284,23 @@ verifyShare flags secret receive =
|
||||
searchShare : Flags -> String -> ItemQuery -> (Result Http.Error ItemLightList -> msg) -> Cmd msg
|
||||
searchShare flags token search receive =
|
||||
Http2.sharePost
|
||||
{ url = flags.config.baseUrl ++ "/api/v1/share/search"
|
||||
{ url = flags.config.baseUrl ++ "/api/v1/share/search/query"
|
||||
, token = token
|
||||
, body = Http.jsonBody (Api.Model.ItemQuery.encode search)
|
||||
, expect = Http.expectJson receive Api.Model.ItemLightList.decoder
|
||||
}
|
||||
|
||||
|
||||
searchShareStats : Flags -> String -> ItemQuery -> (Result Http.Error SearchStats -> msg) -> Cmd msg
|
||||
searchShareStats flags token search receive =
|
||||
Http2.sharePost
|
||||
{ url = flags.config.baseUrl ++ "/api/v1/share/search/stats"
|
||||
, token = token
|
||||
, body = Http.jsonBody (Api.Model.ItemQuery.encode search)
|
||||
, expect = Http.expectJson receive Api.Model.SearchStats.decoder
|
||||
}
|
||||
|
||||
|
||||
shareAttachmentPreviewURL : String -> String
|
||||
shareAttachmentPreviewURL id =
|
||||
"/api/v1/share/attachment/" ++ id ++ "/preview?withFallback=true"
|
||||
|
@ -15,6 +15,7 @@ module Comp.SearchMenu exposing
|
||||
, isFulltextSearch
|
||||
, isNamesSearch
|
||||
, linkTargetMsg
|
||||
, setFromStats
|
||||
, textSearchString
|
||||
, update
|
||||
, updateDrop
|
||||
@ -379,6 +380,11 @@ type Msg
|
||||
| ToggleOpenAllAkkordionTabs
|
||||
|
||||
|
||||
setFromStats : SearchStats -> Msg
|
||||
setFromStats stats =
|
||||
GetStatsResp (Ok stats)
|
||||
|
||||
|
||||
linkTargetMsg : LinkTarget -> Maybe Msg
|
||||
linkTargetMsg linkTarget =
|
||||
case linkTarget of
|
||||
|
@ -245,6 +245,12 @@ makeWorkModel sel model =
|
||||
}
|
||||
|
||||
|
||||
noEmptyTags : Model -> Bool
|
||||
noEmptyTags model =
|
||||
Dict.filter (\k -> \v -> v.count == 0) model.availableTags
|
||||
|> Dict.isEmpty
|
||||
|
||||
|
||||
type Msg
|
||||
= ToggleTag String
|
||||
| ToggleCat String
|
||||
@ -422,6 +428,7 @@ viewTagsDrop2 texts ddm wm settings model =
|
||||
[ a
|
||||
[ class S.secondaryBasicButtonPlain
|
||||
, class "border rounded flex-none px-1 py-1"
|
||||
, classList [ ( "hidden", noEmptyTags model ) ]
|
||||
, href "#"
|
||||
, onClick ToggleShowEmpty
|
||||
]
|
||||
|
@ -9,6 +9,7 @@ module Page.Share.Data exposing (Mode(..), Model, Msg(..), PageError(..), init)
|
||||
|
||||
import Api
|
||||
import Api.Model.ItemLightList exposing (ItemLightList)
|
||||
import Api.Model.SearchStats exposing (SearchStats)
|
||||
import Api.Model.ShareSecret exposing (ShareSecret)
|
||||
import Api.Model.ShareVerifyResult exposing (ShareVerifyResult)
|
||||
import Comp.ItemCardList
|
||||
@ -41,7 +42,6 @@ type alias Model =
|
||||
, verifyResult : ShareVerifyResult
|
||||
, passwordModel : PasswordModel
|
||||
, pageError : PageError
|
||||
, items : ItemLightList
|
||||
, searchMenuModel : Comp.SearchMenu.Model
|
||||
, powerSearchInput : Comp.PowerSearchInput.Model
|
||||
, searchInProgress : Bool
|
||||
@ -58,7 +58,6 @@ emptyModel flags =
|
||||
, passwordFailed = False
|
||||
}
|
||||
, pageError = PageErrorNone
|
||||
, items = Api.Model.ItemLightList.empty
|
||||
, searchMenuModel = Comp.SearchMenu.init flags
|
||||
, powerSearchInput = Comp.PowerSearchInput.init
|
||||
, searchInProgress = False
|
||||
@ -79,6 +78,7 @@ init shareId flags =
|
||||
type Msg
|
||||
= VerifyResp (Result Http.Error ShareVerifyResult)
|
||||
| SearchResp (Result Http.Error ItemLightList)
|
||||
| StatsResp (Result Http.Error SearchStats)
|
||||
| SetPassword String
|
||||
| SubmitPassword
|
||||
| SearchMenuMsg Comp.SearchMenu.Msg
|
||||
|
@ -91,6 +91,16 @@ update flags settings shareId msg model =
|
||||
SearchResp (Err err) ->
|
||||
noSub ( { model | pageError = PageErrorHttp err, searchInProgress = False }, Cmd.none )
|
||||
|
||||
StatsResp (Ok stats) ->
|
||||
update flags
|
||||
settings
|
||||
shareId
|
||||
(SearchMenuMsg (Comp.SearchMenu.setFromStats stats))
|
||||
model
|
||||
|
||||
StatsResp (Err err) ->
|
||||
noSub ( { model | pageError = PageErrorHttp err }, Cmd.none )
|
||||
|
||||
SetPassword pw ->
|
||||
let
|
||||
pm =
|
||||
@ -191,8 +201,14 @@ makeSearchCmd flags model =
|
||||
, query = Q.renderMaybe mq
|
||||
, searchMode = Just (Data.SearchMode.asString Data.SearchMode.Normal)
|
||||
}
|
||||
|
||||
searchCmd =
|
||||
Api.searchShare flags model.verifyResult.token (request xq) SearchResp
|
||||
|
||||
statsCmd =
|
||||
Api.searchShareStats flags model.verifyResult.token (request xq) StatsResp
|
||||
in
|
||||
Api.searchShare flags model.verifyResult.token (request xq) SearchResp
|
||||
Cmd.batch [ searchCmd, statsCmd ]
|
||||
|
||||
|
||||
linkTargetMsg : LinkTarget -> Maybe Msg
|
||||
|
Reference in New Issue
Block a user