Add application button for temperature profiles
Add "setTargetFromProfile" and "setTargetToZero" wrapper for setting entire profiles Add helper function to retrieve the temperature profiles description
This commit is contained in:
1 parent
a01128b273
commit
ca493459b3
5 files changed
+78
-1
No files matched your search
@@ -121,6 +121,7 @@ date of first contribution):
|
||||
* [Josh Friend](https://github.com/joshfriend)
|
||||
* [Lachlan Cresswell](https://github.com/lachyc)
|
||||
* [Khoi Pham](https://github.com/osubuu)
|
||||
* [Federico Nembrini](https://github.com/FedericoNembrini)
|
||||
|
||||
OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
|
||||
[Daid Braam](https://github.com/daid). Parts of its communication layer and
|
||||
|
||||
@@ -621,6 +621,23 @@ function formatTemperature(temp, showF, offThreshold) {
|
||||
}
|
||||
}
|
||||
|
||||
// Return the temperatures string from the given temperature profile
|
||||
function formatTemperatureProfileDescription(temperatureProfile, hasBed, hasChamber) {
|
||||
if(temperatureProfile === undefined) return "-";
|
||||
|
||||
var temperatureProfileDescription = gettext("Extruder") + ": " + formatTemperature(temperatureProfile.extruder);
|
||||
|
||||
if(hasBed) {
|
||||
temperatureProfileDescription += " - " + gettext("Bed") + ": " + formatTemperature(temperatureProfile.bed);
|
||||
}
|
||||
|
||||
if(hasChamber) {
|
||||
temperatureProfileDescription += " - " + gettext("Chamber") + ": " + formatTemperature(temperatureProfile.chamber);
|
||||
}
|
||||
|
||||
return temperatureProfileDescription;
|
||||
}
|
||||
|
||||
function formatNumberK(num) {
|
||||
if (num > 1000) {
|
||||
num = num / 1000.0;
|
||||
|
||||
@@ -616,6 +616,26 @@ $(function() {
|
||||
return self.setTargetToValue(item, value);
|
||||
};
|
||||
|
||||
// Wrapper of self.setTargetFromProfile() to apply all the temperature from a temperature profile
|
||||
self.setTargetsFromProfile = function(temperatureProfile) {
|
||||
if(temperatureProfile === undefined) {
|
||||
console.log("temperatureProfile is undefined!");
|
||||
return;
|
||||
}
|
||||
|
||||
if(self.hasBed()) {
|
||||
self.setTargetFromProfile(self.bedTemp, temperatureProfile);
|
||||
}
|
||||
|
||||
if(self.hasChamber()) {
|
||||
self.setTargetFromProfile(self.chamberTemp, temperatureProfile);
|
||||
}
|
||||
|
||||
self.tools().forEach(function(element) {
|
||||
self.setTargetFromProfile(element, temperatureProfile);
|
||||
});
|
||||
};
|
||||
|
||||
self.setTargetFromProfile = function(item, profile) {
|
||||
if (!profile) return OctoPrintClient.createRejectedDeferred();
|
||||
|
||||
@@ -634,6 +654,21 @@ $(function() {
|
||||
return self.setTargetToValue(item, target);
|
||||
};
|
||||
|
||||
// Wrapper of self.setTargetToZero() to set off all the temperatures
|
||||
self.setTargetsToZero = function() {
|
||||
if(self.hasBed()) {
|
||||
self.setTargetToZero(self.bedTemp);
|
||||
}
|
||||
|
||||
if(self.hasChamber()) {
|
||||
self.setTargetToZero(self.chamberTemp);
|
||||
}
|
||||
|
||||
self.tools().forEach(function(element) {
|
||||
self.setTargetToZero(element);
|
||||
});
|
||||
};
|
||||
|
||||
self.setTargetToZero = function(item) {
|
||||
self.clearAutosendTarget(item);
|
||||
return self.setTargetToValue(item, 0);
|
||||
|
||||
@@ -487,6 +487,14 @@ table {
|
||||
&.temperature_target {
|
||||
width: 42%;
|
||||
overflow: visible;
|
||||
|
||||
& > span {
|
||||
line-height: 1.9em;
|
||||
}
|
||||
|
||||
& > .btn-group {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
|
||||
&.temperature_offset {
|
||||
|
||||
@@ -9,7 +9,23 @@
|
||||
<tr>
|
||||
<th class="temperature_tool"></th>
|
||||
<th class="temperature_actual" title="{{ _('Current actual temperature as reported by your printer')|edq }}">{{ _('Actual') }}</th>
|
||||
<th class="temperature_target" title="{{ _('Current target temperature as reported by your printer')|edq }}">{{ _('Target') }}</th>
|
||||
<th class="temperature_target">
|
||||
<span title="{{ _('Current target temperature as reported by your printer')|edq }}">{{ _('Target') }}</span>
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-small dropdown-toggle" title="{{ _('Set temperature profile')|edq }}" data-toggle="dropdown" data-bind="enable: $root.isOperational() && $root.loginState.hasPermissionKo($root.access.permissions.CONTROL)()"><i class="fa fa-wrench"></i> <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="javascript:void(0)" data-bind="click: $root.setTargetsToZero">{{ _('Off') }}</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<!-- ko foreach: $root.temperature_profiles -->
|
||||
<li>
|
||||
<a href="javascript:void(0)" data-bind="click: function() { $root.setTargetsFromProfile($data);}, text: $data.name, attr: {title: formatTemperatureProfileDescription($data, $root.hasBed(), $root.hasChamber())}"></a>
|
||||
</li>
|
||||
<!-- /ko -->
|
||||
</ul>
|
||||
</div>
|
||||
</th>
|
||||
<th class="temperature_offset" title="{{ _('Offset to apply to temperature commands sent from files')|edq }}">{{ _('Offset') }}</th>
|
||||
</tr>
|
||||
<!-- ko foreach: tools -->
|
||||
|
||||
Reference in new issue
Block a user