Run prettier over ALL files once

No other changes done in this commit
This commit is contained in:
Veeck
2020-05-11 22:22:32 +02:00
parent 3a5a29efc0
commit abb5dc5739
160 changed files with 2369 additions and 2210 deletions

View File

@@ -1,4 +1,5 @@
# Module: Update Notification
The `updatenotification` module is one of the default modules of the MagicMirror.
This will display a message whenever a new version of the MagicMirror application is available.

View File

@@ -6,21 +6,18 @@ var defaultModules = require(__dirname + "/../defaultmodules.js");
var NodeHelper = require("node_helper");
module.exports = NodeHelper.create({
config: {},
updateTimer: null,
updateProcessStarted: false,
start: function () {
},
configureModules: function(modules) {
start: function () {},
configureModules: function (modules) {
// Push MagicMirror itself , biggest chance it'll show up last in UI and isn't overwritten
// others will be added in front
// this method returns promises so we can't wait for every one to resolve before continuing
simpleGits.push({"module": "default", "git": SimpleGit(path.normalize(__dirname + "/../../../"))});
simpleGits.push({ module: "default", git: SimpleGit(path.normalize(__dirname + "/../../../")) });
var promises = [];
@@ -33,7 +30,7 @@ module.exports = NodeHelper.create({
//console.log("checking git for module="+moduleName)
let stat = fs.statSync(path.join(moduleFolder, ".git"));
promises.push(this.resolveRemote(moduleName, moduleFolder));
} catch(err) {
} catch (err) {
// Error when directory .git doesn't exist
// This module is not managed with git, skip
continue;
@@ -47,7 +44,7 @@ module.exports = NodeHelper.create({
socketNotificationReceived: function (notification, payload) {
if (notification === "CONFIG") {
this.config = payload;
} else if(notification === "MODULES") {
} else if (notification === "MODULES") {
// if this is the 1st time thru the update check process
if (!this.updateProcessStarted) {
this.updateProcessStarted = true;
@@ -56,7 +53,7 @@ module.exports = NodeHelper.create({
}
},
resolveRemote: function(moduleName, moduleFolder) {
resolveRemote: function (moduleName, moduleFolder) {
return new Promise((resolve, reject) => {
var git = SimpleGit(moduleFolder);
git.getRemotes(true, (err, remotes) => {
@@ -65,19 +62,19 @@ module.exports = NodeHelper.create({
return resolve();
}
// Folder has .git and has at least one git remote, watch this folder
simpleGits.unshift({"module": moduleName, "git": git});
simpleGits.unshift({ module: moduleName, git: git });
resolve();
});
});
},
performFetch: function() {
performFetch: function () {
var self = this;
simpleGits.forEach((sg) => {
sg.git.fetch().status((err, data) => {
data.module = sg.module;
if (!err) {
sg.git.log({"-1": null}, (err, data2) => {
sg.git.log({ "-1": null }, (err, data2) => {
if (!err && data2.latest && "hash" in data2.latest) {
data.hash = data2.latest.hash;
self.sendSocketNotification("STATUS", data);
@@ -90,19 +87,19 @@ module.exports = NodeHelper.create({
this.scheduleNextFetch(this.config.updateInterval);
},
scheduleNextFetch: function(delay) {
scheduleNextFetch: function (delay) {
if (delay < 60 * 1000) {
delay = 60 * 1000;
}
var self = this;
clearTimeout(this.updateTimer);
this.updateTimer = setTimeout(function() {
this.updateTimer = setTimeout(function () {
self.performFetch();
}, delay);
},
ignoreUpdateChecking: function(moduleName) {
ignoreUpdateChecking: function (moduleName) {
// Should not check for updates for default modules
if (defaultModules.indexOf(moduleName) >= 0) {
return true;
@@ -116,5 +113,4 @@ module.exports = NodeHelper.create({
// The rest of the modules that passes should check for updates
return false;
}
});

View File

@@ -5,7 +5,6 @@
* MIT Licensed.
*/
Module.register("updatenotification", {
defaults: {
updateInterval: 10 * 60 * 1000, // every 10 minutes
refreshInterval: 24 * 60 * 60 * 1000, // one day
@@ -18,7 +17,10 @@ Module.register("updatenotification", {
start: function () {
var self = this;
Log.log("Start updatenotification");
setInterval( () => { self.moduleList = {};self.updateDom(2); } , self.config.refreshInterval);
setInterval(() => {
self.moduleList = {};
self.updateDom(2);
}, self.config.refreshInterval);
},
notificationReceived: function (notification, payload, sender) {
@@ -39,16 +41,15 @@ Module.register("updatenotification", {
var self = this;
if (payload && payload.behind > 0) {
// if we haven't seen info for this module
if(this.moduleList[payload.module] === undefined){
if (this.moduleList[payload.module] === undefined) {
// save it
this.moduleList[payload.module]=payload;
this.moduleList[payload.module] = payload;
self.updateDom(2);
}
//self.show(1000, { lockString: self.identifier });
} else if (payload && payload.behind === 0){
} else if (payload && payload.behind === 0) {
// if the module WAS in the list, but shouldn't be
if(this.moduleList[payload.module] !== undefined){
if (this.moduleList[payload.module] !== undefined) {
// remove it
delete this.moduleList[payload.module];
self.updateDom(2);
@@ -56,23 +57,18 @@ Module.register("updatenotification", {
}
},
diffLink: function(module, text) {
diffLink: function (module, text) {
var localRef = module.hash;
var 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.
getDom: function () {
var wrapper = document.createElement("div");
if(this.suspended === false){
if (this.suspended === false) {
// process the hash of module info found
for(var key of Object.keys(this.moduleList)){
for (var key of Object.keys(this.moduleList)) {
let m = this.moduleList[key];
var message = document.createElement("div");
@@ -93,7 +89,7 @@ Module.register("updatenotification", {
var text = document.createElement("span");
if (m.module === "default") {
text.innerHTML = this.translate("UPDATE_NOTIFICATION");
subtextHtml = this.diffLink(m,subtextHtml);
subtextHtml = this.diffLink(m, subtextHtml);
} else {
text.innerHTML = this.translate("UPDATE_NOTIFICATION_MODULE", {
MODULE_NAME: m.module
@@ -112,11 +108,11 @@ Module.register("updatenotification", {
return wrapper;
},
suspend: function() {
this.suspended=true;
suspend: function () {
this.suspended = true;
},
resume: function() {
this.suspended=false;
resume: function () {
this.suspended = false;
this.updateDom(2);
}
});