46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
import * as helpers from "./helpers.js";
|
|
import * as ui from "./ui.js";
|
|
|
|
export function load() {
|
|
RecoverPrinterInfos();
|
|
}
|
|
|
|
export function RecoverPrinterInfos() {
|
|
const temperaturesRoute = 'http://192.168.50.239/api/printer';
|
|
helpers.fetchData(temperaturesRoute).then(data => {
|
|
ui.DisplayTemperatures(data);
|
|
})
|
|
.catch(error => {
|
|
console.error(error);
|
|
});
|
|
}
|
|
|
|
export function RecoverJobInfos() {
|
|
let url = "http://192.168.50.239/api/job";
|
|
helpers.fetchData(url).then(data => {
|
|
ui.DisplayJob(data);
|
|
})
|
|
.catch(error => {
|
|
console.error(error);
|
|
});
|
|
}
|
|
|
|
export function setNewBedTemps(temp) {
|
|
let url = "http://192.168.50.239/api/printer/bed";
|
|
let json = {
|
|
"command": "target",
|
|
"target": temp
|
|
}
|
|
helpers.sendPostRequest(url, json);
|
|
}
|
|
|
|
export function setNewHotEndTemps(temp) {
|
|
let url = "http://192.168.50.239/api/printer/tool";
|
|
let json = {
|
|
"command": "target",
|
|
"targets": {
|
|
"tool0": temp
|
|
}
|
|
}
|
|
helpers.sendPostRequest(url, json);
|
|
} |