mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 10:29:34 +00:00
Share page skeleton
This commit is contained in:
parent
aa21e7a74c
commit
97922340d9
@ -32,6 +32,7 @@ import Page.ManageData.Data
|
||||
import Page.NewInvite.Data
|
||||
import Page.Queue.Data
|
||||
import Page.Register.Data
|
||||
import Page.Share.Data
|
||||
import Page.Upload.Data
|
||||
import Page.UserSettings.Data
|
||||
import Url exposing (Url)
|
||||
@ -52,6 +53,7 @@ type alias Model =
|
||||
, uploadModel : Page.Upload.Data.Model
|
||||
, newInviteModel : Page.NewInvite.Data.Model
|
||||
, itemDetailModel : Page.ItemDetail.Data.Model
|
||||
, shareModel : Page.Share.Data.Model
|
||||
, navMenuOpen : Bool
|
||||
, userMenuOpen : Bool
|
||||
, subs : Sub Msg
|
||||
@ -85,6 +87,9 @@ init key url flags_ settings =
|
||||
( loginm, loginc ) =
|
||||
Page.Login.Data.init flags (Page.loginPageReferrer page)
|
||||
|
||||
( shm, shc ) =
|
||||
Page.Share.Data.init (Page.shareId page) flags
|
||||
|
||||
homeViewMode =
|
||||
if settings.searchMenuVisible then
|
||||
Page.Home.Data.SearchView
|
||||
@ -106,6 +111,7 @@ init key url flags_ settings =
|
||||
, uploadModel = Page.Upload.Data.emptyModel
|
||||
, newInviteModel = Page.NewInvite.Data.emptyModel
|
||||
, itemDetailModel = Page.ItemDetail.Data.emptyModel
|
||||
, shareModel = shm
|
||||
, navMenuOpen = False
|
||||
, userMenuOpen = False
|
||||
, subs = Sub.none
|
||||
@ -120,6 +126,7 @@ init key url flags_ settings =
|
||||
, Cmd.map ManageDataMsg mdc
|
||||
, Cmd.map CollSettingsMsg csc
|
||||
, Cmd.map LoginMsg loginc
|
||||
, Cmd.map ShareMsg shc
|
||||
]
|
||||
)
|
||||
|
||||
@ -162,6 +169,7 @@ type Msg
|
||||
| UploadMsg Page.Upload.Data.Msg
|
||||
| NewInviteMsg Page.NewInvite.Data.Msg
|
||||
| ItemDetailMsg Page.ItemDetail.Data.Msg
|
||||
| ShareMsg Page.Share.Data.Msg
|
||||
| Logout
|
||||
| LogoutResp (Result Http.Error ())
|
||||
| SessionCheckResp (Result Http.Error AuthResult)
|
||||
|
@ -34,6 +34,8 @@ import Page.Queue.Data
|
||||
import Page.Queue.Update
|
||||
import Page.Register.Data
|
||||
import Page.Register.Update
|
||||
import Page.Share.Data
|
||||
import Page.Share.Update
|
||||
import Page.Upload.Data
|
||||
import Page.Upload.Update
|
||||
import Page.UserSettings.Data
|
||||
@ -114,6 +116,9 @@ updateWithSub msg model =
|
||||
HomeMsg lm ->
|
||||
updateHome lm model
|
||||
|
||||
ShareMsg lm ->
|
||||
updateShare lm model
|
||||
|
||||
LoginMsg lm ->
|
||||
updateLogin lm model
|
||||
|
||||
@ -313,6 +318,23 @@ applyClientSettings model settings =
|
||||
{ model | uiSettings = settings }
|
||||
|
||||
|
||||
updateShare : Page.Share.Data.Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||
updateShare lmsg model =
|
||||
case Page.shareId model.page of
|
||||
Just id ->
|
||||
let
|
||||
result =
|
||||
Page.Share.Update.update model.flags id lmsg model.shareModel
|
||||
in
|
||||
( { model | shareModel = result.model }
|
||||
, Cmd.map ShareMsg result.cmd
|
||||
, Sub.map ShareMsg result.sub
|
||||
)
|
||||
|
||||
Nothing ->
|
||||
( model, Cmd.none, Sub.none )
|
||||
|
||||
|
||||
updateItemDetail : Page.ItemDetail.Data.Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||
updateItemDetail lmsg model =
|
||||
let
|
||||
@ -568,3 +590,6 @@ initPage model_ page =
|
||||
, updateQueue Page.Queue.Data.StopRefresh
|
||||
]
|
||||
model
|
||||
|
||||
SharePage _ ->
|
||||
( model, Cmd.none, Sub.none )
|
||||
|
@ -27,6 +27,7 @@ import Page.ManageData.View2 as ManageData
|
||||
import Page.NewInvite.View2 as NewInvite
|
||||
import Page.Queue.View2 as Queue
|
||||
import Page.Register.View2 as Register
|
||||
import Page.Share.View as Share
|
||||
import Page.Upload.View2 as Upload
|
||||
import Page.UserSettings.View2 as UserSettings
|
||||
import Styles as S
|
||||
@ -41,13 +42,9 @@ view model =
|
||||
|
||||
topNavbar : Model -> Html Msg
|
||||
topNavbar model =
|
||||
case model.flags.account of
|
||||
case Data.Flags.getAccount model.flags of
|
||||
Just acc ->
|
||||
if acc.success then
|
||||
topNavUser acc model
|
||||
|
||||
else
|
||||
topNavAnon model
|
||||
topNavUser acc model
|
||||
|
||||
Nothing ->
|
||||
topNavAnon model
|
||||
@ -86,7 +83,16 @@ topNavAnon model =
|
||||
[ id "top-nav"
|
||||
, class styleTopNav
|
||||
]
|
||||
[ headerNavItem model
|
||||
[ B.genericButton
|
||||
{ label = ""
|
||||
, icon = "fa fa-bars"
|
||||
, handler = onClick ToggleSidebar
|
||||
, disabled = not (Page.hasSidebar model.page)
|
||||
, attrs = [ href "#" ]
|
||||
, baseStyle = "font-bold inline-flex items-center px-4 py-2"
|
||||
, activeStyle = "hover:bg-blue-200 dark:hover:bg-bluegray-800 w-12"
|
||||
}
|
||||
, headerNavItem model
|
||||
, div [ class "flex flex-grow justify-end" ]
|
||||
[ langMenu model
|
||||
, a
|
||||
@ -157,6 +163,9 @@ mainContent model =
|
||||
|
||||
ItemDetailPage id ->
|
||||
viewItemDetail texts id model
|
||||
|
||||
SharePage id ->
|
||||
viewShare texts id model
|
||||
)
|
||||
|
||||
|
||||
@ -411,6 +420,24 @@ dropdownMenu =
|
||||
" absolute right-0 bg-white dark:bg-bluegray-800 border dark:border-bluegray-700 dark:text-bluegray-300 shadow-lg opacity-1 transition duration-200 min-w-max "
|
||||
|
||||
|
||||
viewShare : Messages -> String -> Model -> List (Html Msg)
|
||||
viewShare texts shareId model =
|
||||
[ Html.map ShareMsg
|
||||
(Share.viewSidebar texts.share
|
||||
model.sidebarVisible
|
||||
model.flags
|
||||
model.uiSettings
|
||||
model.shareModel
|
||||
)
|
||||
, Html.map ShareMsg
|
||||
(Share.viewContent texts.share
|
||||
model.flags
|
||||
model.uiSettings
|
||||
model.shareModel
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
viewHome : Messages -> Model -> List (Html Msg)
|
||||
viewHome texts model =
|
||||
[ Html.map HomeMsg
|
||||
|
@ -9,7 +9,9 @@ module Data.Flags exposing
|
||||
( Config
|
||||
, Flags
|
||||
, accountString
|
||||
, getAccount
|
||||
, getToken
|
||||
, isAuthenticated
|
||||
, withAccount
|
||||
, withoutAccount
|
||||
)
|
||||
@ -43,6 +45,24 @@ type alias Flags =
|
||||
}
|
||||
|
||||
|
||||
isAuthenticated : Flags -> Bool
|
||||
isAuthenticated flags =
|
||||
getAccount flags /= Nothing
|
||||
|
||||
|
||||
getAccount : Flags -> Maybe AuthResult
|
||||
getAccount flags =
|
||||
Maybe.andThen
|
||||
(\ar ->
|
||||
if ar.success then
|
||||
Just ar
|
||||
|
||||
else
|
||||
Nothing
|
||||
)
|
||||
flags.account
|
||||
|
||||
|
||||
getToken : Flags -> Maybe String
|
||||
getToken flags =
|
||||
flags.account
|
||||
|
@ -21,6 +21,7 @@ import Messages.Page.ManageData
|
||||
import Messages.Page.NewInvite
|
||||
import Messages.Page.Queue
|
||||
import Messages.Page.Register
|
||||
import Messages.Page.Share
|
||||
import Messages.Page.Upload
|
||||
import Messages.Page.UserSettings
|
||||
import Messages.UiLanguage exposing (UiLanguage(..))
|
||||
@ -44,6 +45,7 @@ type alias Messages =
|
||||
, userSettings : Messages.Page.UserSettings.Texts
|
||||
, manageData : Messages.Page.ManageData.Texts
|
||||
, home : Messages.Page.Home.Texts
|
||||
, share : Messages.Page.Share.Texts
|
||||
}
|
||||
|
||||
|
||||
@ -109,6 +111,7 @@ gb =
|
||||
, userSettings = Messages.Page.UserSettings.gb
|
||||
, manageData = Messages.Page.ManageData.gb
|
||||
, home = Messages.Page.Home.gb
|
||||
, share = Messages.Page.Share.gb
|
||||
}
|
||||
|
||||
|
||||
@ -129,4 +132,5 @@ de =
|
||||
, userSettings = Messages.Page.UserSettings.de
|
||||
, manageData = Messages.Page.ManageData.de
|
||||
, home = Messages.Page.Home.de
|
||||
, share = Messages.Page.Share.de
|
||||
}
|
||||
|
22
modules/webapp/src/main/elm/Messages/Page/Share.elm
Normal file
22
modules/webapp/src/main/elm/Messages/Page/Share.elm
Normal file
@ -0,0 +1,22 @@
|
||||
{-
|
||||
Copyright 2020 Eike K. & Contributors
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-}
|
||||
|
||||
|
||||
module Messages.Page.Share exposing (..)
|
||||
|
||||
|
||||
type alias Texts =
|
||||
{}
|
||||
|
||||
|
||||
gb : Texts
|
||||
gb =
|
||||
{}
|
||||
|
||||
|
||||
de : Texts
|
||||
de =
|
||||
{}
|
@ -21,6 +21,7 @@ module Page exposing
|
||||
, pageName
|
||||
, pageToString
|
||||
, set
|
||||
, shareId
|
||||
, uploadId
|
||||
)
|
||||
|
||||
@ -59,6 +60,7 @@ type Page
|
||||
| UploadPage (Maybe String)
|
||||
| NewInvitePage
|
||||
| ItemDetailPage String
|
||||
| SharePage String
|
||||
|
||||
|
||||
isSecured : Page -> Bool
|
||||
@ -94,6 +96,9 @@ isSecured page =
|
||||
ItemDetailPage _ ->
|
||||
True
|
||||
|
||||
SharePage _ ->
|
||||
False
|
||||
|
||||
|
||||
{-| Currently, all secured pages have a sidebar, except UploadPage.
|
||||
-}
|
||||
@ -103,6 +108,9 @@ hasSidebar page =
|
||||
UploadPage _ ->
|
||||
False
|
||||
|
||||
SharePage _ ->
|
||||
True
|
||||
|
||||
_ ->
|
||||
isSecured page
|
||||
|
||||
@ -160,6 +168,9 @@ pageName page =
|
||||
ItemDetailPage _ ->
|
||||
"Item"
|
||||
|
||||
SharePage _ ->
|
||||
"Share"
|
||||
|
||||
|
||||
loginPageReferrer : Page -> LoginData
|
||||
loginPageReferrer page =
|
||||
@ -171,6 +182,16 @@ loginPageReferrer page =
|
||||
emptyLoginData
|
||||
|
||||
|
||||
shareId : Page -> Maybe String
|
||||
shareId page =
|
||||
case page of
|
||||
SharePage id ->
|
||||
Just id
|
||||
|
||||
_ ->
|
||||
Nothing
|
||||
|
||||
|
||||
uploadId : Page -> Maybe String
|
||||
uploadId page =
|
||||
case page of
|
||||
@ -224,6 +245,9 @@ pageToString page =
|
||||
ItemDetailPage id ->
|
||||
"/app/item/" ++ id
|
||||
|
||||
SharePage id ->
|
||||
"/app/share/" ++ id
|
||||
|
||||
|
||||
pageFromString : String -> Maybe Page
|
||||
pageFromString str =
|
||||
@ -280,6 +304,7 @@ parser =
|
||||
, Parser.map (UploadPage Nothing) (s pathPrefix </> s "upload")
|
||||
, Parser.map NewInvitePage (s pathPrefix </> s "newinvite")
|
||||
, Parser.map ItemDetailPage (s pathPrefix </> s "item" </> string)
|
||||
, Parser.map SharePage (s pathPrefix </> s "share" </> string)
|
||||
]
|
||||
|
||||
|
||||
|
32
modules/webapp/src/main/elm/Page/Share/Data.elm
Normal file
32
modules/webapp/src/main/elm/Page/Share/Data.elm
Normal file
@ -0,0 +1,32 @@
|
||||
{-
|
||||
Copyright 2020 Eike K. & Contributors
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-}
|
||||
|
||||
|
||||
module Page.Share.Data exposing (Model, Msg, init)
|
||||
|
||||
import Data.Flags exposing (Flags)
|
||||
|
||||
|
||||
type alias Model =
|
||||
{}
|
||||
|
||||
|
||||
init : Maybe String -> Flags -> ( Model, Cmd Msg )
|
||||
init shareId flags =
|
||||
case shareId of
|
||||
Just id ->
|
||||
let
|
||||
_ =
|
||||
Debug.log "share" id
|
||||
in
|
||||
( {}, Cmd.none )
|
||||
|
||||
Nothing ->
|
||||
( {}, Cmd.none )
|
||||
|
||||
|
||||
type Msg
|
||||
= Msg
|
23
modules/webapp/src/main/elm/Page/Share/Update.elm
Normal file
23
modules/webapp/src/main/elm/Page/Share/Update.elm
Normal file
@ -0,0 +1,23 @@
|
||||
{-
|
||||
Copyright 2020 Eike K. & Contributors
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-}
|
||||
|
||||
|
||||
module Page.Share.Update exposing (UpdateResult, update)
|
||||
|
||||
import Data.Flags exposing (Flags)
|
||||
import Page.Share.Data exposing (..)
|
||||
|
||||
|
||||
type alias UpdateResult =
|
||||
{ model : Model
|
||||
, cmd : Cmd Msg
|
||||
, sub : Sub Msg
|
||||
}
|
||||
|
||||
|
||||
update : Flags -> String -> Msg -> Model -> UpdateResult
|
||||
update flags shareId msg model =
|
||||
UpdateResult model Cmd.none Sub.none
|
38
modules/webapp/src/main/elm/Page/Share/View.elm
Normal file
38
modules/webapp/src/main/elm/Page/Share/View.elm
Normal file
@ -0,0 +1,38 @@
|
||||
{-
|
||||
Copyright 2020 Eike K. & Contributors
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-}
|
||||
|
||||
|
||||
module Page.Share.View exposing (viewContent, viewSidebar)
|
||||
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Messages.Page.Share exposing (Texts)
|
||||
import Page.Share.Data exposing (..)
|
||||
import Styles as S
|
||||
|
||||
|
||||
viewSidebar : Texts -> Bool -> Flags -> UiSettings -> Model -> Html Msg
|
||||
viewSidebar _ visible _ _ _ =
|
||||
div
|
||||
[ id "sidebar"
|
||||
, classList [ ( "hidden", not visible ) ]
|
||||
]
|
||||
[ text "sidebar" ]
|
||||
|
||||
|
||||
viewContent : Texts -> Flags -> UiSettings -> Model -> Html Msg
|
||||
viewContent texts flags _ model =
|
||||
div
|
||||
[ id "content"
|
||||
, class "h-full flex flex-col"
|
||||
, class S.content
|
||||
]
|
||||
[ h1 [ class S.header1 ]
|
||||
[ text "Share Page!"
|
||||
]
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user