Dashboard page template

This commit is contained in:
eikek 2022-01-26 21:21:01 +01:00
parent c38ab3ef82
commit e6775f77dc
11 changed files with 182 additions and 7 deletions

View File

@ -26,6 +26,7 @@ import Http
import Messages.UiLanguage exposing (UiLanguage) import Messages.UiLanguage exposing (UiLanguage)
import Page exposing (Page(..)) import Page exposing (Page(..))
import Page.CollectiveSettings.Data import Page.CollectiveSettings.Data
import Page.Dashboard.Data
import Page.ItemDetail.Data import Page.ItemDetail.Data
import Page.Login.Data import Page.Login.Data
import Page.ManageData.Data import Page.ManageData.Data
@ -57,6 +58,7 @@ type alias Model =
, itemDetailModel : Page.ItemDetail.Data.Model , itemDetailModel : Page.ItemDetail.Data.Model
, shareModel : Page.Share.Data.Model , shareModel : Page.Share.Data.Model
, shareDetailModel : Page.ShareDetail.Data.Model , shareDetailModel : Page.ShareDetail.Data.Model
, dashboardModel : Page.Dashboard.Data.Model
, navMenuOpen : Bool , navMenuOpen : Bool
, userMenuOpen : Bool , userMenuOpen : Bool
, subs : Sub Msg , subs : Sub Msg
@ -98,6 +100,9 @@ init key url flags_ settings =
( sdm, sdc ) = ( sdm, sdc ) =
Page.ShareDetail.Data.init (Page.pageShareDetail page) flags Page.ShareDetail.Data.init (Page.pageShareDetail page) flags
( dbm, dbc ) =
Page.Dashboard.Data.init flags
searchViewMode = searchViewMode =
if settings.searchMenuVisible then if settings.searchMenuVisible then
Page.Search.Data.SearchView Page.Search.Data.SearchView
@ -121,6 +126,7 @@ init key url flags_ settings =
, itemDetailModel = Page.ItemDetail.Data.emptyModel , itemDetailModel = Page.ItemDetail.Data.emptyModel
, shareModel = shm , shareModel = shm
, shareDetailModel = sdm , shareDetailModel = sdm
, dashboardModel = dbm
, navMenuOpen = False , navMenuOpen = False
, userMenuOpen = False , userMenuOpen = False
, subs = Sub.none , subs = Sub.none
@ -133,7 +139,8 @@ init key url flags_ settings =
, jobsWaiting = 0 , jobsWaiting = 0
} }
, Cmd.batch , Cmd.batch
[ Cmd.map UserSettingsMsg uc [ Cmd.map DashboardMsg dbc
, Cmd.map UserSettingsMsg uc
, Cmd.map ManageDataMsg mdc , Cmd.map ManageDataMsg mdc
, Cmd.map CollSettingsMsg csc , Cmd.map CollSettingsMsg csc
, Cmd.map LoginMsg loginc , Cmd.map LoginMsg loginc
@ -183,6 +190,7 @@ type Msg
| ItemDetailMsg Page.ItemDetail.Data.Msg | ItemDetailMsg Page.ItemDetail.Data.Msg
| ShareMsg Page.Share.Data.Msg | ShareMsg Page.Share.Data.Msg
| ShareDetailMsg Page.ShareDetail.Data.Msg | ShareDetailMsg Page.ShareDetail.Data.Msg
| DashboardMsg Page.Dashboard.Data.Msg
| Logout | Logout
| LogoutResp (Result Http.Error ()) | LogoutResp (Result Http.Error ())
| SessionCheckResp (Result Http.Error AuthResult) | SessionCheckResp (Result Http.Error AuthResult)

View File

@ -22,6 +22,8 @@ import Messages exposing (Messages)
import Page exposing (Page(..)) import Page exposing (Page(..))
import Page.CollectiveSettings.Data import Page.CollectiveSettings.Data
import Page.CollectiveSettings.Update import Page.CollectiveSettings.Update
import Page.Dashboard.Data
import Page.Dashboard.Update
import Page.ItemDetail.Data import Page.ItemDetail.Data
import Page.ItemDetail.Update import Page.ItemDetail.Update
import Page.Login.Data import Page.Login.Data
@ -157,6 +159,9 @@ updateWithSub msg model =
ItemDetailMsg m -> ItemDetailMsg m ->
updateItemDetail texts m model updateItemDetail texts m model
DashboardMsg m ->
updateDashboard m model
VersionResp (Ok info) -> VersionResp (Ok info) ->
( { model | version = info }, Cmd.none, Sub.none ) ( { model | version = info }, Cmd.none, Sub.none )
@ -366,6 +371,18 @@ applyClientSettings texts model settings =
{ model | uiSettings = settings } { model | uiSettings = settings }
updateDashboard : Page.Dashboard.Data.Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
updateDashboard lmsg model =
let
( dbm, dbc ) =
Page.Dashboard.Update.update model.flags lmsg model.dashboardModel
in
( { model | dashboardModel = dbm }
, Cmd.map DashboardMsg dbc
, Sub.none
)
updateShareDetail : Page.ShareDetail.Data.Msg -> Model -> ( Model, Cmd Msg, Sub Msg ) updateShareDetail : Page.ShareDetail.Data.Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
updateShareDetail lmsg model = updateShareDetail lmsg model =
case Page.pageShareDetail model.page of case Page.pageShareDetail model.page of
@ -685,3 +702,6 @@ initPage model_ page =
_ -> _ ->
( model, Cmd.none, Sub.none ) ( model, Cmd.none, Sub.none )
DashboardPage ->
( model, Cmd.none, Sub.none )

View File

@ -19,6 +19,7 @@ import Messages.App exposing (Texts)
import Messages.UiLanguage import Messages.UiLanguage
import Page exposing (Page(..)) import Page exposing (Page(..))
import Page.CollectiveSettings.View2 as CollectiveSettings import Page.CollectiveSettings.View2 as CollectiveSettings
import Page.Dashboard.View as Dashboard
import Page.ItemDetail.View2 as ItemDetail import Page.ItemDetail.View2 as ItemDetail
import Page.Login.View2 as Login import Page.Login.View2 as Login
import Page.ManageData.View2 as ManageData import Page.ManageData.View2 as ManageData
@ -133,7 +134,7 @@ headerNavItem authenticated model =
[ class "inline-flex font-bold items-center px-4" [ class "inline-flex font-bold items-center px-4"
, classList [ ( "hover:bg-blue-200 dark:hover:bg-slate-800", authenticated ) ] , classList [ ( "hover:bg-blue-200 dark:hover:bg-slate-800", authenticated ) ]
, if authenticated then , if authenticated then
Page.href SearchPage Page.href DashboardPage
else else
href "#" href "#"
@ -160,6 +161,9 @@ mainContent model =
, class styleMain , class styleMain
] ]
(case model.page of (case model.page of
DashboardPage ->
viewDashboard texts model
SearchPage -> SearchPage ->
viewSearch texts model viewSearch texts model
@ -280,7 +284,7 @@ dataMenu texts _ model =
, classList [ ( "hidden", not model.navMenuOpen ) ] , classList [ ( "hidden", not model.navMenuOpen ) ]
] ]
[ dataPageLink model [ dataPageLink model
SearchPage DashboardPage
[] []
[ img [ img
[ class "w-4 inline-block" [ class "w-4 inline-block"
@ -288,10 +292,18 @@ dataMenu texts _ model =
] ]
[] []
, div [ class "inline-block ml-2" ] , div [ class "inline-block ml-2" ]
[ text texts.items [ text texts.dashboard
] ]
] ]
, div [ class "py-1" ] [ hr [ class S.border ] [] ] , div [ class "py-1" ] [ hr [ class S.border ] [] ]
, dataPageLink model
SearchPage
[]
[ i [ class "fa fa-search w-6" ] []
, span [ class "ml-1" ]
[ text texts.items
]
]
, dataPageLink model , dataPageLink model
ManageDataPage ManageDataPage
[] []
@ -467,6 +479,24 @@ dropdownMenu =
" absolute right-0 bg-white dark:bg-slate-800 border dark:border-slate-700 dark:text-slate-300 shadow-lg opacity-1 transition duration-200 min-w-max " " absolute right-0 bg-white dark:bg-slate-800 border dark:border-slate-700 dark:text-slate-300 shadow-lg opacity-1 transition duration-200 min-w-max "
viewDashboard : Messages -> Model -> List (Html Msg)
viewDashboard texts model =
[ Html.map DashboardMsg
(Dashboard.viewSidebar texts.dashboard
model.sidebarVisible
model.flags
model.uiSettings
model.dashboardModel
)
, Html.map DashboardMsg
(Dashboard.viewContent texts.dashboard
model.flags
model.uiSettings
model.dashboardModel
)
]
viewShare : Messages -> String -> Model -> List (Html Msg) viewShare : Messages -> String -> Model -> List (Html Msg)
viewShare texts shareId model = viewShare texts shareId model =
[ Html.map ShareMsg [ Html.map ShareMsg

View File

@ -14,6 +14,7 @@ module Messages exposing
import Messages.App import Messages.App
import Messages.Page.CollectiveSettings import Messages.Page.CollectiveSettings
import Messages.Page.Dashboard
import Messages.Page.ItemDetail import Messages.Page.ItemDetail
import Messages.Page.Login import Messages.Page.Login
import Messages.Page.ManageData import Messages.Page.ManageData
@ -48,6 +49,7 @@ type alias Messages =
, search : Messages.Page.Search.Texts , search : Messages.Page.Search.Texts
, share : Messages.Page.Share.Texts , share : Messages.Page.Share.Texts
, shareDetail : Messages.Page.ShareDetail.Texts , shareDetail : Messages.Page.ShareDetail.Texts
, dashboard : Messages.Page.Dashboard.Texts
} }
@ -115,6 +117,7 @@ gb =
, search = Messages.Page.Search.gb , search = Messages.Page.Search.gb
, share = Messages.Page.Share.gb , share = Messages.Page.Share.gb
, shareDetail = Messages.Page.ShareDetail.gb , shareDetail = Messages.Page.ShareDetail.gb
, dashboard = Messages.Page.Dashboard.gb
} }
@ -137,4 +140,5 @@ de =
, search = Messages.Page.Search.de , search = Messages.Page.Search.de
, share = Messages.Page.Share.de , share = Messages.Page.Share.de
, shareDetail = Messages.Page.ShareDetail.de , shareDetail = Messages.Page.ShareDetail.de
, dashboard = Messages.Page.Dashboard.de
} }

View File

@ -24,6 +24,7 @@ type alias Texts =
, newInvites : String , newInvites : String
, help : String , help : String
, newItemsArrived : String , newItemsArrived : String
, dashboard : String
} }
@ -40,6 +41,7 @@ gb =
, newInvites = "New Invites" , newInvites = "New Invites"
, help = "Help" , help = "Help"
, newItemsArrived = "New items arrived!" , newItemsArrived = "New items arrived!"
, dashboard = "Dashboard"
} }
@ -56,4 +58,5 @@ de =
, newInvites = "Neue Einladung" , newInvites = "Neue Einladung"
, help = "Hilfe (English)" , help = "Hilfe (English)"
, newItemsArrived = "Neue Dokumente eingetroffen!" , newItemsArrived = "Neue Dokumente eingetroffen!"
, dashboard = "Dashboard"
} }

View File

@ -0,0 +1,15 @@
module Messages.Page.Dashboard exposing (Texts, de, gb)
type alias Texts =
{}
gb : Texts
gb =
{}
de : Texts
de =
{}

View File

@ -63,11 +63,15 @@ type Page
| ItemDetailPage String | ItemDetailPage String
| SharePage String | SharePage String
| ShareDetailPage String String | ShareDetailPage String String
| DashboardPage
isSecured : Page -> Bool isSecured : Page -> Bool
isSecured page = isSecured page =
case page of case page of
DashboardPage ->
True
SearchPage -> SearchPage ->
True True
@ -141,6 +145,9 @@ loginPage p =
pageName : Page -> String pageName : Page -> String
pageName page = pageName page =
case page of case page of
DashboardPage ->
"dashboard"
SearchPage -> SearchPage ->
"Search" "Search"
@ -226,6 +233,9 @@ uploadId page =
pageToString : Page -> String pageToString : Page -> String
pageToString page = pageToString page =
case page of case page of
DashboardPage ->
"/app/dashboard"
SearchPage -> SearchPage ->
"/app/search" "/app/search"
@ -312,12 +322,14 @@ pathPrefix =
parser : Parser (Page -> a) a parser : Parser (Page -> a) a
parser = parser =
oneOf oneOf
[ Parser.map SearchPage [ Parser.map DashboardPage
(oneOf (oneOf
[ Parser.top [ Parser.top
, s pathPrefix </> s "search" , s pathPrefix
, s pathPrefix </> s "dashboard"
] ]
) )
, Parser.map SearchPage (s pathPrefix </> s "search")
, Parser.map LoginPage (s pathPrefix </> s "login" <?> loginPageParser) , Parser.map LoginPage (s pathPrefix </> s "login" <?> loginPageParser)
, Parser.map ManageDataPage (s pathPrefix </> s "managedata") , Parser.map ManageDataPage (s pathPrefix </> s "managedata")
, Parser.map CollectiveSettingPage (s pathPrefix </> s "csettings") , Parser.map CollectiveSettingPage (s pathPrefix </> s "csettings")

View File

@ -0,0 +1,27 @@
{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Page.Dashboard.Data exposing
( Model
, Msg(..)
, init
)
import Data.Flags exposing (Flags)
type alias Model =
{}
init : Flags -> ( Model, Cmd Msg )
init flags =
( {}, Cmd.none )
type Msg
= Init

View File

@ -0,0 +1,18 @@
{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Page.Dashboard.Update exposing (update)
import Data.Flags exposing (Flags)
import Page.Dashboard.Data exposing (..)
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
update flags msg model =
case msg of
Init ->
( model, Cmd.none )

View File

@ -0,0 +1,38 @@
{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Page.Dashboard.View exposing (viewContent, viewSidebar)
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Messages.Page.Dashboard exposing (Texts)
import Page.Dashboard.Data exposing (..)
import Styles as S
viewSidebar : Texts -> Bool -> Flags -> UiSettings -> Model -> Html Msg
viewSidebar texts visible _ _ model =
div
[ id "sidebar"
, class S.sidebar
, class S.sidebarBg
, classList [ ( "hidden", not visible ) ]
]
[ div [ class "" ]
[ h1 [ class S.header1 ]
[ text "sidebar"
]
]
]
viewContent : Texts -> Flags -> UiSettings -> Model -> Html Msg
viewContent texts _ _ model =
div [] []

View File

@ -53,7 +53,7 @@ update loginData flags msg model =
AuthResp (Ok lr) -> AuthResp (Ok lr) ->
let let
gotoRef = gotoRef =
Maybe.withDefault SearchPage loginData.referrer |> Page.goto Maybe.withDefault DashboardPage loginData.referrer |> Page.goto
in in
if lr.success && not lr.requireSecondFactor then if lr.success && not lr.requireSecondFactor then
( { model | formState = AuthSuccess lr, password = "" } ( { model | formState = AuthSuccess lr, password = "" }