2020-07-26 08:50:34 +00:00
|
|
|
/* Magic Mirror
|
|
|
|
* Module: MMM-covid19
|
|
|
|
*
|
|
|
|
* Author: Sebastian Mark
|
|
|
|
* CC-BY-SA (https://creativecommons.org/licenses/by-sa/4.0/deed.de)
|
|
|
|
* for civil use only
|
|
|
|
*/
|
|
|
|
|
2021-07-02 06:30:19 +00:00
|
|
|
Module.register("MMM-MyCovid19", {
|
2020-07-26 08:50:34 +00:00
|
|
|
defaults: {
|
|
|
|
region: "Bonn",
|
2021-09-01 17:33:04 +00:00
|
|
|
updateInterval: 3 * 60 * 60 * 1000, // 3h
|
2020-07-26 08:50:34 +00:00
|
|
|
fadeSpeed: 0,
|
|
|
|
showHeader: true,
|
|
|
|
appendLocationNameToHeader: true,
|
|
|
|
},
|
|
|
|
cases: {
|
|
|
|
new7: "N/A",
|
2020-09-27 17:52:25 +00:00
|
|
|
new7_100k: "N/A",
|
2020-07-26 08:50:34 +00:00
|
|
|
active: "N/A",
|
|
|
|
total: "N/A",
|
|
|
|
death: "N/A",
|
|
|
|
cured: "N/A",
|
|
|
|
ts: "N/A",
|
|
|
|
},
|
|
|
|
|
|
|
|
start: function() {
|
|
|
|
// init module and set update intervall
|
2021-09-01 17:33:04 +00:00
|
|
|
var self = this
|
|
|
|
Log.log(self.name + ' is started!');
|
|
|
|
self.sendSocketNotification("{{MODULE_NAME}}-get_cases", self.config.region);
|
2020-07-26 08:50:34 +00:00
|
|
|
setInterval(function() {
|
2021-09-01 17:33:04 +00:00
|
|
|
self.sendSocketNotification("{{MODULE_NAME}}-get_cases", self.config.region);
|
|
|
|
self.updateDom(self.config.fadeSpeed);
|
|
|
|
}, self.config.updateInterval);
|
2020-07-26 08:50:34 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
getHeader: function() {
|
|
|
|
// set module header
|
|
|
|
if (this.config.showHeader) {
|
|
|
|
this.data.header = "COVID-19 Daten";
|
|
|
|
if (this.config.appendLocationNameToHeader) {
|
|
|
|
this.data.header += " für " + this.config.region;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return this.data.header;
|
|
|
|
},
|
|
|
|
|
2020-07-26 16:40:10 +00:00
|
|
|
getStyles: function () {
|
|
|
|
// load custom css for module
|
2021-07-02 06:30:19 +00:00
|
|
|
return ["MMM-MyCovid19.css"];
|
2020-07-26 16:40:10 +00:00
|
|
|
},
|
2020-07-26 08:50:34 +00:00
|
|
|
|
2020-07-26 16:40:10 +00:00
|
|
|
getTemplate: function () {
|
|
|
|
// load template for layout
|
2021-07-02 06:30:19 +00:00
|
|
|
return 'MMM-MyCovid19.njk';
|
2020-07-26 16:40:10 +00:00
|
|
|
},
|
2020-07-26 08:50:34 +00:00
|
|
|
|
2020-07-26 16:40:10 +00:00
|
|
|
getTemplateData: function () {
|
|
|
|
// pass variables to template
|
|
|
|
return { cases: this.cases }
|
2020-07-26 08:50:34 +00:00
|
|
|
},
|
|
|
|
|
2021-09-01 17:33:04 +00:00
|
|
|
socketNotificationReceived: function(notification, payload) {
|
|
|
|
// receive cases from node_helper
|
|
|
|
this.cases = payload;
|
|
|
|
this.updateDom(this.config.fadeSpeed);
|
2020-07-26 08:50:34 +00:00
|
|
|
},
|
|
|
|
});
|