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

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

@ -22,6 +22,8 @@ import Messages exposing (Messages)
import Page exposing (Page(..))
import Page.CollectiveSettings.Data
import Page.CollectiveSettings.Update
import Page.Dashboard.Data
import Page.Dashboard.Update
import Page.ItemDetail.Data
import Page.ItemDetail.Update
import Page.Login.Data
@ -157,6 +159,9 @@ updateWithSub msg model =
ItemDetailMsg m ->
updateItemDetail texts m model
DashboardMsg m ->
updateDashboard m model
VersionResp (Ok info) ->
( { model | version = info }, Cmd.none, Sub.none )
@ -366,6 +371,18 @@ applyClientSettings texts model 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 lmsg model =
case Page.pageShareDetail model.page of
@ -685,3 +702,6 @@ initPage model_ page =
_ ->
( model, Cmd.none, Sub.none )
DashboardPage ->
( model, Cmd.none, Sub.none )

@ -19,6 +19,7 @@ import Messages.App exposing (Texts)
import Messages.UiLanguage
import Page exposing (Page(..))
import Page.CollectiveSettings.View2 as CollectiveSettings
import Page.Dashboard.View as Dashboard
import Page.ItemDetail.View2 as ItemDetail
import Page.Login.View2 as Login
import Page.ManageData.View2 as ManageData
@ -133,7 +134,7 @@ headerNavItem authenticated model =
[ class "inline-flex font-bold items-center px-4"
, classList [ ( "hover:bg-blue-200 dark:hover:bg-slate-800", authenticated ) ]
, if authenticated then
Page.href SearchPage
Page.href DashboardPage
else
href "#"
@ -160,6 +161,9 @@ mainContent model =
, class styleMain
]
(case model.page of
DashboardPage ->
viewDashboard texts model
SearchPage ->
viewSearch texts model
@ -280,7 +284,7 @@ dataMenu texts _ model =
, classList [ ( "hidden", not model.navMenuOpen ) ]
]
[ dataPageLink model
SearchPage
DashboardPage
[]
[ img
[ class "w-4 inline-block"
@ -288,10 +292,18 @@ dataMenu texts _ model =
]
[]
, div [ class "inline-block ml-2" ]
[ text texts.items
[ text texts.dashboard
]
]
, 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
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 "
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 texts shareId model =
[ Html.map ShareMsg

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

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

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

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

@ -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

@ -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 )

@ -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 [] []

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