Detect how to display pdf files

Closes: #1099
This commit is contained in:
eikek
2021-10-06 23:20:16 +02:00
parent b6187bb88d
commit f216c472ee
15 changed files with 217 additions and 87 deletions

View File

@ -100,7 +100,6 @@ type alias Model =
, sentMailsOpen : Bool
, attachMeta : Dict String Comp.AttachmentMeta.Model
, attachMetaOpen : Bool
, pdfNativeView : Maybe Bool
, attachModal : Maybe ConfirmModalValue
, addFilesOpen : Bool
, addFilesModel : Comp.Dropzone.Model
@ -236,7 +235,6 @@ emptyModel =
, sentMailsOpen = False
, attachMeta = Dict.empty
, attachMetaOpen = False
, pdfNativeView = Nothing
, attachModal = Nothing
, addFilesOpen = False
, addFilesModel = Comp.Dropzone.init []
@ -316,7 +314,6 @@ type Msg
| SentMailsResp (Result Http.Error SentMails)
| AttachMetaClick String
| AttachMetaMsg String Comp.AttachmentMeta.Msg
| TogglePdfNativeView Bool
| RequestDeleteAttachment String
| DeleteAttachConfirmed String
| RequestDeleteSelected

View File

@ -85,12 +85,8 @@ view texts flags settings model pos attach =
, style "max-height" "calc(100vh - 140px)"
, style "min-height" "500px"
]
[ iframe
[ if Maybe.withDefault settings.nativePdfPreview model.pdfNativeView then
src fileUrl
else
src (fileUrl ++ "/view")
[ embed
[ src <| Data.UiSettings.pdfUrl settings flags fileUrl
, class "absolute h-full w-full top-0 left-0 mx-0 py-0"
, id "ds-pdf-view-iframe"
]
@ -254,18 +250,6 @@ attachHeader texts settings model _ attach =
, classList [ ( "hidden", not attach.converted ) ]
]
}
, { icon =
if Maybe.withDefault settings.nativePdfPreview model.pdfNativeView then
"fa fa-toggle-on"
else
"fa fa-toggle-off"
, label = texts.renderPdfByBrowser
, attrs =
[ onClick (TogglePdfNativeView settings.nativePdfPreview)
, href "#"
]
}
, { icon =
if isAttachMetaOpen model attach.id then
"fa fa-toggle-on"

View File

@ -913,19 +913,6 @@ update key flags inav settings msg model =
Nothing ->
resultModel model
TogglePdfNativeView default ->
resultModel
{ model
| pdfNativeView =
case model.pdfNativeView of
Just flag ->
Just (not flag)
Nothing ->
Just (not default)
, attachmentDropdownOpen = False
}
DeleteAttachConfirmed attachId ->
let
cmd =