BREAK: move color and icon for trend to template

This commit is contained in:
Sebastian Mark 2020-10-15 21:04:28 +02:00
parent b2b121c0b1
commit 2d3d3708ec
2 changed files with 24 additions and 9 deletions

View file

@ -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 = "<span class=bad>&nearr;</span>";
this.cases.trend = "bad";
} else if (currentToLastWeekDiff > 0) {
this.cases.trend = "<span class=warn>&nearr;</span>";
this.cases.trend = "warn";
} else if (currentToLastWeekDiff == 0) {
this.cases.trend = "&rarr;";
this.cases.trend = "even";
} else if (currentToLastWeekDiff < 0) {
this.cases.trend = "<span class=good>&searr;</span>";
this.cases.trend = "good";
}
},
});

View file

@ -1,5 +1,24 @@
<!-- color and arrow type of trends -->
{% if cases.trend == "even" %}
{% set trend_class = "none" %}
{% set trend = "&rarr;" %}
{% elif cases.trend == "good" %}
{% set trend_class = cases.trend %}
{% set trend = "&searr;" %}
{% elif cases.trend == "warn" %}
{% set trend_class = cases.trend %}
{% set trend = "&nearr;" %}
{% elif cases.trend == "bad" %}
{% set trend_class = cases.trend %}
{% set trend = "&nearr;" %}
{% endif %}
<div class="small covid19">
<span class="bright new7">Neu: {{ cases.new7 }} ({{ cases.new7_100k }}) {{ cases.trend | safe }}</span><br/>
<span class="bright new7">
Neu: {{ cases.new7 }}
({{ cases.new7_100k }})
<span class={{trend_class}}>{{ trend | safe }}</span>
</span><br/>
<span class="bright active">Aktiv: {{ cases.active }}</span><br/>
<span class="total">Gesamt: {{ cases.total }}</span><br/>
<span class="death">Tote: {{ cases.death }}</span><br/>