From 283d8c750e6d62ce3c5ea7fb7f56e9ec3a562ae9 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Wed, 15 Dec 2021 02:17:17 +0000 Subject: [PATCH] :sparkles: Builds CPU history widget --- docs/widgets.md | 43 +++++++- src/components/Widgets/NdCpuHistory.vue | 141 ++++++++++++++++++++++++ src/components/Widgets/WidgetBase.vue | 11 +- src/views/Home.vue | 1 + 4 files changed, 193 insertions(+), 3 deletions(-) create mode 100644 src/components/Widgets/NdCpuHistory.vue diff --git a/docs/widgets.md b/docs/widgets.md index d957a503..611bed60 100644 --- a/docs/widgets.md +++ b/docs/widgets.md @@ -16,7 +16,6 @@ Dashy has support for displaying dynamic content in the form of widgets. There a - [Stock Price History](#stock-price-history) - [Joke of the Day](#joke) - [Flight Data](#flight-data) - - [Example Widget](#example-widget) - [Self-Hosted Services Widgets](#dynamic-widgets) - [Dynamic Widgets](#dynamic-widgets) - [Iframe Widget](#iframe-widget) @@ -367,6 +366,30 @@ Displays airport departure and arrival flights, using data from [AeroDataBox](ht --- +## Self-Hosted Services Widgets + +### CPU History (NetData) + +Pull recent CPU usage history from NetData. + +

+ +##### Options + +**Field** | **Type** | **Required** | **Description** +--- | --- | --- | --- +**`host`** | `string` | Required | The URL to your NetData instance + +##### Example + +```yaml +- type: nd-cpu-history + options: + host: http://192.168.1.1:19999 +``` + +--- + ## Dynamic Widgets ### Iframe Widget @@ -397,7 +420,7 @@ Many websites and apps provide their own embeddable widgets. These can be used w ⚠️ **NOTE:** Use with extreme caution. Embedding a script from an untrustworthy source may have serious unintended consequences. -

+

##### Options @@ -410,6 +433,22 @@ Many websites and apps provide their own embeddable widgets. These can be used w ##### Example +```yaml +- type: embed + options: + scriptSrc: https://cdn.speedcheck.org/basic/scbjs.min.js + html: | +
+
+ + Speedcheck + +
+
+``` + +Or + ```yaml - type: embed options: diff --git a/src/components/Widgets/NdCpuHistory.vue b/src/components/Widgets/NdCpuHistory.vue new file mode 100644 index 00000000..9d967d3f --- /dev/null +++ b/src/components/Widgets/NdCpuHistory.vue @@ -0,0 +1,141 @@ + + + + + diff --git a/src/components/Widgets/WidgetBase.vue b/src/components/Widgets/WidgetBase.vue index abc81472..3034bcf8 100644 --- a/src/components/Widgets/WidgetBase.vue +++ b/src/components/Widgets/WidgetBase.vue @@ -102,6 +102,13 @@ @error="handleError" :ref="widgetRef" /> + -
{{ handleError('No widget type was specified') }}
+
{{ handleError('Widget type was not found') }}
@@ -143,6 +150,7 @@ import ExchangeRates from '@/components/Widgets/ExchangeRates.vue'; import StockPriceChart from '@/components/Widgets/StockPriceChart.vue'; import Jokes from '@/components/Widgets/Jokes.vue'; import Flights from '@/components/Widgets/Flights.vue'; +import NdCpuHistory from '@/components/Widgets/NdCpuHistory.vue'; import IframeWidget from '@/components/Widgets/IframeWidget.vue'; import EmbedWidget from '@/components/Widgets/EmbedWidget.vue'; @@ -165,6 +173,7 @@ export default { StockPriceChart, Jokes, Flights, + NdCpuHistory, IframeWidget, EmbedWidget, }, diff --git a/src/views/Home.vue b/src/views/Home.vue index b4a822ae..63ad1dd6 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -258,6 +258,7 @@ export default { else { let itemsFound = true; this.sections.forEach((section) => { + if (section.widgets && section.widgets.length > 0) itemsFound = false; if (this.filterTiles(section.items, this.searchValue).length > 0) itemsFound = false; }); return itemsFound;