parent
84ff4b6416
commit
94b8d6601d
|
@ -42,67 +42,15 @@ $(function() {
|
|||
'margin-left': function() { return -($(this).width() /2); }
|
||||
});
|
||||
return false;
|
||||
})
|
||||
});
|
||||
|
||||
//~~ Temperature control (should really move to knockout click binding)
|
||||
//~~ Temperature
|
||||
|
||||
$("#temp_newTemp_set").click(function() {
|
||||
var newTemp = $("#temp_newTemp").val();
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/temperature",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: { temp: newTemp },
|
||||
success: function() {$("#temp_newTemp").val("")}
|
||||
})
|
||||
})
|
||||
$("#temp_newBedTemp_set").click(function() {
|
||||
var newBedTemp = $("#temp_newBedTemp").val();
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/temperature",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: { bedTemp: newBedTemp },
|
||||
success: function() {$("#temp_newBedTemp").val("")}
|
||||
})
|
||||
})
|
||||
$('#tabs a[data-toggle="tab"]').on('shown', function (e) {
|
||||
temperatureViewModel.updatePlot();
|
||||
terminalViewModel.updateOutput();
|
||||
});
|
||||
|
||||
//~~ Terminal
|
||||
|
||||
$("#terminal-send").click(function () {
|
||||
var command = $("#terminal-command").val();
|
||||
|
||||
/*
|
||||
var re = /^([gm][0-9]+)(\s.*)?/;
|
||||
var commandMatch = command.match(re);
|
||||
if (commandMatch != null) {
|
||||
command = commandMatch[1].toUpperCase() + ((commandMatch[2] !== undefined) ? commandMatch[2] : "");
|
||||
}
|
||||
*/
|
||||
|
||||
if (command) {
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/command",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify({"command": command})
|
||||
})
|
||||
$("#terminal-command").val('')
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
$("#terminal-command").keyup(function (event) {
|
||||
if (event.keyCode == 13) {
|
||||
$("#terminal-send").click()
|
||||
}
|
||||
})
|
||||
|
||||
//~~ Gcode upload
|
||||
|
||||
function gcode_upload_done(e, data) {
|
||||
|
|
|
@ -18,6 +18,7 @@ function LoginStateViewModel() {
|
|||
|
||||
self.subscribers = [];
|
||||
self.subscribe = function(callback) {
|
||||
if (callback === undefined) return;
|
||||
self.subscribers.push(callback);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@ function TemperatureViewModel(loginStateViewModel, settingsViewModel) {
|
|||
self.targetTemp = ko.observable(undefined);
|
||||
self.bedTargetTemp = ko.observable(undefined);
|
||||
|
||||
self.newTemp = ko.observable(undefined);
|
||||
self.newBedTemp = ko.observable(undefined);
|
||||
|
||||
self.isErrorOrClosed = ko.observable(undefined);
|
||||
self.isOperational = ko.observable(undefined);
|
||||
self.isPrinting = ko.observable(undefined);
|
||||
|
@ -18,38 +21,6 @@ function TemperatureViewModel(loginStateViewModel, settingsViewModel) {
|
|||
|
||||
self.temperature_profiles = settingsViewModel.temperature_profiles;
|
||||
|
||||
self.setTempFromProfile = function(profile) {
|
||||
if (!profile)
|
||||
return;
|
||||
self.setTemp(profile.extruder);
|
||||
}
|
||||
|
||||
self.setTemp = function(temp) {
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/temperature",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: { temp: temp },
|
||||
success: function() {$("#temp_newTemp").val("")}
|
||||
})
|
||||
};
|
||||
|
||||
self.setBedTempFromProfile = function(profile) {
|
||||
if (!profile)
|
||||
return;
|
||||
self.setBedTemp(profile.bed);
|
||||
}
|
||||
|
||||
self.setBedTemp = function(bedTemp) {
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/temperature",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: { bedTemp: bedTemp },
|
||||
success: function() {$("#temp_newBedTemp").val("")}
|
||||
})
|
||||
};
|
||||
|
||||
self.tempString = ko.computed(function() {
|
||||
if (!self.temp())
|
||||
return "-";
|
||||
|
@ -172,4 +143,45 @@ function TemperatureViewModel(loginStateViewModel, settingsViewModel) {
|
|||
]
|
||||
$.plot($("#temperature-graph"), data, self.plotOptions);
|
||||
}
|
||||
|
||||
self.setTempFromProfile = function(profile) {
|
||||
if (!profile)
|
||||
return;
|
||||
self._updateTemperature(profile.extruder, "temp");
|
||||
}
|
||||
|
||||
self.setTemp = function() {
|
||||
self._updateTemperature(self.newTemp(), "temp", function(){self.targetTemp(self.newTemp()); self.newTemp("");});
|
||||
};
|
||||
|
||||
self.setBedTempFromProfile = function(profile) {
|
||||
self._updateTemperature(profile.bed, "bedTemp");
|
||||
}
|
||||
|
||||
self.setBedTemp = function() {
|
||||
self._updateTemperature(self.newBedTemp(), "bedTemp", function() {self.bedTargetTemp(self.newBedTemp()); self.newBedTemp("");});
|
||||
};
|
||||
|
||||
self._updateTemperature = function(temp, type, callback) {
|
||||
var data = {};
|
||||
data[type] = temp;
|
||||
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/temperature",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: data,
|
||||
success: function() { if (callback !== undefined) callback(); }
|
||||
})
|
||||
}
|
||||
|
||||
self.handleEnter = function(event, type) {
|
||||
if (event.keyCode == 13) {
|
||||
if (type == "temp") {
|
||||
self.setTemp();
|
||||
} else if (type == "bedTemp") {
|
||||
self.setBedTemp();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ function TerminalViewModel(loginStateViewModel) {
|
|||
|
||||
self.log = [];
|
||||
|
||||
self.command = ko.observable(undefined);
|
||||
|
||||
self.isErrorOrClosed = ko.observable(undefined);
|
||||
self.isOperational = ko.observable(undefined);
|
||||
self.isPrinting = ko.observable(undefined);
|
||||
|
@ -80,4 +82,32 @@ function TerminalViewModel(loginStateViewModel) {
|
|||
container.scrollTop(container[0].scrollHeight - container.height())
|
||||
}
|
||||
}
|
||||
|
||||
self.sendCommand = function() {
|
||||
/*
|
||||
var re = /^([gm][0-9]+)(\s.*)?/;
|
||||
var commandMatch = command.match(re);
|
||||
if (commandMatch != null) {
|
||||
command = commandMatch[1].toUpperCase() + ((commandMatch[2] !== undefined) ? commandMatch[2] : "");
|
||||
}
|
||||
*/
|
||||
|
||||
var command = self.command();
|
||||
if (command) {
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/command",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify({"command": command})
|
||||
});
|
||||
self.command("");
|
||||
}
|
||||
}
|
||||
|
||||
self.handleEnter = function(event) {
|
||||
if (event.keyCode == 13) {
|
||||
self.sendCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -259,11 +259,11 @@
|
|||
<div style="display: none;" data-bind="visible: loginState.isUser">
|
||||
<label for="temp_newTemp">New Target</label>
|
||||
<div class="input-append">
|
||||
<input type="text" id="temp_newTemp" data-bind="attr: {placeholder: targetTemp}, enable: isOperational() && loginState.isUser()" class="tempInput">
|
||||
<input type="text" class="input-mini text-right" data-bind="value: newTemp, attr: {placeholder: targetTemp}, enable: isOperational() && loginState.isUser(), event: { keyup: function(d, e) {$root.handleEnter(e, 'temp');} }" class="tempInput">
|
||||
<span class="add-on">°C</span>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button type="submit" class="btn" id="temp_newTemp_set" data-bind="enable: isOperational() && loginState.isUser()">Set</button>
|
||||
<button type="submit" class="btn" data-bind="click: setTemp, enable: isOperational() && loginState.isUser()">Set</button>
|
||||
<button class="btn dropdown-toggle" data-toggle="dropdown" data-bind="enable: isOperational() && loginState.isUser()">
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
|
@ -291,11 +291,11 @@
|
|||
<div style="display: none;" data-bind="visible: loginState.isUser">
|
||||
<label for="temp_newBedTemp">New Target</label>
|
||||
<div class="input-append">
|
||||
<input type="text" id="temp_newBedTemp" data-bind="attr: {placeholder: bedTargetTemp}, enable: isOperational() && loginState.isUser()" class="tempInput">
|
||||
<input type="text" class="input-mini text-right" data-bind="value: newBedTemp, attr: {placeholder: bedTargetTemp}, enable: isOperational() && loginState.isUser(), event: { keyup: function(d, e) {$root.handleEnter(event, 'bedTemp');} }" class="tempInput">
|
||||
<span class="add-on">°C</span>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button type="submit" class="btn" id="temp_newBedTemp_set" data-bind="enable: isOperational() && loginState.isUser()">Set</button>
|
||||
<button type="submit" class="btn" data-bind="click: setBedTemp, enable: isOperational() && loginState.isUser()">Set</button>
|
||||
<button class="btn dropdown-toggle" data-toggle="dropdown" data-bind="enable: isOperational() && loginState.isUser()">
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
|
@ -514,8 +514,8 @@
|
|||
</label>
|
||||
|
||||
<div class="input-append" style="display: none;" data-bind="visible: loginState.isUser">
|
||||
<input type="text" id="terminal-command" data-bind="enable: isOperational() && loginState.isUser()">
|
||||
<button class="btn" type="button" id="terminal-send" data-bind="enable: isOperational() && loginState.isUser()">Send</button>
|
||||
<input type="text" id="terminal-command" data-bind="value: command, event: { keyup: function(d,e) { handleEnter(e); } }, enable: isOperational() && loginState.isUser()">
|
||||
<button class="btn" type="button" id="terminal-send" data-bind="click: sendCommand, enable: isOperational() && loginState.isUser()">Send</button>
|
||||
</div>
|
||||
</div>
|
||||
{% if enableTimelapse %}
|
||||
|
|
Loading…
Reference in New Issue