Rolled back appearance settings
Associating them with the current printer profile is misleading as long as a printer profile represents both a physical printer and a type machine. In the future this association will have to be split, to allow for configuration of printers with respective machine profiles (name subject to be changed).
This commit is contained in:
parent
873a825e57
commit
c7afae38a8
7 changed files with 82 additions and 29 deletions
|
|
@ -35,6 +35,10 @@ def getSettings():
|
|||
"key": s.get(["api", "key"]) if admin_permission.can() else "n/a",
|
||||
"allowCrossOrigin": s.get(["api", "allowCrossOrigin"])
|
||||
},
|
||||
"appearance": {
|
||||
"name": s.get(["appearance", "name"]),
|
||||
"color": s.get(["appearance", "color"])
|
||||
},
|
||||
"printer": {
|
||||
"defaultExtrusionLength": s.getInt(["printerParameters", "defaultExtrusionLength"])
|
||||
},
|
||||
|
|
@ -120,6 +124,10 @@ def setSettings():
|
|||
if "key" in data["api"].keys(): s.set(["api", "key"], data["api"]["key"], True)
|
||||
if "allowCrossOrigin" in data["api"].keys(): s.setBoolean(["api", "allowCrossOrigin"], data["api"]["allowCrossOrigin"])
|
||||
|
||||
if "appearance" in data.keys():
|
||||
if "name" in data["appearance"].keys(): s.set(["appearance", "name"], data["appearance"]["name"])
|
||||
if "color" in data["appearance"].keys(): s.set(["appearance", "color"], data["appearance"]["color"])
|
||||
|
||||
if "printer" in data.keys():
|
||||
if "defaultExtrusionLength" in data["printer"]: s.setInt(["printerParameters", "defaultExtrusionLength"], data["printer"]["defaultExtrusionLength"])
|
||||
|
||||
|
|
|
|||
|
|
@ -111,6 +111,10 @@ default_settings = {
|
|||
"pauseTriggers": [],
|
||||
"defaultExtrusionLength": 5
|
||||
},
|
||||
"appearance": {
|
||||
"name": "",
|
||||
"color": "default"
|
||||
},
|
||||
"controls": [],
|
||||
"system": {
|
||||
"actions": []
|
||||
|
|
@ -292,15 +296,6 @@ class Settings(object):
|
|||
|
||||
dirty = True
|
||||
|
||||
if "appearance" in self._config:
|
||||
if "name" in self._config["appearance"]:
|
||||
default_profile["name"] = self._config["appearance"]["name"]
|
||||
if "color" in self._config["appearance"]:
|
||||
default_profile["color"] = self._config["appearance"]["color"]
|
||||
|
||||
del self._config["appearance"]
|
||||
dirty = True
|
||||
|
||||
if dirty:
|
||||
if not "printerProfiles" in self._config:
|
||||
self._config["printerProfiles"] = dict()
|
||||
|
|
|
|||
|
|
@ -1,33 +1,20 @@
|
|||
function AppearanceViewModel(settingsViewModel, printerStateViewModel) {
|
||||
var self = this;
|
||||
|
||||
self.settings = settingsViewModel;
|
||||
self.printerState = printerStateViewModel;
|
||||
|
||||
self.connected = ko.observable(false);
|
||||
|
||||
self.printerState.isErrorOrClosed.subscribe(function() {
|
||||
self.connected(!self.printerState.isErrorOrClosed());
|
||||
});
|
||||
self.name = settingsViewModel.appearance_name;
|
||||
self.color = settingsViewModel.appearance_color;
|
||||
|
||||
self.brand = ko.computed(function() {
|
||||
if (self.settings.printerProfiles.currentProfileData().name() && self.connected())
|
||||
return gettext("OctoPrint") + ": " + self.settings.printerProfiles.currentProfileData().name();
|
||||
if (self.name())
|
||||
return gettext("OctoPrint") + ": " + self.name();
|
||||
else
|
||||
return gettext("OctoPrint");
|
||||
});
|
||||
|
||||
self.title = ko.computed(function() {
|
||||
if (self.settings.printerProfiles.currentProfileData().name() && self.connected())
|
||||
return self.settings.printerProfiles.currentProfileData().name() + " [" + gettext("OctoPrint") + "]";
|
||||
if (self.name())
|
||||
return self.name() + " [" + gettext("OctoPrint") + "]";
|
||||
else
|
||||
return gettext("OctoPrint");
|
||||
});
|
||||
|
||||
self.color = ko.computed(function() {
|
||||
if (self.settings.printerProfiles.currentProfileData().color() && self.connected())
|
||||
return self.settings.printerProfiles.currentProfileData().color();
|
||||
else
|
||||
return "default";
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ function ConnectionViewModel(loginStateViewModel, settingsViewModel, printerProf
|
|||
var portPreference = response.options.portPreference;
|
||||
var baudratePreference = response.options.baudratePreference;
|
||||
var printerPreference = response.options.printerProfilePreference;
|
||||
var printerProfiles = response.options.printerProfiles;
|
||||
|
||||
self.portOptions(ports);
|
||||
self.baudrateOptions(baudrates);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,43 @@ function SettingsViewModel(loginStateViewModel, usersViewModel, printerProfilesV
|
|||
self.api_key = ko.observable(undefined);
|
||||
self.api_allowCrossOrigin = ko.observable(undefined);
|
||||
|
||||
self.appearance_name = ko.observable(undefined);
|
||||
self.appearance_color = ko.observable(undefined);
|
||||
|
||||
self.appearance_available_colors = ko.observable([
|
||||
{key: "default", name: gettext("default")},
|
||||
{key: "red", name: gettext("red")},
|
||||
{key: "orange", name: gettext("orange")},
|
||||
{key: "yellow", name: gettext("yellow")},
|
||||
{key: "green", name: gettext("green")},
|
||||
{key: "blue", name: gettext("blue")},
|
||||
{key: "violet", name: gettext("violet")},
|
||||
{key: "black", name: gettext("black")}
|
||||
]);
|
||||
|
||||
self.appearance_colorName = function(color) {
|
||||
switch (color) {
|
||||
case "red":
|
||||
return gettext("red");
|
||||
case "orange":
|
||||
return gettext("orange");
|
||||
case "yellow":
|
||||
return gettext("yellow");
|
||||
case "green":
|
||||
return gettext("green");
|
||||
case "blue":
|
||||
return gettext("blue");
|
||||
case "violet":
|
||||
return gettext("violet");
|
||||
case "black":
|
||||
return gettext("black");
|
||||
case "default":
|
||||
return gettext("default");
|
||||
default:
|
||||
return color;
|
||||
}
|
||||
};
|
||||
|
||||
self.printer_defaultExtrusionLength = ko.observable(undefined);
|
||||
|
||||
self.webcam_streamUrl = ko.observable(undefined);
|
||||
|
|
@ -101,6 +138,9 @@ function SettingsViewModel(loginStateViewModel, usersViewModel, printerProfilesV
|
|||
self.api_key(response.api.key);
|
||||
self.api_allowCrossOrigin(response.api.allowCrossOrigin);
|
||||
|
||||
self.appearance_name(response.appearance.name);
|
||||
self.appearance_color(response.appearance.color);
|
||||
|
||||
self.printer_defaultExtrusionLength(response.printer.defaultExtrusionLength);
|
||||
|
||||
self.webcam_streamUrl(response.webcam.streamUrl);
|
||||
|
|
@ -158,6 +198,10 @@ function SettingsViewModel(loginStateViewModel, usersViewModel, printerProfilesV
|
|||
"key": self.api_key(),
|
||||
"allowCrossOrigin": self.api_allowCrossOrigin()
|
||||
},
|
||||
"appearance" : {
|
||||
"name": self.appearance_name(),
|
||||
"color": self.appearance_color()
|
||||
},
|
||||
"printer": {
|
||||
"defaultExtrusionLength": self.printer_defaultExtrusionLength()
|
||||
},
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@
|
|||
<div class="accordion span4">
|
||||
<div class="accordion-group" data-bind="visible: loginState.isUser" id="connection_accordion">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle" data-toggle="collapse" href="#connection"><i class="icon-signal"></i> {{ _('Connection') }}</a>
|
||||
<a class="accordion-toggle" data-toggle="collapse" data-target="#connection"><i class="icon-signal"></i> {{ _('Connection') }}</a>
|
||||
</div>
|
||||
<div class="accordion-body collapse in" id="connection">
|
||||
<div class="accordion-inner">
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
<li><a href="#settings_api" data-toggle="tab">{{ _('API') }}</a></li>
|
||||
<li class="nav-header">OctoPrint</li>
|
||||
<li><a href="#settings_folder" data-toggle="tab">{{ _('Folders') }}</a></li>
|
||||
<li><a href="#settings_appearance" data-toggle="tab">{{ _('Appearance') }}</a></li>
|
||||
<li><a href="#settings_logs" data-toggle="tab">{{ _('Logs') }}</a></li>
|
||||
{% if settingsPlugins %}
|
||||
<li class="nav-header">Plugins</li>
|
||||
|
|
@ -477,6 +478,23 @@
|
|||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tab-pane" id="settings_appearance">
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-appearanceName">{{ _('Title') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: appearance_name" id="settings-appearanceName">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-appearanceColor">{{ _('Color') }}</label>
|
||||
<div class="controls">
|
||||
<select id="settings-appearanceColor" data-bind="value: appearance_color, options: appearance_available_colors, optionsText: 'name', optionsValue: 'key'">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tab-pane" id="settings_api">
|
||||
<form class="form-horizontal" onsubmit="return false;">
|
||||
<div class="control-group">
|
||||
|
|
|
|||
Loading…
Reference in a new issue