diff --git a/.gitignore b/.gitignore index db4561e..6c185d9 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,5 @@ docs/_build/ # PyBuilder target/ +.idea +OctoPrint-PrintHistory.iml diff --git a/octoprint_printhistory/__init__.py b/octoprint_printhistory/__init__.py index 7d6dfe4..c86d824 100644 --- a/octoprint_printhistory/__init__.py +++ b/octoprint_printhistory/__init__.py @@ -8,11 +8,43 @@ import octoprint.plugin import octoprint.events -class PrintHistoryPlugin(octoprint.plugin.EventHandlerPlugin, +class PrintHistoryPlugin(octoprint.plugin.StartupPlugin, + octoprint.plugin.EventHandlerPlugin, octoprint.plugin.SettingsPlugin, octoprint.plugin.TemplatePlugin, octoprint.plugin.AssetPlugin): - - + + def on_after_startup(self): + self._logger.info("Hello World from Print History Plugin!") + self.get + + def get_template_configs(self): + return [ + dict(type="tab", name="History") + ] + + #~~ EventPlugin API + + def on_event(self, event, payload): + + supported_event = None + + if event == octoprint.events.Events.PRINT_STARTED: + supported_event = octoprint.events.Events.PRINT_STARTED + + elif event == octoprint.events.Events.PRINT_DONE: + supported_event = octoprint.events.Events.PRINT_DONE + + elif event == octoprint.events.Events.PRINT_CANCELLED: + supported_event = octoprint.events.Events.PRINT_CANCELLED + + if supported_event is None: + return + + self._logger.info("event: %s" % supported_event) + metadata = self._file_manager.get_metadata(payload["origin"], payload["file"]) + self._logger.info("metadata: %s" % metadata) + + __plugin_name__ = "Print History Plugin" __plugin_implementations__ = [PrintHistoryPlugin()] diff --git a/octoprint_printhistory/templates/printhistory_tab.jinja2 b/octoprint_printhistory/templates/printhistory_tab.jinja2 new file mode 100644 index 0000000..76f9ac5 --- /dev/null +++ b/octoprint_printhistory/templates/printhistory_tab.jinja2 @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + +
FilenameStatusDate & print timeFilament usage
TestOKan hour ago / 01:46:163.24m / 20.10cm³
Total: + 04:46:16 + 123.24m / 220.10cm³ +