diff --git a/.versioneer-lookup b/.versioneer-lookup index 7fd9ad046..fc6923cd5 100644 --- a/.versioneer-lookup +++ b/.versioneer-lookup @@ -24,10 +24,10 @@ maintenance 1.3.11 e14c00f135bf2a955e54ac3f0a2928d8440055d2 pep440-dev fix/.* 1.3.11 e14c00f135bf2a955e54ac3f0a2928d8440055d2 pep440-dev improve/.* 1.3.11 e14c00f135bf2a955e54ac3f0a2928d8440055d2 pep440-dev -# staging/maintenance is currently the branch for preparation of 1.3.10rc2 +# staging/maintenance is currently the branch for preparation of 1.3.10rc3 # so is regressionfix/... -staging/maintenance 1.3.10rc2 e14c00f135bf2a955e54ac3f0a2928d8440055d2 pep440-dev -regressionfix/.* 1.3.10rc2 e14c00f135bf2a955e54ac3f0a2928d8440055d2 pep440-dev +staging/maintenance 1.3.10rc2 de42ce73f7c4a73b892e405dc34dcf1e38f36f22 pep440-dev +regressionfix/.* 1.3.10rc2 de42ce73f7c4a73b892e405dc34dcf1e38f36f22 pep440-dev # every other branch is a development branch and thus gets resolved to 1.4.0-dev for now .* 1.4.0 7f5d03d0549bcbd26f40e7e4a3297ea5204fb1cc pep440-dev diff --git a/CHANGELOG.md b/CHANGELOG.md index 9757c2d2a..46171f121 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,38 @@ # OctoPrint Changelog -## 1.3.10rc1 (2018-11-05) +## 1.3.10rc2 (2018-11-13) + +### Improvements + + * Anonymous Usage Tracking: Added elapsed time & reason of print failure to tracking (to be able to distinguish cancelled from errored out prints) + * Anonymous Usage Tracking: Added undervoltage/overheat detection on Pis to tracking (to correlate print failures to power issues, see also [#2878](https://github.com/foosel/OctoPrint/pull/2878)). + * Printer Safety Plugin: Added Ender 3 stock firmware to detection + * Added documentation for `octoprint.util.commandline` module + +### Bug fixes + + * [#2872](https://github.com/foosel/OctoPrint/issues/2872) - Fix Timeout when connecting to printer that doesn't send `start` on connect + * [#2873](https://github.com/foosel/OctoPrint/issues/2873) - Fix GCODE viewer no longer being able to load files. + * [#2876](https://github.com/foosel/OctoPrint/issues/2876) - Fix semi functional UI when access control is disabled + * [#2879](https://github.com/foosel/OctoPrint/issues/2879) - Fix favicon in Firefox + * Anonymous Usage Tracking: More error resilience for the wizard to possibly work around issues observed with the first RC (for which sadly no information was provided to reproduce and analyse). + * Softwareupdate: More resilience against invalid data in config + +### Unreproduced issues + +The following issues were reported in RC1 but so far have been unreproduced and further data to analyse them is still missing. If you encounter any of them please report back with a [fully filled out issue template](https://github.com/foosel/OctoPrint/blob/master/CONTRIBUTING.md#what-should-i-include-in-a-bug-report): + + * [Not possible to complete Anonymous Usage Tracking setup wizard](https://discourse.octoprint.org/t/anonymous-usage-setup/5151) + +### Special thanks to all the contributors! + +Special thanks to everyone who contributed to this release candidate, especially @tedder for his PR. + +### More information + + * [Commits](https://github.com/foosel/OctoPrint/compare/1.3.10rc1...1.3.10rc2) + +## 1.3.10rc1 (2018-11-06) ### Heads-up for plugin authors regarding the `sarge` dependency diff --git a/SUPPORTERS.md b/SUPPORTERS.md index 2ddb3b341..d9e245d1b 100644 --- a/SUPPORTERS.md +++ b/SUPPORTERS.md @@ -6,25 +6,23 @@ thanks to everyone who contributed! ## Patreon Patrons + * Andre Bubel * Andrew Moorby * Arnljot Arntsen * Boris Hussein * Brad Jackson - * Brian E. Tyler + * Charles Haislip * Christian Petropolis * Christian Wolf * COLLE+McVOY * D Brian Kimmel * DeltaMaker 3D Printers * E3D BigBox + * Eric Betts + * Eric Slape * Ernesto Martinez - * F. Kunsmann * Frank Sander * George Robles - * günter weber - * Hydra Research LLC - * James Seigel - * Jeff Moe * Jeff Renfer * Jefferson Hunt * Jeremiah Avery @@ -35,7 +33,6 @@ thanks to everyone who contributed! * Kaile Riser * Kale Stedman * Kazuhiro Ogura - * Kodama Inc. * Lewis Newby * LulzBot® * Makespace Madrid @@ -43,21 +40,18 @@ thanks to everyone who contributed! * Martin Beattie * Michael Aumock * Miles Flavel - * mitchell hirsch - * Noe Ruiz * Patrick McGinnis + * Prof Yuh Wen Chen * Randy C. Will * Robert Gusek * Roger Strolz - * Roy Cortes * Rudolff Vang * Samer Najia * Simon Hallam * Stefan Krister * Sven Mueller - * Symbiotic Devices * Thomas Hatley * Timothy D Hoogland * Trent Shumay -and 1351 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)! \ No newline at end of file +and 1376 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)! \ No newline at end of file diff --git a/docs/events/index.rst b/docs/events/index.rst index a97e7e385..288f8d82f 100644 --- a/docs/events/index.rst +++ b/docs/events/index.rst @@ -141,7 +141,8 @@ Disconnected The server has disconnected from the printer Error - An error has occurred in the printer communication. + An unrecoverable error has been encountered, either as reported by the firmware (e.g. a thermal runaway) or + on the connection. Payload: @@ -338,6 +339,8 @@ PrintFailed * ``name``: the file's name * ``path``: the file's path within its storage location * ``origin``: the origin storage location of the file, either ``local`` or ``sdcard`` + * ``time``: the elapsed time of the print when it failed, in seconds (float) + * ``reason``: the reason the print failed, either ``cancelled`` or ``error`` .. deprecated:: 1.3.0 diff --git a/docs/modules/util.rst b/docs/modules/util.rst index 32a61b728..156a25ff3 100644 --- a/docs/modules/util.rst +++ b/docs/modules/util.rst @@ -6,4 +6,10 @@ octoprint.util .. automodule:: octoprint.util :members: +.. _sec-modules-util-commandline: +octoprint.util.commandline +-------------------------- + +.. automodule:: octoprint.util.commandline + :members: diff --git a/setup.py b/setup.py index 7977f8c92..5fb420016 100644 --- a/setup.py +++ b/setup.py @@ -13,47 +13,52 @@ import octoprint_setuptools #----------------------------------------------------------------------------------------------------------------------- # Supported python versions -PYTHON_REQUIRES = ">=2.7.3,<3" # TODO change to >=2.7.9,<3 in 1.3.11 +PYTHON_REQUIRES = ">=2.7.9,<3" # Requirements for our application INSTALL_REQUIRES = [ - "flask>=0.12,<0.13", - "werkzeug>=0.11.1,<0.12", - "tornado==4.5.3", - "Jinja2>=2.8.1,<2.9", # Jinja 2.9 has breaking changes WRT template scope - we can't - # guarantee backwards compatibility for plugins and such with that - # version, hence we need to pin to a lower version for now. See #1697 - #"sockjs-tornado>=1.0.3,<1.1", # current version is incompatible to tornado 5, we use a - # vendored one - "PyYAML>=3.12,<3.13", - "Flask-Login>=0.4,<0.5", + # the following dependencies are non trivial to update since later versions introduce backwards incompatible + # changes that might affect plugins, or due to other observed problems + + "flask>=0.12,<0.13", # newer versions require newer Jinja versions + "Jinja2>=2.8.1,<2.9", # Jinja 2.9 has breaking changes WRT template scope - we can't + # guarantee backwards compatibility for plugins and such with that + # version, hence we need to pin to a lower version for now. See #1697 + "tornado==4.5.3", # a memory leak was observed in tornado >= 5, see #2585 + "Flask-Login>=0.2.11,<0.3", # some functions changed to properties in 0.3 + "regex!=2018.11.6", # avoid broken 2018.11.6. See #2874 + + # anything below this should be checked on releases for new versions + "Flask-Principal>=0.4,<0.5", - "Flask-Babel>=0.11,<0.12", + "Flask-Babel>=0.12,<0.13", "Flask-Assets>=0.12,<0.13", - "markdown>=2.6.4,<2.7", + "werkzeug>=0.14.1,<0.15", + "PyYAML>=3.13,<4", + "markdown>=3.0,<3.1", "pyserial>=3.4,<3.5", "netaddr>=0.7.19,<0.8", - "watchdog>=0.8.3,<0.9", + "watchdog>=0.9.0,<0.10", "sarge==0.1.5post0", - "netifaces>=0.10.6,<0.11", - "pylru>=1.0.9,<1.1", - "rsa>=3.4,<3.5", + "netifaces>=0.10.7,<0.11", + "pylru>=1.1,<1.2", + "rsa>=4.0,<5", "pkginfo>=1.4.2,<1.5", - "requests>=2.18.4,<3", - "semantic_version>=2.6.0,<2.7", - "psutil>=5.4.6,<5.5", - "Click>=6.7,<6.8", + "requests>=2.20.0,<3", + "semantic_version>=2.6,<2.7", + "psutil>=5.4.8,<5.5", + "Click>=7,<8", "awesome-slugify>=1.6.5,<1.7", "feedparser>=5.2.1,<5.3", "chainmap>=1.0.2,<1.1", - "future>=0.15.2,<0.16", - "scandir>=1.3,<1.4", - "websocket-client>=0.40.0,<0.41", - "python-dateutil>=2.6.1,<2.7", + "future>=0.17,<0.18", + "scandir>=1.9,<1.10", + "websocket-client>=0.53,<0.54", + "python-dateutil>=2.7.5,<2.8", "wrapt>=1.10.11,<1.11", - "futures>=3.1.1,<3.2", - "emoji>=0.4.5,<0.5", - "monotonic>=1.3,<1.4", + "futures>=3.2,<3.3", + "emoji>=0.5.1,<0.6", + "monotonic>=1.5,<1.6", "frozendict>=1.2,<1.3" ] @@ -66,7 +71,7 @@ EXTRA_REQUIRES = dict( develop=[ # Testing dependencies "mock>=2.0.0,<3", - "nose>=1.3.0,<1.4", + "nose>=1.3.7,<1.4", "ddt", # Documentation dependencies @@ -78,7 +83,7 @@ EXTRA_REQUIRES = dict( # Dependencies for developing OctoPrint plugins plugins=[ - "cookiecutter>=1.5,<1.7" + "cookiecutter>=1.6,<1.7" ] ) diff --git a/src/octoprint/plugins/forcelogin/__init__.py b/src/octoprint/plugins/forcelogin/__init__.py index ed12abdbc..90a11ca74 100644 --- a/src/octoprint/plugins/forcelogin/__init__.py +++ b/src/octoprint/plugins/forcelogin/__init__.py @@ -85,6 +85,9 @@ class ForceLoginPlugin(octoprint.plugin.UiPlugin, if self._user_manager.enabled and not self._user_manager.has_been_customized(): # ACL hasn't been configured yet, make an exception return + elif not self._user_manager.enabled: + # ACL isn't enabled + return if flask.request.endpoint in ("api.login",): return @@ -99,6 +102,9 @@ class ForceLoginPlugin(octoprint.plugin.UiPlugin, if self._user_manager.enabled and not self._user_manager.has_been_customized(): # ACL hasn't been configured yet, make an exception return + elif not self._user_manager.enabled: + # ACL isn't enabled + return import tornado.web from octoprint.server.util.flask import get_flask_user_from_request @@ -111,6 +117,9 @@ class ForceLoginPlugin(octoprint.plugin.UiPlugin, if self._user_manager.enabled and not self._user_manager.has_been_customized(): # ACL hasn't been configured yet, make an exception return True + elif not self._user_manager.enabled: + # ACL isn't enabled + return True return user is not None and not user.is_anonymous and user.is_active @@ -118,6 +127,9 @@ class ForceLoginPlugin(octoprint.plugin.UiPlugin, if self._user_manager.enabled and not self._user_manager.has_been_customized(): # ACL hasn't been configured yet, make an exception return True + elif not self._user_manager.enabled: + # ACL isn't enabled + return True if message in ("connected", "reauthRequired"): return True diff --git a/src/octoprint/plugins/pi_support/__init__.py b/src/octoprint/plugins/pi_support/__init__.py index 28b4f3d03..8ea0af7be 100644 --- a/src/octoprint/plugins/pi_support/__init__.py +++ b/src/octoprint/plugins/pi_support/__init__.py @@ -35,10 +35,9 @@ _FLAG_PAST_UNDERVOLTAGE = 1 << 16 _FLAG_PAST_FREQ_CAPPED = 1 << 17 _FLAG_PAST_THROTTLED = 1 << 18 - class ThrottleState(object): @classmethod - def from_value(cls, value): + def from_value(cls, value=0): if value == 0: return ThrottleState() @@ -47,10 +46,12 @@ class ThrottleState(object): throttled=_FLAG_THROTTLED & value == _FLAG_THROTTLED, past_undervoltage=_FLAG_PAST_UNDERVOLTAGE & value == _FLAG_PAST_UNDERVOLTAGE, past_freq_capped=_FLAG_PAST_FREQ_CAPPED & value == _FLAG_PAST_FREQ_CAPPED, - past_throttled=_FLAG_PAST_THROTTLED & value == _FLAG_PAST_THROTTLED) + past_throttled=_FLAG_PAST_THROTTLED & value == _FLAG_PAST_THROTTLED, + raw_value=value) return ThrottleState(**kwargs) def __init__(self, **kwargs): + self._raw_value = kwargs.get('raw_value', -1) self._undervoltage = False self._freq_capped = False self._throttled = False @@ -111,7 +112,8 @@ class ThrottleState(object): and self._past_throttled == other._past_throttled def as_dict(self): - return dict(current_undervoltage=self.current_undervoltage, + return dict(raw_value=self._raw_value, + current_undervoltage=self.current_undervoltage, past_undervoltage=self.past_undervoltage, current_overheat=self.current_overheat, past_overheat=self.past_overheat, @@ -242,6 +244,16 @@ class PiSupportPlugin(octoprint.plugin.EnvironmentDetectionPlugin, def _check_throttled_state_condition(self): return self._throttle_functional + def get_throttle_state(self, run_now=False): + """Exposed as public helper.""" + if run_now: + self._check_throttled_state() + + if not self._throttle_functional: + return False + + return self._throttle_state.as_dict() + def _check_throttled_state(self): command = self._settings.get(["vcgencmd_throttle_check_command"]) @@ -278,6 +290,7 @@ class PiSupportPlugin(octoprint.plugin.EnvironmentDetectionPlugin, self._plugin_manager.send_plugin_message(self._identifier, dict(type="throttle_state", state=self._throttle_state.as_dict())) + self._event_bus.fire("plugin_pi_support_throttle_state", self._throttle_state.as_dict()) __plugin_name__ = "Pi Support Plugin" @@ -299,5 +312,9 @@ def __plugin_check__(): return "raspberry pi" in proc_dt_model.lower() def __plugin_load__(): + plugin = PiSupportPlugin() global __plugin_implementation__ - __plugin_implementation__ = PiSupportPlugin() + __plugin_implementation__ = plugin + + global __plugin_helpers__ + __plugin_helpers__ = dict(get_throttled=plugin.get_throttle_state) diff --git a/src/octoprint/plugins/printer_safety_check/__init__.py b/src/octoprint/plugins/printer_safety_check/__init__.py index 1fcba8d91..5709b8daa 100644 --- a/src/octoprint/plugins/printer_safety_check/__init__.py +++ b/src/octoprint/plugins/printer_safety_check/__init__.py @@ -37,6 +37,10 @@ ANYCUBIC_RECEIVED_TEST = lambda line: line and (ANYCUBIC_AUTHOR1 in line.lower() CR10S_AUTHOR = " | Author: (CR-10Slanguage)".lower() CR10S_RECEIVED_TEST = lambda line: line and CR10S_AUTHOR in line.lower() +# Creality Ender 3 +ENDER3_AUTHOR = " | Author: (Ender3)".lower() +ENDER3_RECEIVED_TEST = lambda line: line and ENDER3_AUTHOR in line.lower() + # Malyan M200 aka Monoprice Select Mini MALYANM200_M115_TEST = lambda name, data: name and name.lower().startswith("malyan") and data.get("MODEL") == "M200" @@ -48,7 +52,7 @@ THERMAL_PROTECTION_CAP_TEST = lambda cap, enabled: cap == "THERMAL_PROTECTION" a SAFETY_CHECKS = { "firmware-unsafe": dict(m115=(ANETA8_M115_TEST, MALYANM200_M115_TEST, REPETIER_BEFORE_092_M115_TEST), - received=(ANYCUBIC_RECEIVED_TEST, CR10S_RECEIVED_TEST), + received=(ANYCUBIC_RECEIVED_TEST, CR10S_RECEIVED_TEST, ENDER3_RECEIVED_TEST), cap=(THERMAL_PROTECTION_CAP_TEST,), message=u"Your printer's firmware is known to lack mandatory safety features (e.g. " \ u"thermal runaway protection). This is a fire risk.") diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py index f8215f238..a586733a3 100644 --- a/src/octoprint/plugins/softwareupdate/__init__.py +++ b/src/octoprint/plugins/softwareupdate/__init__.py @@ -134,6 +134,9 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, update_check_hooks = self._plugin_manager.get_hooks("octoprint.plugin.softwareupdate.check_config") check_providers = self._settings.get(["check_providers"], merged=True) + if not isinstance(check_providers, dict): + check_providers = dict() + effective_configs = dict() for name, hook in update_check_hooks.items(): diff --git a/src/octoprint/plugins/tracking/__init__.py b/src/octoprint/plugins/tracking/__init__.py index 108b275e5..ab57f5c50 100644 --- a/src/octoprint/plugins/tracking/__init__.py +++ b/src/octoprint/plugins/tracking/__init__.py @@ -39,6 +39,8 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, def __init__(self): self._environment = None + self._throttle_state = None + self._helpers_get_throttle_state = None self._printer_connection_parameters = None self._url = None self._ping_worker = None @@ -60,7 +62,8 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, printjob=True, plugin=True, update=True, - printer=True)) + printer=True, + throttled=True)) def get_settings_restricted_paths(self): return dict(admin=[["enabled"], ["unique_id"], ["events"]], @@ -84,13 +87,19 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, ##~~ StartupPlugin def on_after_startup(self): - self._track_startup() - ping = self._settings.get_int(["ping"]) if ping: self._ping_worker = RepeatedTimer(ping, self._track_ping) self._ping_worker.start() + # cautiously look for the get_throttled helper from pi_support + pi_helper = self._plugin_manager.get_helpers("pi_support", "get_throttled") + if pi_helper and 'get_throttled' in pi_helper: + self._helpers_get_throttle_state = pi_helper['get_throttled'] + + # now that we have everything set up, phone home. + self._track_startup() + ##~~ ShutdownPlugin def on_shutdown(self): @@ -101,8 +110,11 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, def on_event(self, event, payload): if event.startswith("plugin_pluginmanager_"): self._track_plugin_event(event, payload) - if event.startswith("plugin_softwareupdate_"): + elif event.startswith("plugin_softwareupdate_"): self._track_update_event(event, payload) + elif event in ("plugin_pi_support_throttle_state",): + self._throttle_state = payload + self._track_throttle_event(event, payload) elif event in (Events.PRINT_STARTED, Events.PRINT_DONE, Events.PRINT_FAILED, Events.PRINT_CANCELLED): self._track_printjob_event(event, payload) elif event in (Events.CONNECTED,): @@ -124,7 +136,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, ##~~ AssetPlugin def get_assets(self): - return dict(js=["js/tracking.js"]) + return dict(js=["js/usage.js"]) ##~~ WizardPlugin @@ -162,6 +174,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, if b"plugins" in self._environment and b"pi_support" in self._environment[b"plugins"]: payload[b"pi_model"] = self._environment[b"plugins"][b"pi_support"][b"model"] + if b"octopi_version" in self._environment[b"plugins"][b"pi_support"]: payload[b"octopi_version"] = self._environment[b"plugins"][b"pi_support"][b"octopi_version"] @@ -195,6 +208,26 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, elif event.endswith("_update_failed"): self._track("update_failed", target=payload.get("target"), from_version=payload.get("from_version"), to_version=payload.get("to_version")) + def _track_throttle_event(self, event, payload): + if not self._settings.get_boolean(["events", "throttled"]): + return + + args = dict(throttled_now=payload[b"current_issue"], + throttled_past=payload[b"past_issue"], + throttled_mask=payload[b"raw_value"], + throttled_voltage_now=payload[b"current_undervoltage"], + throttled_voltage_past=payload[b"past_undervoltage"], + throttled_overheat_now=payload[b"current_overheat"], + throttled_overheat_past=payload[b"past_overheat"]) + + if payload[b"current_issue"]: + track_event = "system_throttled" + else: + track_event = "system_unthrottled" + + if track_event is not None: + self._track(track_event, **args) + def _track_printjob_event(self, event, payload): if not self._settings.get_boolean(["events", "printjob"]): return @@ -216,10 +249,27 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, args[b"elapsed"] = elapsed track_event = "print_done" elif event == Events.PRINT_FAILED: + try: + elapsed = int(payload.get(b"time")) + except ValueError: + elapsed = "unknown" + args[b"elapsed"] = elapsed + args[b"reason"] = payload.get(b"reason", "unknown") track_event = "print_failed" elif event == Events.PRINT_CANCELLED: track_event = "print_cancelled" + if callable(self._helpers_get_throttle_state): + try: + throttle_state = self._helpers_get_throttle_state(run_now=True) + if throttle_state and (throttle_state.get(b"current_issue", False) or throttle_state.get(b"past_issue", False)): + args[b"throttled_now"] = throttle_state[b"current_issue"] + args[b"throttled_past"] = throttle_state[b"past_issue"] + args[b"throttled_mask"] = throttle_state[b"raw_value"] + except: + # ignored + pass + if track_event is not None: self._track(track_event, **args) @@ -246,15 +296,18 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, server = self._settings.get([b"server"]) url = server.format(id=self._settings.get([b"unique_id"]), event=event) + # Don't print the URL or UUID! That would expose the UUID in forums/tickets + # if pasted. It's okay for the user to know their uuid, but it shouldn't be shared. headers = {"User-Agent": "OctoPrint/{}".format(get_octoprint_version_string())} try: params = urlencode(kwargs, doseq=True).replace("+", "%20") + requests.get(url, params=params, timeout=3.1, headers=headers) - self._logger.debug("Sent tracking event to {}".format(url)) + self._logger.info("Sent tracking event {}, payload: {!r}".format(event, kwargs)) except: if self._logger.isEnabledFor(logging.DEBUG): self._logger.exception("Error while sending event to anonymous usage tracking".format(url)) diff --git a/src/octoprint/plugins/tracking/static/js/tracking.js b/src/octoprint/plugins/tracking/static/js/usage.js similarity index 63% rename from src/octoprint/plugins/tracking/static/js/tracking.js rename to src/octoprint/plugins/tracking/static/js/usage.js index 6855450b6..1a8517313 100644 --- a/src/octoprint/plugins/tracking/static/js/tracking.js +++ b/src/octoprint/plugins/tracking/static/js/usage.js @@ -1,5 +1,5 @@ $(function() { - function TrackingViewModel(parameters) { + function UsageViewModel(parameters) { var self = this; self.settingsViewModel = parameters[0]; @@ -7,16 +7,16 @@ $(function() { self.setup = ko.observable(false); self.decision = ko.observable(); + self.active = ko.observable(); self.required = false; - self.active = false; - self.enableTracking = function() { + self.enableUsage = function() { self.settingsViewModel.settings.plugins.tracking.enabled(true); self.decision(true); self._sendData(); }; - self.disableTracking = function() { + self.disableUsage = function() { self.settingsViewModel.settings.plugins.tracking.enabled(false); self.decision(false); self._sendData(); @@ -45,7 +45,7 @@ $(function() { }; self.onWizardPreventSettingsRefreshDialog = function() { - return self.active; + return self.active(); }; self.onWizardDetails = function(response) { @@ -68,17 +68,33 @@ $(function() { } }; - self.active = true; + self.active(true); self.settingsViewModel.saveData(data) .done(function() { self.setup(true); - self.active = false; + self.active(false); + }) + .fail(function() { + self.decision(false); + self.setup(true); + self.active(false); + + var message = gettext("Please open a " + + "bug report on this. Make sure to include all requested information, including your " + + "JS console and " + + "octoprint.log."); + new PNotify({ + title: gettext("Something went wrong"), + text: _.sprintf(message, {bugreport: "https://github.com/foosel/OctoPrint/blob/master/CONTRIBUTING.md#how-to-file-a-bug-report", jsconsole: "https://webmasters.stackexchange.com/a/77337"}), + type: "error", + hide: false + }); }); }; } OCTOPRINT_VIEWMODELS.push([ - TrackingViewModel, + UsageViewModel, ["settingsViewModel"], "#wizard_plugin_tracking" ]); diff --git a/src/octoprint/plugins/tracking/templates/tracking_settings.jinja2 b/src/octoprint/plugins/tracking/templates/tracking_settings.jinja2 index 3a5fa8a08..217bc26c6 100644 --- a/src/octoprint/plugins/tracking/templates/tracking_settings.jinja2 +++ b/src/octoprint/plugins/tracking/templates/tracking_settings.jinja2 @@ -37,6 +37,9 @@ + diff --git a/src/octoprint/plugins/tracking/templates/tracking_wizard.jinja2 b/src/octoprint/plugins/tracking/templates/tracking_wizard.jinja2 index ebc2896f0..2a0b5645f 100644 --- a/src/octoprint/plugins/tracking/templates/tracking_wizard.jinja2 +++ b/src/octoprint/plugins/tracking/templates/tracking_wizard.jinja2 @@ -9,8 +9,8 @@

- {{ _('Disable Anonymous Usage Tracking') }} - {{ _('Enable Anonymous Usage Tracking') }} + {{ _('Disable Anonymous Usage Tracking') }} + {{ _('Enable Anonymous Usage Tracking') }}