Skip to content

Commit

Permalink
Basic stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
imrahil committed Mar 19, 2015
1 parent 0070ccd commit 3ea82c4
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ docs/_build/

# PyBuilder
target/
.idea
OctoPrint-PrintHistory.iml
38 changes: 35 additions & 3 deletions octoprint_printhistory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
19 changes: 19 additions & 0 deletions octoprint_printhistory/templates/printhistory_tab.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<table class="table table-bordered table-hover">
<tr>
<th style="width: 30%">Filename</th>
<th style="width: 10%; text-align: center;">Status</th>
<th style="width: 30%">Date &amp; print time</th>
<th style="width: 30%">Filament usage</th>
</tr>
<tr>
<td>Test</td>
<td style="text-align: center;">OK</td>
<td>an hour ago / 01:46:16</td>
<td>3.24m / 20.10cm³</td>
</tr>
<tr>
<th colspan="2">Total:</td>
<th>04:46:16</td>
<th>123.24m / 220.10cm³</td>
</tr>
</table>

0 comments on commit 3ea82c4

Please sign in to comment.