diff --git a/Dockerfile b/Dockerfile index 48e5d2f3..1d9a4931 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,12 +7,10 @@ WORKDIR /app COPY --link package.json pnpm-lock.yaml* ./ -RUN < config/settings.yaml - NEXT_PUBLIC_BUILDTIME=$BUILDTIME NEXT_PUBLIC_VERSION=$VERSION NEXT_PUBLIC_REVISION=$REVISION npm run build -EOF +SHELL ["/bin/ash", "-xeo", "pipefail", "-c"] +RUN npm run telemetry \ + && mkdir config && echo '---' > config/settings.yaml \ + && NEXT_PUBLIC_BUILDTIME=$BUILDTIME NEXT_PUBLIC_VERSION=$VERSION NEXT_PUBLIC_REVISION=$REVISION npm run build # Production image, copy all the files and run next FROM docker.io/node:18-alpine AS runner @@ -50,12 +46,15 @@ ENV NODE_ENV production WORKDIR /app # Copy files from context (this allows the files to copy before the builder stage is done). -COPY --link package.json next.config.js ./ -COPY --link /public ./public +COPY --link --chown=1000:1000 package.json next.config.js ./ +COPY --link --chown=1000:1000 /public ./public/ # Copy files from builder -COPY --link --from=builder /app/.next/standalone ./ -COPY --link --from=builder /app/.next/static/ ./.next/static/ +COPY --link --from=builder --chown=1000:1000 /app/.next/standalone ./ +COPY --link --from=builder --chown=1000:1000 /app/.next/static/ ./.next/static/ +COPY --link --chmod=755 docker-entrypoint.sh /usr/local/bin/ + +RUN apk add --no-cache su-exec ENV PORT 3000 EXPOSE $PORT @@ -63,4 +62,5 @@ EXPOSE $PORT HEALTHCHECK --interval=10s --timeout=3s --start-period=20s \ CMD wget --no-verbose --tries=1 --spider --no-check-certificate http://localhost:$PORT/api/healthcheck || exit 1 +ENTRYPOINT ["docker-entrypoint.sh"] CMD ["node", "server.js"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 5603d7e5..bf443461 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -2,8 +2,22 @@ set -e +# Default to root, so old installations won't break +export PUID=${PUID:-0} +export PGID=${PGID:-0} + # This is in attempt to preserve the original behavior of the Dockerfile, # while also supporting the lscr.io /config directory [ ! -d "/app/config" ] && ln -s /config /app/config -node server.js +# Set privileges for /app but only if pid 1 user is root and we are dropping privileges. +# If container is run as an unprivileged user, it means owner already handled ownership setup on their own. +# Running chown in that case (as non-root) will cause error +[ "$(id -u)" == "0" ] && [ "${PUID}" != "0" ] && chown -R ${PUID}:${PGID} /app + +# Drop privileges (when asked to) if root, otherwise run as current user +if [ "$(id -u)" == "0" ] && [ "${PUID}" != "0" ]; then + su-exec ${PUID}:${PGID} "$@" +else + exec "$@" +fi diff --git a/public/locales/ar/common.json b/public/locales/ar/common.json index bcdc306e..94a4525a 100644 --- a/public/locales/ar/common.json +++ b/public/locales/ar/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/bg/common.json b/public/locales/bg/common.json index aeb2fdb7..e20e0a25 100644 --- a/public/locales/bg/common.json +++ b/public/locales/bg/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/ca/common.json b/public/locales/ca/common.json index ff08ff99..db7cdd5c 100644 --- a/public/locales/ca/common.json +++ b/public/locales/ca/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/cs/common.json b/public/locales/cs/common.json index 5d404844..1edeab46 100644 --- a/public/locales/cs/common.json +++ b/public/locales/cs/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/da/common.json b/public/locales/da/common.json index d818bd5c..eadf268f 100644 --- a/public/locales/da/common.json +++ b/public/locales/da/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/de/common.json b/public/locales/de/common.json index 89ba1e7d..9cbd6f2a 100644 --- a/public/locales/de/common.json +++ b/public/locales/de/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 55edf803..d9f2a53f 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -424,7 +424,7 @@ "print_progress": "Progress", "layers": "Layers" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/eo/common.json b/public/locales/eo/common.json index c6904e37..783533bf 100644 --- a/public/locales/eo/common.json +++ b/public/locales/eo/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/es/common.json b/public/locales/es/common.json index e38f2323..5b7ea7b0 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -415,10 +415,10 @@ "queued": "A la espera", "series": "Serie" }, - "octoPrint": { + "octoprint": { + "temp_bed": "Bed temp", "printer_state": "Status", "temp_tool": "Tool temp", - "temp_bed": "Bed temp", "job_completion": "Completion" } } diff --git a/public/locales/fi/common.json b/public/locales/fi/common.json index cf2dfa58..02ef5c8d 100644 --- a/public/locales/fi/common.json +++ b/public/locales/fi/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/fr/common.json b/public/locales/fr/common.json index efc10a41..c8b60225 100644 --- a/public/locales/fr/common.json +++ b/public/locales/fr/common.json @@ -415,7 +415,7 @@ "queued": "En attente", "series": "Séries" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/he/common.json b/public/locales/he/common.json index 057cdafa..993f3afd 100644 --- a/public/locales/he/common.json +++ b/public/locales/he/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/hi/common.json b/public/locales/hi/common.json index 5cc8dd16..3cd43358 100644 --- a/public/locales/hi/common.json +++ b/public/locales/hi/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/hr/common.json b/public/locales/hr/common.json index aa47cd15..886b0791 100644 --- a/public/locales/hr/common.json +++ b/public/locales/hr/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/hu/common.json b/public/locales/hu/common.json index 6f668aff..c77aa79a 100644 --- a/public/locales/hu/common.json +++ b/public/locales/hu/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/it/common.json b/public/locales/it/common.json index 845d3427..b53bfc93 100644 --- a/public/locales/it/common.json +++ b/public/locales/it/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/ja/common.json b/public/locales/ja/common.json index 4704baa1..bc493fcb 100644 --- a/public/locales/ja/common.json +++ b/public/locales/ja/common.json @@ -415,10 +415,10 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { + "temp_bed": "Bed temp", "printer_state": "Status", "temp_tool": "Tool temp", - "temp_bed": "Bed temp", "job_completion": "Completion" } } diff --git a/public/locales/lv/common.json b/public/locales/lv/common.json index 03830336..4c9b7487 100644 --- a/public/locales/lv/common.json +++ b/public/locales/lv/common.json @@ -415,7 +415,7 @@ "print_progress": "Progress", "layers": "Layers" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/ms/common.json b/public/locales/ms/common.json index ce612966..04144e8a 100644 --- a/public/locales/ms/common.json +++ b/public/locales/ms/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/nb-NO/common.json b/public/locales/nb-NO/common.json index 8955bdcd..22fe7057 100644 --- a/public/locales/nb-NO/common.json +++ b/public/locales/nb-NO/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/nl/common.json b/public/locales/nl/common.json index db1aadb3..4fc76d08 100644 --- a/public/locales/nl/common.json +++ b/public/locales/nl/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/pl/common.json b/public/locales/pl/common.json index b5610f99..d23d3970 100644 --- a/public/locales/pl/common.json +++ b/public/locales/pl/common.json @@ -394,28 +394,28 @@ "numberOfLeases": "Dzierżawy" }, "xteve": { - "streams_all": "All Streams", - "streams_active": "Active Streams", - "streams_xepg": "XEPG Channels" + "streams_all": "Wszystkie strumienie", + "streams_active": "Aktywne strumienie", + "streams_xepg": "Kanały XEPG" }, "opnsense": { - "cpu": "CPU Load", - "memory": "Active Memory", - "wanUpload": "WAN Upload", - "wanDownload": "WAN Download" + "cpu": "Obciążenie procesora", + "memory": "Pamięć rzeczywista", + "wanUpload": "WAN wysyłanie", + "wanDownload": "WAN pobieranie" }, "moonraker": { - "printer_state": "Printer State", - "print_status": "Print Status", - "print_progress": "Progress", - "layers": "Layers" + "printer_state": "Stan drukarki", + "print_status": "Status wydruku", + "print_progress": "Postęp", + "layers": "Warstwy" }, "medusa": { - "wanted": "Wanted", - "queued": "Queued", - "series": "Series" + "wanted": "Poszukiwane", + "queued": "Zakolejkowane", + "series": "Seria" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/pt-BR/common.json b/public/locales/pt-BR/common.json index ebcf61cc..bfad7706 100644 --- a/public/locales/pt-BR/common.json +++ b/public/locales/pt-BR/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/pt/common.json b/public/locales/pt/common.json index 8a81448c..218967d1 100644 --- a/public/locales/pt/common.json +++ b/public/locales/pt/common.json @@ -424,7 +424,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/ro/common.json b/public/locales/ro/common.json index 0de37484..a1f9983d 100644 --- a/public/locales/ro/common.json +++ b/public/locales/ro/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/ru/common.json b/public/locales/ru/common.json index 2fff4ca0..e0ba440c 100644 --- a/public/locales/ru/common.json +++ b/public/locales/ru/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/sr/common.json b/public/locales/sr/common.json index f424d2f8..a299df63 100644 --- a/public/locales/sr/common.json +++ b/public/locales/sr/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/sv/common.json b/public/locales/sv/common.json index 650b5422..14249d45 100644 --- a/public/locales/sv/common.json +++ b/public/locales/sv/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/te/common.json b/public/locales/te/common.json index aad40d9c..61fb4601 100644 --- a/public/locales/te/common.json +++ b/public/locales/te/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/tr/common.json b/public/locales/tr/common.json index 88c83ac3..401a069f 100644 --- a/public/locales/tr/common.json +++ b/public/locales/tr/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/uk/common.json b/public/locales/uk/common.json index 72435e12..35238330 100644 --- a/public/locales/uk/common.json +++ b/public/locales/uk/common.json @@ -415,7 +415,7 @@ "queued": "У черзі", "series": "Серії" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/vi/common.json b/public/locales/vi/common.json index 6a32f636..c2c4f8ec 100644 --- a/public/locales/vi/common.json +++ b/public/locales/vi/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/yue/common.json b/public/locales/yue/common.json index 5c91c674..b3186da0 100644 --- a/public/locales/yue/common.json +++ b/public/locales/yue/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/zh-CN/common.json b/public/locales/zh-CN/common.json index 72fd7fee..48d01b82 100644 --- a/public/locales/zh-CN/common.json +++ b/public/locales/zh-CN/common.json @@ -415,7 +415,7 @@ "queued": "Queued", "series": "Series" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/public/locales/zh-Hant/common.json b/public/locales/zh-Hant/common.json index 48d8f913..53ea1ef5 100644 --- a/public/locales/zh-Hant/common.json +++ b/public/locales/zh-Hant/common.json @@ -61,20 +61,20 @@ "timeleft": "剩餘時間" }, "rutorrent": { - "active": "Active", - "upload": "上傳", - "download": "下載" + "active": "活動中", + "upload": "上行速率", + "download": "下行速率" }, "radarr": { "movies": "電影", "wanted": "關注中", "queued": "已加入佇列", - "missing": "遺失" + "missing": "缺少" }, "sonarr": { "wanted": "關注中", "queued": "已加入佇列", - "series": "系列" + "series": "影集" }, "readarr": { "wanted": "關注中", @@ -93,13 +93,13 @@ "processing": "處理中" }, "pihole": { - "queries": "查詢數", + "queries": "查詢", "blocked": "已阻擋", "gravity": "Gravity" }, "speedtest": { - "upload": "上行", - "download": "下行", + "upload": "上行速率", + "download": "下行速率", "ping": "Ping" }, "portainer": { @@ -132,23 +132,23 @@ "prowlarr": { "enableIndexers": "索引器", "numberOfGrabs": "抓取", - "numberOfQueries": "查詢數", + "numberOfQueries": "查詢", "numberOfFailGrabs": "抓取失敗", "numberOfFailQueries": "查詢失敗" }, "transmission": { - "download": "下載", - "upload": "上傳", - "leech": "Leech", - "seed": "Seed" + "download": "下行速率", + "upload": "上行速率", + "leech": "未完成下載", + "seed": "已完成下載" }, "jackett": { "configured": "已配置", "errored": "發生錯誤" }, "bazarr": { - "missingEpisodes": "缺失的劇集", - "missingMovies": "缺失的電影" + "missingEpisodes": "缺少的劇集", + "missingMovies": "缺少的電影" }, "lidarr": { "wanted": "關注中", @@ -156,16 +156,16 @@ "albums": "專輯" }, "adguard": { - "queries": "查詢數", + "queries": "查詢", "blocked": "已阻擋", "filtered": "已過濾", "latency": "延遲" }, "qbittorrent": { - "download": "下載", - "upload": "上傳", - "leech": "Leech", - "seed": "Seed" + "download": "下行速率", + "upload": "上行速率", + "leech": "未完成下載", + "seed": "已完成下載" }, "mastodon": { "user_count": "使用者", @@ -216,8 +216,8 @@ "wait": "請稍後" }, "changedetectionio": { - "totalObserved": "Total Observed", - "diffsDetected": "Diffs Detected" + "totalObserved": "總監測數", + "diffsDetected": "偵測到的變更" }, "wmo": { "0-day": "晴", @@ -345,16 +345,16 @@ "total": "全部" }, "deluge": { - "download": "下載", - "upload": "上傳", - "leech": "Leech", - "seed": "Seed" + "download": "下行速率", + "upload": "上行速率", + "leech": "未完成下載", + "seed": "已完成下載" }, "flood": { - "download": "下載", - "upload": "上傳", - "leech": "Leech", - "seed": "Seed" + "download": "下行速率", + "upload": "上行速率", + "leech": "未完成下載", + "seed": "已完成下載" }, "tdarr": { "queue": "佇列", @@ -382,10 +382,10 @@ "connectedSwitches": "已連接的交換器" }, "downloadstation": { - "download": "下載", - "upload": "上傳", - "leech": "Leech", - "seed": "Seed" + "download": "下行速率", + "upload": "上行速率", + "leech": "未完成下載", + "seed": "已完成下載" }, "mikrotik": { "cpuLoad": "CPU負載", @@ -405,17 +405,17 @@ "wanDownload": "WAN下載" }, "moonraker": { - "printer_state": "Printer State", - "print_status": "Print Status", - "print_progress": "Progress", - "layers": "Layers" + "printer_state": "列印機狀態", + "print_status": "列印狀態", + "print_progress": "進度", + "layers": "層" }, "medusa": { - "wanted": "Wanted", - "queued": "Queued", - "series": "Series" + "wanted": "關注中", + "queued": "已加入佇列", + "series": "影集" }, - "octoPrint": { + "octoprint": { "printer_state": "Status", "temp_tool": "Tool temp", "temp_bed": "Bed temp", diff --git a/src/pages/api/docker/stats/[...service].js b/src/pages/api/docker/stats/[...service].js index 82604f8c..84e90065 100644 --- a/src/pages/api/docker/stats/[...service].js +++ b/src/pages/api/docker/stats/[...service].js @@ -1,16 +1,18 @@ import Docker from "dockerode"; import getDockerArguments from "utils/config/docker"; +import createLogger from "utils/logger"; + +const logger = createLogger("dockerStatsService"); export default async function handler(req, res) { const { service } = req.query; const [containerName, containerServer] = service; if (!containerName && !containerServer) { - res.status(400).send({ + return res.status(400).send({ error: "docker query parameters are required", }); - return; } try { @@ -23,10 +25,9 @@ export default async function handler(req, res) { // bad docker connections can result in a object? // in any case, this ensures the result is the expected array if (!Array.isArray(containers)) { - res.status(500).send({ + return res.status(500).send({ error: "query failed", }); - return; } const containerNames = containers.map((container) => container.Names[0].replace(/^\//, "")); @@ -36,10 +37,9 @@ export default async function handler(req, res) { const container = docker.getContainer(containerName); const stats = await container.stats({ stream: false }); - res.status(200).json({ + return res.status(200).json({ stats, }); - return; } // Try with a service deployed in Docker Swarm, if enabled @@ -61,19 +61,19 @@ export default async function handler(req, res) { const container = docker.getContainer(taskContainerId); const stats = await container.stats({ stream: false }); - res.status(200).json({ + return res.status(200).json({ stats, }); - return; } } - res.status(200).send({ + return res.status(200).send({ error: "not found", }); - } catch { - res.status(500).send({ - error: {message: "Unknown error"}, + } catch (e) { + logger.error(e); + return res.status(500).send({ + error: {message: e?.message ?? "Unknown error"}, }); } } diff --git a/src/pages/api/docker/status/[...service].js b/src/pages/api/docker/status/[...service].js index fa54e6f3..f232eb98 100644 --- a/src/pages/api/docker/status/[...service].js +++ b/src/pages/api/docker/status/[...service].js @@ -1,6 +1,9 @@ import Docker from "dockerode"; import getDockerArguments from "utils/config/docker"; +import createLogger from "utils/logger"; + +const logger = createLogger("dockerStatusService"); export default async function handler(req, res) { const { service } = req.query; @@ -68,9 +71,10 @@ export default async function handler(req, res) { return res.status(200).send({ error: "not found", }); - } catch { + } catch (e) { + logger.error(e); return res.status(500).send({ - error: "unknown error", + error: {message: e?.message ?? "Unknown error"}, }); } } diff --git a/src/utils/config/service-helpers.js b/src/utils/config/service-helpers.js index 28f4d76d..2024e10d 100644 --- a/src/utils/config/service-helpers.js +++ b/src/utils/config/service-helpers.js @@ -214,7 +214,8 @@ export function cleanServiceGroups(groups) { defaultinterval, namespace, // kubernetes widget app, - podSelector + podSelector, + wan // opnsense widget } = cleanedService.widget; cleanedService.widget = { @@ -237,6 +238,9 @@ export function cleanServiceGroups(groups) { if (app) cleanedService.widget.app = app; if (podSelector) cleanedService.widget.podSelector = podSelector; } + if (type === "opnsense") { + if (wan) cleanedService.widget.wan = wan; + } } return cleanedService; diff --git a/src/widgets/components.js b/src/widgets/components.js index 5b09416f..2896f159 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -31,7 +31,7 @@ const components = { nextdns: dynamic(() => import("./nextdns/component")), npm: dynamic(() => import("./npm/component")), nzbget: dynamic(() => import("./nzbget/component")), - octoPrint: dynamic(() => import("./octoPrint/component")), + octoprint: dynamic(() => import("./octoprint/component")), omada: dynamic(() => import("./omada/component")), ombi: dynamic(() => import("./ombi/component")), opnsense: dynamic(() => import("./opnsense/component")), diff --git a/src/widgets/octoPrint/component.jsx b/src/widgets/octoprint/component.jsx similarity index 68% rename from src/widgets/octoPrint/component.jsx rename to src/widgets/octoprint/component.jsx index b58a5c95..6935fe59 100644 --- a/src/widgets/octoPrint/component.jsx +++ b/src/widgets/octoprint/component.jsx @@ -23,7 +23,7 @@ export default function Component({ service }) { if (!printerStats || !state || !tempTool || !tempBed) { return ( - + ); } @@ -36,29 +36,29 @@ export default function Component({ service }) { if (!jobStats || !completion) { return ( - - - - + + + + ); } return ( - - - - + + + + ); } return ( - - - + + + ); } diff --git a/src/widgets/octoPrint/widget.js b/src/widgets/octoprint/widget.js similarity index 100% rename from src/widgets/octoPrint/widget.js rename to src/widgets/octoprint/widget.js diff --git a/src/widgets/opnsense/component.jsx b/src/widgets/opnsense/component.jsx index 53396b31..61753b47 100644 --- a/src/widgets/opnsense/component.jsx +++ b/src/widgets/opnsense/component.jsx @@ -33,16 +33,14 @@ export default function Component({ service }) { const cpu = 100 - parseFloat(cpuIdle); const memory = activityData.headers[3].match(/Mem: (.+) Active,/)[1]; - const wanUpload = interfaceData.interfaces.wan['bytes transmitted']; - const wanDownload = interfaceData.interfaces.wan['bytes received']; + const wan = widget.wan ? interfaceData.interfaces[widget.wan] : interfaceData.interfaces.wan; return ( - - - + {wan && } + {wan && } ); } diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index f5d34eb4..a1cc061c 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -25,7 +25,7 @@ import navidrome from "./navidrome/widget"; import nextdns from "./nextdns/widget"; import npm from "./npm/widget"; import nzbget from "./nzbget/widget"; -import octoPrint from "./octoPrint/widget"; +import octoprint from "./octoprint/widget"; import omada from "./omada/widget"; import ombi from "./ombi/widget"; import opnsense from "./opnsense/widget"; @@ -86,7 +86,7 @@ const widgets = { nextdns, npm, nzbget, - octoPrint, + octoprint, omada, ombi, opnsense,