Outline dashboard model

This commit is contained in:
eikek
2022-01-26 21:21:55 +01:00
parent cb3005211b
commit 0337be98f9
9 changed files with 240 additions and 7 deletions

View File

@@ -15,6 +15,7 @@ module Page.Dashboard.Data exposing
import Api
import Comp.BookmarkChooser
import Comp.DashboardView
import Comp.EquipmentManage
import Comp.FolderManage
import Comp.NotificationHookManage
@@ -26,6 +27,7 @@ import Comp.SourceManage
import Comp.TagManage
import Data.Bookmarks exposing (AllBookmarks)
import Data.Flags exposing (Flags)
import Page.Dashboard.DefaultDashboard as DefaultDashboard
type alias SideMenuModel =
@@ -41,12 +43,19 @@ type alias Model =
init : Flags -> ( Model, Cmd Msg )
init flags =
let
( dm, dc ) =
Comp.DashboardView.init flags DefaultDashboard.value
in
( { sideMenu =
{ bookmarkChooser = Comp.BookmarkChooser.init Data.Bookmarks.empty
}
, content = NoContent
, content = Home dm
}
, initCmd flags
, Cmd.batch
[ initCmd flags
, Cmd.map DashboardMsg dc
]
)
@@ -72,6 +81,7 @@ type Msg
| EquipmentMsg Comp.EquipmentManage.Msg
| TagMsg Comp.TagManage.Msg
| FolderMsg Comp.FolderManage.Msg
| DashboardMsg Comp.DashboardView.Msg
| InitNotificationHook
| InitDashboard
| InitPeriodicQuery
@@ -85,7 +95,7 @@ type Msg
type Content
= NoContent
= Home Comp.DashboardView.Model
| Webhook Comp.NotificationHookManage.Model
| PeriodicQuery Comp.PeriodicQueryTaskManage.Model
| Source Comp.SourceManage.Model

View File

@@ -0,0 +1,57 @@
module Page.Dashboard.DefaultDashboard exposing (..)
import Data.Box exposing (Box)
import Data.BoxContent exposing (BoxContent(..))
import Data.Dashboard exposing (Dashboard)
import Data.ItemArrange
value : Dashboard
value =
{ name = "Default"
, columns = 2
, boxes =
[ messageBox
, newDocuments
, summary
]
}
messageBox : Box
messageBox =
{ name = "Welcome Message"
, visible = True
, decoration = False
, colspan = 2
, content =
BoxMessage
{ title = "Welcome to Docspell"
, body = ""
}
}
newDocuments : Box
newDocuments =
{ name = "New Documents"
, visible = True
, decoration = True
, colspan = 1
, content =
BoxQuery
{ query = "inbox:yes"
, view = Data.ItemArrange.List
}
}
summary : Box
summary =
{ name = "Summary"
, visible = True
, decoration = True
, colspan = 1
, content =
BoxSummary { query = "" }
}

View File

@@ -9,6 +9,7 @@ module Page.Dashboard.Update exposing (update)
import Browser.Navigation as Nav
import Comp.BookmarkChooser
import Comp.DashboardView
import Comp.EquipmentManage
import Comp.FolderManage
import Comp.NotificationHookManage
@@ -22,6 +23,7 @@ import Data.Flags exposing (Flags)
import Messages.Page.Dashboard exposing (Texts)
import Page exposing (Page(..))
import Page.Dashboard.Data exposing (..)
import Page.Dashboard.DefaultDashboard
import Set
@@ -56,7 +58,11 @@ update texts navKey flags msg model =
)
InitDashboard ->
( { model | content = NoContent }, Cmd.none, Sub.none )
let
( dm, dc ) =
Comp.DashboardView.init flags Page.Dashboard.DefaultDashboard.value
in
( { model | content = Home dm }, Cmd.map DashboardMsg dc, Sub.none )
InitNotificationHook ->
let
@@ -235,6 +241,9 @@ update texts navKey flags msg model =
_ ->
unit model
DashboardMsg lm ->
unit model
unit : Model -> ( Model, Cmd Msg, Sub Msg )
unit m =

View File

@@ -7,6 +7,7 @@
module Page.Dashboard.View exposing (viewContent, viewSidebar)
import Comp.DashboardView
import Comp.EquipmentManage
import Comp.FolderManage
import Comp.NotificationHookManage
@@ -20,7 +21,6 @@ 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 Page.Dashboard.SideMenu as SideMenu
@@ -46,8 +46,9 @@ viewContent texts flags settings model =
, class S.content
]
[ case model.content of
NoContent ->
div [] []
Home m ->
Html.map DashboardMsg
(Comp.DashboardView.view m)
Webhook m ->
viewHookManage texts settings m