From f8634a5098635f8cdab69eb0169b192713d76558 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Sun, 15 Nov 2020 01:12:52 +0100 Subject: [PATCH] Use js pdf renderer for file view when settings tell so --- modules/webapp/src/main/elm/Comp/ItemCard.elm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/webapp/src/main/elm/Comp/ItemCard.elm b/modules/webapp/src/main/elm/Comp/ItemCard.elm index 6b3a1938..31836733 100644 --- a/modules/webapp/src/main/elm/Comp/ItemCard.elm +++ b/modules/webapp/src/main/elm/Comp/ItemCard.elm @@ -187,7 +187,7 @@ view cfg settings model item = else [ selectedDimmer - , previewMenu model item (currentAttachment model item) + , previewMenu settings model item (currentAttachment model item) , previewImage settings cardAction model item ] ) @@ -407,16 +407,23 @@ previewImage settings cardAction model item = ] -previewMenu : Model -> ItemLight -> Maybe AttachmentLight -> Html Msg -previewMenu model item mainAttach = +previewMenu : UiSettings -> Model -> ItemLight -> Maybe AttachmentLight -> Html Msg +previewMenu settings model item mainAttach = let pageCount = Maybe.andThen .pageCount mainAttach |> Maybe.withDefault 0 + mkAttachUrl id = + if settings.nativePdfPreview then + Api.fileURL id + + else + Api.fileURL id ++ "/view" + attachUrl = Maybe.map .id mainAttach - |> Maybe.map ((++) "/api/v1/sec/attachment/") + |> Maybe.map mkAttachUrl |> Maybe.withDefault "/api/v1/sec/attachment/none" gotoFileBtn =