diff --git a/ui/charts.go b/ui/charts.go index 4305d6ef..4222bab2 100644 --- a/ui/charts.go +++ b/ui/charts.go @@ -123,16 +123,6 @@ func CreateItem() []Item { Content: "This is a card that displays dynamic entity count data", Widget: "entityCount", }, - { - Title: "Label Card", - Content: "This is a label card", - Widget: "label", - }, - { - Title: "Progress Bar", - Content: "This is a progress bar", - Widget: "progressBar", - }, } return items diff --git a/ui/web/static/js/charts.js b/ui/web/static/js/charts.js index 2b55ad99..379f79a7 100644 --- a/ui/web/static/js/charts.js +++ b/ui/web/static/js/charts.js @@ -604,7 +604,7 @@ class EntityCount extends Chart { super(widgetID, chartData); this.Style = { width: "400px", - height: "175px", + height: "220px", }; this.Content = this.#generateContent(); } @@ -617,16 +617,14 @@ class EntityCount extends Chart {
Entity Count
-

35

+

35

- `; + `; } } @@ -755,35 +753,6 @@ class HorizontalBarChart extends Echart { } } -class LabelCard extends Chart { - constructor(chartData, widgetID) { - super(widgetID, chartData); - this.Style = { - width: "420px", - height: "180px", - }; - this.Content = this.#generateContent(); - } - - #generateContent() { - return ` -
-
-
-
Label
-
-
-

Selected Entity: Thing6

-
- -
-
-`; - } -} - class TimeSeriesLineChart extends Echart { constructor(chartData, widgetID) { super(widgetID, chartData); @@ -1313,40 +1282,6 @@ class PieChart extends Echart { } } -class ProgressBar extends Chart { - constructor(chartData, widgetID) { - super(widgetID, chartData); - this.Style = { - width: "400px", - height: "100px", - }; - this.Content = this.#generateContent(); - } - - #generateContent() { - return ` -
-
-
-
${this.chartData.title}
-
-
-
-
-
-
- -
-
- `; - } -} - class SharedDatasetChart extends Echart { constructor(chartData, widgetID) { super(widgetID, chartData); @@ -1853,9 +1788,10 @@ class ValueCard extends Chart { super(widgetID, chartData); this.Style = { width: "400px", - height: "200px", + height: "220px", }; this.Content = this.#generateContent(); + this.Script = this.#generateScript(); } #generateContent() { @@ -1876,6 +1812,36 @@ class ValueCard extends Chart { `; } + + #generateScript() { + return ` + (function() { + var valueCard = document.getElementById("${this.ID}"); + + async function getData() { + try { + const response = await fetch( + "${pathPrefix}/data?channel=${this.chartData.channel}"+ + "&publisher=${this.chartData.thing}" + + "&name=${this.chartData.valueName}" + + "&limit=1", + ); + if (response.ok) { + const data = await response.json(); + valueCard.querySelector(".value").textContent = data.messages[0].value; + } else { + console.error("HTTP request failed with status: ", response.status); + } + } catch (error) { + console.error("Failed to fetch card data: ", error); + } + } + + getData(); + setInterval(getData, "${this.chartData.updateInterval}"); + })(); + `; + } } const chartTypes = { @@ -1890,13 +1856,11 @@ const chartTypes = { entityCount: EntityCount, gaugeChart: GaugeChart, horizontalBarChart: HorizontalBarChart, - labelCard: LabelCard, lineChart: TimeSeriesLineChart, multiBarChart: MultiBarChart, multiGaugeChart: MultiGaugeChart, multipleLineChart: MultipleLineChart, pieChart: PieChart, - progressBar: ProgressBar, sharedDatasetChart: SharedDatasetChart, speedGaugeChart: SpeedGaugeChart, stackedLineChart: StackedLineChart, diff --git a/ui/web/templates/charts/labelmodal.html b/ui/web/templates/charts/labelmodal.html deleted file mode 100644 index 7d36064a..00000000 --- a/ui/web/templates/charts/labelmodal.html +++ /dev/null @@ -1,104 +0,0 @@ - - -{{ define "labelmodal" }} - - - -{{ end }} diff --git a/ui/web/templates/charts/progressbarmodal.html b/ui/web/templates/charts/progressbarmodal.html deleted file mode 100644 index ada7e2b4..00000000 --- a/ui/web/templates/charts/progressbarmodal.html +++ /dev/null @@ -1,206 +0,0 @@ - - -{{ define "progressbarmodal" }} - - - -{{ end }} diff --git a/ui/web/templates/charts/valuecardmodal.html b/ui/web/templates/charts/valuecardmodal.html index 762de3c1..12a66a8c 100644 --- a/ui/web/templates/charts/valuecardmodal.html +++ b/ui/web/templates/charts/valuecardmodal.html @@ -104,11 +104,11 @@
Please enter a valid interval
diff --git a/ui/web/templates/dashboard.html b/ui/web/templates/dashboard.html index 0a80b908..8bdd7fa3 100644 --- a/ui/web/templates/dashboard.html +++ b/ui/web/templates/dashboard.html @@ -117,8 +117,6 @@
Widgets
{{ template "alarmstablemodal" . }} {{ template "entitiestablemodal" . }} {{ template "entitycountmodal" . }} - {{ template "progressbarmodal" . }} - {{ template "labelmodal" . }}