diff --git a/Dockerfile b/Dockerfile index 48e5d2f30..1d9a49317 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 5603d7e58..bf443461f 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 853ad4c76..3e9f3a66b 100644 --- a/public/locales/ar/common.json +++ b/public/locales/ar/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/bg/common.json b/public/locales/bg/common.json index c30b4c3d9..4ee070177 100644 --- a/public/locales/bg/common.json +++ b/public/locales/bg/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "print_progress": "Progress", + "printer_state": "Printer State", + "print_status": "Print Status", + "layers": "Layers" } } diff --git a/public/locales/ca/common.json b/public/locales/ca/common.json index 2b2fdd9e9..f7c09cee6 100644 --- a/public/locales/ca/common.json +++ b/public/locales/ca/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/cs/common.json b/public/locales/cs/common.json index 170c4a217..f749e0f5d 100644 --- a/public/locales/cs/common.json +++ b/public/locales/cs/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "print_progress": "Progress", + "printer_state": "Printer State", + "print_status": "Print Status", + "layers": "Layers" } } diff --git a/public/locales/da/common.json b/public/locales/da/common.json index c8845105f..fe967fe04 100644 --- a/public/locales/da/common.json +++ b/public/locales/da/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/de/common.json b/public/locales/de/common.json index e32ba18b1..8037d4c8c 100644 --- a/public/locales/de/common.json +++ b/public/locales/de/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 1f7464f74..5abd77d6e 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -417,5 +417,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } \ No newline at end of file diff --git a/public/locales/eo/common.json b/public/locales/eo/common.json index a073234fa..11e7ad548 100644 --- a/public/locales/eo/common.json +++ b/public/locales/eo/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "layers": "Layers", + "print_progress": "Progress" } } diff --git a/public/locales/es/common.json b/public/locales/es/common.json index c0026c8f4..20d0f35df 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -164,7 +164,7 @@ "qbittorrent": { "download": "Bajada", "upload": "Subida", - "leech": "Leech", + "leech": "Depender", "seed": "Semillas" }, "mastodon": { @@ -347,14 +347,14 @@ "deluge": { "download": "Descarga", "upload": "Subida", - "leech": "Leech", + "leech": "Depender", "seed": "Semilla" }, "flood": { "download": "Descargar", "upload": "Subir", - "leech": "Leech", - "seed": "Seed" + "leech": "Depender", + "seed": "Semillas" }, "tdarr": { "queue": "Cola", @@ -403,5 +403,11 @@ "memory": "Memoria activa", "wanUpload": "Carga WAN", "wanDownload": "Descargar WAN" + }, + "moonraker": { + "printer_state": "Estado de la impresora", + "print_status": "Estado de la impresora", + "print_progress": "Progreso", + "layers": "Capas" } } diff --git a/public/locales/fi/common.json b/public/locales/fi/common.json index f7871dac7..161d31a08 100644 --- a/public/locales/fi/common.json +++ b/public/locales/fi/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/fr/common.json b/public/locales/fr/common.json index ab46de39d..da81f2378 100644 --- a/public/locales/fr/common.json +++ b/public/locales/fr/common.json @@ -403,5 +403,11 @@ "memory": "Mém. Utilisée", "wanUpload": "WAN Envoi", "wanDownload": "WAN Récep." + }, + "moonraker": { + "printer_state": "État Imprimante", + "print_status": "Statut Imprimante", + "print_progress": "Progression", + "layers": "Couches" } } diff --git a/public/locales/he/common.json b/public/locales/he/common.json index e211074c9..3ecf387d7 100644 --- a/public/locales/he/common.json +++ b/public/locales/he/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/hi/common.json b/public/locales/hi/common.json index 098362eef..c876d79d3 100644 --- a/public/locales/hi/common.json +++ b/public/locales/hi/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/hr/common.json b/public/locales/hr/common.json index 15343ff56..de22db79c 100644 --- a/public/locales/hr/common.json +++ b/public/locales/hr/common.json @@ -403,5 +403,11 @@ "memory": "Aktivna memorija", "wanUpload": "WAN prijenos", "wanDownload": "WAN preuzimanje" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/hu/common.json b/public/locales/hu/common.json index 0d77fd4c7..912345ab1 100644 --- a/public/locales/hu/common.json +++ b/public/locales/hu/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "layers": "Layers", + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress" } } diff --git a/public/locales/it/common.json b/public/locales/it/common.json index 8ba5f96f6..7defae315 100644 --- a/public/locales/it/common.json +++ b/public/locales/it/common.json @@ -403,5 +403,11 @@ "memory": "Memoria in uso", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/ja/common.json b/public/locales/ja/common.json index 11913e363..a372c3f9d 100644 --- a/public/locales/ja/common.json +++ b/public/locales/ja/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/ms/common.json b/public/locales/ms/common.json index ed9e49032..6b62fd21d 100644 --- a/public/locales/ms/common.json +++ b/public/locales/ms/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/nb-NO/common.json b/public/locales/nb-NO/common.json index 7f9b2c803..e066d9700 100644 --- a/public/locales/nb-NO/common.json +++ b/public/locales/nb-NO/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/nl/common.json b/public/locales/nl/common.json index c5c9ea0b0..2c09cd505 100644 --- a/public/locales/nl/common.json +++ b/public/locales/nl/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/pl/common.json b/public/locales/pl/common.json index 07ce69f2b..d5c588701 100644 --- a/public/locales/pl/common.json +++ b/public/locales/pl/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/pt-BR/common.json b/public/locales/pt-BR/common.json index 68aacbf44..cd49dc176 100644 --- a/public/locales/pt-BR/common.json +++ b/public/locales/pt-BR/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/pt/common.json b/public/locales/pt/common.json index f3cd28f51..6d9229b2d 100644 --- a/public/locales/pt/common.json +++ b/public/locales/pt/common.json @@ -412,5 +412,11 @@ "memory": "Memória Ativa", "wanUpload": "Envio WAN", "wanDownload": "WAN Descarga" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/ro/common.json b/public/locales/ro/common.json index 0a1080e12..ef9d6e5ac 100644 --- a/public/locales/ro/common.json +++ b/public/locales/ro/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/ru/common.json b/public/locales/ru/common.json index 6fb5d4f4c..71923d1d7 100644 --- a/public/locales/ru/common.json +++ b/public/locales/ru/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/sr/common.json b/public/locales/sr/common.json index 6e220e049..6a675f012 100644 --- a/public/locales/sr/common.json +++ b/public/locales/sr/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/sv/common.json b/public/locales/sv/common.json index d682d3688..eb73e8240 100644 --- a/public/locales/sv/common.json +++ b/public/locales/sv/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "print_progress": "Progress", + "printer_state": "Printer State", + "print_status": "Print Status", + "layers": "Layers" } } diff --git a/public/locales/te/common.json b/public/locales/te/common.json index f5c14b37a..fb976853b 100644 --- a/public/locales/te/common.json +++ b/public/locales/te/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/tr/common.json b/public/locales/tr/common.json index b4d093bb9..f8be2a1bd 100644 --- a/public/locales/tr/common.json +++ b/public/locales/tr/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/uk/common.json b/public/locales/uk/common.json index fc94a529c..28a5a87f4 100644 --- a/public/locales/uk/common.json +++ b/public/locales/uk/common.json @@ -403,5 +403,11 @@ "memory": "Активна пам'ять", "wanUpload": "Вивантаження WAN", "wanDownload": "Завантаження WAN" + }, + "moonraker": { + "printer_state": "Стан принтера", + "print_status": "Статус друку", + "print_progress": "Прогрес", + "layers": "Шари" } } diff --git a/public/locales/vi/common.json b/public/locales/vi/common.json index 870e3fe56..2c2c64aa8 100644 --- a/public/locales/vi/common.json +++ b/public/locales/vi/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/yue/common.json b/public/locales/yue/common.json index 1b3468273..77727d4af 100644 --- a/public/locales/yue/common.json +++ b/public/locales/yue/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "print_progress": "Progress", + "layers": "Layers", + "printer_state": "Printer State", + "print_status": "Print Status" } } diff --git a/public/locales/zh-CN/common.json b/public/locales/zh-CN/common.json index cf4c4a3fd..abad42665 100644 --- a/public/locales/zh-CN/common.json +++ b/public/locales/zh-CN/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN Upload", "wanDownload": "WAN Download" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/public/locales/zh-Hant/common.json b/public/locales/zh-Hant/common.json index 2da41ca45..ff14d256c 100644 --- a/public/locales/zh-Hant/common.json +++ b/public/locales/zh-Hant/common.json @@ -403,5 +403,11 @@ "memory": "Active Memory", "wanUpload": "WAN上傳", "wanDownload": "WAN下載" + }, + "moonraker": { + "printer_state": "Printer State", + "print_status": "Print Status", + "print_progress": "Progress", + "layers": "Layers" } } diff --git a/src/components/bookmarks/item.jsx b/src/components/bookmarks/item.jsx index 17fcbe9ea..89dd698d1 100644 --- a/src/components/bookmarks/item.jsx +++ b/src/components/bookmarks/item.jsx @@ -19,7 +19,7 @@ export default function Item({ bookmark }) {
{bookmark.icon &&
- +
} {!bookmark.icon && bookmark.abbr} diff --git a/src/components/resolvedicon.jsx b/src/components/resolvedicon.jsx index 3dad2b0e2..8657a754b 100644 --- a/src/components/resolvedicon.jsx +++ b/src/components/resolvedicon.jsx @@ -1,9 +1,9 @@ import Image from "next/future/image"; -export default function ResolvedIcon({ icon, width = 32, height = 32 }) { +export default function ResolvedIcon({ icon, width = 32, height = 32, alt = "logo" }) { // direct or relative URLs if (icon.startsWith("http") || icon.startsWith("/")) { - return logo; + return {alt}; } // mdi- prefixed, material design icons @@ -31,7 +31,7 @@ export default function ResolvedIcon({ icon, width = 32, height = 32 }) { src={`https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/${iconName}.png`} width={width} height={height} - alt="logo" + alt={alt} /> ); -} \ No newline at end of file +} diff --git a/src/widgets/components.js b/src/widgets/components.js index 98afefbf6..2956cfde2 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -24,6 +24,7 @@ const components = { medusa: dynamic(() => import("./medusa/component")), miniflux: dynamic(() => import("./miniflux/component")), mikrotik: dynamic(() => import("./mikrotik/component")), + moonraker: dynamic(() => import("./moonraker/component")), navidrome: dynamic(() => import("./navidrome/component")), nextdns: dynamic(() => import("./nextdns/component")), npm: dynamic(() => import("./npm/component")), diff --git a/src/widgets/moonraker/component.jsx b/src/widgets/moonraker/component.jsx new file mode 100644 index 000000000..81bf8b908 --- /dev/null +++ b/src/widgets/moonraker/component.jsx @@ -0,0 +1,51 @@ +import { useTranslation } from "next-i18next"; + +import Container from "components/services/widget/container"; +import Block from "components/services/widget/block"; +import useWidgetAPI from "utils/proxy/use-widget-api"; + +export default function Component({ service }) { + const { t } = useTranslation(); + + const { widget } = service; + + const { data: printStats, error: printStatsError } = useWidgetAPI(widget, "print_stats"); + const { data: displayStatus, error: displayStatsError } = useWidgetAPI(widget, "display_status"); + const { data: webHooks, error: webHooksError } = useWidgetAPI(widget, "webhooks"); + + if (printStatsError || displayStatsError || webHooksError) { + const finalError = printStatsError ?? displayStatsError ?? webHooksError; + return ; + } + + if (!printStats || !displayStatus || !webHooks) { + return ( + + + + ); + } + + if (webHooks.result.status.webhooks.state === "shutdown") { + return ( + + + + ); + } + + let currentLayer = "-"; + let totalLayer = "-"; + if (printStats.result.status.print_stats.info.total_layer !== null) { + currentLayer = printStats.result.status.print_stats.info.current_layer; + totalLayer = printStats.result.status.print_stats.info.total_layer; + } + + return ( + + + + + + ); +} diff --git a/src/widgets/moonraker/widget.js b/src/widgets/moonraker/widget.js new file mode 100644 index 000000000..314a8670e --- /dev/null +++ b/src/widgets/moonraker/widget.js @@ -0,0 +1,20 @@ +import genericProxyHandler from "utils/proxy/handlers/generic"; + +const widget = { + api: "{url}/printer/objects/query?{endpoint}", + proxyHandler: genericProxyHandler, + + mappings: { + print_stats: { + endpoint: "print_stats", + }, + display_status: { + endpoint: "display_status", + }, + webhooks: { + endpoint: "webhooks", + }, + }, +}; + +export default widget; diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index b13dd9644..88b47dde6 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -19,6 +19,7 @@ import mastodon from "./mastodon/widget"; import medusa from "./medusa/widget"; import miniflux from "./miniflux/widget"; import mikrotik from "./mikrotik/widget"; +import moonraker from "./moonraker/widget"; import navidrome from "./navidrome/widget"; import nextdns from "./nextdns/widget"; import npm from "./npm/widget"; @@ -77,6 +78,7 @@ const widgets = { medusa, miniflux, mikrotik, + moonraker, navidrome, nextdns, npm,