From 388ffa2c449106a898ac20e7cb4be750c9d7f891 Mon Sep 17 00:00:00 2001 From: Dushyant Ahuja Date: Mon, 7 Oct 2019 21:34:58 +0100 Subject: [PATCH 1/2] Update to add new variable showOnlyWhilePrinting This would ensure that the module only shows when the printer is printing and gets hidden if the printer is not printing. Makes for a clutter-free dashboard. --- octomirror-module.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/octomirror-module.js b/octomirror-module.js index a0f75d9..26410ca 100644 --- a/octomirror-module.js +++ b/octomirror-module.js @@ -17,6 +17,7 @@ Module.register("octomirror-module", { showDetailsWhenOffline: true, interactive: true, // Set to false to hide the file drop down and only show the stream. debugMode: false, // Set to true to log all messages from OctoPrint Socket + showOnlyWhilePrinting: false, }, //Override dom generator. @@ -239,6 +240,13 @@ Module.register("octomirror-module", { $("#opBedTemp")[0].innerHTML = (temps.bed.actual) ? temps.bed.actual.round10(1) + "°C" : "N/A"; $("#opBedTempTgt")[0].innerHTML = (temps.bed.target) ? Math.round(temps.bed.target) + "°C" : "N/A"; } + + if (data.state.text != "Printing" & this.config.showOnlyWhilePrinting){ + this.hide(); + } + else { + this.show(); + } }, notificationReceived: function(notification, payload, sender) { @@ -278,4 +286,4 @@ Number.prototype.round10 = function(precision) { var tempNumber = this * factor; var roundedTempNumber = Math.round(tempNumber); return roundedTempNumber / factor; -}; \ No newline at end of file +}; From 61bfb34f7b1915ff892d1eb431f7fe0118b2b7f6 Mon Sep 17 00:00:00 2001 From: Dushyant Ahuja Date: Mon, 7 Oct 2019 21:36:55 +0100 Subject: [PATCH 2/2] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f7afc63..2e4158d 100644 --- a/README.md +++ b/README.md @@ -61,9 +61,10 @@ To use this module, add it to the modules array in the `config/config.js` file: | `showDetailsWhenOffline` | *Optional* Whether or not to hide the printer details when the printer is offline (file name, time, temps) | `interactive` | *Optional* Allow interactive control of the printer: choose files to print and upload new files.
*Default:* `true`. Set to `false` to hide the drop downs, if you don't use the Mirror to control anything. | `debugMode` | *Optional* Prints all messages received from the printer socket to the console log, for debugging only and developing more features. +| `showOnlyWhilePrinting`| *Optional* Set to true so that the modules gets hidden when the printer is not printing. *Default:* `false` ## Development and Feature Requests * If you have any feature requests or find any bugs, please post about it on the [MagicMirror Forum](https://forum.magicmirror.builders) or open an Issue on this repo. * This module exposes the full client API for an OctoPrint instance and only displays the info that is useful to me at the moment, if there is something else you would like added, please let me know. The API is here: - - http://docs.octoprint.org/en/master/api/push.html \ No newline at end of file + - http://docs.octoprint.org/en/master/api/push.html