diff --git a/public/locales/en/common.json b/public/locales/en/common.json
index d05c8921..0aa94d5f 100644
--- a/public/locales/en/common.json
+++ b/public/locales/en/common.json
@@ -423,8 +423,6 @@
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",
- "job_time_elapsed": "Elpased",
- "job_time_left": "Left",
"job_completion": "Completion"
}
}
diff --git a/src/widgets/octoPrint/component.jsx b/src/widgets/octoPrint/component.jsx
index 91890a60..9ba9d5fe 100644
--- a/src/widgets/octoPrint/component.jsx
+++ b/src/widgets/octoPrint/component.jsx
@@ -2,22 +2,6 @@ import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import useWidgetAPI from "utils/proxy/use-widget-api";
-const formatSecs = (totalSecs) => {
- let secs = totalSecs;
- const days = Math.floor(secs / 86400);
- secs -= days * 86400;
- let hours = Math.floor(secs / 3600);
- secs -= hours * 3600;
- let mins = Math.floor(secs / 60);
- secs -= mins * 60;
-
- if (hours < 10) hours = `0${hours}`;
- if (mins < 10) mins = `0${mins}`;
- if (secs < 10) secs = `0${secs}`;
-
- return days === 0 ? `${hours}:${mins}:${secs}` : `${days}:${hours}:${mins}:${secs}`;
-};
-
export default function Component({ service }) {
const { widget } = service;
@@ -32,7 +16,15 @@ export default function Component({ service }) {
return ;
}
- if (!printerStats) {
+ if (jobStatsError) {
+ return ;
+ }
+
+ const state = printerStats?.state?.text;
+ const tempTool = printerStats?.temperature?.tool0?.actual;
+ const tempBed = printerStats?.temperature?.bed?.actual;
+
+ if (!printerStats || !state || !tempTool || !tempBed) {
return (
@@ -40,46 +32,27 @@ export default function Component({ service }) {
);
}
- const state = printerStats.state.text;
-
- if (state === "Not found" || Object.entries(printerStats.temperature).length === 0) {
- return (
-
-
-
- );
- }
-
if (state === "Printing" || state === "Paused") {
- if (jobStatsError) {
- return ;
- }
+ const { completion } = jobStats.progress;
- const { printTimeLeft, printTime, completion } = jobStats.progress;
-
- if (!jobStats || !printTimeLeft || !printTime || !completion) {
+ if (!jobStats || !completion) {
return (
-
-
+
+
+
);
}
return (
- <>
-
-
-
-
-
-
-
-
-
-
- >
+
+
+
+
+
+
);
}
diff --git a/src/widgets/octoPrint/proxy.js b/src/widgets/octoPrint/proxy.js
deleted file mode 100644
index e634b9dd..00000000
--- a/src/widgets/octoPrint/proxy.js
+++ /dev/null
@@ -1,58 +0,0 @@
-import getServiceWidget from "utils/config/service-helpers";
-import { formatApiCall } from "utils/proxy/api-helpers";
-import validateWidgetData from "utils/proxy/validate-widget-data";
-import { httpProxy } from "utils/proxy/http";
-import createLogger from "utils/logger";
-import widgets from "widgets/widgets";
-
-const logger = createLogger("octoPrintProxyHandler");
-
-export default async function octoPrintProxyHandler(req, res, map) {
- const { group, service, endpoint } = req.query;
-
- if (group && service) {
- const widget = await getServiceWidget(group, service);
-
- if (!widgets?.[widget.type]?.api) {
- return res.status(403).json({ error: "Service does not support API calls" });
- }
-
- if (widget) {
- const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget }));
-
- const [status, contentType, data] = await httpProxy(url, {
- method: req.method,
- });
-
- let resultData = data;
-
- if (!validateWidgetData(widget, endpoint, resultData)) {
- if ((status === 500 || status === 502 || status === 409) && widget.silencePrinterNotFound) {
- resultData = { state: { text: "Not found" } };
- return res.status(status).send(resultData);
- }
- return res.status(status).json({ error: { message: "Invalid data", url, data: resultData } });
- }
-
- if (status === 200 && map) {
- resultData = map(data);
- }
-
- if (contentType) res.setHeader("Content-Type", contentType);
-
- if (status === 204 || status === 304) {
- return res.status(status).end();
- }
-
- if (status >= 400) {
- logger.debug("HTTP Error %d calling %s//%s%s...", status, url.protocol, url.hostname, url.pathname);
- return res.status(status).json({ error: { message: "HTTP Error", url, data } });
- }
-
- return res.status(status).send(resultData);
- }
- }
-
- logger.debug("Invalid or missing proxy service type '%s' in group '%s'", service, group);
- return res.status(400).json({ error: "Invalid proxy service type" });
-}
diff --git a/src/widgets/octoPrint/widget.js b/src/widgets/octoPrint/widget.js
index 850de605..591c1dae 100644
--- a/src/widgets/octoPrint/widget.js
+++ b/src/widgets/octoPrint/widget.js
@@ -1,8 +1,8 @@
-import octoPrintProxyHandler from "./proxy";
+import genericProxyHandler from "utils/proxy/handlers/generic";
const widget = {
api: "{url}/api/{endpoint}?apikey={key}",
- proxyHandler: octoPrintProxyHandler,
+ proxyHandler: genericProxyHandler,
mappings: {
printer_stats: {