mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-28 11:08:27 +00:00
Some predefined boxes for a dashboard
This commit is contained in:
@ -11,6 +11,8 @@ module Page.Dashboard.Data exposing
|
||||
, Msg(..)
|
||||
, SideMenuModel
|
||||
, init
|
||||
, reloadDashboard
|
||||
, reloadUiSettings
|
||||
)
|
||||
|
||||
import Api
|
||||
@ -26,8 +28,8 @@ import Comp.ShareManage
|
||||
import Comp.SourceManage
|
||||
import Comp.TagManage
|
||||
import Data.Bookmarks exposing (AllBookmarks)
|
||||
import Data.Dashboard exposing (Dashboard)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Page.Dashboard.DefaultDashboard as DefaultDashboard
|
||||
|
||||
|
||||
type alias SideMenuModel =
|
||||
@ -41,11 +43,11 @@ type alias Model =
|
||||
}
|
||||
|
||||
|
||||
init : Flags -> ( Model, Cmd Msg )
|
||||
init flags =
|
||||
init : Flags -> Dashboard -> ( Model, Cmd Msg )
|
||||
init flags db =
|
||||
let
|
||||
( dm, dc ) =
|
||||
Comp.DashboardView.init flags DefaultDashboard.value
|
||||
Comp.DashboardView.init flags db
|
||||
in
|
||||
( { sideMenu =
|
||||
{ bookmarkChooser = Comp.BookmarkChooser.init Data.Bookmarks.empty
|
||||
@ -69,6 +71,16 @@ initCmd flags =
|
||||
Api.getBookmarks flags ignoreBookmarkError
|
||||
|
||||
|
||||
reloadDashboard : Msg
|
||||
reloadDashboard =
|
||||
InitDashboard
|
||||
|
||||
|
||||
reloadUiSettings : Msg
|
||||
reloadUiSettings =
|
||||
InitDashboard
|
||||
|
||||
|
||||
type Msg
|
||||
= GetBookmarksResp AllBookmarks
|
||||
| BookmarkMsg Comp.BookmarkChooser.Msg
|
||||
|
@ -1,57 +1,121 @@
|
||||
module Page.Dashboard.DefaultDashboard exposing (..)
|
||||
module Page.Dashboard.DefaultDashboard exposing (getDefaultDashboard, value)
|
||||
|
||||
import Data.Box exposing (Box)
|
||||
import Data.BoxContent exposing (BoxContent(..))
|
||||
import Data.BoxContent exposing (BoxContent(..), SearchQuery(..), SummaryShow(..))
|
||||
import Data.Dashboard exposing (Dashboard)
|
||||
import Data.ItemArrange
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.ItemTemplate as IT
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Messages
|
||||
import Messages.Page.DefaultDashboard exposing (Texts)
|
||||
import Messages.UiLanguage
|
||||
|
||||
|
||||
value : Dashboard
|
||||
value =
|
||||
{ name = "Default"
|
||||
value : Texts -> Dashboard
|
||||
value texts =
|
||||
{ name = texts.default
|
||||
, columns = 2
|
||||
, boxes =
|
||||
[ messageBox
|
||||
, newDocuments
|
||||
, summary
|
||||
[ messageBox texts
|
||||
, summary2
|
||||
, newDocuments texts
|
||||
, dueDocuments texts
|
||||
, summary texts
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
messageBox : Box
|
||||
messageBox =
|
||||
{ name = "Welcome Message"
|
||||
getDefaultDashboard : Flags -> UiSettings -> Dashboard
|
||||
getDefaultDashboard flags settings =
|
||||
let
|
||||
lang =
|
||||
Data.UiSettings.getUiLanguage flags settings Messages.UiLanguage.English
|
||||
|
||||
texts =
|
||||
Messages.get lang
|
||||
in
|
||||
value texts.dashboard.defaultDashboard
|
||||
|
||||
|
||||
|
||||
--- Boxes
|
||||
|
||||
|
||||
messageBox : Texts -> Box
|
||||
messageBox texts =
|
||||
{ name = texts.welcomeName
|
||||
, visible = True
|
||||
, decoration = False
|
||||
, colspan = 2
|
||||
, content =
|
||||
BoxMessage
|
||||
{ title = "Welcome to Docspell"
|
||||
, body = ""
|
||||
{ title = texts.welcomeTitle
|
||||
, body = texts.welcomeBody
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
newDocuments : Box
|
||||
newDocuments =
|
||||
{ name = "New Documents"
|
||||
newDocuments : Texts -> Box
|
||||
newDocuments texts =
|
||||
{ name = texts.newDocsName
|
||||
, visible = True
|
||||
, decoration = True
|
||||
, colspan = 1
|
||||
, content =
|
||||
BoxQuery
|
||||
{ query = "inbox:yes"
|
||||
, view = Data.ItemArrange.List
|
||||
{ query = SearchQueryString "inbox:yes"
|
||||
, limit = 5
|
||||
, details = True
|
||||
, header = []
|
||||
, columns = []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
summary : Box
|
||||
summary =
|
||||
{ name = "Summary"
|
||||
dueDocuments : Texts -> Box
|
||||
dueDocuments texts =
|
||||
{ name = texts.dueInDays 10
|
||||
, visible = True
|
||||
, decoration = True
|
||||
, colspan = 1
|
||||
, content =
|
||||
BoxSummary { query = "" }
|
||||
BoxQuery
|
||||
{ query = SearchQueryString "due>today;-10d due<today;+10d"
|
||||
, limit = 5
|
||||
, details = True
|
||||
, header = texts.dueHeaderColumns
|
||||
, columns =
|
||||
[ IT.name
|
||||
, IT.correspondent
|
||||
, IT.dueDateShort
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
summary : Texts -> Box
|
||||
summary texts =
|
||||
{ name = texts.summaryName
|
||||
, visible = True
|
||||
, decoration = True
|
||||
, colspan = 1
|
||||
, content =
|
||||
BoxSummary
|
||||
{ query = SearchQueryString ""
|
||||
, show = SummaryShowGeneral
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
summary2 : Box
|
||||
summary2 =
|
||||
{ name = ""
|
||||
, visible = True
|
||||
, decoration = True
|
||||
, colspan = 2
|
||||
, content =
|
||||
BoxSummary
|
||||
{ query = SearchQueryString ""
|
||||
, show = SummaryShowFields False
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import Comp.ShareManage
|
||||
import Comp.SourceManage
|
||||
import Comp.TagManage
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Messages.Page.Dashboard exposing (Texts)
|
||||
import Page exposing (Page(..))
|
||||
import Page.Dashboard.Data exposing (..)
|
||||
@ -27,8 +28,8 @@ import Page.Dashboard.DefaultDashboard
|
||||
import Set
|
||||
|
||||
|
||||
update : Texts -> Nav.Key -> Flags -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||
update texts navKey flags msg model =
|
||||
update : Texts -> UiSettings -> Nav.Key -> Flags -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||
update texts settings navKey flags msg model =
|
||||
case msg of
|
||||
GetBookmarksResp list ->
|
||||
let
|
||||
@ -59,8 +60,11 @@ update texts navKey flags msg model =
|
||||
|
||||
InitDashboard ->
|
||||
let
|
||||
board =
|
||||
Page.Dashboard.DefaultDashboard.getDefaultDashboard flags settings
|
||||
|
||||
( dm, dc ) =
|
||||
Comp.DashboardView.init flags Page.Dashboard.DefaultDashboard.value
|
||||
Comp.DashboardView.init flags board
|
||||
in
|
||||
( { model | content = Home dm }, Cmd.map DashboardMsg dc, Sub.none )
|
||||
|
||||
@ -242,7 +246,16 @@ update texts navKey flags msg model =
|
||||
unit model
|
||||
|
||||
DashboardMsg lm ->
|
||||
unit model
|
||||
case model.content of
|
||||
Home m ->
|
||||
let
|
||||
( dm, dc ) =
|
||||
Comp.DashboardView.update lm m
|
||||
in
|
||||
( { model | content = Home dm }, Cmd.map DashboardMsg dc, Sub.none )
|
||||
|
||||
_ ->
|
||||
unit model
|
||||
|
||||
|
||||
unit : Model -> ( Model, Cmd Msg, Sub Msg )
|
||||
|
@ -48,7 +48,7 @@ viewContent texts flags settings model =
|
||||
[ case model.content of
|
||||
Home m ->
|
||||
Html.map DashboardMsg
|
||||
(Comp.DashboardView.view m)
|
||||
(Comp.DashboardView.view texts.dashboard m)
|
||||
|
||||
Webhook m ->
|
||||
viewHookManage texts settings m
|
||||
|
@ -563,7 +563,7 @@ editMenuBar texts model svm =
|
||||
searchStats : Texts -> Flags -> UiSettings -> Model -> List (Html Msg)
|
||||
searchStats texts _ settings model =
|
||||
if settings.searchStatsVisible then
|
||||
[ Comp.SearchStatsView.view2 texts.searchStatsView "my-2" model.searchStats
|
||||
[ Comp.SearchStatsView.view texts.searchStatsView "my-2" model.searchStats
|
||||
]
|
||||
|
||||
else
|
||||
|
Reference in New Issue
Block a user