mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 10:29:34 +00:00
View attachments from a share
This commit is contained in:
parent
9eb2f9c6fe
commit
c62b8526be
@ -143,6 +143,7 @@ module Api exposing
|
||||
, setTagsMultiple
|
||||
, setUnconfirmed
|
||||
, shareAttachmentPreviewURL
|
||||
, shareFileURL
|
||||
, shareItemBasePreviewURL
|
||||
, startClassifier
|
||||
, startEmptyTrash
|
||||
@ -2311,6 +2312,11 @@ shareItemBasePreviewURL itemId =
|
||||
"/api/v1/share/item/" ++ itemId ++ "/preview?withFallback=true"
|
||||
|
||||
|
||||
shareFileURL : String -> String
|
||||
shareFileURL attachId =
|
||||
"/api/v1/share/attachment/" ++ attachId
|
||||
|
||||
|
||||
|
||||
--- Helper
|
||||
|
||||
|
@ -58,6 +58,7 @@ type alias ViewConfig =
|
||||
, extraClasses : String
|
||||
, previewUrl : AttachmentLight -> String
|
||||
, previewUrlFallback : ItemLight -> String
|
||||
, attachUrl : AttachmentLight -> String
|
||||
}
|
||||
|
||||
|
||||
@ -219,7 +220,7 @@ view2 texts cfg settings model item =
|
||||
, metaDataContent2 texts settings item
|
||||
, notesContent2 settings item
|
||||
, fulltextResultsContent2 item
|
||||
, previewMenu2 texts settings model item (currentAttachment model item)
|
||||
, previewMenu2 texts settings cfg model item (currentAttachment model item)
|
||||
, selectedDimmer
|
||||
]
|
||||
)
|
||||
@ -473,8 +474,8 @@ previewImage2 cfg settings cardAction model item =
|
||||
]
|
||||
|
||||
|
||||
previewMenu2 : Texts -> UiSettings -> Model -> ItemLight -> Maybe AttachmentLight -> Html Msg
|
||||
previewMenu2 texts settings model item mainAttach =
|
||||
previewMenu2 : Texts -> UiSettings -> ViewConfig -> Model -> ItemLight -> Maybe AttachmentLight -> Html Msg
|
||||
previewMenu2 texts settings cfg model item mainAttach =
|
||||
let
|
||||
pageCount =
|
||||
Maybe.andThen .pageCount mainAttach
|
||||
@ -486,16 +487,15 @@ previewMenu2 texts settings model item mainAttach =
|
||||
fieldHidden f =
|
||||
Data.UiSettings.fieldHidden settings f
|
||||
|
||||
mkAttachUrl id =
|
||||
mkAttachUrl attach =
|
||||
if settings.nativePdfPreview then
|
||||
Api.fileURL id
|
||||
cfg.attachUrl attach
|
||||
|
||||
else
|
||||
Api.fileURL id ++ "/view"
|
||||
cfg.attachUrl attach ++ "/view"
|
||||
|
||||
attachUrl =
|
||||
Maybe.map .id mainAttach
|
||||
|> Maybe.map mkAttachUrl
|
||||
Maybe.map mkAttachUrl mainAttach
|
||||
|> Maybe.withDefault "/api/v1/sec/attachment/none"
|
||||
|
||||
dueDate =
|
||||
|
@ -164,6 +164,7 @@ type alias ViewConfig =
|
||||
, selection : ItemSelection
|
||||
, previewUrl : AttachmentLight -> String
|
||||
, previewUrlFallback : ItemLight -> String
|
||||
, attachUrl : AttachmentLight -> String
|
||||
}
|
||||
|
||||
|
||||
@ -219,7 +220,7 @@ viewItem2 texts model cfg settings item =
|
||||
""
|
||||
|
||||
vvcfg =
|
||||
Comp.ItemCard.ViewConfig cfg.selection currentClass cfg.previewUrl cfg.previewUrlFallback
|
||||
Comp.ItemCard.ViewConfig cfg.selection currentClass cfg.previewUrl cfg.previewUrlFallback cfg.attachUrl
|
||||
|
||||
cardModel =
|
||||
Dict.get item.id model.itemCards
|
||||
|
@ -476,6 +476,7 @@ itemCardList texts _ settings model =
|
||||
(Data.ItemSelection.Active svm.ids)
|
||||
previewUrl
|
||||
previewUrlFallback
|
||||
(.id >> Api.fileURL)
|
||||
|
||||
_ ->
|
||||
Comp.ItemCardList.ViewConfig
|
||||
@ -483,6 +484,7 @@ itemCardList texts _ settings model =
|
||||
Data.ItemSelection.Inactive
|
||||
previewUrl
|
||||
previewUrlFallback
|
||||
(.id >> Api.fileURL)
|
||||
in
|
||||
[ Html.map ItemCardListMsg
|
||||
(Comp.ItemCardList.view2 texts.itemCardList
|
||||
|
@ -25,6 +25,7 @@ view texts settings model =
|
||||
, selection = Data.ItemSelection.Inactive
|
||||
, previewUrl = \attach -> Api.shareAttachmentPreviewURL attach.id
|
||||
, previewUrlFallback = \item -> Api.shareItemBasePreviewURL item.id
|
||||
, attachUrl = .id >> Api.shareFileURL
|
||||
}
|
||||
in
|
||||
div []
|
||||
|
Loading…
x
Reference in New Issue
Block a user