diff --git a/octoprint_dashboard/__init__.py b/octoprint_dashboard/__init__.py index f284d6b..ff33a9e 100644 --- a/octoprint_dashboard/__init__.py +++ b/octoprint_dashboard/__init__.py @@ -12,10 +12,16 @@ def on_after_startup(self): self._logger.info("Dashboard started") def on_event(self, event, payload): - if event == "DisplayLayerProgress_layerChanged" or event == "DisplayLayerProgress_progressChanged": - #self._logger.info(payload.get('currentLayer')) - self._plugin_manager.send_plugin_message(self._identifier, dict(totalLayer=payload.get('totalLayer'), - currentLayer=payload.get('currentLayer'), + if event == "DisplayLayerProgress_layerChanged" or event == "DisplayLayerProgress_progressChanged" or event == "DisplayLayerProgress_fanspeedChanged": + newCurrentLayer = 0 + newTotalLayer = 0 + #self._logger.info("Layer: " + payload.get('currentLayer')) + if payload.get('totalLayer').isdigit(): + newTotalLayer = int(payload.get('totalLayer')) + 1 # Because DisplayLayerProgress is base 0 + if payload.get('currentLayer').isdigit(): + newCurrentLayer = int(payload.get('currentLayer')) + 1 + self._plugin_manager.send_plugin_message(self._identifier, dict(totalLayer=newTotalLayer, + currentLayer=newCurrentLayer, currentHeight=payload.get('currentHeight'), totalHeightWithExtrusion=payload.get('totalHeightWithExtrusion'), feedrate=payload.get('feedrate'), diff --git a/octoprint_dashboard/static/js/dashboard.js b/octoprint_dashboard/static/js/dashboard.js index cdf4e24..d750af9 100644 --- a/octoprint_dashboard/static/js/dashboard.js +++ b/octoprint_dashboard/static/js/dashboard.js @@ -16,8 +16,8 @@ $(function() { self.displaylayerprogressViewModel = parameters[5]; - self.totalLayer = ko.observable(0); - self.currentLayer = ko.observable(0); + self.totalLayer = ko.observable("-"); + self.currentLayer = ko.observable("-"); self.currentHeight = ko.observable("-"); self.totalHeightWithExtrusion = ko.observable("-"); self.feedrate = ko.observable("-"); @@ -32,7 +32,7 @@ $(function() { self.DisplayLayerProgressAvailable = function() { if (self.settingsViewModel.settings.plugins.DisplayLayerProgress) return; - else return "Can't get stats from DisplayLayerprogress. Is it installed, enabled and on the latest version?"; + else return "Can't get stats from DisplayLayerprogress. Is it installed, enabled and on the latest version?"; } //Events from displaylayerprogress Plugin @@ -40,8 +40,8 @@ $(function() { if (plugin != "dashboard") { return; } - if (data.totalLayer) { self.totalLayer( parseInt(data.totalLayer) + 1); } - if (data.currentLayer) { self.currentLayer(parseInt(data.currentLayer) + 1); } + if (data.totalLayer) { self.totalLayer(data.totalLayer); } + if (data.currentLayer) { self.currentLayer(data.currentLayer); } if (data.currentHeight) { self.currentHeight(data.currentHeight); } if (data.totalHeightWithExtrusion) { self.totalHeightWithExtrusion(data.totalHeightWithExtrusion); } if (data.feedrate) { self.feedrate(data.feedrate); } diff --git a/octoprint_dashboard/templates/dashboard_tab.jinja2 b/octoprint_dashboard/templates/dashboard_tab.jinja2 index 43c5ce0..14034d2 100644 --- a/octoprint_dashboard/templates/dashboard_tab.jinja2 +++ b/octoprint_dashboard/templates/dashboard_tab.jinja2 @@ -23,9 +23,9 @@ - - - + + + @@ -37,9 +37,9 @@ - - - + + + @@ -49,16 +49,16 @@ - - - + + +
- + diff --git a/setup.py b/setup.py index d21748c..b84735a 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "OctoPrint-Dashboard" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "1.0.0" +plugin_version = "1.1.0" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module