From 0c6623bf06d2ebbf7353592fd11e6399db2de7a5 Mon Sep 17 00:00:00 2001 From: Henk Date: Mon, 26 Aug 2024 14:40:44 -0700 Subject: [PATCH] Dashboard layout improvements. --- bindings/hiveoview/src/views/base.gohtml | 7 - .../dashboard/RenderDashboardPage.gohtml | 64 +++++++-- .../directory/RenderConfirmDeleteTD.gohtml | 27 ++-- .../views/history/RenderHistoryPage.gohtml | 97 ++++++------- .../hiveoview/src/views/login/login.gohtml | 2 +- .../views/thing/RenderActionRequest.gohtml | 83 ++++++----- .../src/views/thing/RenderEditProperty.gohtml | 66 +++++---- .../src/views/thing/RenderThingDetails.go | 5 +- .../src/views/thing/RenderThingDetails.gohtml | 6 +- .../src/views/thing/eventList.gohtml | 3 +- .../src/views/tile/RenderEditTile.gohtml | 47 +++--- .../src/views/tile/RenderTile.gohtml | 41 ++---- .../src/views/tile/widgets/TextCard.gohtml | 28 ++-- bindings/hiveoview/src/webcomp/h-classes.css | 70 ++++----- bindings/hiveoview/src/webcomp/h-modal.js | 90 +++++++----- bindings/hiveoview/src/webcomp/h-theme.css | 134 +++++++++++++++++- bindings/hiveoview/src/webcomp/h-timechart.js | 15 +- bindings/hiveoview/src/webcomp/h-toast.js | 2 +- bindings/hiveoview/test/components.html | 4 +- bindings/hiveoview/test/test-dialog1.html.sav | 2 +- 20 files changed, 479 insertions(+), 314 deletions(-) diff --git a/bindings/hiveoview/src/views/base.gohtml b/bindings/hiveoview/src/views/base.gohtml index 7689abfc..57b1af5b 100644 --- a/bindings/hiveoview/src/views/base.gohtml +++ b/bindings/hiveoview/src/views/base.gohtml @@ -87,11 +87,4 @@ height: 100%; } - /*!* show a pointer for checkboxes and their labels*/ - /*credits: https://stackoverflow.com/questions/41614446/change-pointer-for-checkbox-html*/ - /**!*/ - /*input[type="checkbox"], input[type="checkbox"] + label {*/ - /* cursor: pointer;*/ - /*}*/ - \ No newline at end of file diff --git a/bindings/hiveoview/src/views/dashboard/RenderDashboardPage.gohtml b/bindings/hiveoview/src/views/dashboard/RenderDashboardPage.gohtml index 8eb3acb8..46ddc560 100644 --- a/bindings/hiveoview/src/views/dashboard/RenderDashboardPage.gohtml +++ b/bindings/hiveoview/src/views/dashboard/RenderDashboardPage.gohtml @@ -14,7 +14,7 @@ {{/*Show the dashboard. Reload when tiles are deleted*/}} -
{{range $k,$v := .Dashboard.Tiles }} -
{{template "RenderTile.gohtml" $.GetTileTemplateData $k}} @@ -67,6 +68,11 @@ // debugger; var options = { // put in gridstack options here animate:true, + draggable: { + // handle: ".drag-target", + cancel: ".no-drag" + }, + nomove:true, float: true, // allow cells to move anywhere cellHeight: 30, // fix the row height to avoid scaling content staticGrid:false, // allow resize in edit mode @@ -102,15 +108,17 @@ {{end}} diff --git a/bindings/hiveoview/src/views/directory/RenderConfirmDeleteTD.gohtml b/bindings/hiveoview/src/views/directory/RenderConfirmDeleteTD.gohtml index eb7d088a..88b186c1 100644 --- a/bindings/hiveoview/src/views/directory/RenderConfirmDeleteTD.gohtml +++ b/bindings/hiveoview/src/views/directory/RenderConfirmDeleteTD.gohtml @@ -20,22 +20,23 @@ + +
+ {{- /*close-modal is handled by h-modal component*/ -}} + + +
-
- {{- /*close-modal is handled by h-modal component*/ -}} - - -
diff --git a/bindings/hiveoview/src/views/history/RenderHistoryPage.gohtml b/bindings/hiveoview/src/views/history/RenderHistoryPage.gohtml index 4c5aeae1..95a4029c 100644 --- a/bindings/hiveoview/src/views/history/RenderHistoryPage.gohtml +++ b/bindings/hiveoview/src/views/history/RenderHistoryPage.gohtml @@ -14,66 +14,63 @@ {{else}} -
-
- {{/* History header section with Thing title, date and nr of history values in the last 24 hours*/}} - + + + - {{/* Show a chart besides the table */}} -
- {{template "historyTable.gohtml" .}} -
- {{template "historyChart.gohtml" .}} -
+ {{/* Show a chart besides the table */}} +
+ {{template "historyTable.gohtml" .}} +
+ {{template "historyChart.gohtml" .}}
-
-
+
+ {{end}} diff --git a/bindings/hiveoview/src/views/login/login.gohtml b/bindings/hiveoview/src/views/login/login.gohtml index e32ce73e..2ca0bc22 100644 --- a/bindings/hiveoview/src/views/login/login.gohtml +++ b/bindings/hiveoview/src/views/login/login.gohtml @@ -50,7 +50,7 @@ border: solid; border-width: 1px; border-color: var(--pico-dropdown-border-color); - border-radius: 10px; + border-radius: var(--pico-card-border-radius); } diff --git a/bindings/hiveoview/src/views/thing/RenderActionRequest.gohtml b/bindings/hiveoview/src/views/thing/RenderActionRequest.gohtml index 59ee7b66..011ac15d 100644 --- a/bindings/hiveoview/src/views/thing/RenderActionRequest.gohtml +++ b/bindings/hiveoview/src/views/thing/RenderActionRequest.gohtml @@ -8,61 +8,70 @@ {{- /*gotype:github.com/hiveot/hub/bindings/hiveoview/src/views/thing.ActionRequestTemplateData*/ -}} -
+

{{.Action.Title}}

- - +
+
+ + {{/* textarea doesnt resize so do this instead*/}} +
{{.Action.Description}}
- {{if .PrevValue}} - - - {{if .Input }} - - - {{end}} - {{end}} + {{if .PrevValue}} + + + {{if .Input }} + + + {{end}} + {{end}} + + {{if .Input}} + + {{template "schemaValue.gohtml" .Input}} + {{end}} +
-
- {{if .Input}} - - {{template "schemaValue.gohtml" .Input}} + {{if .Status.Progress}} +
status {{.Status.Progress}}
{{end}} -
+
- {{if .Status.Progress}} -
status {{.Status.Progress}}
- {{end}} +
+ {{- /*close-modal is handled by h-modal component*/ -}} + + +
- -
- {{- /*close-modal is handled by h-modal component*/ -}} - - -
\ No newline at end of file diff --git a/bindings/hiveoview/src/views/thing/RenderEditProperty.gohtml b/bindings/hiveoview/src/views/thing/RenderEditProperty.gohtml index 9cbe0bd2..d31e9b51 100644 --- a/bindings/hiveoview/src/views/thing/RenderEditProperty.gohtml +++ b/bindings/hiveoview/src/views/thing/RenderEditProperty.gohtml @@ -2,42 +2,46 @@ {{- /*gotype:github.com/hiveot/hub/bindings/hiveoview/src/views/thing.RenderEditPropertyTemplateData*/ -}} - +
-

Edit Configuration

+

Edit Configuration

-
-
-
- - + + + + {{/* textarea doesnt resize so do this instead*/}} +
{{.DataSchema.Description}}
+ + + + {{template "schemaValue.gohtml" .}} + + + +
+ {{- /*close-modal is handled by h-modal component*/ -}} + + +
- - - {{template "schemaValue.gohtml" .}} - -
- -
-
- {{- /*close-modal is handled by h-modal component*/ -}} - - -
-
\ No newline at end of file diff --git a/bindings/hiveoview/src/views/thing/RenderThingDetails.go b/bindings/hiveoview/src/views/thing/RenderThingDetails.go index a7169293..fc6709e8 100644 --- a/bindings/hiveoview/src/views/thing/RenderThingDetails.go +++ b/bindings/hiveoview/src/views/thing/RenderThingDetails.go @@ -21,7 +21,8 @@ import ( const TemplateFile = "RenderThingDetails.gohtml" const RenderActionRequestPath = "/action/{thingID}/{key}/request" const RenderEditPropertyPath = "/property/{thingID}/{key}/edit" -const RenderConfirmDeleteTDPath = "/directory/{thingID}/confirmDelete" +const RenderConfirmDeleteTDPath = "/directory/{thingID}/confirmDeleteTD" +const RenderRawTDPath = "/thing/{thingID}/raw" type ThingDetailsTemplateData struct { Title string @@ -43,6 +44,7 @@ type ThingDetailsTemplateData struct { // URLs RenderConfirmDeleteTDPath string + RenderRawTDPath string } // GetHistory returns the 24 hour history for the given key @@ -82,6 +84,7 @@ func RenderThingDetails(w http.ResponseWriter, r *http.Request) { ThingID: thingID, Title: "details of thing", RenderConfirmDeleteTDPath: utils.Substitute(RenderConfirmDeleteTDPath, pathParams), + RenderRawTDPath: utils.Substitute(RenderRawTDPath, pathParams), } // Read the TD being displayed and its latest values diff --git a/bindings/hiveoview/src/views/thing/RenderThingDetails.gohtml b/bindings/hiveoview/src/views/thing/RenderThingDetails.gohtml index 95315b09..cf8b72dc 100644 --- a/bindings/hiveoview/src/views/thing/RenderThingDetails.gohtml +++ b/bindings/hiveoview/src/views/thing/RenderThingDetails.gohtml @@ -19,7 +19,7 @@ hx-get="" hx-swap="innerHTML" hx-target="#detailsPage" - class="h-panel container-fluid"> + > @@ -59,8 +59,8 @@ value="{{.ThingID}}"/> - diff --git a/bindings/hiveoview/src/views/thing/eventList.gohtml b/bindings/hiveoview/src/views/thing/eventList.gohtml index c4ba2423..0a43c28e 100644 --- a/bindings/hiveoview/src/views/thing/eventList.gohtml +++ b/bindings/hiveoview/src/views/thing/eventList.gohtml @@ -49,6 +49,8 @@ {{end}}
+ + {{/*Description*/}}
{{$v.Description}}
{{/* Updated*/}} @@ -62,7 +64,6 @@ {{/* history*/}}
{{template "historyChart.gohtml" $.GetHistory $k }} - hist
{{end}} diff --git a/bindings/hiveoview/src/views/tile/RenderEditTile.gohtml b/bindings/hiveoview/src/views/tile/RenderEditTile.gohtml index 5b451006..7e6f4d76 100644 --- a/bindings/hiveoview/src/views/tile/RenderEditTile.gohtml +++ b/bindings/hiveoview/src/views/tile/RenderEditTile.gohtml @@ -2,11 +2,10 @@ {{- /*gotype:github.com/hiveot/hub/bindings/hiveoview/src/views/tile.EditTileTemplateData*/ -}} - -
+ +
-

Edit Tile

+

Edit Tile

@@ -29,7 +28,7 @@ Current value: {{.GetTypeLabel .Tile.TileType}} -
-
-
- {{- /*close-modal is handled by h-modal component*/ -}} - - -
+
+ {{- /*close-modal is handled by h-modal component*/ -}} + + +
+
diff --git a/bindings/hiveoview/src/views/tile/RenderTile.gohtml b/bindings/hiveoview/src/views/tile/RenderTile.gohtml index df81c095..6a176cec 100644 --- a/bindings/hiveoview/src/views/tile/RenderTile.gohtml +++ b/bindings/hiveoview/src/views/tile/RenderTile.gohtml @@ -1,32 +1,36 @@ {{- /*gotype:github.com/hiveot/hub/bindings/hiveoview/src/views/tile.RenderTileTemplateData*/ -}} +{{/*Tile CSS is defined in RenderDashboardPage.gohtml*/}} + {{if not .Tile.ID}} {{/* hx-params="none" hides hx-vals defined in parent*/}}
+ hx-get="{{.ReRenderTilePath}}" +>

reloading tile fragment...

{{else}} -
- -
+
{{.Tile.Title}}
{{template "tileMenu.gohtml" .}}
-
+
{{if eq .Tile.TileType "lineChart"}} {{template "LineChart.gohtml" .}} @@ -42,30 +46,7 @@ {{template "TextCard.gohtml" .}} {{end}} -
-
- - {{end}} \ No newline at end of file diff --git a/bindings/hiveoview/src/views/tile/widgets/TextCard.gohtml b/bindings/hiveoview/src/views/tile/widgets/TextCard.gohtml index 59e52e19..a5b0c1fb 100644 --- a/bindings/hiveoview/src/views/tile/widgets/TextCard.gohtml +++ b/bindings/hiveoview/src/views/tile/widgets/TextCard.gohtml @@ -3,24 +3,32 @@ {{- /*gotype:github.com/hiveot/hub/bindings/hiveoview/src/views/tile.RenderTileTemplateData*/ -}} {{if eq (len .Tile.Sources) 1 }} + {{/* A single source is displayed as large text*/}} {{$s := (index $.Tile.Sources 0)}} -
+
{{$.GetValue $s.ThingID $s.Key}}
+ {{else}} + {{/* A list of sources is displayed as a table*/}}
+ style="width:100%; height:100%; overflow:auto; margin:0"> + + style="grid-template-columns:1fr max-content"> {{range .Tile.Sources}} - - + + {{end}} @@ -28,9 +36,3 @@ {{end}} - \ No newline at end of file diff --git a/bindings/hiveoview/src/webcomp/h-classes.css b/bindings/hiveoview/src/webcomp/h-classes.css index ff69c234..19806d01 100644 --- a/bindings/hiveoview/src/webcomp/h-classes.css +++ b/bindings/hiveoview/src/webcomp/h-classes.css @@ -32,33 +32,9 @@ background: linear-gradient(to right, var(--pico-background-color), var(--pico-color), var(--pico-background-color)); } -/* apply to a table to show using CSS grid - */ -/*.h-grid-table {*/ -/* display: grid;*/ -/* border-collapse: collapse;*/ -/* min-width: 100%;*/ -/* border: 1px solid gray;*/ - -/* td {*/ -/* overflow: hidden;*/ -/* text-overflow: ellipsis;*/ -/* }*/ - -/* thead, tbody, tr {*/ -/* display: contents;*/ -/* }*/ - -/* !*show an ellipsis in a span element that is using a flexbox parent*!*/ - -/* span {*/ -/* display: block;*/ -/* overflow: hidden;*/ -/* white-space: nowrap;*/ -/* text-overflow: ellipsis*/ -/* }*/ -/*}*/ - +/* h-grid-table is a simple table using grid layout and ul/li list items + * the first row is the table header. +*/ .h-grid-table { display: grid; padding: 0; @@ -75,22 +51,28 @@ .h-grid-table li div { font-weight: var(--pico-font-weight); - background-color: var(--pico-card-sectioning-background-color); + background-color: var(--pico-card-background-color); padding: calc(var(--pico-spacing) / 2) var(--pico-spacing); } +.h-grid-table[striped] li:nth-child(even) div { + background-color: var(--pico-form-element-active-background-color); +} +/* table header override*/ .h-grid-table li:first-child div { font-variant-caps: small-caps; - background-color: var(--pico-form-element-background-color); --pico-font-weight: 600; - /*border-bottom: 1px solid var(--pico-form-element-border-color);*/ border-bottom: 1px solid var(--pico-form-element-active-border-color); } -.h-grid-table[striped] li:nth-child(odd) div { - background-color: var(--pico-background-color); +/* h-grid-table as a table instead of list. Use thead for th title*/ +.h-grid-table td { + background-color: var(--pico-backround-color); + border-bottom: 1px solid var(--pico-form-element-border-color); +} +.h-grid-table[striped] td:nth-child(even) div { + background-color: var(--pico-table-row-stripped-background-color); } - .h-grow { flex-grow: 1; @@ -147,11 +129,11 @@ /* panel with background color and flex col*/ .h-panel { - background-color: var(--pico-background-color); - display: flex; - flex-direction: column; - border: 1px solid var(--pico-border-color); - padding: var(--pico-block-spacing-horizontal) var(--pico-block-spacing-vertical); + /*background-color: var(--pico-background-color);*/ + /*display: flex;*/ + /*flex-direction: column;*/ + /*border: 1px solid var(--pico-border-color);*/ + /*padding: var(--pico-block-spacing-horizontal) var(--pico-block-spacing-vertical);*/ } /* flexbox row with items centered */ @@ -210,17 +192,22 @@ ul li:hover{ background-color: var(--pico-dropdown-hover-background-color); } +/* modal with mask settings */ h-modal { /*The opacity of the modal mask*/ - --mask-opacity: 70%; + --mask-opacity: 80%; /*The background color of the modal mask*/ - --mask-background: #dfe5e7; + --mask-background: var(--pico-background-color); /* the animation timing of opening and closing the modal */ --animation-duration: 500ms; } +/* the top level article (panel) inside a model has no bottom margin */ +h-modal > article { + margin:0; +} /* Horizontal navigation bar - * navbar highlights the tab with the href matching the url. + * h-navbar highlights the tab with the href matching the url. * this requires that */ .h-navbar { @@ -250,7 +237,6 @@ h-modal { text-transform: uppercase; transition: border .3s ease-in-out; - /*border-bottom: 2px solid var(--pico-form-element-border-color);*/ border-bottom: 2px solid var(--pico-form-element-border-color); } diff --git a/bindings/hiveoview/src/webcomp/h-modal.js b/bindings/hiveoview/src/webcomp/h-modal.js index 00aa0501..d62a9df4 100644 --- a/bindings/hiveoview/src/webcomp/h-modal.js +++ b/bindings/hiveoview/src/webcomp/h-modal.js @@ -28,34 +28,38 @@ const closeIconSvg = "M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" const template = document.createElement('template') template.innerHTML = ` -
{{.Title}}{{$.GetValue .ThingID .Key}} +
{{.Title}}
+
+
{{$.GetValue .ThingID .Key}}
+