Added new serial config options to UI

Also pushed more advanced config option into an initially hidden
"Advanced Options" section, similar to other places.
This commit is contained in:
Gina Häußge 2015-08-13 13:08:20 +02:00
parent 5c2ae378e1
commit 84b343a751
3 changed files with 40 additions and 9 deletions

View file

@ -85,7 +85,9 @@ def getSettings():
"log": s.getBoolean(["serial", "log"]),
"additionalPorts": s.get(["serial", "additionalPorts"]),
"additionalBaudrates": s.get(["serial", "additionalBaudrates"]),
"longRunningCommands": s.get(["serial", "longRunningCommands"])
"longRunningCommands": s.get(["serial", "longRunningCommands"]),
"checksumRequiringCommands": s.get(["serial", "checksumRequiringCommands"]),
"helloCommand": s.get(["serial", "helloCommand"])
},
"folder": {
"uploads": s.getBaseFolder("uploads"),
@ -223,6 +225,8 @@ def setSettings():
if "additionalPorts" in data["serial"] and isinstance(data["serial"]["additionalPorts"], (list, tuple)): s.set(["serial", "additionalPorts"], data["serial"]["additionalPorts"])
if "additionalBaudrates" in data["serial"] and isinstance(data["serial"]["additionalBaudrates"], (list, tuple)): s.set(["serial", "additionalBaudrates"], data["serial"]["additionalBaudrates"])
if "longRunningCommands" in data["serial"] and isinstance(data["serial"]["longRunningCommands"], (list, tuple)): s.set(["serial", "longRunningCommands"], data["serial"]["longRunningCommands"])
if "checksumRequiringCommands" in data["serial"] and isinstance(data["serial"]["checksumRequiringCommands"], (list, tuple)): s.set(["serial", "checksumRequiringCommands"], data["serial"]["checksumRequiringCommands"])
if "helloCommand" in data["serial"]: s.set(["serial", "helloCommand"], data["serial"]["helloCommand"])
oldLog = s.getBoolean(["serial", "log"])
if "log" in data["serial"].keys(): s.setBoolean(["serial", "log"], data["serial"]["log"])

View file

@ -133,6 +133,8 @@ $(function() {
self.serial_additionalPorts = ko.observable(undefined);
self.serial_additionalBaudrates = ko.observable(undefined);
self.serial_longRunningCommands = ko.observable(undefined);
self.serial_checksumRequiringCommands = ko.observable(undefined);
self.serial_helloCommand = ko.observable(undefined);
self.folder_uploads = ko.observable(undefined);
self.folder_timelapse = ko.observable(undefined);
@ -433,6 +435,8 @@ $(function() {
self.serial_additionalPorts(response.serial.additionalPorts.join("\n"));
self.serial_additionalBaudrates(response.serial.additionalBaudrates.join(", "));
self.serial_longRunningCommands(response.serial.longRunningCommands.join(", "));
self.serial_checksumRequiringCommands(response.serial.checksumRequiringCommands.join(", "));
self.serial_helloCommand(response.serial.helloCommand);
self.folder_uploads(response.folder.uploads);
self.folder_timelapse(response.folder.timelapse);
@ -521,7 +525,9 @@ $(function() {
"log": self.serial_log(),
"additionalPorts": commentableLinesToArray(self.serial_additionalPorts()),
"additionalBaudrates": _.map(splitTextToArray(self.serial_additionalBaudrates(), ",", true, function(item) { return !isNaN(parseInt(item)); }), function(item) { return parseInt(item); }),
"longRunningCommands": splitTextToArray(self.serial_longRunningCommands(), ",", true)
"longRunningCommands": splitTextToArray(self.serial_longRunningCommands(), ",", true),
"checksumRequiringCommands": splitTextToArray(self.serial_checksumRequiringCommands(), ",", true),
"helloCommand": self.serial_helloCommand()
},
"folder": {
"uploads": self.folder_uploads(),

View file

@ -70,13 +70,6 @@
</label>
</div>
</div>
<div class="control-group">
<label class="control-label" for="settings-serialLongRunningCommands">{{ _('Long running commands') }}</label>
<div class="controls">
<input type="text" class="input-block-level" id="settings-serialLongRunningCommands" data-bind="value: serial_longRunningCommands">
<span class="help-inline">{{ _('Use this to specify the commands known to take a long time to complete without output from your printer and hence might cause timeout issues. Just the G or M code, comma separated.')|format(glob_url="http://docs.python.org/2/library/glob.html") }}</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="settings-serialAdditionalPorts">{{ _('Additional serial ports') }}</label>
<div class="controls">
@ -91,4 +84,32 @@
<span class="help-inline">{{ _('Use this to define additional serial port baud rates to list for connecting with, e.g. <code>123456</code>. Comma separated.')|format(glob_url="http://docs.python.org/2/library/glob.html") }}</span>
</div>
</div>
<div>
<div><small><a href="#" class="muted" onclick="$(this).children().toggleClass('icon-caret-right icon-caret-down').parent().parent().parent().next().slideToggle('fast')"><i class="icon-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
<div class="hide">
<div class="control-group" title="{{ _('Command to send to the firmware on first handshake attempt.') }}">
<label class="control-label" for="settings-serialHelloCommand">{{ _('"Hello" command') }}</label>
<div class="controls">
<input type="text" class="input-block-level" id="settings-serialHelloCommand" data-bind="value: serial_helloCommand">
<span class="help-inline">{{ _('Use this to specify the commands known to take a long time to complete without output from your printer and hence might cause timeout issues. Just the G or M code, comma separated.')|format(glob_url="http://docs.python.org/2/library/glob.html") }}</span>
</div>
</div>
<div class="control-group" title="{{ _('Commands that are know to run long and hence should suppress communication timeouts from being triggered.') }}">
<label class="control-label" for="settings-serialLongRunningCommands">{{ _('Long running commands') }}</label>
<div class="controls">
<input type="text" class="input-block-level" id="settings-serialLongRunningCommands" data-bind="value: serial_longRunningCommands">
<span class="help-inline">{{ _('Use this to specify the commands known to take a long time to complete without output from your printer and hence might cause timeout issues. Just the G or M code, comma separated.') }}</span>
</div>
</div>
<div class="control-group" title="{{ _('Commands that always require a line number and checksum to be sent with them.') }}">
<label class="control-label" for="settings-serialChecksumRequiringCommands">{{ _('Commands that always require a checksum') }}</label>
<div class="controls">
<input type="text" class="input-block-level" id="settings-checksumRequiringCommands" data-bind="value: serial_checksumRequiringCommands">
<span class="help-inline">{{ _('Use this to specify which commands <strong>always</strong> need to be sent with a checksum. Comma separated list.') }}</span>
</div>
</div>
</div>
</div>
</form>