Several improvements
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
/* global Module, MM */
|
||||
/* global Module, MM, NCCFormatDuration */
|
||||
|
||||
Module.register("MMM-NextcloudCookbook", {
|
||||
defaults: {
|
||||
controlPath: "/MMM-NextcloudCookbook/control",
|
||||
controlUrl: "",
|
||||
animationSpeed: 400,
|
||||
shareUrl: "",
|
||||
sharePassword: ""
|
||||
@@ -18,6 +19,10 @@ Module.register("MMM-NextcloudCookbook", {
|
||||
return ["MMM-NextcloudCookbook.css"];
|
||||
},
|
||||
|
||||
getScripts() {
|
||||
return ["lib/format-duration.js"];
|
||||
},
|
||||
|
||||
socketNotificationReceived(notification, payload) {
|
||||
if (notification !== "STATE") return;
|
||||
this.state = payload;
|
||||
@@ -47,12 +52,14 @@ Module.register("MMM-NextcloudCookbook", {
|
||||
|
||||
const qr = document.createElement("a");
|
||||
qr.className = "ncc-qr";
|
||||
qr.href = this.config.controlPath;
|
||||
qr.href = this.config.controlUrl || this.config.controlPath;
|
||||
qr.setAttribute("aria-label", "Open recipe controller");
|
||||
const qrLabel = document.createElement("span");
|
||||
qrLabel.textContent = "Recipe mode control:";
|
||||
const qrImage = document.createElement("img");
|
||||
qrImage.src = "/MMM-NextcloudCookbook/qr.svg";
|
||||
qrImage.alt = "Recipe controller QR code";
|
||||
qr.appendChild(qrImage);
|
||||
qr.append(qrLabel, qrImage);
|
||||
root.appendChild(qr);
|
||||
|
||||
if (!this.state.active) return root;
|
||||
@@ -88,9 +95,9 @@ Module.register("MMM-NextcloudCookbook", {
|
||||
|
||||
const metadata = [
|
||||
["Yield", recipe.recipeYield],
|
||||
["Prep", recipe.prepTime],
|
||||
["Cook", recipe.cookTime],
|
||||
["Total", recipe.totalTime]
|
||||
["Prep", NCCFormatDuration(recipe.prepTime)],
|
||||
["Cook", NCCFormatDuration(recipe.cookTime)],
|
||||
["Total", NCCFormatDuration(recipe.totalTime)]
|
||||
].filter(([, value]) => value);
|
||||
if (metadata.length) {
|
||||
const list = document.createElement("dl");
|
||||
|
||||
Reference in New Issue
Block a user