From b265421a46e4d79be5016f65a8f305c3345716cb Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Sun, 22 Mar 2020 22:00:37 +0100 Subject: [PATCH] Allow to use the browser's pdf viewer The viewerjs library has some limitations. Sometimes PDFs are quite blurry and some content is displayed scrambled. Switching to the browsers build-in PDF viewer (for chromium and firefox) fixes this. So while on mobile the viewerjs is the only working viewer, for desktop use it might be desireable to use the browsers builtin viewer instead. --- Changelog.md | 2 ++ .../webapp/src/main/elm/Comp/ItemDetail.elm | 29 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index 1219a2a0..393620e0 100644 --- a/Changelog.md +++ b/Changelog.md @@ -19,6 +19,8 @@ increase in accuracy by about 10%. - A due date that is found during text analysis is now set on the item. If multiple due dates are found, the earliest one is used. +- Allow to switch between viewerjs PDF viewer or the browser's builtin + viewer. ### Configuration Changes diff --git a/modules/webapp/src/main/elm/Comp/ItemDetail.elm b/modules/webapp/src/main/elm/Comp/ItemDetail.elm index e6a3c124..8df1a9cd 100644 --- a/modules/webapp/src/main/elm/Comp/ItemDetail.elm +++ b/modules/webapp/src/main/elm/Comp/ItemDetail.elm @@ -35,7 +35,7 @@ import DatePicker exposing (DatePicker) import Dict exposing (Dict) import Html exposing (..) import Html.Attributes exposing (..) -import Html.Events exposing (onClick, onInput) +import Html.Events exposing (onCheck, onClick, onInput) import Http import Markdown import Page exposing (Page(..)) @@ -74,6 +74,7 @@ type alias Model = , sentMailsOpen : Bool , attachMeta : Dict String Comp.AttachmentMeta.Model , attachMetaOpen : Bool + , pdfNativeView : Bool } @@ -160,6 +161,7 @@ emptyModel = , sentMailsOpen = False , attachMeta = Dict.empty , attachMetaOpen = False + , pdfNativeView = False } @@ -212,6 +214,7 @@ type Msg | SentMailsResp (Result Http.Error SentMails) | AttachMetaClick String | AttachMetaMsg String Comp.AttachmentMeta.Msg + | TogglePdfNativeView @@ -935,6 +938,11 @@ update key flags next msg model = Nothing -> ( model, Cmd.none ) + TogglePdfNativeView -> + ( { model | pdfNativeView = not model.pdfNativeView } + , Cmd.none + ) + -- view @@ -1206,6 +1214,17 @@ renderAttachmentView model pos attach = , text (Util.Size.bytesReadable Util.Size.B (toFloat attach.size)) , text ")" ] + , div [ class "item" ] + [ div [ class "ui slider checkbox" ] + [ input + [ type_ "checkbox" + , onCheck (\_ -> TogglePdfNativeView) + , checked model.pdfNativeView + ] + [] + , label [] [ text "Native view" ] + ] + ] , div [ class "right menu" ] [ a [ classList @@ -1234,7 +1253,7 @@ renderAttachmentView model pos attach = "Goto original file" else - "This is the original file" + "The file was not converted." ) , href (fileUrl ++ "/original") , target "_new" @@ -1269,7 +1288,11 @@ renderAttachmentView model pos attach = ] ] [ iframe - [ src (fileUrl ++ "/view") + [ if model.pdfNativeView then + src fileUrl + + else + src (fileUrl ++ "/view") ] [] ]