Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: prusa3d/Prusa-Link-Web
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6a3135e79b25eeb3afe402060ab9ac6e99176bef
Choose a base ref
..
head repository: prusa3d/Prusa-Link-Web
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5a30485e2bb2a36cc98253a2c38a577f11813288
Choose a head ref
Showing with 11 additions and 4 deletions.
  1. +1 −1 src/printer/components/files.js
  2. +4 −2 src/printer/components/job.js
  3. +6 −1 src/state.js
2 changes: 1 addition & 1 deletion src/printer/components/files.js
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ function getCurrentApiPath(fileName) {
return getApiPath(storage.path, path, fileName);
}

function getApiPath(origin, path, file) {
export function getApiPath(origin, path, file) {
const apiPath = ["/api/v1/files", origin, path, file].filter((e) => !!e)
.join("/");

6 changes: 4 additions & 2 deletions src/printer/components/job.js
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ import { resinRefill } from "../views/refill";
import { JobPendingStates, LinkState, OperationalStates } from "../../state";
import { setButtonLoading, unsetButtonLoading } from "../../helpers/button";
import printer from "..";
import { getApiPath } from "./files";

let pendingCommand = null;
let pendingDownload = null;
@@ -228,7 +229,7 @@ function setupCancelButton(state, jobId) {

if (btnStop) {
if (jobId) {
const isVisible = jobId && ![LinkState.REFILL, LinkState.POUR_IN_RESIN].includes(state);
const isVisible = jobId && ![LinkState.REFILL, LinkState.POUR_IN_RESIN, LinkState.SELECTED].includes(state);
setVisible(btnStop, isVisible);
btnStop.onclick = () => {
cancelJob(jobId, {
@@ -251,11 +252,12 @@ function setupCancelButton(state, jobId) {
function setupStartButton(state, file, jobId) {
const btn = document.querySelector("#job #start");
const actionAllowed = OperationalStates.includes(state);
const url = `/api/v1/files${file.resource}`;

if (btn) {
setVisible(btn, actionAllowed);
setEnabled(btn, actionAllowed);
btn.onclick = () => startJob(state !== LinkState.READY, file.resource);
btn.onclick = () => startJob(state !== LinkState.READY, url);
}
}

7 changes: 6 additions & 1 deletion src/state.js
Original file line number Diff line number Diff line change
@@ -12,10 +12,11 @@ export const LinkState = {
PAUSED: "PAUSED",
FINISHED: "FINISHED",
STOPPED: "STOPPED",
SELECTED: "SELECTED",
ERROR: "ERROR",
ATTENTION: "ATTENTION",
fromApi: (linkState) => {
switch (linkState) {
switch (linkState.toUpperCase()) {
case "IDLE": return LinkState.IDLE;
case "READY": return LinkState.READY;
case "BUSY": return LinkState.BUSY;
@@ -28,6 +29,8 @@ export const LinkState = {
// sla specific
case "POUR IN RESIN": return LinkState.POUR_IN_RESIN;
case "FEED ME": return LinkState.REFILL;
case "SELECTED": return LinkState.SELECTED;
case "UNKNOWN": return LinkState.UNKNOWN;
default:
console.error(`Unsupported state: ${linkState}`);
return LinkState.UNKNOWN;
@@ -39,6 +42,7 @@ export const OperationalStates = [
LinkState.IDLE,
LinkState.READY,
LinkState.FINISHED,
LinkState.SELECTED,
];

export const JobPendingStates = [
@@ -59,6 +63,7 @@ export const translateState = (state) => {
case LinkState.ERROR: return translate("prop.st-error");
case LinkState.ATTENTION: return translate("prop.st-attention");
case LinkState.POUR_IN_RESIN: return translate("prop.st-pour-resin");
case LinkState.SELECTED: return translate("prop.st-ready");
case LinkState.REFILL: return translate("prop.st-feedme");
default:
console.error(`Unsupported state: ${state}`);