mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 10:58:26 +00:00
Show item detail for a shared item
This commit is contained in:
@ -17,6 +17,7 @@ import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick)
|
||||
import QRCode
|
||||
import Styles as S
|
||||
import Svg.Attributes as SvgA
|
||||
|
||||
|
||||
view : Flags -> String -> Model -> UrlId -> Html Msg
|
||||
@ -111,7 +112,7 @@ type UrlId
|
||||
|
||||
qrCodeView : String -> Html msg
|
||||
qrCodeView message =
|
||||
QRCode.encode message
|
||||
|> Result.map QRCode.toSvg
|
||||
QRCode.fromString message
|
||||
|> Result.map (QRCode.toSvg [ SvgA.class "w-64 h-64" ])
|
||||
|> Result.withDefault
|
||||
(text "Error generating QR code")
|
||||
|
@ -23,6 +23,7 @@ import Markdown
|
||||
import Messages.Comp.OtpSetup exposing (Texts)
|
||||
import QRCode
|
||||
import Styles as S
|
||||
import Svg.Attributes as SvgA
|
||||
|
||||
|
||||
type Model
|
||||
@ -389,8 +390,8 @@ viewDisabled texts model =
|
||||
|
||||
qrCodeView : Texts -> String -> Html msg
|
||||
qrCodeView texts message =
|
||||
QRCode.encode message
|
||||
|> Result.map QRCode.toSvg
|
||||
QRCode.fromString message
|
||||
|> Result.map (QRCode.toSvg [ SvgA.class "w-64 h-64" ])
|
||||
|> Result.withDefault
|
||||
(Html.text texts.errorGeneratingQR)
|
||||
|
||||
|
@ -14,6 +14,7 @@ import Html.Attributes exposing (..)
|
||||
import Messages.Comp.ShareView exposing (Texts)
|
||||
import QRCode
|
||||
import Styles as S
|
||||
import Svg.Attributes as SvgA
|
||||
|
||||
|
||||
type alias ViewSettings =
|
||||
@ -178,7 +179,7 @@ viewDisabled cfg texts share =
|
||||
|
||||
qrCodeView : Texts -> String -> Html msg
|
||||
qrCodeView texts message =
|
||||
QRCode.encode message
|
||||
|> Result.map QRCode.toSvg
|
||||
QRCode.fromString message
|
||||
|> Result.map (QRCode.toSvg [ SvgA.class "w-64 h-64" ])
|
||||
|> Result.withDefault
|
||||
(Html.text texts.qrCodeError)
|
||||
|
@ -32,6 +32,7 @@ import Messages.Comp.SourceManage exposing (Texts)
|
||||
import Ports
|
||||
import QRCode
|
||||
import Styles as S
|
||||
import Svg.Attributes as SvgA
|
||||
|
||||
|
||||
type alias Model =
|
||||
@ -226,8 +227,8 @@ update flags msg model =
|
||||
|
||||
qrCodeView : Texts -> String -> Html msg
|
||||
qrCodeView texts message =
|
||||
QRCode.encode message
|
||||
|> Result.map QRCode.toSvg
|
||||
QRCode.fromString message
|
||||
|> Result.map (QRCode.toSvg [ SvgA.class "w-64 h-64" ])
|
||||
|> Result.withDefault
|
||||
(Html.text texts.errorGeneratingQR)
|
||||
|
||||
|
95
modules/webapp/src/main/elm/Comp/UrlCopy.elm
Normal file
95
modules/webapp/src/main/elm/Comp/UrlCopy.elm
Normal file
@ -0,0 +1,95 @@
|
||||
module Comp.UrlCopy exposing (..)
|
||||
|
||||
import Comp.Basic as B
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick)
|
||||
import Ports
|
||||
import QRCode
|
||||
import Styles as S
|
||||
import Svg.Attributes as SvgA
|
||||
|
||||
|
||||
type Msg
|
||||
= Print String
|
||||
|
||||
|
||||
update : Msg -> Cmd msg
|
||||
update msg =
|
||||
case msg of
|
||||
Print id ->
|
||||
Ports.printElement id
|
||||
|
||||
|
||||
initCopy : String -> Cmd msg
|
||||
initCopy data =
|
||||
Ports.initClipboard <| clipboardData data
|
||||
|
||||
|
||||
clipboardData : String -> ( String, String )
|
||||
clipboardData data =
|
||||
( "share-url", "#button-share-url" )
|
||||
|
||||
|
||||
view : String -> Html Msg
|
||||
view data =
|
||||
let
|
||||
( elementId, buttonId ) =
|
||||
clipboardData data
|
||||
|
||||
btnId =
|
||||
String.dropLeft 1 buttonId
|
||||
|
||||
printId =
|
||||
"print-qr-code"
|
||||
in
|
||||
div [ class "flex flex-col items-center" ]
|
||||
[ div
|
||||
[ class S.border
|
||||
, class S.qrCode
|
||||
, id printId
|
||||
]
|
||||
[ qrCodeView data
|
||||
]
|
||||
, div
|
||||
[ class "flex w-64"
|
||||
]
|
||||
[ p
|
||||
[ id elementId
|
||||
, class "font-mono text-xs py-2 mx-auto break-all"
|
||||
]
|
||||
[ text data
|
||||
]
|
||||
]
|
||||
, div [ class "flex flex-row mt-1 space-x-2 items-center w-full" ]
|
||||
[ B.primaryButton
|
||||
{ label = "Copy"
|
||||
, icon = "fa fa-copy"
|
||||
, handler = href "#"
|
||||
, disabled = False
|
||||
, attrs =
|
||||
[ id btnId
|
||||
, class "flex flex-grow items-center justify-center"
|
||||
, attribute "data-clipboard-target" ("#" ++ elementId)
|
||||
]
|
||||
}
|
||||
, B.primaryButton
|
||||
{ label = "Print"
|
||||
, icon = "fa fa-print"
|
||||
, handler = onClick (Print printId)
|
||||
, disabled = False
|
||||
, attrs =
|
||||
[ href "#"
|
||||
, class "flex flex-grow items-center justify-center"
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
qrCodeView : String -> Html msg
|
||||
qrCodeView message =
|
||||
QRCode.fromString message
|
||||
|> Result.map (QRCode.toSvg [ SvgA.class "w-64 h-64" ])
|
||||
|> Result.withDefault
|
||||
(text "Error generating QR code")
|
Reference in New Issue
Block a user