mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 10:29:34 +00:00
Outline dashboard model
This commit is contained in:
parent
cb3005211b
commit
0337be98f9
28
modules/webapp/src/main/elm/Comp/BoxView.elm
Normal file
28
modules/webapp/src/main/elm/Comp/BoxView.elm
Normal file
@ -0,0 +1,28 @@
|
||||
module Comp.BoxView exposing (..)
|
||||
|
||||
import Data.Box exposing (Box)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Html exposing (Html, div)
|
||||
|
||||
|
||||
type alias Model =
|
||||
{}
|
||||
|
||||
|
||||
type Msg
|
||||
= Dummy
|
||||
|
||||
|
||||
init : Flags -> Box -> ( Model, Cmd Msg )
|
||||
init flags box =
|
||||
( {}, Cmd.none )
|
||||
|
||||
|
||||
|
||||
--- Update
|
||||
--- View
|
||||
|
||||
|
||||
view : Model -> Html Msg
|
||||
view model =
|
||||
div [] []
|
79
modules/webapp/src/main/elm/Comp/DashboardView.elm
Normal file
79
modules/webapp/src/main/elm/Comp/DashboardView.elm
Normal file
@ -0,0 +1,79 @@
|
||||
module Comp.DashboardView exposing (Model, Msg, init, view, viewBox)
|
||||
|
||||
import Comp.BoxView
|
||||
import Data.Box exposing (Box)
|
||||
import Data.Dashboard exposing (Dashboard)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Dict exposing (Dict)
|
||||
import Html exposing (Html, div)
|
||||
import Html.Attributes exposing (class)
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ dashboard : Dashboard
|
||||
, boxModels : List Comp.BoxView.Model
|
||||
}
|
||||
|
||||
|
||||
type Msg
|
||||
= BoxMsg Comp.BoxView.Msg
|
||||
|
||||
|
||||
init : Flags -> Dashboard -> ( Model, Cmd Msg )
|
||||
init flags db =
|
||||
let
|
||||
( boxModels, cmds ) =
|
||||
List.map (Comp.BoxView.init flags) db.boxes
|
||||
|> List.map (Tuple.mapSecond <| Cmd.map BoxMsg)
|
||||
|> List.unzip
|
||||
in
|
||||
( { dashboard = db
|
||||
, boxModels = boxModels
|
||||
}
|
||||
, Cmd.batch cmds
|
||||
)
|
||||
|
||||
|
||||
|
||||
--- View
|
||||
|
||||
|
||||
view : Model -> Html Msg
|
||||
view model =
|
||||
div
|
||||
[ class (gridStyle model.dashboard)
|
||||
]
|
||||
(List.map viewBox model.boxModels)
|
||||
|
||||
|
||||
viewBox : Comp.BoxView.Model -> Html Msg
|
||||
viewBox box =
|
||||
Html.map BoxMsg
|
||||
(Comp.BoxView.view box)
|
||||
|
||||
|
||||
|
||||
--- Helpers
|
||||
|
||||
|
||||
gridStyle : Dashboard -> String
|
||||
gridStyle db =
|
||||
let
|
||||
colStyle =
|
||||
case db.columns of
|
||||
1 ->
|
||||
""
|
||||
|
||||
2 ->
|
||||
"md:grid-cols-2"
|
||||
|
||||
3 ->
|
||||
"md:grid-cols-3"
|
||||
|
||||
4 ->
|
||||
"md:grid-cols-4"
|
||||
|
||||
_ ->
|
||||
"md:grid-cols-5"
|
||||
in
|
||||
"grid gap-4 grid-cols-1 " ++ colStyle
|
12
modules/webapp/src/main/elm/Data/Box.elm
Normal file
12
modules/webapp/src/main/elm/Data/Box.elm
Normal file
@ -0,0 +1,12 @@
|
||||
module Data.Box exposing (Box)
|
||||
|
||||
import Data.BoxContent exposing (BoxContent)
|
||||
|
||||
|
||||
type alias Box =
|
||||
{ name : String
|
||||
, visible : Bool
|
||||
, decoration : Bool
|
||||
, colspan : Int
|
||||
, content : BoxContent
|
||||
}
|
27
modules/webapp/src/main/elm/Data/BoxContent.elm
Normal file
27
modules/webapp/src/main/elm/Data/BoxContent.elm
Normal file
@ -0,0 +1,27 @@
|
||||
module Data.BoxContent exposing (BoxContent(..), MessageData, QueryData, SummaryData)
|
||||
|
||||
import Data.ItemArrange exposing (ItemArrange)
|
||||
|
||||
|
||||
type BoxContent
|
||||
= BoxUpload
|
||||
| BoxMessage MessageData
|
||||
| BoxQuery QueryData
|
||||
| BoxSummary SummaryData
|
||||
|
||||
|
||||
type alias MessageData =
|
||||
{ title : String
|
||||
, body : String
|
||||
}
|
||||
|
||||
|
||||
type alias QueryData =
|
||||
{ query : String
|
||||
, view : ItemArrange
|
||||
}
|
||||
|
||||
|
||||
type alias SummaryData =
|
||||
{ query : String
|
||||
}
|
10
modules/webapp/src/main/elm/Data/Dashboard.elm
Normal file
10
modules/webapp/src/main/elm/Data/Dashboard.elm
Normal file
@ -0,0 +1,10 @@
|
||||
module Data.Dashboard exposing (Dashboard)
|
||||
|
||||
import Data.Box exposing (Box)
|
||||
|
||||
|
||||
type alias Dashboard =
|
||||
{ name : String
|
||||
, columns : Int
|
||||
, boxes : List Box
|
||||
}
|
@ -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
|
||||
|
@ -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 = "" }
|
||||
}
|
@ -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 =
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user