diff --git a/.gitignore b/.gitignore index 9574a29..564ea90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .vscode *.pyc +*.egg-info* diff --git a/octoprint_enclosure/__init__.py b/octoprint_enclosure/__init__.py index 139464c..af4c8bf 100644 --- a/octoprint_enclosure/__init__.py +++ b/octoprint_enclosure/__init__.py @@ -14,12 +14,13 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, octoprint.plugin.TemplateP # ~~ TemplatePlugin def get_template_configs(self): return [ - dict(type="settings", template="enclosure_settings.jinja2", custom_bindings=True) + dict(type="settings", template="enclosureSettings.jinja2", custom_bindings=True) ] # ~~ AssetPlugin mixin def get_assets(self): - return dict(js=["js/enclosure.js", "js/bootstrap-colorpicker.min.js"], + return dict( + js=["js/enclosure.js", "js/bootstrap-colorpicker.min.js"], css=["css/bootstrap-colorpicker.css", "css/enclosure.css"]) # ~~ Softwareupdate hook diff --git a/octoprint_enclosure/old_stuff/static/css/bootstrap-colorpicker.css b/octoprint_enclosure/old_stuff/static/css/bootstrap-colorpicker.css index 26cb0de..0dfa89c 100644 --- a/octoprint_enclosure/old_stuff/static/css/bootstrap-colorpicker.css +++ b/octoprint_enclosure/old_stuff/static/css/bootstrap-colorpicker.css @@ -226,5 +226,4 @@ } .colorpicker-inline.colorpicker-visible { display: inline-block; -} -/*# sourceMappingURL=bootstrap-colorpicker.css.map */ \ No newline at end of file +} \ No newline at end of file diff --git a/octoprint_enclosure/static/css/bootstrap-colorpicker.css b/octoprint_enclosure/static/css/bootstrap-colorpicker.css index 26cb0de..0dfa89c 100644 --- a/octoprint_enclosure/static/css/bootstrap-colorpicker.css +++ b/octoprint_enclosure/static/css/bootstrap-colorpicker.css @@ -226,5 +226,4 @@ } .colorpicker-inline.colorpicker-visible { display: inline-block; -} -/*# sourceMappingURL=bootstrap-colorpicker.css.map */ \ No newline at end of file +} \ No newline at end of file diff --git a/octoprint_enclosure/static/js/enclosure.js b/octoprint_enclosure/static/js/enclosure.js index af6d044..f9f6d9a 100644 --- a/octoprint_enclosure/static/js/enclosure.js +++ b/octoprint_enclosure/static/js/enclosure.js @@ -1,8 +1,75 @@ $(function () { - function EnclosureViewModel(parameters) { - self.showAddOutputDialog = function (data) { - var editDialog = $("#settings_outputs_editDialog"); + var cleanOutput = function () { + return { + index_id: "", + label: "", + output_type: "Regular", + gpio: { + pin_name: "" + } + } + }; + + function EnclosureOutputEditorViewModel(parameters) { + var self = this; + + self.isNew = ko.observable(false); + self.label = ko.observable(); + self.output_type = ko.observable(); + self.gpio_pin = ko.observable(); + + self.fromOutputData = function (data) { + + self.isNew(data === undefined); + + if (data === undefined) { + data = cleanOutput(); + } + + self.label(data.label); + self.output_type(data.output_type); + self.gpio_pin(data.gpio.pin_name); + + }; + + self.toOutputData = function () { + var output_data = { + index_id: "", + label: self.label(), + output_type: self.output_type(), + gpio: { + pin_name: self.gpio_pin() + } + } + return output_data + }; + + // end of EnclosureOutputEditorViewModel + }; + + function EnclosureViewModel(parameters) { + var self = this; + + self.settingsViewModel = parameters[0]; + self.connectionViewModel = parameters[1]; + self.printerStateViewModel = parameters[2]; + + self.enclosureOutputs = ko.observableArray(); + + self.createOutputEditor = function (data) { + var outputEditor = new EnclosureOutputEditorViewModel(); + + return outputEditor; + }; + + self.outputEditor = self.createOutputEditor(); + + self.showOutputEditorDialog = function (data) { + + self.outputEditor.fromOutputData(data); + + var editDialog = $("#settings_outputs_edit_dialog"); editDialog.modal({ minHeight: function () { @@ -14,12 +81,23 @@ $(function () { return -($(this).width() / 2); } }); - } + }; + self.addOutputs = function () { + var output = self.outputEditor.toOutputData(); + + }; + + self.print = function () { + console.log(self); + }; + + // end of EnclosureViewModel }; + OCTOPRINT_VIEWMODELS.push({ construct: EnclosureViewModel, // ViewModels your plugin depends on, e.g. loginStateViewModel, settingsViewModel, ... @@ -28,4 +106,4 @@ $(function () { elements: ["#settings_plugin_enclosure"] }); -}); \ No newline at end of file +}) \ No newline at end of file diff --git a/octoprint_enclosure/templates/enclosureSettings.jinja2 b/octoprint_enclosure/templates/enclosureSettings.jinja2 new file mode 100644 index 0000000..a6d0db4 --- /dev/null +++ b/octoprint_enclosure/templates/enclosureSettings.jinja2 @@ -0,0 +1,5 @@ +

{{ _('Raspberry Pi Outputs') }}

+ +{% include "outputTable.jinja2" %} + +{% include "outputEditor.jinja2" %} \ No newline at end of file diff --git a/octoprint_enclosure/templates/enclosure_settings.jinja2 b/octoprint_enclosure/templates/enclosure_settings.jinja2 deleted file mode 100644 index cb73115..0000000 --- a/octoprint_enclosure/templates/enclosure_settings.jinja2 +++ /dev/null @@ -1,5 +0,0 @@ -

{{ _('Raspberry Pi Outputs Testaaa') }}

- -{% include "outputTable.jinja2" %} - -{% include "outputSettingsEditor.jinja2" %} \ No newline at end of file diff --git a/octoprint_enclosure/templates/outputEditor.jinja2 b/octoprint_enclosure/templates/outputEditor.jinja2 new file mode 100644 index 0000000..ca5611c --- /dev/null +++ b/octoprint_enclosure/templates/outputEditor.jinja2 @@ -0,0 +1,44 @@ + + + diff --git a/octoprint_enclosure/templates/outputEditorGeneral.jinja2 b/octoprint_enclosure/templates/outputEditorGeneral.jinja2 new file mode 100644 index 0000000..64c0dbd --- /dev/null +++ b/octoprint_enclosure/templates/outputEditorGeneral.jinja2 @@ -0,0 +1,9 @@ +
+
+ +
+ + Name displayed on Enclosure Tab +
+
+
diff --git a/octoprint_enclosure/templates/outputSettingsEditor.jinja2 b/octoprint_enclosure/templates/outputSettingsEditor.jinja2 deleted file mode 100644 index becb6d2..0000000 --- a/octoprint_enclosure/templates/outputSettingsEditor.jinja2 +++ /dev/null @@ -1,13 +0,0 @@ - \ No newline at end of file diff --git a/octoprint_enclosure/templates/outputTable.jinja2 b/octoprint_enclosure/templates/outputTable.jinja2 index 70de5e8..720f363 100644 --- a/octoprint_enclosure/templates/outputTable.jinja2 +++ b/octoprint_enclosure/templates/outputTable.jinja2 @@ -12,5 +12,5 @@
- +
diff --git a/setup.py b/setup.py index 3dd24a9..d8c2425 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ plugin_url = "https://github.com/vitormhenrique/OctoPrint-Enclosure" plugin_license = "AGPLv3" # Any additional requirements besides OctoPrint should be listed here -plugin_requires = ["RPi.GPIO>=0.6.5","requests>=2.7"] +plugin_requires = [] additional_setup_parameters = {}