-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added settings, and button display to control tab, as well as other c…
…hanges
- Loading branch information
Showing
4 changed files
with
91 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,76 @@ | ||
# coding=utf-8 | ||
from __future__ import absolute_import | ||
import octoprint.plugin | ||
import octoprint.settings | ||
|
||
class MultiCamPlugin(octoprint.plugin.StartupPlugin, | ||
octoprint.plugin.TemplatePlugin, | ||
octoprint.plugin.SettingsPlugin, | ||
octoprint.plugin.AssetPlugin): | ||
|
||
def get_assets(self): | ||
return dict( | ||
js=["js/multicam.js"], | ||
css=["css/multicam.css"] | ||
) | ||
|
||
def on_after_startup(self): | ||
self._logger.info("MultiCam Loaded! (more: %s)" % self._settings.get(["multicamStream1"])) | ||
|
||
def get_settings_defaults(self): | ||
return dict(multicamStream1="") | ||
return dict(multicam_profiles=[{'name':'Default','URL':octoprint.settings.settings().get(["webcam","stream"])}]) | ||
|
||
def on_settings_save(self, data): | ||
old_profiles = self._settings.get(["multicam_profiles"]) | ||
|
||
octoprint.plugin.SettingsPlugin.on_settings_save(self, data) | ||
|
||
new_profiles = self._settings.get(["multicam_profiles"]) | ||
if old_profiles != new_profiles: | ||
self._logger.info("profiles changed from {old_profiles} to {new_profiles} reordering tabs.".format(**locals())) | ||
flattened_profiles = [] | ||
for profiles in new_profiles: | ||
flattened_profiles.append(profiles["name"]) | ||
self._settings.global_set(["name","URL"],flattened_profiles) | ||
self._plugin_manager.send_plugin_message(self._identifier, dict(reload=True)) | ||
|
||
def get_template_configs(self): | ||
return [ | ||
dict(type="settings", custom_bindings=True), | ||
dict(type="generic", template="multicam.jinja2", custom_bindings=True) | ||
] | ||
|
||
def get_assets(self): | ||
##~~ Softwareupdate hook | ||
def get_version(self): | ||
return self._plugin_version | ||
|
||
def get_update_information(self): | ||
return dict( | ||
js=["js/multicam.js"], | ||
css=["css/multicam.css"] | ||
multicam=dict( | ||
displayName="MultiCam", | ||
displayVersion=self._plugin_version, | ||
|
||
# version check: github repository | ||
type="github_release", | ||
user="mikedmor", | ||
repo="OctoPrint_MultiCam", | ||
current=self._plugin_version, | ||
|
||
# update method: pip | ||
pip="https://github.com/mikedmor/OctoPrint_MultiCam/archive/{target_version}.zip" | ||
) | ||
) | ||
|
||
__plugin_name__ = "MultiCam" | ||
__plugin_implementation__ = MultiCamPlugin() | ||
|
||
def __plugin_load__(): | ||
global __plugin_implementation__ | ||
__plugin_implementation__ = MultiCamPlugin() | ||
|
||
global __plugin_hooks__ | ||
__plugin_hooks__ = { | ||
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
<!-- ko allowBindings: false --> | ||
<!-- ko allowBindings: true --> | ||
<div class="jog-panel" id="camControl"> | ||
<h1>Webcams</h1> | ||
<div> | ||
<button class="btn btn-block control-box" data-bind="click: loadWebcam" disabled>Webcam 1</button> | ||
<button class="btn btn-block control-box" data-bind="click: loadWebcam">Webcam 2</button> | ||
<div data-bind="foreach: settings.settings.plugins.multicam.multicam_profiles"> | ||
<button class="btn btn-block control-box" data-bind="click: $parent.loadWebcam, text: name">Default (before bind)</button> | ||
</div> | ||
</div> | ||
<!-- /ko --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters