BREAK: move color and icon for trend to template
This commit is contained in:
parent
b2b121c0b1
commit
2d3d3708ec
2 changed files with 24 additions and 9 deletions
|
@ -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>↗</span>";
|
||||
this.cases.trend = "bad";
|
||||
} else if (currentToLastWeekDiff > 0) {
|
||||
this.cases.trend = "<span class=warn>↗</span>";
|
||||
this.cases.trend = "warn";
|
||||
} else if (currentToLastWeekDiff == 0) {
|
||||
this.cases.trend = "→";
|
||||
this.cases.trend = "even";
|
||||
} else if (currentToLastWeekDiff < 0) {
|
||||
this.cases.trend = "<span class=good>↘</span>";
|
||||
this.cases.trend = "good";
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,5 +1,24 @@
|
|||
<!-- color and arrow type of trends -->
|
||||
{% 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 %}
|
||||
|
||||
<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/>
|
||||
|
|
Loading…
Reference in a new issue