From 1af4c676ad502d4c97cb51af0ec501988e73c483 Mon Sep 17 00:00:00 2001 From: alfonsopl Date: Mon, 30 Nov 2020 16:22:12 +0100 Subject: [PATCH] Confirm bed clear --- octoprint_astroprint/__init__.py | 19 ++++-- .../boxrouter/handlers/requesthandler.py | 3 +- .../static/css/astroprint.css | 60 +++++++++++++++++++ .../templates/astroprint_settings.jinja2 | 7 +++ setup.py | 2 +- 5 files changed, 84 insertions(+), 7 deletions(-) diff --git a/octoprint_astroprint/__init__.py b/octoprint_astroprint/__init__.py index d94dc36..8d6ffda 100755 --- a/octoprint_astroprint/__init__.py +++ b/octoprint_astroprint/__init__.py @@ -136,15 +136,18 @@ def capabilities(self): capabilities = ['remotePrint', # Indicates whether this device supports starting a print job remotely 'multiExtruders', # Support for multiple extruders 'allowPrintFile', # Support for printing a printfile not belonging to any design - 'acceptPrintJobId', # Accept created print job from cloud, - 'cleanState' # Support bed not clean state + 'acceptPrintJobId' # Accept created print job from cloud, ] + if self._settings.get(["check_clear_bed"]) : + capabilities.append('cleanState') # Support bed not clean state return capabilities def on_startup(self, host, port, *args, **kwargs): self._logger.info("Starting AstoPrint Plugin") self.register_printer_listener() self.db = AstroprintDB(self) + if not self._settings.get(['check_clear_bed']): + self.set_bed_clear(True) ## Move old mysql database data to new yaml file for logged users oldDbFile = os.path.join(self.get_plugin_data_folder(),"octoprint_astroprint.db") @@ -184,7 +187,10 @@ def get_printer(self): @property def isBedClear(self): - return self._bed_clear + if self._settings.get(['check_clear_bed']): + return self._bed_clear + else: + return True def set_bed_clear(self, clear, sendUpdate = False): if clear != self._bed_clear: @@ -261,6 +267,7 @@ def get_settings_defaults(self): filament = {'name' : None, 'color' : None}, camera = False, bedClear = True, + check_clear_bed = True, #Adittional printer settings max_nozzle_temp = 280, #only for being set by AstroPrintCloud, it wont affect octoprint settings max_bed_temp = 140, @@ -370,7 +377,8 @@ def on_event(self, event, payload): elif event == Events.PRINT_CANCELLED or event == Events.PRINT_FAILED: self.send_event("canPrint", True) - self.set_bed_clear(False) + if self._settings.get(['check_clear_bed']): + self.set_bed_clear(False) if self.user and self.astroprintCloud.currentPrintingJob: self.astroprintCloud.updatePrintJob("failed", self.materialCounter.totalConsumedFilament) self.astroprintCloud.currentPrintingJob = None @@ -378,7 +386,8 @@ def on_event(self, event, payload): self._analyzed_job_layers = None elif event == Events.PRINT_DONE: - self.set_bed_clear(False) + if self._settings.get(['check_clear_bed']): + self.set_bed_clear(False) if self.user and self.astroprintCloud.currentPrintingJob: self.astroprintCloud.updatePrintJob("success", self.materialCounter.totalConsumedFilament) self.astroprintCloud.currentPrintingJob = None diff --git a/octoprint_astroprint/boxrouter/handlers/requesthandler.py b/octoprint_astroprint/boxrouter/handlers/requesthandler.py index 3e83fe7..9dc4411 100755 --- a/octoprint_astroprint/boxrouter/handlers/requesthandler.py +++ b/octoprint_astroprint/boxrouter/handlers/requesthandler.py @@ -243,5 +243,6 @@ def photo(self, data, clientId, done): }) def set_bed_clear(self, clear, _, done): - self.plugin.set_bed_clear(clear) + if self._settings.get(['check_clear_bed']): + self.plugin.set_bed_clear(clear) done(None) diff --git a/octoprint_astroprint/static/css/astroprint.css b/octoprint_astroprint/static/css/astroprint.css index 04e9d9f..93b9d99 100755 --- a/octoprint_astroprint/static/css/astroprint.css +++ b/octoprint_astroprint/static/css/astroprint.css @@ -312,3 +312,63 @@ margin-left: 10px; color: rgba(0, 135, 205, 0.3); } + +.switch { + position: relative; + display: inline-block; + width: 60px; + height: 34px; +} + +.switch input { + opacity: 0; + width: 0; + height: 0; +} + +.slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #ccc; + -webkit-transition: .4s; + transition: .4s; +} + +.slider:before { + position: absolute; + content: ""; + height: 26px; + width: 26px; + left: 4px; + bottom: 4px; + background-color: white; + -webkit-transition: .4s; + transition: .4s; +} + +input:checked + .slider { + background-color: #2196F3; +} + +input:focus + .slider { + box-shadow: 0 0 1px #2196F3; +} + +input:checked + .slider:before { + -webkit-transform: translateX(26px); + -ms-transform: translateX(26px); + transform: translateX(26px); +} + +/* Rounded sliders */ +.slider.round { + border-radius: 34px; +} + +.slider.round:before { + border-radius: 50%; +} diff --git a/octoprint_astroprint/templates/astroprint_settings.jinja2 b/octoprint_astroprint/templates/astroprint_settings.jinja2 index ce37536..ade2d7f 100755 --- a/octoprint_astroprint/templates/astroprint_settings.jinja2 +++ b/octoprint_astroprint/templates/astroprint_settings.jinja2 @@ -75,6 +75,13 @@ °C +
+ + +

Remote Control Options

diff --git a/setup.py b/setup.py index 4ddef9d..08d5fb8 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "AstroPrint" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "1.6.2" +plugin_version = "1.6.3" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module