Merge remote-tracking branch 'upstream/main' into main

This commit is contained in:
KillahBee 2023-01-23 15:26:47 -05:00
commit cf19158bda
45 changed files with 164 additions and 144 deletions

View File

@ -7,12 +7,10 @@ WORKDIR /app
COPY --link package.json pnpm-lock.yaml* ./ COPY --link package.json pnpm-lock.yaml* ./
RUN <<EOF SHELL ["/bin/ash", "-xeo", "pipefail", "-c"]
set -xe RUN apk add --no-cache libc6-compat \
apk add libc6-compat && apk add --no-cache --virtual .gyp python3 make g++ \
apk add --virtual .gyp python3 make g++ && npm install -g pnpm
npm install -g pnpm
EOF
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store pnpm fetch | grep -v "cross-device link not permitted\|Falling back to copying packages from store" RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store pnpm fetch | grep -v "cross-device link not permitted\|Falling back to copying packages from store"
@ -29,12 +27,10 @@ ARG REVISION
COPY --link --from=deps /app/node_modules ./node_modules/ COPY --link --from=deps /app/node_modules ./node_modules/
COPY . . COPY . .
RUN <<EOF SHELL ["/bin/ash", "-xeo", "pipefail", "-c"]
set -xe RUN npm run telemetry \
npm run telemetry && mkdir config && echo '---' > config/settings.yaml \
mkdir config && echo '-' > config/settings.yaml && NEXT_PUBLIC_BUILDTIME=$BUILDTIME NEXT_PUBLIC_VERSION=$VERSION NEXT_PUBLIC_REVISION=$REVISION npm run build
NEXT_PUBLIC_BUILDTIME=$BUILDTIME NEXT_PUBLIC_VERSION=$VERSION NEXT_PUBLIC_REVISION=$REVISION npm run build
EOF
# Production image, copy all the files and run next # Production image, copy all the files and run next
FROM docker.io/node:18-alpine AS runner FROM docker.io/node:18-alpine AS runner
@ -50,12 +46,15 @@ ENV NODE_ENV production
WORKDIR /app WORKDIR /app
# Copy files from context (this allows the files to copy before the builder stage is done). # 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 --chown=1000:1000 package.json next.config.js ./
COPY --link /public ./public COPY --link --chown=1000:1000 /public ./public/
# Copy files from builder # Copy files from builder
COPY --link --from=builder /app/.next/standalone ./ COPY --link --from=builder --chown=1000:1000 /app/.next/standalone ./
COPY --link --from=builder /app/.next/static/ ./.next/static/ 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 ENV PORT 3000
EXPOSE $PORT EXPOSE $PORT
@ -63,4 +62,5 @@ EXPOSE $PORT
HEALTHCHECK --interval=10s --timeout=3s --start-period=20s \ 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 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"] CMD ["node", "server.js"]

View File

@ -2,8 +2,22 @@
set -e 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, # This is in attempt to preserve the original behavior of the Dockerfile,
# while also supporting the lscr.io /config directory # while also supporting the lscr.io /config directory
[ ! -d "/app/config" ] && ln -s /config /app/config [ ! -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

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -424,7 +424,7 @@
"print_progress": "Progress", "print_progress": "Progress",
"layers": "Layers" "layers": "Layers"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,10 +415,10 @@
"queued": "A la espera", "queued": "A la espera",
"series": "Serie" "series": "Serie"
}, },
"octoPrint": { "octoprint": {
"temp_bed": "Bed temp",
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp",
"job_completion": "Completion" "job_completion": "Completion"
} }
} }

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "En attente", "queued": "En attente",
"series": "Séries" "series": "Séries"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,10 +415,10 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"temp_bed": "Bed temp",
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp",
"job_completion": "Completion" "job_completion": "Completion"
} }
} }

View File

@ -415,7 +415,7 @@
"print_progress": "Progress", "print_progress": "Progress",
"layers": "Layers" "layers": "Layers"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -394,28 +394,28 @@
"numberOfLeases": "Dzierżawy" "numberOfLeases": "Dzierżawy"
}, },
"xteve": { "xteve": {
"streams_all": "All Streams", "streams_all": "Wszystkie strumienie",
"streams_active": "Active Streams", "streams_active": "Aktywne strumienie",
"streams_xepg": "XEPG Channels" "streams_xepg": "Kanały XEPG"
}, },
"opnsense": { "opnsense": {
"cpu": "CPU Load", "cpu": "Obciążenie procesora",
"memory": "Active Memory", "memory": "Pamięć rzeczywista",
"wanUpload": "WAN Upload", "wanUpload": "WAN wysyłanie",
"wanDownload": "WAN Download" "wanDownload": "WAN pobieranie"
}, },
"moonraker": { "moonraker": {
"printer_state": "Printer State", "printer_state": "Stan drukarki",
"print_status": "Print Status", "print_status": "Status wydruku",
"print_progress": "Progress", "print_progress": "Postęp",
"layers": "Layers" "layers": "Warstwy"
}, },
"medusa": { "medusa": {
"wanted": "Wanted", "wanted": "Poszukiwane",
"queued": "Queued", "queued": "Zakolejkowane",
"series": "Series" "series": "Seria"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -424,7 +424,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "У черзі", "queued": "У черзі",
"series": "Серії" "series": "Серії"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued", "queued": "Queued",
"series": "Series" "series": "Series"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -61,20 +61,20 @@
"timeleft": "剩餘時間" "timeleft": "剩餘時間"
}, },
"rutorrent": { "rutorrent": {
"active": "Active", "active": "活動中",
"upload": "上", "upload": "上行速率",
"download": "下" "download": "下行速率"
}, },
"radarr": { "radarr": {
"movies": "電影", "movies": "電影",
"wanted": "關注中", "wanted": "關注中",
"queued": "已加入佇列", "queued": "已加入佇列",
"missing": "遺失" "missing": "缺少"
}, },
"sonarr": { "sonarr": {
"wanted": "關注中", "wanted": "關注中",
"queued": "已加入佇列", "queued": "已加入佇列",
"series": "系列" "series": "影集"
}, },
"readarr": { "readarr": {
"wanted": "關注中", "wanted": "關注中",
@ -93,13 +93,13 @@
"processing": "處理中" "processing": "處理中"
}, },
"pihole": { "pihole": {
"queries": "查詢", "queries": "查詢",
"blocked": "已阻擋", "blocked": "已阻擋",
"gravity": "Gravity" "gravity": "Gravity"
}, },
"speedtest": { "speedtest": {
"upload": "上行", "upload": "上行速率",
"download": "下行", "download": "下行速率",
"ping": "Ping" "ping": "Ping"
}, },
"portainer": { "portainer": {
@ -132,23 +132,23 @@
"prowlarr": { "prowlarr": {
"enableIndexers": "索引器", "enableIndexers": "索引器",
"numberOfGrabs": "抓取", "numberOfGrabs": "抓取",
"numberOfQueries": "查詢", "numberOfQueries": "查詢",
"numberOfFailGrabs": "抓取失敗", "numberOfFailGrabs": "抓取失敗",
"numberOfFailQueries": "查詢失敗" "numberOfFailQueries": "查詢失敗"
}, },
"transmission": { "transmission": {
"download": "下", "download": "下行速率",
"upload": "上", "upload": "上行速率",
"leech": "Leech", "leech": "未完成下載",
"seed": "Seed" "seed": "已完成下載"
}, },
"jackett": { "jackett": {
"configured": "已配置", "configured": "已配置",
"errored": "發生錯誤" "errored": "發生錯誤"
}, },
"bazarr": { "bazarr": {
"missingEpisodes": "缺的劇集", "missingEpisodes": "缺的劇集",
"missingMovies": "缺的電影" "missingMovies": "缺的電影"
}, },
"lidarr": { "lidarr": {
"wanted": "關注中", "wanted": "關注中",
@ -156,16 +156,16 @@
"albums": "專輯" "albums": "專輯"
}, },
"adguard": { "adguard": {
"queries": "查詢", "queries": "查詢",
"blocked": "已阻擋", "blocked": "已阻擋",
"filtered": "已過濾", "filtered": "已過濾",
"latency": "延遲" "latency": "延遲"
}, },
"qbittorrent": { "qbittorrent": {
"download": "下", "download": "下行速率",
"upload": "上", "upload": "上行速率",
"leech": "Leech", "leech": "未完成下載",
"seed": "Seed" "seed": "已完成下載"
}, },
"mastodon": { "mastodon": {
"user_count": "使用者", "user_count": "使用者",
@ -216,8 +216,8 @@
"wait": "請稍後" "wait": "請稍後"
}, },
"changedetectionio": { "changedetectionio": {
"totalObserved": "Total Observed", "totalObserved": "總監測數",
"diffsDetected": "Diffs Detected" "diffsDetected": "偵測到的變更"
}, },
"wmo": { "wmo": {
"0-day": "晴", "0-day": "晴",
@ -345,16 +345,16 @@
"total": "全部" "total": "全部"
}, },
"deluge": { "deluge": {
"download": "下", "download": "下行速率",
"upload": "上", "upload": "上行速率",
"leech": "Leech", "leech": "未完成下載",
"seed": "Seed" "seed": "已完成下載"
}, },
"flood": { "flood": {
"download": "下", "download": "下行速率",
"upload": "上", "upload": "上行速率",
"leech": "Leech", "leech": "未完成下載",
"seed": "Seed" "seed": "已完成下載"
}, },
"tdarr": { "tdarr": {
"queue": "佇列", "queue": "佇列",
@ -382,10 +382,10 @@
"connectedSwitches": "已連接的交換器" "connectedSwitches": "已連接的交換器"
}, },
"downloadstation": { "downloadstation": {
"download": "下", "download": "下行速率",
"upload": "上", "upload": "上行速率",
"leech": "Leech", "leech": "未完成下載",
"seed": "Seed" "seed": "已完成下載"
}, },
"mikrotik": { "mikrotik": {
"cpuLoad": "CPU負載", "cpuLoad": "CPU負載",
@ -405,17 +405,17 @@
"wanDownload": "WAN下載" "wanDownload": "WAN下載"
}, },
"moonraker": { "moonraker": {
"printer_state": "Printer State", "printer_state": "列印機狀態",
"print_status": "Print Status", "print_status": "列印狀態",
"print_progress": "Progress", "print_progress": "進度",
"layers": "Layers" "layers": ""
}, },
"medusa": { "medusa": {
"wanted": "Wanted", "wanted": "關注中",
"queued": "Queued", "queued": "已加入佇列",
"series": "Series" "series": "影集"
}, },
"octoPrint": { "octoprint": {
"printer_state": "Status", "printer_state": "Status",
"temp_tool": "Tool temp", "temp_tool": "Tool temp",
"temp_bed": "Bed temp", "temp_bed": "Bed temp",

View File

@ -1,16 +1,18 @@
import Docker from "dockerode"; import Docker from "dockerode";
import getDockerArguments from "utils/config/docker"; import getDockerArguments from "utils/config/docker";
import createLogger from "utils/logger";
const logger = createLogger("dockerStatsService");
export default async function handler(req, res) { export default async function handler(req, res) {
const { service } = req.query; const { service } = req.query;
const [containerName, containerServer] = service; const [containerName, containerServer] = service;
if (!containerName && !containerServer) { if (!containerName && !containerServer) {
res.status(400).send({ return res.status(400).send({
error: "docker query parameters are required", error: "docker query parameters are required",
}); });
return;
} }
try { try {
@ -23,10 +25,9 @@ export default async function handler(req, res) {
// bad docker connections can result in a <Buffer ...> object? // bad docker connections can result in a <Buffer ...> object?
// in any case, this ensures the result is the expected array // in any case, this ensures the result is the expected array
if (!Array.isArray(containers)) { if (!Array.isArray(containers)) {
res.status(500).send({ return res.status(500).send({
error: "query failed", error: "query failed",
}); });
return;
} }
const containerNames = containers.map((container) => container.Names[0].replace(/^\//, "")); 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 container = docker.getContainer(containerName);
const stats = await container.stats({ stream: false }); const stats = await container.stats({ stream: false });
res.status(200).json({ return res.status(200).json({
stats, stats,
}); });
return;
} }
// Try with a service deployed in Docker Swarm, if enabled // 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 container = docker.getContainer(taskContainerId);
const stats = await container.stats({ stream: false }); const stats = await container.stats({ stream: false });
res.status(200).json({ return res.status(200).json({
stats, stats,
}); });
return;
} }
} }
res.status(200).send({ return res.status(200).send({
error: "not found", error: "not found",
}); });
} catch { } catch (e) {
res.status(500).send({ logger.error(e);
error: {message: "Unknown error"}, return res.status(500).send({
error: {message: e?.message ?? "Unknown error"},
}); });
} }
} }

View File

@ -1,6 +1,9 @@
import Docker from "dockerode"; import Docker from "dockerode";
import getDockerArguments from "utils/config/docker"; import getDockerArguments from "utils/config/docker";
import createLogger from "utils/logger";
const logger = createLogger("dockerStatusService");
export default async function handler(req, res) { export default async function handler(req, res) {
const { service } = req.query; const { service } = req.query;
@ -68,9 +71,10 @@ export default async function handler(req, res) {
return res.status(200).send({ return res.status(200).send({
error: "not found", error: "not found",
}); });
} catch { } catch (e) {
logger.error(e);
return res.status(500).send({ return res.status(500).send({
error: "unknown error", error: {message: e?.message ?? "Unknown error"},
}); });
} }
} }

View File

@ -214,7 +214,8 @@ export function cleanServiceGroups(groups) {
defaultinterval, defaultinterval,
namespace, // kubernetes widget namespace, // kubernetes widget
app, app,
podSelector podSelector,
wan // opnsense widget
} = cleanedService.widget; } = cleanedService.widget;
cleanedService.widget = { cleanedService.widget = {
@ -237,6 +238,9 @@ export function cleanServiceGroups(groups) {
if (app) cleanedService.widget.app = app; if (app) cleanedService.widget.app = app;
if (podSelector) cleanedService.widget.podSelector = podSelector; if (podSelector) cleanedService.widget.podSelector = podSelector;
} }
if (type === "opnsense") {
if (wan) cleanedService.widget.wan = wan;
}
} }
return cleanedService; return cleanedService;

View File

@ -31,7 +31,7 @@ const components = {
nextdns: dynamic(() => import("./nextdns/component")), nextdns: dynamic(() => import("./nextdns/component")),
npm: dynamic(() => import("./npm/component")), npm: dynamic(() => import("./npm/component")),
nzbget: dynamic(() => import("./nzbget/component")), nzbget: dynamic(() => import("./nzbget/component")),
octoPrint: dynamic(() => import("./octoPrint/component")), octoprint: dynamic(() => import("./octoprint/component")),
omada: dynamic(() => import("./omada/component")), omada: dynamic(() => import("./omada/component")),
ombi: dynamic(() => import("./ombi/component")), ombi: dynamic(() => import("./ombi/component")),
opnsense: dynamic(() => import("./opnsense/component")), opnsense: dynamic(() => import("./opnsense/component")),

View File

@ -23,7 +23,7 @@ export default function Component({ service }) {
if (!printerStats || !state || !tempTool || !tempBed) { if (!printerStats || !state || !tempTool || !tempBed) {
return ( return (
<Container service={service}> <Container service={service}>
<Block label="octoPrint.printer_state" /> <Block label="octoprint.printer_state" />
</Container> </Container>
); );
} }
@ -36,29 +36,29 @@ export default function Component({ service }) {
if (!jobStats || !completion) { if (!jobStats || !completion) {
return ( return (
<Container service={service}> <Container service={service}>
<Block label="octoPrint.printer_state" /> <Block label="octoprint.printer_state" />
<Block label="octoPrint.temp_tool" /> <Block label="octoprint.temp_tool" />
<Block label="octoPrint.temp_bed" /> <Block label="octoprint.temp_bed" />
<Block label="octoPrint.job_completion" /> <Block label="octoprint.job_completion" />
</Container> </Container>
); );
} }
return ( return (
<Container service={service}> <Container service={service}>
<Block label="octoPrint.printer_state" value={printerStats.state.text} /> <Block label="octoprint.printer_state" value={printerStats.state.text} />
<Block label="octoPrint.temp_tool" value={`${printerStats.temperature.tool0.actual} °C`} /> <Block label="octoprint.temp_tool" value={`${printerStats.temperature.tool0.actual} °C`} />
<Block label="octoPrint.temp_bed" value={`${printerStats.temperature.bed.actual} °C`} /> <Block label="octoprint.temp_bed" value={`${printerStats.temperature.bed.actual} °C`} />
<Block label="octoPrint.job_completion" value={`${completion.toFixed(2)}%`} /> <Block label="octoprint.job_completion" value={`${completion.toFixed(2)}%`} />
</Container> </Container>
); );
} }
return ( return (
<Container service={service}> <Container service={service}>
<Block label="octoPrint.printer_state" value={printerStats.state.text} /> <Block label="octoprint.printer_state" value={printerStats.state.text} />
<Block label="octoPrint.temp_tool" value={`${printerStats.temperature.tool0.actual} °C`} /> <Block label="octoprint.temp_tool" value={`${printerStats.temperature.tool0.actual} °C`} />
<Block label="octoPrint.temp_bed" value={`${printerStats.temperature.bed.actual} °C`} /> <Block label="octoprint.temp_bed" value={`${printerStats.temperature.bed.actual} °C`} />
</Container> </Container>
); );
} }

View File

@ -33,16 +33,14 @@ export default function Component({ service }) {
const cpu = 100 - parseFloat(cpuIdle); const cpu = 100 - parseFloat(cpuIdle);
const memory = activityData.headers[3].match(/Mem: (.+) Active,/)[1]; const memory = activityData.headers[3].match(/Mem: (.+) Active,/)[1];
const wanUpload = interfaceData.interfaces.wan['bytes transmitted']; const wan = widget.wan ? interfaceData.interfaces[widget.wan] : interfaceData.interfaces.wan;
const wanDownload = interfaceData.interfaces.wan['bytes received'];
return ( return (
<Container service={service}> <Container service={service}>
<Block label="opnsense.cpu" value={t("common.percent", { value: cpu.toFixed(2) })} /> <Block label="opnsense.cpu" value={t("common.percent", { value: cpu.toFixed(2) })} />
<Block label="opnsense.memory" value={memory} /> <Block label="opnsense.memory" value={memory} />
<Block label="opnsense.wanUpload" value={t("common.bytes", { value: wanUpload })} /> {wan && <Block label="opnsense.wanUpload" value={t("common.bytes", { value: wan['bytes transmitted'] })} />}
<Block label="opnsense.wanDownload" value={t("common.bytes", { value: wanDownload })} /> {wan && <Block label="opnsense.wanDownload" value={t("common.bytes", { value: wan['bytes received'] })} />}
</Container> </Container>
); );
} }

View File

@ -25,7 +25,7 @@ import navidrome from "./navidrome/widget";
import nextdns from "./nextdns/widget"; import nextdns from "./nextdns/widget";
import npm from "./npm/widget"; import npm from "./npm/widget";
import nzbget from "./nzbget/widget"; import nzbget from "./nzbget/widget";
import octoPrint from "./octoPrint/widget"; import octoprint from "./octoprint/widget";
import omada from "./omada/widget"; import omada from "./omada/widget";
import ombi from "./ombi/widget"; import ombi from "./ombi/widget";
import opnsense from "./opnsense/widget"; import opnsense from "./opnsense/widget";
@ -86,7 +86,7 @@ const widgets = {
nextdns, nextdns,
npm, npm,
nzbget, nzbget,
octoPrint, octoprint,
omada, omada,
ombi, ombi,
opnsense, opnsense,