mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 10:58:26 +00:00
Dashboard page template
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user