mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Use es6 notation in updatenotification module
This commit is contained in:
parent
de93b3294f
commit
2dea9398f2
@ -18,19 +18,18 @@ Module.register("updatenotification", {
|
|||||||
|
|
||||||
// Override start method.
|
// Override start method.
|
||||||
start: function () {
|
start: function () {
|
||||||
var self = this;
|
|
||||||
Log.info("Starting module: " + this.name);
|
Log.info("Starting module: " + this.name);
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
self.moduleList = {};
|
this.moduleList = {};
|
||||||
self.updateDom(2);
|
this.updateDom(2);
|
||||||
}, self.config.refreshInterval);
|
}, this.config.refreshInterval);
|
||||||
},
|
},
|
||||||
|
|
||||||
notificationReceived: function (notification, payload, sender) {
|
notificationReceived: function (notification, payload, sender) {
|
||||||
if (notification === "DOM_OBJECTS_CREATED") {
|
if (notification === "DOM_OBJECTS_CREATED") {
|
||||||
this.sendSocketNotification("CONFIG", this.config);
|
this.sendSocketNotification("CONFIG", this.config);
|
||||||
this.sendSocketNotification("MODULES", Module.definitions);
|
this.sendSocketNotification("MODULES", Module.definitions);
|
||||||
//this.hide(0, { lockString: self.identifier });
|
//this.hide(0, { lockString: this.identifier });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -42,13 +41,12 @@ Module.register("updatenotification", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
updateUI: function (payload) {
|
updateUI: function (payload) {
|
||||||
var self = this;
|
|
||||||
if (payload && payload.behind > 0) {
|
if (payload && payload.behind > 0) {
|
||||||
// if we haven't seen info for this module
|
// if we haven't seen info for this module
|
||||||
if (this.moduleList[payload.module] === undefined) {
|
if (this.moduleList[payload.module] === undefined) {
|
||||||
// save it
|
// save it
|
||||||
this.moduleList[payload.module] = payload;
|
this.moduleList[payload.module] = payload;
|
||||||
self.updateDom(2);
|
this.updateDom(2);
|
||||||
}
|
}
|
||||||
//self.show(1000, { lockString: self.identifier });
|
//self.show(1000, { lockString: self.identifier });
|
||||||
} else if (payload && payload.behind === 0) {
|
} else if (payload && payload.behind === 0) {
|
||||||
@ -56,41 +54,41 @@ Module.register("updatenotification", {
|
|||||||
if (this.moduleList[payload.module] !== undefined) {
|
if (this.moduleList[payload.module] !== undefined) {
|
||||||
// remove it
|
// remove it
|
||||||
delete this.moduleList[payload.module];
|
delete this.moduleList[payload.module];
|
||||||
self.updateDom(2);
|
this.updateDom(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
diffLink: function (module, text) {
|
diffLink: function (module, text) {
|
||||||
var localRef = module.hash;
|
const localRef = module.hash;
|
||||||
var remoteRef = module.tracking.replace(/.*\//, "");
|
const remoteRef = module.tracking.replace(/.*\//, "");
|
||||||
return '<a href="https://github.com/MichMich/MagicMirror/compare/' + localRef + "..." + remoteRef + '" ' + 'class="xsmall dimmed" ' + 'style="text-decoration: none;" ' + 'target="_blank" >' + text + "</a>";
|
return '<a href="https://github.com/MichMich/MagicMirror/compare/' + localRef + "..." + remoteRef + '" ' + 'class="xsmall dimmed" ' + 'style="text-decoration: none;" ' + 'target="_blank" >' + text + "</a>";
|
||||||
},
|
},
|
||||||
|
|
||||||
// Override dom generator.
|
// Override dom generator.
|
||||||
getDom: function () {
|
getDom: function () {
|
||||||
var wrapper = document.createElement("div");
|
const wrapper = document.createElement("div");
|
||||||
if (this.suspended === false) {
|
if (this.suspended === false) {
|
||||||
// process the hash of module info found
|
// process the hash of module info found
|
||||||
for (var key of Object.keys(this.moduleList)) {
|
for (const key of Object.keys(this.moduleList)) {
|
||||||
let m = this.moduleList[key];
|
let m = this.moduleList[key];
|
||||||
|
|
||||||
var message = document.createElement("div");
|
const message = document.createElement("div");
|
||||||
message.className = "small bright";
|
message.className = "small bright";
|
||||||
|
|
||||||
var icon = document.createElement("i");
|
const icon = document.createElement("i");
|
||||||
icon.className = "fa fa-exclamation-circle";
|
icon.className = "fa fa-exclamation-circle";
|
||||||
icon.innerHTML = " ";
|
icon.innerHTML = " ";
|
||||||
message.appendChild(icon);
|
message.appendChild(icon);
|
||||||
|
|
||||||
var updateInfoKeyName = m.behind === 1 ? "UPDATE_INFO_SINGLE" : "UPDATE_INFO_MULTIPLE";
|
const updateInfoKeyName = m.behind === 1 ? "UPDATE_INFO_SINGLE" : "UPDATE_INFO_MULTIPLE";
|
||||||
|
|
||||||
var subtextHtml = this.translate(updateInfoKeyName, {
|
let subtextHtml = this.translate(updateInfoKeyName, {
|
||||||
COMMIT_COUNT: m.behind,
|
COMMIT_COUNT: m.behind,
|
||||||
BRANCH_NAME: m.current
|
BRANCH_NAME: m.current
|
||||||
});
|
});
|
||||||
|
|
||||||
var text = document.createElement("span");
|
const text = document.createElement("span");
|
||||||
if (m.module === "default") {
|
if (m.module === "default") {
|
||||||
text.innerHTML = this.translate("UPDATE_NOTIFICATION");
|
text.innerHTML = this.translate("UPDATE_NOTIFICATION");
|
||||||
subtextHtml = this.diffLink(m, subtextHtml);
|
subtextHtml = this.diffLink(m, subtextHtml);
|
||||||
@ -103,7 +101,7 @@ Module.register("updatenotification", {
|
|||||||
|
|
||||||
wrapper.appendChild(message);
|
wrapper.appendChild(message);
|
||||||
|
|
||||||
var subtext = document.createElement("div");
|
const subtext = document.createElement("div");
|
||||||
subtext.innerHTML = subtextHtml;
|
subtext.innerHTML = subtextHtml;
|
||||||
subtext.className = "xsmall dimmed";
|
subtext.className = "xsmall dimmed";
|
||||||
wrapper.appendChild(subtext);
|
wrapper.appendChild(subtext);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user