From 2d3d3708ec16174ddbf22271e19ea4adee5402cd Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Thu, 15 Oct 2020 21:04:28 +0200 Subject: [PATCH] BREAK: move color and icon for trend to template --- MMM-covid19.js | 12 ++++-------- MMM-covid19.njk | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/MMM-covid19.js b/MMM-covid19.js index b6ef413..3c18de4 100644 --- a/MMM-covid19.js +++ b/MMM-covid19.js @@ -82,19 +82,15 @@ Module.register("MMM-covid19", { // determine trend: // calc this and last weeks cases and substract // result is the difference of new cases between this and last week - // +10: red (arrow up) - // +0: orange (arrow up) - // 0: normal (arrow right) - // -0: green (arrow down) currentToLastWeekDiff = (data[this.config.region]["last_7"] * 2) - data[this.config.region]["last_14"] if (currentToLastWeekDiff > 10) { - this.cases.trend = ""; + this.cases.trend = "bad"; } else if (currentToLastWeekDiff > 0) { - this.cases.trend = ""; + this.cases.trend = "warn"; } else if (currentToLastWeekDiff == 0) { - this.cases.trend = "→"; + this.cases.trend = "even"; } else if (currentToLastWeekDiff < 0) { - this.cases.trend = ""; + this.cases.trend = "good"; } }, }); diff --git a/MMM-covid19.njk b/MMM-covid19.njk index 8decfaf..27fa6fd 100644 --- a/MMM-covid19.njk +++ b/MMM-covid19.njk @@ -1,5 +1,24 @@ + +{% if cases.trend == "even" %} + {% set trend_class = "none" %} + {% set trend = "→" %} +{% elif cases.trend == "good" %} + {% set trend_class = cases.trend %} + {% set trend = "↘" %} +{% elif cases.trend == "warn" %} + {% set trend_class = cases.trend %} + {% set trend = "↗" %} +{% elif cases.trend == "bad" %} + {% set trend_class = cases.trend %} + {% set trend = "↗" %} +{% endif %} +
- Neu: {{ cases.new7 }} ({{ cases.new7_100k }}) {{ cases.trend | safe }}
+ + Neu: {{ cases.new7 }} + ({{ cases.new7_100k }}) + {{ trend | safe }} +
Aktiv: {{ cases.active }}
Gesamt: {{ cases.total }}
Tote: {{ cases.death }}