Readonly dashboard

This commit is contained in:
eikek
2022-01-26 21:22:51 +01:00
parent 67f1575707
commit 2c2b34cd89
29 changed files with 597 additions and 199 deletions

View File

@ -59,7 +59,7 @@ viewSidebar texts visible _ _ model =
[ Icons.sourceIcon2 ""
, span
[ class "ml-3" ]
[ text texts.sources ]
[ text texts.basics.sources ]
]
, a
[ href "#"
@ -70,7 +70,7 @@ viewSidebar texts visible _ _ model =
[ Icons.shareIcon ""
, span
[ class "ml-3" ]
[ text texts.shares ]
[ text texts.basics.shares ]
]
, a
[ href "#"
@ -238,7 +238,7 @@ viewSources texts flags settings model =
]
[ Icons.sourceIcon2 ""
, div [ class "ml-3" ]
[ text texts.sources
[ text texts.basics.sources
]
]
, Html.map SourceMsg (Comp.SourceManage.view2 texts.sourceManage flags settings model.sourceModel)
@ -253,7 +253,7 @@ viewShares texts settings flags model =
]
[ Icons.shareIcon ""
, div [ class "ml-3" ]
[ text texts.shares
[ text texts.basics.shares
]
]
, Html.map ShareMsg (Comp.ShareManage.view texts.shareManage settings flags model.shareModel)

View File

@ -27,6 +27,7 @@ import Comp.PersonManage
import Comp.ShareManage
import Comp.SourceManage
import Comp.TagManage
import Comp.UploadForm
import Data.Bookmarks exposing (AllBookmarks)
import Data.Dashboard exposing (Dashboard)
import Data.Flags exposing (Flags)
@ -73,7 +74,7 @@ initCmd flags =
reloadDashboard : Msg
reloadDashboard =
InitDashboard
ReloadDashboardData
reloadUiSettings : Msg
@ -93,6 +94,7 @@ type Msg
| EquipmentMsg Comp.EquipmentManage.Msg
| TagMsg Comp.TagManage.Msg
| FolderMsg Comp.FolderManage.Msg
| UploadMsg Comp.UploadForm.Msg
| DashboardMsg Comp.DashboardView.Msg
| InitNotificationHook
| InitDashboard
@ -104,6 +106,8 @@ type Msg
| InitEquipment
| InitTags
| InitFolder
| InitUpload
| ReloadDashboardData
type Content
@ -117,3 +121,4 @@ type Content
| Equipment Comp.EquipmentManage.Model
| Tags Comp.TagManage.Model
| Folder Comp.FolderManage.Model
| Upload Comp.UploadForm.Model

View File

@ -17,9 +17,10 @@ value texts =
, columns = 2
, boxes =
[ messageBox texts
, summary2
, fieldStats
, newDocuments texts
, dueDocuments texts
, upload
, summary texts
]
}
@ -107,8 +108,8 @@ summary texts =
}
summary2 : Box
summary2 =
fieldStats : Box
fieldStats =
{ name = ""
, visible = True
, decoration = True
@ -119,3 +120,14 @@ summary2 =
, show = SummaryShowFields False
}
}
upload : Box
upload =
{ name = ""
, visible = True
, decoration = True
, colspan = 1
, content =
BoxUpload Nothing
}

View File

@ -1,6 +1,8 @@
module Page.Dashboard.SideMenu exposing (view)
import Api.Model.VersionInfo exposing (VersionInfo)
import Comp.BookmarkChooser
import Data.Flags exposing (Flags)
import Data.Icons as Icons
import Data.UiSettings exposing (UiSettings)
import Html exposing (Attribute, Html, a, div, h3, span, text)
@ -12,18 +14,18 @@ import Page.Dashboard.Data exposing (Msg(..), SideMenuModel)
import Styles as S
view : Texts -> UiSettings -> SideMenuModel -> Html Msg
view texts _ model =
div [ class "flex flex-col" ]
view : Texts -> VersionInfo -> UiSettings -> SideMenuModel -> Html Msg
view texts versionInfo _ model =
div [ class "flex flex-col flex-grow" ]
[ div [ class "mt-2" ]
[ menuLink [ onClick InitDashboard, href "#" ] (Icons.dashboardIcon "") "Dashboard"
, menuLink [ Page.href (SearchPage Nothing) ] (Icons.searchIcon "") "Items"
[ menuLink [ onClick InitDashboard, href "#" ] (Icons.dashboardIcon "") texts.dashboardLink
, menuLink [ Page.href (SearchPage Nothing) ] (Icons.searchIcon "") texts.basics.items
]
, h3
[ class S.header3
, class "italic mt-3"
]
[ text "Bookmarks"
[ text texts.bookmarks
]
, div [ class "ml-2" ]
[ Html.map BookmarkMsg
@ -38,29 +40,44 @@ view texts _ model =
[ class S.header3
, class "italic mt-3"
]
[ text "Manage"
[ text texts.settings
]
, div [ class "ml-2 mb-2" ]
[ menuLink [ onClick InitOrganization, href "#" ] (Icons.organizationIcon "") "Organization"
, menuLink [ onClick InitPerson, href "#" ] (Icons.personIcon "") "Person"
, menuLink [ onClick InitEquipment, href "#" ] (Icons.equipmentIcon "") "Equipment"
, menuLink [ onClick InitTags, href "#" ] (Icons.tagsIcon "") "Tags"
, menuLink [ onClick InitFolder, href "#" ] (Icons.folderIcon "") "Folder"
]
, div [ class "ml-2" ]
[ menuLink [ onClick InitNotificationHook, href "#" ] (Icons.notificationHooksIcon "") "Webhooks"
, menuLink [ onClick InitPeriodicQuery, href "#" ] (Icons.periodicTasksIcon "") "Periodic Queries"
, menuLink [ onClick InitSource, href "#" ] (Icons.sourceIcon2 "") "Sources"
, menuLink [ onClick InitShare, href "#" ] (Icons.shareIcon "") "Shares"
[ menuLink [ onClick InitNotificationHook, href "#" ] (Icons.notificationHooksIcon "") texts.basics.notificationHooks
, menuLink [ onClick InitPeriodicQuery, href "#" ] (Icons.periodicTasksIcon "") texts.basics.periodicQueries
, menuLink [ onClick InitSource, href "#" ] (Icons.sourceIcon2 "") texts.basics.sources
, menuLink [ onClick InitShare, href "#" ] (Icons.shareIcon "") texts.basics.shares
]
, h3
[ class S.header3
, class "italic mt-3"
]
[ text "Misc"
[ text texts.manage
]
, div [ class "ml-2 mb-2" ]
[ menuLink [ onClick InitOrganization, href "#" ] (Icons.organizationIcon "") texts.basics.organization
, menuLink [ onClick InitPerson, href "#" ] (Icons.personIcon "") texts.basics.person
, menuLink [ onClick InitEquipment, href "#" ] (Icons.equipmentIcon "") texts.basics.equipment
, menuLink [ onClick InitTags, href "#" ] (Icons.tagsIcon "") texts.basics.tags
, menuLink [ onClick InitFolder, href "#" ] (Icons.folderIcon "") texts.basics.folder
]
, h3
[ class S.header3
, class "italic mt-3"
]
[ text texts.misc
]
, div [ class "ml-2" ]
[ menuLink [ href "#", target "_blank" ] (Icons.documentationIcon "") "Documentation"
[ menuLink [ onClick InitUpload, href "#" ] (Icons.fileUploadIcon "") texts.uploadFiles
]
, div [ class "mt-2 opacity-75" ]
[ menuLink [ href Data.UiSettings.documentationSite, target "_blank" ] (Icons.documentationIcon "") texts.documentation
]
, div [ class "flex flex-grow items-end" ]
[ div [ class "text-center text-xs w-full opacity-50" ]
[ text "Docspell "
, text versionInfo.version
]
]
]

View File

@ -19,6 +19,7 @@ import Comp.PersonManage
import Comp.ShareManage
import Comp.SourceManage
import Comp.TagManage
import Comp.UploadForm
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Messages.Page.Dashboard exposing (Texts)
@ -26,6 +27,7 @@ import Page exposing (Page(..))
import Page.Dashboard.Data exposing (..)
import Page.Dashboard.DefaultDashboard
import Set
import Styles exposing (content)
update : Texts -> UiSettings -> Nav.Key -> Flags -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
@ -59,14 +61,19 @@ update texts settings navKey flags msg model =
)
InitDashboard ->
let
board =
Page.Dashboard.DefaultDashboard.getDefaultDashboard flags settings
case model.content of
Home _ ->
update texts settings navKey flags ReloadDashboardData model
( dm, dc ) =
Comp.DashboardView.init flags board
in
( { model | content = Home dm }, Cmd.map DashboardMsg dc, Sub.none )
_ ->
let
board =
Page.Dashboard.DefaultDashboard.getDefaultDashboard flags settings
( dm, dc ) =
Comp.DashboardView.init flags board
in
( { model | content = Home dm }, Cmd.map DashboardMsg dc, Sub.none )
InitNotificationHook ->
let
@ -131,6 +138,13 @@ update texts settings navKey flags msg model =
in
( { model | content = Folder fm }, Cmd.map FolderMsg fc, Sub.none )
InitUpload ->
let
um =
Comp.UploadForm.init
in
( { model | content = Upload um }, Cmd.none, Sub.none )
NotificationHookMsg lm ->
case model.content of
Webhook nhm ->
@ -245,18 +259,37 @@ update texts settings navKey flags msg model =
_ ->
unit model
UploadMsg lm ->
case model.content of
Upload m ->
let
( um, uc, us ) =
Comp.UploadForm.update Nothing flags lm m
in
( { model | content = Upload um }, Cmd.map UploadMsg uc, Sub.map UploadMsg us )
_ ->
unit model
DashboardMsg lm ->
case model.content of
Home m ->
let
( dm, dc ) =
Comp.DashboardView.update lm m
( dm, dc, ds ) =
Comp.DashboardView.update flags lm m
in
( { model | content = Home dm }, Cmd.map DashboardMsg dc, Sub.none )
( { model | content = Home dm }, Cmd.map DashboardMsg dc, Sub.map DashboardMsg ds )
_ ->
unit model
ReloadDashboardData ->
let
lm =
DashboardMsg Comp.DashboardView.reloadData
in
update texts settings navKey flags lm model
unit : Model -> ( Model, Cmd Msg, Sub Msg )
unit m =

View File

@ -7,6 +7,7 @@
module Page.Dashboard.View exposing (viewContent, viewSidebar)
import Api.Model.VersionInfo exposing (VersionInfo)
import Comp.DashboardView
import Comp.EquipmentManage
import Comp.FolderManage
@ -17,6 +18,7 @@ import Comp.PersonManage
import Comp.ShareManage
import Comp.SourceManage
import Comp.TagManage
import Comp.UploadForm
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
@ -27,15 +29,15 @@ import Page.Dashboard.SideMenu as SideMenu
import Styles as S
viewSidebar : Texts -> Bool -> Flags -> UiSettings -> Model -> Html Msg
viewSidebar texts visible _ settings model =
viewSidebar : Texts -> Bool -> Flags -> VersionInfo -> UiSettings -> Model -> Html Msg
viewSidebar texts visible flags versionInfo settings model =
div
[ id "sidebar"
, class S.sidebar
, class S.sidebarBg
, classList [ ( "hidden", not visible ) ]
]
[ SideMenu.view texts settings model.sideMenu
[ SideMenu.view texts versionInfo settings model.sideMenu
]
@ -48,7 +50,7 @@ viewContent texts flags settings model =
[ case model.content of
Home m ->
Html.map DashboardMsg
(Comp.DashboardView.view texts.dashboard m)
(Comp.DashboardView.view texts.dashboard flags settings m)
Webhook m ->
viewHookManage texts settings m
@ -76,6 +78,9 @@ viewContent texts flags settings model =
Folder m ->
viewFolder texts flags m
Upload m ->
viewUplod texts flags settings m
]
@ -83,11 +88,29 @@ viewContent texts flags settings model =
--- Helpers
viewUplod : Texts -> Flags -> UiSettings -> Comp.UploadForm.Model -> Html Msg
viewUplod texts flags settings model =
let
viewCfg =
{ showForm = True
, sourceId = Nothing
, lightForm = False
}
in
div []
[ h1 [ class S.header1 ]
[ text texts.uploadFiles
]
, Html.map UploadMsg <|
Comp.UploadForm.view texts.uploadForm viewCfg flags settings model
]
viewFolder : Texts -> Flags -> Comp.FolderManage.Model -> Html Msg
viewFolder texts flags model =
div []
[ h1 [ class S.header1 ]
[ text "Folder"
[ text texts.basics.folder
]
, Html.map FolderMsg <|
Comp.FolderManage.view2 texts.folderManage flags model
@ -98,7 +121,7 @@ viewTags : Texts -> UiSettings -> Comp.TagManage.Model -> Html Msg
viewTags texts settings model =
div []
[ h1 [ class S.header1 ]
[ text "Tags"
[ text texts.basics.tags
]
, Html.map TagMsg <|
Comp.TagManage.view2 texts.tagManage settings model
@ -109,7 +132,7 @@ viewEquipment : Texts -> Comp.EquipmentManage.Model -> Html Msg
viewEquipment texts model =
div []
[ h1 [ class S.header1 ]
[ text "Equipment"
[ text texts.basics.equipment
]
, Html.map EquipmentMsg <|
Comp.EquipmentManage.view2 texts.equipManage model
@ -120,7 +143,7 @@ viewPerson : Texts -> UiSettings -> Comp.PersonManage.Model -> Html Msg
viewPerson texts settings model =
div []
[ h1 [ class S.header1 ]
[ text "Person"
[ text texts.basics.person
]
, Html.map PersonMsg <|
Comp.PersonManage.view2 texts.personManage settings model
@ -131,7 +154,7 @@ viewOrganization : Texts -> UiSettings -> Comp.OrgManage.Model -> Html Msg
viewOrganization texts settings model =
div []
[ h1 [ class S.header1 ]
[ text "Organizations"
[ text texts.basics.organization
]
, Html.map OrganizationMsg <|
Comp.OrgManage.view2 texts.organizationManage settings model
@ -142,7 +165,7 @@ viewShare : Texts -> Flags -> UiSettings -> Comp.ShareManage.Model -> Html Msg
viewShare texts flags settings model =
div []
[ h1 [ class S.header1 ]
[ text "Shares"
[ text texts.basics.shares
]
, Html.map ShareMsg <|
Comp.ShareManage.view texts.shareManage settings flags model
@ -153,7 +176,7 @@ viewSource : Texts -> Flags -> UiSettings -> Comp.SourceManage.Model -> Html Msg
viewSource texts flags settings model =
div []
[ h1 [ class S.header1 ]
[ text "Sources"
[ text texts.basics.sources
]
, Html.map SourceMsg <|
Comp.SourceManage.view2 texts.sourceManage flags settings model
@ -164,7 +187,7 @@ viewPeriodicQuery : Texts -> UiSettings -> Comp.PeriodicQueryTaskManage.Model ->
viewPeriodicQuery texts settings model =
div []
[ h1 [ class S.header1 ]
[ text "Periodic Queries"
[ text texts.basics.periodicQueries
]
, Html.map PeriodicQueryMsg <|
Comp.PeriodicQueryTaskManage.view texts.periodicQueryManage settings model
@ -175,7 +198,7 @@ viewHookManage : Texts -> UiSettings -> Comp.NotificationHookManage.Model -> Htm
viewHookManage texts settings model =
div []
[ h1 [ class S.header1 ]
[ text "Notification Hooks"
[ text texts.basics.notificationHooks
]
, Html.map NotificationHookMsg <|
Comp.NotificationHookManage.view texts.notificationHookManage settings model

View File

@ -15,6 +15,7 @@ import Html.Attributes exposing (..)
import Messages.Page.Upload exposing (Texts)
import Page exposing (Page(..))
import Page.Upload.Data exposing (..)
import Styles
viewSidebar : Maybe String -> Bool -> Flags -> UiSettings -> Model -> Html Msg
@ -28,5 +29,18 @@ viewSidebar _ _ _ _ _ =
viewContent : Texts -> Maybe String -> Flags -> UiSettings -> Model -> Html Msg
viewContent texts sourceId flags settings model =
Html.map UploadMsg
(Comp.UploadForm.view texts.uploadForm sourceId flags settings model.uploadForm)
let
viewCfg =
{ sourceId = sourceId
, showForm = True
, lightForm = False
}
in
div
[ id "content"
, class Styles.content
, class "mt-4"
]
[ Html.map UploadMsg
(Comp.UploadForm.view texts.uploadForm viewCfg flags settings model.uploadForm)
]

View File

@ -97,7 +97,7 @@ viewSidebar texts visible _ _ model =
[ i [ class "fa fa-bell" ] []
, span
[ class "ml-3" ]
[ text texts.webhooks ]
[ text texts.basics.notificationHooks ]
]
, a
[ href "#"
@ -119,7 +119,7 @@ viewSidebar texts visible _ _ model =
[ i [ class "fa fa-history" ] []
, span
[ class "ml-3" ]
[ text texts.genericQueries ]
[ text texts.basics.periodicQueries ]
]
]
]
@ -396,7 +396,7 @@ viewNotificationInfo texts settings model =
[ i [ class "fa fa-bell" ] []
, span
[ class "ml-3" ]
[ text texts.webhooks ]
[ text texts.basics.notificationHooks ]
]
, div [ class "ml-3 text-sm opacity-50" ]
[ text texts.webhookInfoText
@ -426,7 +426,7 @@ viewNotificationInfo texts settings model =
[ Icons.periodicTasksIcon ""
, span
[ class "ml-3" ]
[ text texts.genericQueries ]
[ text texts.basics.periodicQueries ]
]
, div [ class "ml-3 text-sm opacity-50" ]
[ text texts.periodicQueryInfoText
@ -465,7 +465,7 @@ viewNotificationQueries texts settings model =
]
[ i [ class "fa fa-history" ] []
, div [ class "ml-3" ]
[ text texts.genericQueries
[ text texts.basics.periodicQueries
]
]
, Markdown.toHtml [ class "opacity-80 text-lg mb-3 markdown-preview" ] texts.periodicQueryInfoText
@ -485,7 +485,7 @@ viewNotificationHooks texts settings model =
]
[ i [ class "fa fa-bell" ] []
, div [ class "ml-3" ]
[ text texts.webhooks
[ text texts.basics.notificationHooks
]
]
, Markdown.toHtml [ class "opacity-80 text-lg mb-3 markdown-preview" ] texts.webhookInfoText