From 12de7d4e444422930b6367c3e6a23da103d52276 Mon Sep 17 00:00:00 2001 From: Gerard Martin <344915+gerjomarty@users.noreply.github.com> Date: Tue, 16 Jun 2020 22:30:53 +0100 Subject: [PATCH] Added hideOnNoWarnings config option When set to true, it will hide the module from view unless there are active warnings to show. Defaults to false. --- MMM-UKMOWeatherWarnings.js | 1 + MMM-UKMOWeatherWarnings.njk | 2 +- README.md | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/MMM-UKMOWeatherWarnings.js b/MMM-UKMOWeatherWarnings.js index a2afdfa..2f82f05 100644 --- a/MMM-UKMOWeatherWarnings.js +++ b/MMM-UKMOWeatherWarnings.js @@ -24,6 +24,7 @@ Module.register("MMM-UKMOWeatherWarnings", { useTestData: false, testUrl: null, backgroundMode: false, + hideOnNoWarnings: false, delta: 0, //minutes }, diff --git a/MMM-UKMOWeatherWarnings.njk b/MMM-UKMOWeatherWarnings.njk index 5d628f7..51b569a 100644 --- a/MMM-UKMOWeatherWarnings.njk +++ b/MMM-UKMOWeatherWarnings.njk @@ -1,5 +1,5 @@ {% if warnings %} - {% if not config.backgroundMode %} + {% if not config.backgroundMode and (not config.hideOnNoWarnings or warnings.items) %}
{{warnings.title}}
{% if warnings.items %} diff --git a/README.md b/README.md index 9cb8db4..ef6b76c 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ var config = { | `useTestData` | *Optional* Whether to use test data instaed of the live feed

**Type:** `boolean`
Default `false` | `testUrl` | *Optional* URL of the test data file

**Type:** `string`
e.g. `http://localhost:8080/modules/MMM-UKMOWeatherWarnings/public/warns.json` | `backgroundMode` | *Optional* Whether to run in background mode, only sending notifications

**Type:** `boolean`
Default `false` +| `hideOnNoWarnings` | *Optional* Whether to hide the module if there are no warnings found

**Type:** `boolean`
Default `false` | `delta` | *Optional* Look ahead delta for current warnings

**Type:** `int`(minutes)
0 #### Regions