From ae52d766421d7b4af0e603a620304b9395b394dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Joz=C3=ADfek?= Date: Wed, 22 May 2024 19:04:33 +0200 Subject: [PATCH] Add a warning when the user runs an outdated Raspberry Pi OS --- src/locales/c.json | 2 ++ src/locales/source/cs.json | 4 +++- src/locales/source/de.json | 4 +++- src/locales/source/en.json | 4 +++- src/locales/source/es.json | 4 +++- src/locales/source/fr.json | 4 +++- src/locales/source/it.json | 4 +++- src/locales/source/kr.json | 6 ++++-- src/locales/source/lt.json | 4 +++- src/locales/source/nl.json | 4 +++- src/locales/source/pl.json | 4 +++- src/locales/source/sk.json | 4 +++- src/printer/components/settings.js | 17 ++++++++++++++++- src/printer/components/toast.js | 20 ++++++++++---------- 14 files changed, 62 insertions(+), 23 deletions(-) diff --git a/src/locales/c.json b/src/locales/c.json index 2ab12e13..4d116f94 100644 --- a/src/locales/c.json +++ b/src/locales/c.json @@ -103,6 +103,8 @@ "msg.modal-p2": "", "msg.offline.not-responsing": "", "msg.offline.please-wait": "", + "msg.outdated-os.message": "", + "msg.outdated-os.title": "", "msg.sla-pour-resin": "", "msg.sla-refill": "", "msg.sysupgrade.pending": "", diff --git a/src/locales/source/cs.json b/src/locales/source/cs.json index cd2d16a0..7917e22c 100644 --- a/src/locales/source/cs.json +++ b/src/locales/source/cs.json @@ -275,5 +275,7 @@ "logs.file-size-unknown": "", "ntf.calibration-error": "", "ntf.low-resin.message": "", - "ntf.low-resin.title": "" + "ntf.low-resin.title": "", + "msg.outdated-os.message": "PrusaLink běží na zastaralém obrazu systému. Nahrajte ho prosím znovu podle tohoto návodu. Bohužel bude nutné PrusaLink znovu nastavit", + "msg.outdated-os.title": "Raspberry Pi OS je zastaralý" } \ No newline at end of file diff --git a/src/locales/source/de.json b/src/locales/source/de.json index 7c548dcd..06c31c7d 100644 --- a/src/locales/source/de.json +++ b/src/locales/source/de.json @@ -289,5 +289,7 @@ "logs.file-size-unknown": "Die Protokolldatei hat eine unbekannte Größe und ist daher nur zum Herunterladen verfügbar", "ntf.calibration-error": "Kalibrierungsfehler", "ntf.low-resin.message": "Die gemessene Harzmenge ist zu gering. Der Druck kann fortgesetzt werden, es kann jedoch ein Nachfüllen erforderlich sein.", - "ntf.low-resin.title": "Harz niedrig" + "ntf.low-resin.title": "Harz niedrig", + "msg.outdated-os.message": "Ihr PrusaLink läuft mit einem veralteten Raspberry Pi Betriebssystem. Folgen Sie dieser Anleitung, um die neueste Version zu flashen. Dies wird PrusaLink zurücksetzen", + "msg.outdated-os.title": "Raspberry Pi OS ist veraltet" } \ No newline at end of file diff --git a/src/locales/source/en.json b/src/locales/source/en.json index 96aeded0..db86ced5 100644 --- a/src/locales/source/en.json +++ b/src/locales/source/en.json @@ -278,5 +278,7 @@ "msg.sysupgrade.title": "Upgrade System Package?", "msg.sysupgrade.wait-for-printer": "Waiting for the printer...", "conn.error_status": "Error", - "conn.printer.not-supported": "" + "conn.printer.not-supported": "", + "msg.outdated-os.message": "Your PrusaLink is running on an outdated Raspberry Pi OS. Follow this guide to flash the latest version. This will reset PrusaLink", + "msg.outdated-os.title": "Raspberry Pi OS is out-of-date" } \ No newline at end of file diff --git a/src/locales/source/es.json b/src/locales/source/es.json index 8bd37313..ae3b37ac 100644 --- a/src/locales/source/es.json +++ b/src/locales/source/es.json @@ -270,5 +270,7 @@ "logs.file-size-unknown": "El archivo de registro es de tamaño desconocido y, por lo tanto, solo está disponible para su descarga.", "ntf.calibration-error": "Error de calibración", "ntf.low-resin.message": "El volumen de resina medido es demasiado bajo. La impresión puede continuar, sin embargo, es posible que se requiera una recarga.", - "ntf.low-resin.title": "Poca resina" + "ntf.low-resin.title": "Poca resina", + "msg.outdated-os.message": "Tu PrusaLink está funcionando con un Raspberry Pi OS obsoleto. Sigue esta guía para flashear la última versión. Esto reiniciará PrusaLink", + "msg.outdated-os.title": "El SO de la Raspberry Pi está desactualizado" } \ No newline at end of file diff --git a/src/locales/source/fr.json b/src/locales/source/fr.json index 5cd5a3ef..afcfccc7 100644 --- a/src/locales/source/fr.json +++ b/src/locales/source/fr.json @@ -281,5 +281,7 @@ "logs.file-size-unknown": "Le fichier de journal est d'une taille inconnue et n'est donc disponible que pour le téléchargement", "ntf.calibration-error": "Erreur de Calibration", "ntf.low-resin.message": "Le volume de résine mesuré est trop bas. L'impression peut continuer, mais un remplissage pourra être nécessaire.", - "ntf.low-resin.title": "Niveau de résine bas" + "ntf.low-resin.title": "Niveau de résine bas", + "msg.outdated-os.message": "Votre PrusaLink fonctionne sur un système un Raspberry Pi OS obsolète. Suivez ce guide pour flasher la dernière version. Cela réinitialisera PrusaLink", + "msg.outdated-os.title": "Raspberry Pi OS est obsolète" } \ No newline at end of file diff --git a/src/locales/source/it.json b/src/locales/source/it.json index d89d1cf9..6adf7fca 100644 --- a/src/locales/source/it.json +++ b/src/locales/source/it.json @@ -270,5 +270,7 @@ "logs.file-size-unknown": "Il file di log è di dimensioni sconosciute e quindi è disponibile solo per il download.", "ntf.calibration-error": "Errore di calibrazione", "ntf.low-resin.message": "Il volume di resina misurato è troppo basso. La stampa può continuare, ma potrebbe essere necessaria una ricarica.", - "ntf.low-resin.title": "Resina bassa" + "ntf.low-resin.title": "Resina bassa", + "msg.outdated-os.message": "Il sistema PrusaLink è in esecuzione su un sistema operativo Raspberry Pi non aggiornato. Seguire questa guida per flashare l'ultima versione. Questo ripristinerà PrusaLink", + "msg.outdated-os.title": "Il sistema operativo di Raspberry Pi è obsoleto" } \ No newline at end of file diff --git a/src/locales/source/kr.json b/src/locales/source/kr.json index 29039742..30a9bf2a 100644 --- a/src/locales/source/kr.json +++ b/src/locales/source/kr.json @@ -279,5 +279,7 @@ "logs.file-size-unknown": "로그파일의 크기를 알 수 없으므로 다운로드만 가능합니다.", "ntf.calibration-error": "캘리브레이션 에러", "ntf.low-resin.message": "측정된 레진양이 적습니다. 인쇄는 계속할 수 있지만 리필이 필요할 수는 있습니다.", - "ntf.low-resin.title": "레진 부족함" -} + "ntf.low-resin.title": "레진 부족함", + "msg.outdated-os.message": "", + "msg.outdated-os.title": "" +} \ No newline at end of file diff --git a/src/locales/source/lt.json b/src/locales/source/lt.json index 4b279067..67ea4d37 100644 --- a/src/locales/source/lt.json +++ b/src/locales/source/lt.json @@ -278,5 +278,7 @@ "logs.file-size-unknown": "", "ntf.calibration-error": "", "ntf.low-resin.message": "", - "ntf.low-resin.title": "" + "ntf.low-resin.title": "", + "msg.outdated-os.message": "", + "msg.outdated-os.title": "" } \ No newline at end of file diff --git a/src/locales/source/nl.json b/src/locales/source/nl.json index 988f1748..3416dd67 100644 --- a/src/locales/source/nl.json +++ b/src/locales/source/nl.json @@ -278,5 +278,7 @@ "logs.file-size-unknown": "", "ntf.calibration-error": "", "ntf.low-resin.message": "", - "ntf.low-resin.title": "" + "ntf.low-resin.title": "", + "msg.outdated-os.message": "", + "msg.outdated-os.title": "" } \ No newline at end of file diff --git a/src/locales/source/pl.json b/src/locales/source/pl.json index 45352468..f36e658d 100644 --- a/src/locales/source/pl.json +++ b/src/locales/source/pl.json @@ -270,5 +270,7 @@ "logs.file-size-unknown": "Plik logu ma nieznany rozmiar i dlatego jest dostępny tylko do pobrania", "ntf.calibration-error": "Błąd kalibracji", "ntf.low-resin.message": "Zmierzona ilość żywicy jest zbyt niska. Drukowanie można kontynuować, jednak konieczne może być uzupełnienie w trakcie.", - "ntf.low-resin.title": "Niski poziom żywicy" + "ntf.low-resin.title": "Niski poziom żywicy", + "msg.outdated-os.message": "Twój PrusaLink działa na nieaktualnej wersji systemu operacyjnego Raspberry Pi. Postępuj zgodnie z tym przewodnikiem, aby wgrać najnowszą wersję. Spowoduje to zresetowanie PrusaLink", + "msg.outdated-os.title": "System operacyjny Raspberry Pi jest nieaktualny" } \ No newline at end of file diff --git a/src/locales/source/sk.json b/src/locales/source/sk.json index 09f09c89..c766b092 100644 --- a/src/locales/source/sk.json +++ b/src/locales/source/sk.json @@ -281,5 +281,7 @@ "logs.file-size-unknown": "", "ntf.calibration-error": "", "ntf.low-resin.message": "", - "ntf.low-resin.title": "" + "ntf.low-resin.title": "", + "msg.outdated-os.message": "", + "msg.outdated-os.title": "" } \ No newline at end of file diff --git a/src/printer/components/settings.js b/src/printer/components/settings.js index 4c2caec1..d61b3403 100644 --- a/src/printer/components/settings.js +++ b/src/printer/components/settings.js @@ -13,12 +13,13 @@ import { getSerialNumber, } from "./settingsActions"; import { handleError } from "./errors"; -import { success } from "./toast"; +import { success, warning } from "./toast"; import { modal } from "./modal"; let serialNumber = null; let prusaLinkVersion = null; let connectUrl = null; +let shownOutdatedOs = false; const logsModule = process.env.WITH_LOGS ? require("./settings/logs").default @@ -68,6 +69,19 @@ function updateApiKey(apiKey) { } } +function checkOldLink(data) { + if (shownOutdatedOs || + typeof data.version.system === "undefined" || + typeof data.version.system.DESCRIPTION === "undefined" || + data.version.system.DESCRIPTION !== "Raspbian GNU/Linux 11 (bullseye)") { + return; + } + const message = translate("msg.outdated-os.message"); + const title = translate("msg.outdated-os.title"); + warning(title, message, ()=> {}, false); + shownOutdatedOs = true; +} + function initBaseSettings() { getJson("/api/version?system=1") .then((result) => { @@ -75,6 +89,7 @@ function initBaseSettings() { version: result.data, }; prusaLinkVersion = data.version.server; + checkOldLink(data); updateProperties("settings", data); updateSystemVersionProperties(data); }) diff --git a/src/printer/components/toast.js b/src/printer/components/toast.js index 8674740d..49d20e3f 100644 --- a/src/printer/components/toast.js +++ b/src/printer/components/toast.js @@ -35,7 +35,7 @@ export const createToast = (title, message, type) => { * onClose: () => void, * }} */ -function show({ title, message, type, onClose }) { +function show({ title, message, type, onClose, autoClose = true }) { const article = createToast(title, message, type); const close = () => { if (toast_context.contains(article)) { @@ -50,7 +50,7 @@ function show({ title, message, type, onClose }) { }); const timeout = timeouts[type]; - if (timeout) + if (timeout && autoClose) setTimeout(close, timeout); toast_context.appendChild(article); @@ -62,8 +62,8 @@ function show({ title, message, type, onClose }) { * @param {string} message * @param {() => void | undefined} onClose */ -export function info(title, message, onClose) { - show({ type: "info", title, message, onClose }); +export function info(title, message, onClose , autoClose = true ) { + show({ type: "info", title, message, onClose, autoClose }); } /** @@ -72,8 +72,8 @@ export function info(title, message, onClose) { * @param {string} message * @param {() => void | undefined} onClose */ -export function warning(title, message, onClose) { - show({ type: "warning", title, message, onClose }); +export function warning(title, message, onClose , autoClose = true ) { + show({ type: "warning", title, message, onClose, autoClose }); } /** @@ -82,8 +82,8 @@ export function warning(title, message, onClose) { * @param {string} message * @param {() => void | undefined} onClose */ -export function success(title, message, onClose) { - show({ type: "success", title, message, onClose }); +export function success(title, message, onClose , autoClose = true ) { + show({ type: "success", title, message, onClose, autoClose }); } /** @@ -92,8 +92,8 @@ export function success(title, message, onClose) { * @param {string} message * @param {() => void | undefined} onClose */ -export function error(title, message, onClose) { - show({ type: "error", title, message, onClose }); +export function error(title, message, onClose , autoClose = true ) { + show({ type: "error", title, message, onClose, autoClose }); } export default { info, warning, success, error };