views: Extracted settings views
This commit is contained in:
parent
a839800e3d
commit
bc6e2029b1
|
@ -9,7 +9,8 @@ class KlipperPlugin(
|
||||||
octoprint.plugin.StartupPlugin,
|
octoprint.plugin.StartupPlugin,
|
||||||
octoprint.plugin.TemplatePlugin,
|
octoprint.plugin.TemplatePlugin,
|
||||||
octoprint.plugin.SettingsPlugin,
|
octoprint.plugin.SettingsPlugin,
|
||||||
octoprint.plugin.AssetPlugin):
|
octoprint.plugin.AssetPlugin,
|
||||||
|
octoprint.plugin.WizardPlugin):
|
||||||
|
|
||||||
def on_after_startup(self):
|
def on_after_startup(self):
|
||||||
pass
|
pass
|
||||||
|
@ -22,14 +23,16 @@ class KlipperPlugin(
|
||||||
replace_connection_panel=True,
|
replace_connection_panel=True,
|
||||||
macros=[{'name':"Echo", 'macro':"ECHO"}],
|
macros=[{'name':"Echo", 'macro':"ECHO"}],
|
||||||
probeHeight=0,
|
probeHeight=0,
|
||||||
probeLift=0,
|
probeLift=5,
|
||||||
probePoints=[{'x':0, 'y':0}])
|
probePoints=[{'x':0, 'y':0}])
|
||||||
|
|
||||||
def get_template_configs(self):
|
def get_template_configs(self):
|
||||||
return [
|
return [
|
||||||
dict(type="navbar", custom_bindings=True),
|
dict(type="navbar", custom_bindings=True),
|
||||||
dict(type="settings", custom_bindings=True),
|
dict(type="settings", custom_bindings=True),
|
||||||
dict(type="wizard", custom_bindings=True),
|
dict(type="generic", name="Assisted Bed Leveling", template="klipper_leveling_dialog.jinja2", custom_bindings=True),
|
||||||
|
dict(type="generic", name="PID Tuning", template="klipper_pid_tuning_dialog.jinja2", custom_bindings=True),
|
||||||
|
dict(type="tab", name="Klipper", template="klipper_tab_main.jinja2", suffix="_main", custom_bindings=True),
|
||||||
dict(type="sidebar",
|
dict(type="sidebar",
|
||||||
custom_bindings=True,
|
custom_bindings=True,
|
||||||
replaces= "connection" if self._settings.get(["replace_connection_panel"]) else "")
|
replaces= "connection" if self._settings.get(["replace_connection_panel"]) else "")
|
||||||
|
@ -37,7 +40,10 @@ class KlipperPlugin(
|
||||||
|
|
||||||
def get_assets(self):
|
def get_assets(self):
|
||||||
return dict(
|
return dict(
|
||||||
js=["js/klipper.js"],
|
js=["js/klipper.js",
|
||||||
|
"js/klipper_settings.js",
|
||||||
|
"js/klipper_leveling.js",
|
||||||
|
"js/klipper_pid_tuning.js"],
|
||||||
css=["css/klipper.css"],
|
css=["css/klipper.css"],
|
||||||
less=["css/klipper.less"]
|
less=["css/klipper.less"]
|
||||||
)
|
)
|
||||||
|
@ -81,6 +87,9 @@ class KlipperPlugin(
|
||||||
self._plugin_manager.send_plugin_message(self._identifier, dict(message=line))
|
self._plugin_manager.send_plugin_message(self._identifier, dict(message=line))
|
||||||
self._plugin_manager.send_plugin_message(self._identifier, dict(message=action))
|
self._plugin_manager.send_plugin_message(self._identifier, dict(message=action))
|
||||||
#self._logger.info("action recieved:".action)
|
#self._logger.info("action recieved:".action)
|
||||||
|
|
||||||
|
def is_wizard_required(self):
|
||||||
|
return True;
|
||||||
|
|
||||||
__plugin_name__ = "Klipper"
|
__plugin_name__ = "Klipper"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
$(function() {
|
||||||
|
function KlipperSettingsViewModel(parameters) {
|
||||||
|
var self = this;
|
||||||
|
self.settings = parameters[0];
|
||||||
|
|
||||||
|
self.addMacro = function() {
|
||||||
|
self.settings.settings.plugins.klipper.macros.push({name: 'Macro', macro: ''});
|
||||||
|
}
|
||||||
|
|
||||||
|
self.removeMacro = function(macro) {
|
||||||
|
self.settings.settings.plugins.klipper.macros.remove(macro);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.moveMacroUp = function(macro) {
|
||||||
|
self.moveItemUp(self.settings.settings.plugins.klipper.macros, macro)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.moveMacroDown = function(macro) {
|
||||||
|
self.moveItemDown(self.settings.settings.plugins.klipper.macros, macro)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
self.addProbePoint = function() {
|
||||||
|
self.settings.settings.plugins.klipper.probePoints.push({x: 0, y:0, z:0});
|
||||||
|
}
|
||||||
|
|
||||||
|
self.removeProbePoint = function(point) {
|
||||||
|
self.settings.settings.plugins.klipper.probePoints.remove(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.moveProbePointUp = function(macro) {
|
||||||
|
self.moveItemUp(self.settings.settings.plugins.klipper.probePoints, macro)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.moveProbePointDown = function(macro) {
|
||||||
|
self.moveItemDown(self.settings.settings.plugins.klipper.probePoints, macro)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.moveItemDown = function(list, item) {
|
||||||
|
var i = list().indexOf(item);
|
||||||
|
if (i < list().length - 1) {
|
||||||
|
var rawList = list();
|
||||||
|
list.splice(i, 2, rawList[i + 1], rawList[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.moveItemUp = function(list, item) {
|
||||||
|
var i = list().indexOf(item);
|
||||||
|
if (i > 0) {
|
||||||
|
var rawList = list();
|
||||||
|
list.splice(i-1, 2, rawList[i], rawList[i-1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OCTOPRINT_VIEWMODELS.push({
|
||||||
|
construct: KlipperSettingsViewModel,
|
||||||
|
dependencies: ["settingsViewModel"],
|
||||||
|
elements: ["#settings_plugin_klipper"]
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue