svgtogcode plugin settings persistance fixed
This commit is contained in:
parent
93acccf522
commit
36545f4bde
9 changed files with 51 additions and 32 deletions
|
|
@ -16,8 +16,8 @@ import octoprint.slicing
|
|||
import octoprint.settings
|
||||
|
||||
default_settings = {
|
||||
"svgtogcode_engine": None,
|
||||
"default_profile": None,
|
||||
"defaultIntensity": 500,
|
||||
"defaultFeedrate": 300,
|
||||
"debug_logging": False
|
||||
}
|
||||
s = octoprint.plugin.plugin_settings("svgtogcode", defaults=default_settings)
|
||||
|
|
@ -153,16 +153,16 @@ class SvgToGcodePlugin(octoprint.plugin.SlicerPlugin,
|
|||
|
||||
def on_settings_load(self):
|
||||
return dict(
|
||||
svgtogcode_engine=s.get(["svgtogcode_engine"]),
|
||||
default_profile=s.get(["default_profile"]),
|
||||
defaultIntensity=s.get(["defaultIntensity"]),
|
||||
defaultFeedrate=s.get(["defaultFeedrate"]),
|
||||
debug_logging=s.getBoolean(["debug_logging"])
|
||||
)
|
||||
|
||||
def on_settings_save(self, data):
|
||||
if "svgtogcode_engine" in data and data["svgtogcode_engine"]:
|
||||
s.set(["svgtogcode_engine"], data["svgtogcode_engine"])
|
||||
if "default_profile" in data and data["default_profile"]:
|
||||
s.set(["default_profile"], data["default_profile"])
|
||||
if "defaultIntensity" in data and data["defaultIntensity"]:
|
||||
s.set(["defaultIntensity"], data["defaultIntensity"])
|
||||
if "defaultFeedrate" in data and data["defaultFeedrate"]:
|
||||
s.set(["defaultFeedrate"], data["defaultFeedrate"])
|
||||
if "debug_logging" in data:
|
||||
old_debug_logging = s.getBoolean(["debug_logging"])
|
||||
new_debug_logging = data["debug_logging"] in octoprint.settings.valid_boolean_trues
|
||||
|
|
@ -177,7 +177,7 @@ class SvgToGcodePlugin(octoprint.plugin.SlicerPlugin,
|
|||
|
||||
def get_template_vars(self):
|
||||
return dict(
|
||||
_settings_menu_entry="SvgToGCode"
|
||||
_settings_menu_entry="Svg GCode Converter"
|
||||
)
|
||||
|
||||
def get_template_folder(self):
|
||||
|
|
@ -187,7 +187,7 @@ class SvgToGcodePlugin(octoprint.plugin.SlicerPlugin,
|
|||
##~~ SlicerPlugin API
|
||||
|
||||
def is_slicer_configured(self):
|
||||
svgtogcode_engine = s.get(["svgtogcode_engine"])
|
||||
# svgtogcode_engine = s.get(["svgtogcode_engine"])
|
||||
# return svgtogcode_engine is not None and os.path.exists(svgtogcode_engine)
|
||||
return True
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
speed: 100
|
||||
intensity: 100
|
||||
speed: 300
|
||||
intensity: 500
|
||||
|
|
|
|||
12
src/octoprint/plugins/svgtogcode/static/js/svg2gcodeVM.js
Normal file
12
src/octoprint/plugins/svgtogcode/static/js/svg2gcodeVM.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function Svg2GcodeViewModel(settingsViewModel) {
|
||||
var self = this;
|
||||
|
||||
self.settings = settingsViewModel;
|
||||
|
||||
self.log = [];
|
||||
|
||||
self.command = ko.observable(undefined);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,11 +1,17 @@
|
|||
<div id="settings_plugin_svgtogcode_dialog" data-bind="allowBindings: true">
|
||||
<h4>{{ _('General') }}</h4>
|
||||
<h4>{{ _('Default settings') }}</h4>
|
||||
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-svgtogcode-path">{{ _('Path to CuraEngine') }}</label>
|
||||
<label class="control-label" for="settings-svgtogcode-defaultIntensity">{{ _('laser intensity') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: settings.plugins.svgtogcode.svgtogcode_engine">
|
||||
<input type="text" class="input-block-level" data-bind="value: settings.plugins.svgtogcode.defaultIntensity">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-svgtogcode-defaultFeedrate">{{ _('laser speed') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: settings.plugins.svgtogcode.defaultFeedrate">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
|
|
@ -16,8 +22,8 @@
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<h4>{{ _('Profiles') }}</h4>
|
||||
<!--
|
||||
<h4>{{ _('Presets') }}</h4>
|
||||
|
||||
<div class="pull-right">
|
||||
<small>{{ _('Sort by') }}: <a href="#" data-bind="click: function() { profiles.changeSorting('id'); }">{{ _('Identifier') }} ({{ _('ascending') }})</a> | <a href="#" data-bind="click: function() { profiles.changeSorting('name'); }">{{ _('Name') }} ({{ _('ascending') }})</a></small>
|
||||
|
|
@ -241,6 +247,7 @@
|
|||
<button class="btn btn-primary" data-bind="click: function() { $root.confirmEditProfile() }">{{ _('Confirm') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -484,7 +484,6 @@ class Printer():
|
|||
self._addTemperatureData(temp, bedTemp)
|
||||
|
||||
def mcPosUpdate(self, MPos, WPos):
|
||||
print WPos
|
||||
self._addPositionData(MPos, WPos)
|
||||
|
||||
def mcStateChange(self, state):
|
||||
|
|
@ -760,7 +759,6 @@ class StateMonitor(object):
|
|||
self._changeEvent.set()
|
||||
|
||||
def setState(self, state):
|
||||
print("state", state)
|
||||
with self._stateMutex:
|
||||
self._state = state
|
||||
self._changeEvent.set()
|
||||
|
|
|
|||
|
|
@ -105,10 +105,17 @@ def getSettings():
|
|||
"enabled": s.getBoolean(["cura", "enabled"]),
|
||||
"path": s.get(["cura", "path"]),
|
||||
"config": s.get(["cura", "config"])
|
||||
}
|
||||
},
|
||||
#"plugins": {
|
||||
# "svgtogcode": {
|
||||
# "defaultIntensity": s.get(["plugins","svgtogcode","defaultIntensity"]),
|
||||
# "defaultFeedrate": s.get(["plugins","svgtogcode","defaultFeedrate"])
|
||||
# }
|
||||
#}
|
||||
}
|
||||
|
||||
def process_plugin_result(name, plugin, result):
|
||||
#print("process_plugin_result", result)
|
||||
if result:
|
||||
if not "plugins" in data:
|
||||
data["plugins"] = dict()
|
||||
|
|
@ -120,6 +127,7 @@ def getSettings():
|
|||
"on_settings_load",
|
||||
callback=process_plugin_result)
|
||||
|
||||
#print("settings.py getSettings: data", data["plugins"])
|
||||
return jsonify(data)
|
||||
|
||||
|
||||
|
|
@ -229,7 +237,7 @@ def setSettings():
|
|||
if name in data["plugins"]:
|
||||
plugin.on_settings_save(data["plugins"][name])
|
||||
|
||||
|
||||
|
||||
s.save()
|
||||
|
||||
return getSettings()
|
||||
|
|
|
|||
|
|
@ -55,15 +55,6 @@ $(function() {
|
|||
}
|
||||
});
|
||||
});
|
||||
// $('#navbar_show_settings').click(function() {
|
||||
// settingsDialog.modal()
|
||||
// .css({
|
||||
// width: 'auto',
|
||||
// 'margin-left': function() { return -($(this).width() /2); }
|
||||
// });
|
||||
//
|
||||
// return false;
|
||||
// });
|
||||
|
||||
//~~ Initialize view models
|
||||
var loginStateViewModel = new LoginStateViewModel();
|
||||
|
|
|
|||
|
|
@ -162,6 +162,9 @@ function SettingsViewModel(loginStateViewModel, usersViewModel) {
|
|||
self.cura_path = ko.observable(undefined);
|
||||
self.cura_config = ko.observable(undefined);
|
||||
|
||||
self.svgtogcode_defaultIntensity = ko.observable(undefined);
|
||||
self.svgtogcode_defaultFeedrate = ko.observable(undefined);
|
||||
|
||||
self.temperature_profiles = ko.observableArray(undefined);
|
||||
|
||||
self.system_actions = ko.observableArray([]);
|
||||
|
|
@ -229,7 +232,7 @@ function SettingsViewModel(loginStateViewModel, usersViewModel) {
|
|||
} else {
|
||||
ko.mapping.fromJS(response, self.settings);
|
||||
}
|
||||
|
||||
|
||||
self.api_enabled(response.api.enabled);
|
||||
self.api_key(response.api.key);
|
||||
self.api_allowCrossOrigin(response.api.allowCrossOrigin);
|
||||
|
|
|
|||
|
|
@ -443,7 +443,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% for plugin_name, vars in settingsPlugins.items() %}
|
||||
<div class="tab-pane" id="settings_plugin_{{ plugin_name }}" data-bind="allowBindings: false">
|
||||
<div class="tab-pane" id="settings_plugin_{{ plugin_name }}" data-bind="allowBindings: true">
|
||||
{% include plugin_name+"_settings_dialog.jinja2" ignore missing %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
|
|
|||
Loading…
Reference in a new issue