Add some static links to the dashboard

This commit is contained in:
eikek
2022-01-26 21:21:19 +01:00
parent e6775f77dc
commit 631450cb16
24 changed files with 736 additions and 146 deletions

View File

@@ -6,22 +6,92 @@
module Page.Dashboard.Data exposing
( Model
( Content(..)
, Model
, Msg(..)
, SideMenuModel
, init
)
import Api
import Comp.BookmarkChooser
import Comp.EquipmentManage
import Comp.FolderManage
import Comp.NotificationHookManage
import Comp.OrgManage
import Comp.PeriodicQueryTaskManage
import Comp.PersonManage
import Comp.ShareManage
import Comp.SourceManage
import Comp.TagManage
import Data.Bookmarks exposing (AllBookmarks)
import Data.Flags exposing (Flags)
type alias SideMenuModel =
{ bookmarkChooser : Comp.BookmarkChooser.Model
}
type alias Model =
{}
{ sideMenu : SideMenuModel
, content : Content
}
init : Flags -> ( Model, Cmd Msg )
init flags =
( {}, Cmd.none )
( { sideMenu =
{ bookmarkChooser = Comp.BookmarkChooser.init Data.Bookmarks.empty
}
, content = NoContent
}
, initCmd flags
)
initCmd : Flags -> Cmd Msg
initCmd flags =
let
ignoreBookmarkError r =
Result.withDefault Data.Bookmarks.empty r
|> GetBookmarksResp
in
Api.getBookmarks flags ignoreBookmarkError
type Msg
= Init
= GetBookmarksResp AllBookmarks
| BookmarkMsg Comp.BookmarkChooser.Msg
| NotificationHookMsg Comp.NotificationHookManage.Msg
| PeriodicQueryMsg Comp.PeriodicQueryTaskManage.Msg
| SourceMsg Comp.SourceManage.Msg
| ShareMsg Comp.ShareManage.Msg
| OrganizationMsg Comp.OrgManage.Msg
| PersonMsg Comp.PersonManage.Msg
| EquipmentMsg Comp.EquipmentManage.Msg
| TagMsg Comp.TagManage.Msg
| FolderMsg Comp.FolderManage.Msg
| InitNotificationHook
| InitDashboard
| InitPeriodicQuery
| InitSource
| InitShare
| InitOrganization
| InitPerson
| InitEquipment
| InitTags
| InitFolder
type Content
= NoContent
| Webhook Comp.NotificationHookManage.Model
| PeriodicQuery Comp.PeriodicQueryTaskManage.Model
| Source Comp.SourceManage.Model
| Share Comp.ShareManage.Model
| Organization Comp.OrgManage.Model
| Person Comp.PersonManage.Model
| Equipment Comp.EquipmentManage.Model
| Tags Comp.TagManage.Model
| Folder Comp.FolderManage.Model

View File

@@ -0,0 +1,80 @@
module Page.Dashboard.SideMenu exposing (view)
import Comp.BookmarkChooser
import Data.Icons as Icons
import Data.UiSettings exposing (UiSettings)
import Html exposing (Attribute, Html, a, div, h3, span, text)
import Html.Attributes exposing (class, href, target)
import Html.Events exposing (onClick)
import Messages.Page.Dashboard exposing (Texts)
import Page exposing (Page(..))
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" ]
[ div [ class "mt-2" ]
[ menuLink [ onClick InitDashboard, href "#" ] (Icons.dashboardIcon "") "Dashboard"
, menuLink [ Page.href SearchPage ] (Icons.searchIcon "") "Items"
]
, h3
[ class S.header3
, class "italic mt-3"
]
[ text "Bookmarks"
]
, div [ class "ml-2" ]
[ Html.map BookmarkMsg
(Comp.BookmarkChooser.viewWith
{ showUser = True, showCollective = True, showShares = False }
texts.bookmarkChooser
model.bookmarkChooser
Comp.BookmarkChooser.emptySelection
)
]
, h3
[ class S.header3
, class "italic mt-3"
]
[ text "Manage"
]
, 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"
]
, h3
[ class S.header3
, class "italic mt-3"
]
[ text "Misc"
]
, div [ class "ml-2" ]
[ menuLink [ href "#", target "_blank" ] (Icons.documentationIcon "") "Documentation"
]
]
menuLink : List (Attribute Msg) -> Html Msg -> String -> Html Msg
menuLink attrs icon label =
a
(attrs
++ [ class "my-1"
, class "flex flex-row items-center rounded px-1 py-1 hover:bg-blue-100 dark:hover:bg-slate-600"
]
)
[ icon
, span [ class "ml-2" ]
[ text label
]
]

View File

@@ -7,12 +7,229 @@
module Page.Dashboard.Update exposing (update)
import Comp.BookmarkChooser
import Comp.EquipmentManage
import Comp.FolderManage
import Comp.NotificationHookManage
import Comp.OrgManage
import Comp.PeriodicQueryTaskManage
import Comp.PersonManage
import Comp.ShareManage
import Comp.SourceManage
import Comp.TagManage
import Data.Flags exposing (Flags)
import Messages.Page.Dashboard exposing (Texts)
import Page.Dashboard.Data exposing (..)
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
update flags msg model =
update : Texts -> Flags -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
update texts flags msg model =
case msg of
Init ->
( model, Cmd.none )
GetBookmarksResp list ->
let
sideMenu =
model.sideMenu
in
unit
{ model | sideMenu = { sideMenu | bookmarkChooser = Comp.BookmarkChooser.init list } }
BookmarkMsg lm ->
let
sideMenu =
model.sideMenu
( bm, sel ) =
Comp.BookmarkChooser.update
lm
sideMenu.bookmarkChooser
Comp.BookmarkChooser.emptySelection
in
( { model | sideMenu = { sideMenu | bookmarkChooser = bm } }
, Cmd.none
, Sub.none
)
InitDashboard ->
( { model | content = NoContent }, Cmd.none, Sub.none )
InitNotificationHook ->
let
( nhm, nhc ) =
Comp.NotificationHookManage.init flags
in
( { model | content = Webhook nhm }, Cmd.map NotificationHookMsg nhc, Sub.none )
InitPeriodicQuery ->
let
( pqm, pqc ) =
Comp.PeriodicQueryTaskManage.init flags
in
( { model | content = PeriodicQuery pqm }, Cmd.map PeriodicQueryMsg pqc, Sub.none )
InitSource ->
let
( sm, sc ) =
Comp.SourceManage.init flags
in
( { model | content = Source sm }, Cmd.map SourceMsg sc, Sub.none )
InitShare ->
let
( sm, sc ) =
Comp.ShareManage.init flags
in
( { model | content = Share sm }, Cmd.map ShareMsg sc, Sub.none )
InitOrganization ->
let
( om, oc ) =
Comp.OrgManage.init flags
in
( { model | content = Organization om }, Cmd.map OrganizationMsg oc, Sub.none )
InitPerson ->
let
( pm, pc ) =
Comp.PersonManage.init flags
in
( { model | content = Person pm }, Cmd.map PersonMsg pc, Sub.none )
InitEquipment ->
let
( em, ec ) =
Comp.EquipmentManage.init flags
in
( { model | content = Equipment em }, Cmd.map EquipmentMsg ec, Sub.none )
InitTags ->
let
( tm, tc ) =
Comp.TagManage.init flags
in
( { model | content = Tags tm }, Cmd.map TagMsg tc, Sub.none )
InitFolder ->
let
( fm, fc ) =
Comp.FolderManage.init flags
in
( { model | content = Folder fm }, Cmd.map FolderMsg fc, Sub.none )
NotificationHookMsg lm ->
case model.content of
Webhook nhm ->
let
( nhm_, nhc ) =
Comp.NotificationHookManage.update flags lm nhm
in
( { model | content = Webhook nhm_ }, Cmd.map NotificationHookMsg nhc, Sub.none )
_ ->
unit model
PeriodicQueryMsg lm ->
case model.content of
PeriodicQuery pqm ->
let
( pqm_, pqc, pqs ) =
Comp.PeriodicQueryTaskManage.update flags lm pqm
in
( { model | content = PeriodicQuery pqm_ }
, Cmd.map PeriodicQueryMsg pqc
, Sub.map PeriodicQueryMsg pqs
)
_ ->
unit model
SourceMsg lm ->
case model.content of
Source m ->
let
( sm, sc ) =
Comp.SourceManage.update flags lm m
in
( { model | content = Source sm }, Cmd.map SourceMsg sc, Sub.none )
_ ->
unit model
ShareMsg lm ->
case model.content of
Share m ->
let
( sm, sc, subs ) =
Comp.ShareManage.update texts.shareManage flags lm m
in
( { model | content = Share sm }
, Cmd.map ShareMsg sc
, Sub.map ShareMsg subs
)
_ ->
unit model
OrganizationMsg lm ->
case model.content of
Organization m ->
let
( om, oc ) =
Comp.OrgManage.update flags lm m
in
( { model | content = Organization om }, Cmd.map OrganizationMsg oc, Sub.none )
_ ->
unit model
PersonMsg lm ->
case model.content of
Person m ->
let
( pm, pc ) =
Comp.PersonManage.update flags lm m
in
( { model | content = Person pm }, Cmd.map PersonMsg pc, Sub.none )
_ ->
unit model
EquipmentMsg lm ->
case model.content of
Equipment m ->
let
( em, ec ) =
Comp.EquipmentManage.update flags lm m
in
( { model | content = Equipment em }, Cmd.map EquipmentMsg ec, Sub.none )
_ ->
unit model
TagMsg lm ->
case model.content of
Tags m ->
let
( tm, tc ) =
Comp.TagManage.update flags lm m
in
( { model | content = Tags tm }, Cmd.map TagMsg tc, Sub.none )
_ ->
unit model
FolderMsg lm ->
case model.content of
Folder m ->
let
( fm, fc ) =
Comp.FolderManage.update flags lm m
in
( { model | content = Folder fm }, Cmd.map FolderMsg fc, Sub.none )
_ ->
unit model
unit : Model -> ( Model, Cmd Msg, Sub Msg )
unit m =
( m, Cmd.none, Sub.none )

View File

@@ -7,6 +7,15 @@
module Page.Dashboard.View exposing (viewContent, viewSidebar)
import Comp.EquipmentManage
import Comp.FolderManage
import Comp.NotificationHookManage
import Comp.OrgManage
import Comp.PeriodicQueryTaskManage
import Comp.PersonManage
import Comp.ShareManage
import Comp.SourceManage
import Comp.TagManage
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
@@ -14,25 +23,159 @@ 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
import Styles as S
viewSidebar : Texts -> Bool -> Flags -> UiSettings -> Model -> Html Msg
viewSidebar texts visible _ _ model =
viewSidebar texts visible _ settings model =
div
[ id "sidebar"
, class S.sidebar
, class S.sidebarBg
, classList [ ( "hidden", not visible ) ]
]
[ div [ class "" ]
[ h1 [ class S.header1 ]
[ text "sidebar"
]
]
[ SideMenu.view texts settings model.sideMenu
]
viewContent : Texts -> Flags -> UiSettings -> Model -> Html Msg
viewContent texts _ _ model =
div [] []
viewContent texts flags settings model =
div
[ id "content"
, class S.content
]
[ case model.content of
NoContent ->
div [] []
Webhook m ->
viewHookManage texts settings m
PeriodicQuery m ->
viewPeriodicQuery texts settings m
Source m ->
viewSource texts flags settings m
Share m ->
viewShare texts flags settings m
Organization m ->
viewOrganization texts settings m
Person m ->
viewPerson texts settings m
Equipment m ->
viewEquipment texts m
Tags m ->
viewTags texts settings m
Folder m ->
viewFolder texts flags m
]
--- Helpers
viewFolder : Texts -> Flags -> Comp.FolderManage.Model -> Html Msg
viewFolder texts flags model =
div []
[ h1 [ class S.header1 ]
[ text "Folder"
]
, Html.map FolderMsg <|
Comp.FolderManage.view2 texts.folderManage flags model
]
viewTags : Texts -> UiSettings -> Comp.TagManage.Model -> Html Msg
viewTags texts settings model =
div []
[ h1 [ class S.header1 ]
[ text "Tags"
]
, Html.map TagMsg <|
Comp.TagManage.view2 texts.tagManage settings model
]
viewEquipment : Texts -> Comp.EquipmentManage.Model -> Html Msg
viewEquipment texts model =
div []
[ h1 [ class S.header1 ]
[ text "Equipment"
]
, Html.map EquipmentMsg <|
Comp.EquipmentManage.view2 texts.equipManage model
]
viewPerson : Texts -> UiSettings -> Comp.PersonManage.Model -> Html Msg
viewPerson texts settings model =
div []
[ h1 [ class S.header1 ]
[ text "Person"
]
, Html.map PersonMsg <|
Comp.PersonManage.view2 texts.personManage settings model
]
viewOrganization : Texts -> UiSettings -> Comp.OrgManage.Model -> Html Msg
viewOrganization texts settings model =
div []
[ h1 [ class S.header1 ]
[ text "Organizations"
]
, Html.map OrganizationMsg <|
Comp.OrgManage.view2 texts.organizationManage settings model
]
viewShare : Texts -> Flags -> UiSettings -> Comp.ShareManage.Model -> Html Msg
viewShare texts flags settings model =
div []
[ h1 [ class S.header1 ]
[ text "Shares"
]
, Html.map ShareMsg <|
Comp.ShareManage.view texts.shareManage settings flags model
]
viewSource : Texts -> Flags -> UiSettings -> Comp.SourceManage.Model -> Html Msg
viewSource texts flags settings model =
div []
[ h1 [ class S.header1 ]
[ text "Sources"
]
, Html.map SourceMsg <|
Comp.SourceManage.view2 texts.sourceManage flags settings model
]
viewPeriodicQuery : Texts -> UiSettings -> Comp.PeriodicQueryTaskManage.Model -> Html Msg
viewPeriodicQuery texts settings model =
div []
[ h1 [ class S.header1 ]
[ text "Periodic Queries"
]
, Html.map PeriodicQueryMsg <|
Comp.PeriodicQueryTaskManage.view texts.periodicQueryManage settings model
]
viewHookManage : Texts -> UiSettings -> Comp.NotificationHookManage.Model -> Html Msg
viewHookManage texts settings model =
div []
[ h1 [ class S.header1 ]
[ text "Notification Hooks"
]
, Html.map NotificationHookMsg <|
Comp.NotificationHookManage.view texts.notificationHookManage settings model
]

View File

@@ -46,7 +46,7 @@ viewSidebar texts visible _ settings model =
, class S.sidebarLink
, menuEntryActive model TagTab
]
[ Icons.tagIcon2 ""
[ Icons.tagIcon ""
, span
[ class "ml-3" ]
[ text texts.basics.tags
@@ -58,7 +58,7 @@ viewSidebar texts visible _ settings model =
, menuEntryActive model EquipTab
, class S.sidebarLink
]
[ Icons.equipmentIcon2 ""
[ Icons.equipmentIcon ""
, span
[ class "ml-3" ]
[ text texts.basics.equipment
@@ -70,7 +70,7 @@ viewSidebar texts visible _ settings model =
, menuEntryActive model OrgTab
, class S.sidebarLink
]
[ Icons.organizationIcon2 ""
[ Icons.organizationIcon ""
, span
[ class "ml-3" ]
[ text texts.basics.organization
@@ -82,7 +82,7 @@ viewSidebar texts visible _ settings model =
, menuEntryActive model PersonTab
, class S.sidebarLink
]
[ Icons.personIcon2 ""
[ Icons.personIcon ""
, span
[ class "ml-3" ]
[ text texts.basics.person
@@ -99,7 +99,7 @@ viewSidebar texts visible _ settings model =
, menuEntryActive model FolderTab
, class S.sidebarLink
]
[ Icons.folderIcon2 ""
[ Icons.folderIcon ""
, span
[ class "ml-3" ]
[ text texts.basics.folder
@@ -186,7 +186,7 @@ viewTags texts settings model =
[ class S.header1
, class "inline-flex items-center"
]
[ Icons.tagIcon2 ""
[ Icons.tagIcon ""
, div [ class "ml-2" ]
[ text texts.basics.tags
]
@@ -206,7 +206,7 @@ viewEquip texts model =
[ class S.header1
, class "inline-flex items-center"
]
[ Icons.equipmentIcon2 ""
[ Icons.equipmentIcon ""
, div [ class "ml-2" ]
[ text texts.basics.equipment
]
@@ -224,7 +224,7 @@ viewOrg texts settings model =
[ class S.header1
, class "inline-flex items-center"
]
[ Icons.organizationIcon2 ""
[ Icons.organizationIcon ""
, div [ class "ml-2" ]
[ text texts.basics.organization
]
@@ -243,7 +243,7 @@ viewPerson texts settings model =
[ class S.header1
, class "inline-flex items-center"
]
[ Icons.personIcon2 ""
[ Icons.personIcon ""
, div [ class "ml-2" ]
[ text texts.basics.person
]
@@ -262,7 +262,7 @@ viewFolder texts flags _ model =
[ class S.header1
, class "inline-flex items-center"
]
[ Icons.folderIcon2 ""
[ Icons.folderIcon ""
, div
[ class "ml-2"
]

View File

@@ -143,7 +143,7 @@ itemData texts flags model shareId itemId =
]
, div [ class boxStyle ]
[ div [ class headerStyle ]
[ Icons.tagsIcon2 "mr-2 ml-2"
[ Icons.tagsIcon "mr-2 ml-2"
, text texts.tagsAndFields
]
, div [ class "flex flex-row items-center flex-wrap font-medium my-1" ]

View File

@@ -18,6 +18,7 @@ import Comp.PeriodicQueryTaskManage
import Comp.ScanMailboxManage
import Comp.UiSettingsManage
import Data.Flags exposing (Flags)
import Data.Icons as Icons
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
@@ -78,7 +79,7 @@ viewSidebar texts visible _ _ model =
, menuEntryActive model NotificationTab
, class S.sidebarLink
]
[ i [ class "fa fa-comment font-thin" ] []
[ Icons.notificationHooksIcon ""
, span
[ class "ml-3" ]
[ text texts.notifications ]
@@ -422,7 +423,7 @@ viewNotificationInfo texts settings model =
, onClick (SetTab NotificationQueriesTab)
, class S.link
]
[ i [ class "fa fa-history" ] []
[ Icons.periodicTasksIcon ""
, span
[ class "ml-3" ]
[ text texts.genericQueries ]