🚧 Further progress on connection profile editing
This commit is contained in:
1 parent
5421c1bfe3
commit
9f2a6cf6e0
10 files changed
+208
-128
No files matched your search
@@ -970,12 +970,20 @@ def fetch_template_data(refresh=False):
|
||||
# settings dialog
|
||||
|
||||
templates["settings"]["entries"] = {
|
||||
"section_printer": (gettext("Printer & Connection"), None),
|
||||
"section_printer": (gettext("Connection & Printer"), None),
|
||||
"connection": (
|
||||
gettext("Connection"),
|
||||
gettext("General"),
|
||||
{
|
||||
"template": "dialogs/settings/connection.jinja2",
|
||||
"_div": "settings_connection",
|
||||
"custom_bindings": False,
|
||||
},
|
||||
),
|
||||
"connectionprofiles": (
|
||||
gettext("Connection Profiles"),
|
||||
{
|
||||
"template": "dialogs/settings/connectionprofiles.jinja2",
|
||||
"_div": "settings_connectionProfiles",
|
||||
"custom_bindings": True,
|
||||
},
|
||||
),
|
||||
|
||||
@@ -344,6 +344,7 @@ default_settings = {
|
||||
"settings": [
|
||||
"section_printer",
|
||||
"connection",
|
||||
"connectionprofiles",
|
||||
"printerprofiles",
|
||||
"temperatures",
|
||||
"terminalfilters",
|
||||
|
||||
@@ -1 +1 @@
|
||||
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn.active,.btn:active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeaLine truncated
|
||||
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn.active,.btn:active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeaLine truncated
|
||||
@@ -185,18 +185,10 @@ $(function () {
|
||||
return result;
|
||||
};
|
||||
|
||||
function EditedConnectionProfile(
|
||||
printerProfiles,
|
||||
protocols,
|
||||
transports,
|
||||
cleanProfile
|
||||
) {
|
||||
function EditedConnectionProfile(connectionViewModel) {
|
||||
var self = this;
|
||||
|
||||
self.printerProfiles = printerProfiles;
|
||||
self.protocols = protocols;
|
||||
self.transports = transports;
|
||||
self.cleanProfile = cleanProfile;
|
||||
self.connectionViewModel = connectionViewModel;
|
||||
|
||||
self.isNew = ko.observable(true);
|
||||
|
||||
@@ -265,29 +257,16 @@ $(function () {
|
||||
self.isNew(data === undefined);
|
||||
|
||||
if (data === undefined) {
|
||||
data = self.cleanProfile();
|
||||
data = self.connectionViewModel.cleanProfile();
|
||||
}
|
||||
|
||||
self.identifier(data.id);
|
||||
self.name(data.name);
|
||||
|
||||
self.printerProfile(
|
||||
_.find(self.printerProfiles(), function (p) {
|
||||
return p.id === data.printer_profile;
|
||||
})
|
||||
);
|
||||
|
||||
self.protocol(
|
||||
_.find(self.protocols(), function (p) {
|
||||
return p.key === data.protocol;
|
||||
})
|
||||
);
|
||||
|
||||
self.transport(
|
||||
_.find(self.transports(), function (p) {
|
||||
return p.key === data.transport;
|
||||
})
|
||||
self.connectionViewModel.printerProfileLookup[data.printer_profile]
|
||||
);
|
||||
self.protocol(self.connectionViewModel.protocolLookup[data.protocol]);
|
||||
self.transport(self.connectionViewModel.transportLookup[data.transport]);
|
||||
|
||||
var processParameters = function (parameters, profile_parameters) {
|
||||
_.each(parameters, function (option) {
|
||||
@@ -317,10 +296,10 @@ $(function () {
|
||||
var profile = {
|
||||
id: identifier,
|
||||
name: self.name(),
|
||||
printerProfile: self.printerProfile(),
|
||||
protocol: self.protocol(),
|
||||
printer_profile: self.printerProfile().id,
|
||||
protocol: self.protocol().key,
|
||||
protocol_parameters: toOptions(self.protocolParameters()),
|
||||
transport: self.transport(),
|
||||
transport: self.transport().key,
|
||||
transport_parameters: toOptions(self.transportParameters())
|
||||
};
|
||||
return profile;
|
||||
@@ -333,13 +312,10 @@ $(function () {
|
||||
};
|
||||
}
|
||||
|
||||
function ConnectionProfileEditorViewModel(parameters) {
|
||||
function ConnectionProfileEditorViewModel(connectionViewModel) {
|
||||
var self = this;
|
||||
|
||||
self.availablePrinterProfiles = parameters[0];
|
||||
self.availableProtocols = parameters[1];
|
||||
self.availableTransports = parameters[2];
|
||||
self.cleanProfile = parameters[3];
|
||||
self.connection = connectionViewModel;
|
||||
|
||||
self.active = ko.observable(false);
|
||||
self.deferred = undefined;
|
||||
@@ -349,13 +325,10 @@ $(function () {
|
||||
|
||||
self.dialog = $("#connectionprofiles_editor_dialog");
|
||||
|
||||
self.profile = new EditedConnectionProfile(
|
||||
self.availablePrinterProfiles,
|
||||
self.availableProtocols,
|
||||
self.availableTransports,
|
||||
self.cleanProfile
|
||||
);
|
||||
self.profile = new EditedConnectionProfile(self.connection);
|
||||
self.overwrite = ko.observable(false);
|
||||
self.showOverwrite = ko.observable(true);
|
||||
|
||||
self.makeDefault = ko.observable(false);
|
||||
self.showMakeDefault = ko.observable(false);
|
||||
|
||||
@@ -368,6 +341,18 @@ $(function () {
|
||||
options = options || {};
|
||||
options.title = options.title || gettext("Edit connection profile");
|
||||
options.button = options.button || gettext("Update");
|
||||
options.showOverwrite =
|
||||
options.showOverwrite !== undefined ? options.showOverwrite : false;
|
||||
|
||||
return self.showDialog(profile, options);
|
||||
};
|
||||
|
||||
self.showSaveAsDialog = function (profile, options) {
|
||||
options = options || {};
|
||||
options.title = options.title || gettext("Edit connection profile");
|
||||
options.button = options.button || gettext("Update");
|
||||
options.showOverwrite =
|
||||
options.showOverwrite !== undefined ? options.showOverwrite : true;
|
||||
|
||||
return self.showDialog(profile, options);
|
||||
};
|
||||
@@ -385,6 +370,7 @@ $(function () {
|
||||
self.buttonText(gettext("Save"));
|
||||
}
|
||||
|
||||
self.showOverwrite(!!options.showOverwrite);
|
||||
self.showMakeDefault(!!options.showMakeDefault);
|
||||
|
||||
self.profile.fromProfileData(profile);
|
||||
@@ -405,7 +391,7 @@ $(function () {
|
||||
|
||||
self.confirm = function () {
|
||||
var profile = self.profile.toProfileData();
|
||||
var overwrite = self.overwrite();
|
||||
var overwrite = !self.showOverwrite() || self.overwrite();
|
||||
var makeDefault = self.showMakeDefault() && self.makeDefault();
|
||||
|
||||
OctoPrint.connectionprofiles
|
||||
@@ -495,6 +481,19 @@ $(function () {
|
||||
self.availablePrinterProfiles = ko.observableArray();
|
||||
self.selectedPrinter = ko.observable();
|
||||
self.preferredPrinter = ko.observable();
|
||||
self.printerProfileLookup = {};
|
||||
|
||||
self.availablePrinterProfiles.subscribe(function () {
|
||||
self.printerProfileLookup = {};
|
||||
_.each(self.availablePrinterProfiles(), function (profile) {
|
||||
self.printerProfileLookup[profile.id] = profile;
|
||||
});
|
||||
});
|
||||
|
||||
self.lookupPrinterProfileName = function (id) {
|
||||
var profile = self.printerProfileLookup[id];
|
||||
return profile ? profile.name : id;
|
||||
};
|
||||
|
||||
// Protocols
|
||||
|
||||
@@ -507,6 +506,14 @@ $(function () {
|
||||
self.showAdvancedProtocolOptions = function () {
|
||||
$("#connection_protocol_dialog").modal("show");
|
||||
};
|
||||
self.protocolLookup = {};
|
||||
|
||||
self.availableProtocols.subscribe(function () {
|
||||
self.protocolLookup = {};
|
||||
_.each(self.availableProtocols(), function (protocol) {
|
||||
self.protocolLookup[protocol.key] = protocol;
|
||||
});
|
||||
});
|
||||
|
||||
self.selectedProtocol.subscribe(function () {
|
||||
var protocol = self.selectedProtocol();
|
||||
@@ -528,6 +535,11 @@ $(function () {
|
||||
);
|
||||
});
|
||||
|
||||
self.lookupProtocolName = function (key) {
|
||||
var protocol = self.protocolLookup[key];
|
||||
return protocol ? protocol.name : key;
|
||||
};
|
||||
|
||||
// Transports
|
||||
|
||||
self.availableTransports = ko.observableArray();
|
||||
@@ -539,6 +551,14 @@ $(function () {
|
||||
self.showAdvancedTransportOptions = function () {
|
||||
$("#connection_transport_dialog").modal("show");
|
||||
};
|
||||
self.transportLookup = {};
|
||||
|
||||
self.availableTransports.subscribe(function () {
|
||||
self.transportLookup = {};
|
||||
_.each(self.availableTransports(), function (transport) {
|
||||
self.transportLookup[transport.key] = transport;
|
||||
});
|
||||
});
|
||||
|
||||
self.selectedTransport.subscribe(function () {
|
||||
var transport = self.selectedTransport();
|
||||
@@ -560,14 +580,12 @@ $(function () {
|
||||
);
|
||||
});
|
||||
|
||||
// Profile editor
|
||||
self.lookupTransportName = function (key) {
|
||||
var transport = self.transportLookup[key];
|
||||
return transport ? transport.name : key;
|
||||
};
|
||||
|
||||
self.editor = new ConnectionProfileEditorViewModel([
|
||||
self.availablePrinterProfiles,
|
||||
self.availableProtocols,
|
||||
self.availableTransports,
|
||||
self.cleanProfile
|
||||
]);
|
||||
// Profile editor
|
||||
|
||||
self.cleanProfile = function () {
|
||||
return {
|
||||
@@ -581,6 +599,8 @@ $(function () {
|
||||
};
|
||||
};
|
||||
|
||||
self.editor = new ConnectionProfileEditorViewModel(self);
|
||||
|
||||
// Various other bits
|
||||
|
||||
self.adjustConnectionParameters = ko.observable();
|
||||
@@ -605,6 +625,8 @@ $(function () {
|
||||
|
||||
self.refreshVisible = ko.observable(true);
|
||||
|
||||
// Data exchange
|
||||
|
||||
self.requestData = function () {
|
||||
if (!self.loginState.hasPermission(self.access.permissions.CONNECTION)) {
|
||||
return;
|
||||
@@ -621,18 +643,6 @@ $(function () {
|
||||
|
||||
//~~ Available options...
|
||||
|
||||
// connection profiles
|
||||
var connections = response.options.connectionProfiles;
|
||||
_.each(connections, function (c) {
|
||||
c.isDefault = ko.pureComputed(function () {
|
||||
return c.id === self.preferredConnectionProfile();
|
||||
});
|
||||
c.isCurrent = ko.pureComputed(function () {
|
||||
return c.id === self.selectedConnectionProfile();
|
||||
});
|
||||
});
|
||||
self.availableConnectionProfiles(connections);
|
||||
|
||||
// printer profiles
|
||||
var printers = response.options.printerProfiles;
|
||||
_.each(printers, function (p) {
|
||||
@@ -675,6 +685,18 @@ $(function () {
|
||||
|
||||
self.availableTransports(transports);
|
||||
|
||||
// connection profiles
|
||||
var connections = response.options.connectionProfiles;
|
||||
_.each(connections, function (c) {
|
||||
c.isDefault = ko.pureComputed(function () {
|
||||
return c.id === self.preferredConnectionProfile();
|
||||
});
|
||||
c.isCurrent = ko.pureComputed(function () {
|
||||
return c.id === self.selectedConnectionProfile();
|
||||
});
|
||||
});
|
||||
self.availableConnectionProfiles(connections);
|
||||
|
||||
//~~ Currently active config
|
||||
|
||||
var connectionKey = response.current.connection;
|
||||
@@ -816,7 +838,7 @@ $(function () {
|
||||
}
|
||||
|
||||
self.editor
|
||||
.showDialog(profile, {button: gettext("Save & Connect")})
|
||||
.showSaveAsDialog(profile, {button: gettext("Save & Connect")})
|
||||
.done(function (profile) {
|
||||
OctoPrint.connection.connect({connection: profile.id});
|
||||
});
|
||||
@@ -850,6 +872,8 @@ $(function () {
|
||||
}
|
||||
};
|
||||
|
||||
// events
|
||||
|
||||
self.onEventSettingsUpdated = function () {
|
||||
self.requestData();
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ $(function () {
|
||||
"name",
|
||||
[],
|
||||
[],
|
||||
10
|
||||
5
|
||||
);
|
||||
self.defaultProfile = ko.observable();
|
||||
self.currentProfile = ko.observable();
|
||||
@@ -39,8 +39,22 @@ $(function () {
|
||||
self.currentProfile(profileId);
|
||||
});
|
||||
|
||||
self.addProfile = function () {
|
||||
return self.connection.editor.showAddDialog().done(function () {
|
||||
self.requestInProgress(true);
|
||||
self.connection.requestData().always(function () {
|
||||
self.requestInProgress(false);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
self.editProfile = function (data) {
|
||||
self.connection.editor.showEditDialog(data);
|
||||
return self.connection.editor.showEditDialog(data).done(function () {
|
||||
self.requestInProgress(true);
|
||||
self.connection.requestData().always(function () {
|
||||
self.requestInProgress(false);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
self.canMakeDefault = function (data) {
|
||||
@@ -87,6 +101,6 @@ $(function () {
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: ConnectionProfilesViewModel,
|
||||
dependencies: ["connectionViewModel"],
|
||||
elements: ["#settings_connection_connectionprofiles"]
|
||||
elements: ["#settings_connectionProfiles"]
|
||||
});
|
||||
});
|
||||
@@ -446,11 +446,34 @@ table {
|
||||
}
|
||||
|
||||
// Connection profiles
|
||||
&.settings_connectionProfiles_profiles_default {
|
||||
width: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&.settings_connectionProfiles_profiles_name {
|
||||
width: 200px;
|
||||
text-overflow: ellipsis;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
&.settings_connectionProfiles_profiles_details {
|
||||
table.settings_connectionProfiles_profiles_details_table {
|
||||
font-size: 0.8em;
|
||||
margin-bottom: 0;
|
||||
|
||||
.settings_connectionProfiles_profiles_details_key {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.settings_connectionProfiles_profiles_action {
|
||||
width: 80px;
|
||||
.actioncol;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<input class="input-block-level" type="text" data-bind="value: editor.profile.identifier, attr: {placeholder: editor.profile.identifierPlaceholder}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div data-bind="visible: editor.showOverwrite" class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: editor.profile.overwrite"> {{ _('Overwrite existing profile') }}
|
||||
@@ -41,7 +41,7 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div data-bind="visible: editor.showMakeDefault" class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: editor.profile.makeDefault"> {{ _('Make default') }}
|
||||
|
||||
@@ -1,61 +1,20 @@
|
||||
<form class="form-horizontal">
|
||||
<ul class="nav nav-pills">
|
||||
<li class="active"><a href="#settings_connection_general" data-toggle="tab">{{ _('General') }}</a></li>
|
||||
<li><a href="#settings_connection_connectionprofiles" data-toggle="tab">{{ _('Connection profiles') }}</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div id="settings_connection_general" class="tab-pane active">
|
||||
<fieldset id="settings_serial_general_logging">
|
||||
<legend>{{ _('Logging') }}</legend>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: connection_log_connection" id="settings-connectionLogConnection"> {{ _('Log communication to <code>connection.log</code>') }} <span class="label label-important">{{ _('Warning') }}</span>
|
||||
<span class="help-block">{{ _('While this can negatively impact performance, a <code>connection.log</code> can be incredibly useful for debugging any issues observed in the communication between OctoPrint and your printer.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: connection_log_commdebug" id="settings-connectionLogCommdebug"> {{ _('Log debug information about communication to <code>commdebug.log</code>') }} <span class="label label-important">{{ _('Warning') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<!-- ko allowBindings: false -->
|
||||
<div id="settings_connection_connectionprofiles" class="tab-pane">
|
||||
<table class="table table-striped table-hover table-condensed table-hover" id="settings_connectionProfiles_profiles" data-bind="visible: profiles.items().length > 0" style="display: none">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="settings_connectionProfiles_profiles_name">{{ _('Name') }}</th>
|
||||
<th class="settings_connectionProfiles_profiles_action">{{ _('Action') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-bind="foreach: profiles.paginatedItems">
|
||||
<tr data-bind="attr: {title: name}">
|
||||
<td class="settings_connectionProfiles_profiles_name"><span class="fa fa-star" data-bind="invisible: !isDefault()"></span> <span data-bind="text: name"></span></td>
|
||||
<td class="settings_connectionProfiles_profiles_action">
|
||||
<a href="javascript:void(0)" class="fa fa-star" title="{{ _('Set as default profile') }}" data-bind="click: function() { if ($root.canMakeDefault($data) && !$root.requestInProgress()) { $root.makeDefault($data); } }, css: {disabled: !$root.canMakeDefault($data) || $root.requestInProgress()}, enabled: $root.canMakeDefault($data) && !$root.requestInProgress()"></a> | <a href="javascript:void(0)" class="fa fa-pencil" title="{{ _('Edit profile') }}" data-bind="click: function() { if (!$root.requestInProgress()) { $root.editProfile($data); } }, css: {disabled: $root.requestInProgress()}, enabled: !$root.requestInProgress()"></a> | <a href="javascript:void(0)" class="fa fa-trash-o" title="{{ _('Delete Profile') }}" data-bind="click: function() { if ($root.canRemove($data) && !$root.requestInProgress()) { $root.removeProfile($data); } }, css: {disabled: !$root.canRemove($data) || $root.requestInProgress()}, enabled: $root.canRemove($data) && !$root.requestInProgress()"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="pagination pagination-mini pagination-centered">
|
||||
<ul>
|
||||
<li data-bind="css: {disabled: profiles.currentPage() === 0}"><a href="#" data-bind="click: profiles.prevPage">«</a></li>
|
||||
</ul>
|
||||
<ul data-bind="foreach: profiles.pages">
|
||||
<li data-bind="css: { active: $data.number === $root.profiles.currentPage(), disabled: $data.number === -1 }"><a href="#" data-bind="text: $data.text, click: function() { $root.profiles.changePage($data.number); }"></a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li data-bind="css: {disabled: profiles.currentPage() === profiles.lastPage()}"><a href="#" data-bind="click: profiles.nextPage">»</a></li>
|
||||
</ul>
|
||||
<fieldset id="settings_serial_general_logging">
|
||||
<legend>{{ _('Logging') }}</legend>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: connection_log_connection" id="settings-connectionLogConnection"> {{ _('Log communication to <code>connection.log</code>') }} <span class="label label-important">{{ _('Warning') }}</span>
|
||||
<span class="help-block">{{ _('While this can negatively impact performance, a <code>connection.log</code> can be incredibly useful for debugging any issues observed in the communication between OctoPrint and your printer.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<!--/ko-->
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: connection_log_commdebug" id="settings-connectionLogCommdebug"> {{ _('Log debug information about communication to <code>commdebug.log</code>') }} <span class="label label-important">{{ _('Warning') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
@@ -0,0 +1,51 @@
|
||||
<h3>{{ _('Connection Profiles') }}</h3>
|
||||
|
||||
<table class="table table-condensed table-hover" id="settings_connectionProfiles_profiles" data-bind="visible: profiles.items().length > 0" style="display: none">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="settings_connectionProfiles_profiles_default"></th>
|
||||
<th class="settings_connectionProfiles_profiles_name">{{ _('Name') }}</th>
|
||||
<th class="settings_connectionProfiles_profiles_details">{{ _('Details') }}</th>
|
||||
<th class="settings_connectionProfiles_profiles_action">{{ _('Action') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-bind="foreach: profiles.paginatedItems">
|
||||
<tr data-bind="attr: {title: name}">
|
||||
<td class="settings_connectionProfiles_profiles_default"><span class="fa fa-star" data-bind="invisible: !isDefault()"></span></td>
|
||||
<td class="settings_connectionProfiles_profiles_name" data-bind="text: $data.name"></td>
|
||||
<td class="settings_connectionProfiles_profiles_details">
|
||||
<table class="table settings_connectionProfiles_profiles_details_table">
|
||||
<tr>
|
||||
<th class="settings_connectionProfiles_profiles_details_key">{{ _('Printer Profile') }}</th>
|
||||
<td class="settings_connectionProfiles_profiles_details_value" data-bind="text: $root.connection.lookupPrinterProfileName($data.printer_profile)"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="settings_connectionProfiles_profiles_details_key">{{ _('Protocol') }}</th>
|
||||
<td class="settings_connectionProfiles_profiles_details_value" data-bind="text: $root.connection.lookupProtocolName($data.protocol)"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="settings_connectionProfiles_profiles_details_key">{{ _('Transport') }}</th>
|
||||
<td class="settings_connectionProfiles_profiles_details_value" data-bind="text: $root.connection.lookupTransportName($data.transport)"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td class="settings_connectionProfiles_profiles_action">
|
||||
<a href="javascript:void(0)" class="fa fa-star" title="{{ _('Set as default profile') }}" data-bind="click: function() { if ($root.canMakeDefault($data) && !$root.requestInProgress()) { $root.makeDefault($data); } }, css: {disabled: !$root.canMakeDefault($data) || $root.requestInProgress()}, enabled: $root.canMakeDefault($data) && !$root.requestInProgress()"></a> | <a href="javascript:void(0)" class="fa fa-pencil" title="{{ _('Edit profile') }}" data-bind="click: function() { if (!$root.requestInProgress()) { $root.editProfile($data); } }, css: {disabled: $root.requestInProgress()}, enabled: !$root.requestInProgress()"></a> | <a href="javascript:void(0)" class="fa fa-trash-o" title="{{ _('Delete Profile') }}" data-bind="click: function() { if ($root.canRemove($data) && !$root.requestInProgress()) { $root.removeProfile($data); } }, css: {disabled: !$root.canRemove($data) || $root.requestInProgress()}, enabled: $root.canRemove($data) && !$root.requestInProgress()"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="pagination pagination-mini pagination-centered">
|
||||
<ul>
|
||||
<li data-bind="css: {disabled: profiles.currentPage() === 0}"><a href="#" data-bind="click: profiles.prevPage">«</a></li>
|
||||
</ul>
|
||||
<ul data-bind="foreach: profiles.pages">
|
||||
<li data-bind="css: { active: $data.number === $root.profiles.currentPage(), disabled: $data.number === -1 }"><a href="#" data-bind="text: $data.text, click: function() { $root.profiles.changePage($data.number); }"></a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li data-bind="css: {disabled: profiles.currentPage() === profiles.lastPage()}"><a href="#" data-bind="click: profiles.nextPage">»</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<button class="btn pull-right" data-bind="click: function() { $root.addProfile(); }"><i class="fas fa-plus"></i> {{ _('Add Profile...') }}</button>
|
||||
@@ -1,4 +1,4 @@
|
||||
<table class="table table-striped table-hover table-condensed table-hover" id="settings_printerProfiles_profiles" data-bind="visible: printerProfiles.profiles.items().length > 0" style="display: none">
|
||||
<table class="table table-condensed table-hover" id="settings_printerProfiles_profiles" data-bind="visible: printerProfiles.profiles.items().length > 0" style="display: none">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="settings_printerProfiles_profiles_name">{{ _('Name') }}</th>
|
||||
|
||||
Reference in new issue
Block a user