Skip to content

Commit

Permalink
Support nodejs update via UI and controller v6 (#2463)
Browse files Browse the repository at this point in the history
  • Loading branch information
foxriver76 authored May 21, 2024
1 parent ed3ad75 commit 02b3c0c
Show file tree
Hide file tree
Showing 14 changed files with 257 additions and 62 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ The icons may not be reused in other projects without the proper flaticon licens
### **WORK IN PROGRESS**
-->
## Changelog
### **WORK IN PROGRESS**
* (foxriver76) support of Node.js upgrade via UI (with js-controller Kiera - v6)

### 6.17.11 (2024-05-20)
* (bluefox) Corrected custom configuration dialog

Expand Down
120 changes: 120 additions & 0 deletions packages/admin/src/src/dialogs/NodeUpdateDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import React from 'react';
import {
Box,
Button, CircularProgress,
Dialog, DialogActions, DialogContent, DialogTitle, Typography,
} from '@mui/material';
import { AdminConnection, I18n } from '@iobroker/adapter-react-v5';
import { Close as CloseIcon, Refresh as RefreshIcon } from '@mui/icons-material';

interface NodeUpdateDialogProps {
/** Called when user closes dialog */
onClose: () => void;
/** The socket connection */
socket: AdminConnection;
/** The host id of the host to upgrade node.js on */
hostId: string;
/** The node.js version to upgrade to */
version: string;
}

interface NodeUpdateDialogState {
/** If update is in progress */
inProgress: boolean;
/** Result from controller */
success: boolean;
/** Error from controller */
error: string;
/** If execution finished */
finished: boolean;
}

interface ControllerResponse {
/** If upgrade was successful */
success: boolean;
/** Error message */
error: string;
}

export default class NodeUpdateDialog extends React.Component<NodeUpdateDialogProps, NodeUpdateDialogState> {
constructor(props: NodeUpdateDialogProps) {
super(props);

this.state = {
inProgress: false,
success: false,
error: '',
finished: false,
};
}

/**
* Render the element
*/
render(): React.JSX.Element {
return <Dialog
open={!0}
maxWidth="lg"
fullWidth
>
<DialogTitle>{I18n.t('Node.js upgrade')}</DialogTitle>
<DialogContent style={{ height: 100, padding: '0 20px', overflow: 'hidden' }}>
{!this.state.finished ? <Typography>{I18n.t('Performing this update will restart the js-controller afterwards!')}</Typography> : null}
{this.state.inProgress ? <Box sx={{ display: 'flex', justifyContent: 'center' }}>
<CircularProgress />
</Box> : null}
{this.state.success ? <Typography>{I18n.t('Node.js update successful, restarting controller now!')}</Typography> : null}
{this.state.error ? <Typography sx={{ color: 'red' }}>{I18n.t('Node.js update failed: %s', this.state.error)}</Typography> : null}
</DialogContent>
<DialogActions>
<Button
disabled={this.state.inProgress || this.state.finished}
color="primary"
variant="contained"
startIcon={<RefreshIcon />}
onClick={() => this.updateNodeJsVersion()}
>
{I18n.t('Upgrade')}
</Button>
<Button
disabled={this.state.inProgress}
variant="contained"
onClick={() => {
this.props.onClose();
}}
color="primary"
startIcon={<CloseIcon />}
>
{I18n.t('Close')}
</Button>
</DialogActions>
</Dialog>;
}

/**
* Update Node.js to given version and restart the controller afterwards
*/
async updateNodeJsVersion(): Promise<void> {
this.setState({ inProgress: true });

const res = await new Promise<ControllerResponse>(resolve => this.props.socket.getRawSocket().emit(
'sendToHost',
this.props.hostId,
'upgradeOsPackages',
{
packages: [{
name: 'nodejs',
// For apt updates we need to be precise about the version, e.g. `18.20.2-1nodesource1`, thus we simply upgrade to the newest version instead
// version: this.props.version,
}],
// restart the controller after the Node.js update
restart: true,
},
(resp: ControllerResponse) => resolve(resp),
));

this.setState({
inProgress: false, success: res.success, error: res.error, finished: true,
});
}
}
16 changes: 10 additions & 6 deletions packages/admin/src/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
"Clear log": "Log löschen",
"Clear on disk permanent": "Von der Disk dauerhaft löschen",
"Click do activate events again, or just wait one minute": "Hier klicken, um die Ereignisse erneut zu aktivieren (oder eine Minute warten)",
"Click for more": "Für mehr klicken ",
"Click on icon": "Auf das Icon klicken um einen Link zu öffnen",
"Click to clear all filters": "Hier klicken, um alle Filter zu löschen",
"Click to copy %s": "hier klicken, um %s zu kopieren",
Expand Down Expand Up @@ -274,7 +275,6 @@
"Custom settings": "Benutzerdefinierte Einstellungen",
"Cyprus": "Zypern",
"Czech Republic": "Tschechien",
"December": "Dezember",
"DB number": "DB-Nummer",
"DD.MM.YY": "DD.MM.YY",
"DD.MM.YYYY": "DD.MM.YYYY",
Expand All @@ -289,6 +289,7 @@
"Debug outputs": "Debug-Ausgaben",
"Debug outputs:": "Debug-Ausgabe",
"Dec": "Dez",
"December": "Dezember",
"Default ACL": "Standard ACL",
"Default History": "Standard-Historie",
"Default Repository": "Standard Repository",
Expand Down Expand Up @@ -479,6 +480,8 @@
"Hide members": "Mitglieder verstecken",
"History data": "Verlaufsdaten",
"History instance": "Verlaufsinstanz",
"History instance not alive": "Verlaufsinstanz nicht aktiv",
"History instance not selected": "Keine Verlaufsinstanz ausgewählt",
"Honduras": "Honduras",
"Hong Kong": "Hong Kong",
"Host": "Server",
Expand Down Expand Up @@ -719,6 +722,9 @@
"No stdout outputs": "Kein Ausgabe in Kommandozeile",
"No version of %s": "Die neueste verfügbare Version von \"%s\" ist erforderlich, es ist jedoch nichts installiert. Bitte installiere zuerst \"%s\" und versuche es dann erneut.",
"Node.js": "Node.js",
"Node.js update failed: %s": "Node.js-Aktualisierung fehlgeschlagen: %s",
"Node.js update successful, restarting controller now!": "Node.js-Update erfolgreich, Controller wird jetzt neu gestartet!",
"Node.js upgrade": "Node.js-Upgrade",
"Non-allowed duplicate entry \"%s\" in column \"%s\"": "Unzulässiger doppelter Eintrag „%s“ in Spalte „%s“",
"None": "Keiner",
"Norfolk Island": "Norfolk Island",
Expand Down Expand Up @@ -776,6 +782,7 @@
"Path": "Pfad",
"Path to storage:": "Pfad zum speichern",
"Pause output": "Ausgabe pausieren",
"Performing this update will restart the js-controller afterwards!": "Wenn Sie dieses Update durchführen, wird der JS-Controller anschließend neu gestartet! Dadurch wird Ihre Node.js-Version auf die neueste verfügbare Version in Ihren konfigurierten Apt-Quellen aktualisiert.",
"Permissions": "Berechtigungen",
"Peru": "Peru",
"Philippines": "Philippinen",
Expand Down Expand Up @@ -1182,6 +1189,7 @@
"You have unsaved changes": "Du hast nicht gespeicherte Änderungen",
"You must set the administrator password": "Sie müssen das Administratorpasswort festlegen",
"You voted for %s on %s": "Sie haben für v%s am %s gestimmt",
"Your are intend to edit ALL objects. Are you sure?": "Sie möchten ALLE Objekte bearbeiten. Sind Sie sicher?",
"Your comment": "Dein Kommentar",
"Your communication with admin is not encrypted": "Ihre Kommunikation mit dem Administrator ist nicht verschlüsselt",
"Your home": "Dein Heim",
Expand Down Expand Up @@ -1586,9 +1594,5 @@
"write": "schreiben",
"write operation": "schreiben",
"wrongPassword": "Benutzername oder Passwort sind falsch",
"yesterday": "gestern",
"History instance not alive": "Verlaufsinstanz nicht aktiv",
"History instance not selected": "Keine Verlaufsinstanz ausgewählt",
"Click for more": "Für mehr klicken ",
"Your are intend to edit ALL objects. Are you sure?": "Sie möchten ALLE Objekte bearbeiten. Sind Sie sicher?"
"yesterday": "gestern"
}
14 changes: 9 additions & 5 deletions packages/admin/src/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
"Clear log": "Clear log",
"Clear on disk permanent": "Clear on disk permanent",
"Click do activate events again, or just wait one minute": "Click do activate events again, or just wait one minute",
"Click for more": "Click for more",
"Click on icon": "Click on icon to open a link",
"Click to clear all filters": "Click to clear all filters",
"Click to copy %s": "Click to copy %s",
Expand Down Expand Up @@ -479,6 +480,8 @@
"Hide members": "Hide members",
"History data": "History data",
"History instance": "History instance",
"History instance not alive": "History instance not alive",
"History instance not selected": "History instance not selected",
"Honduras": "Honduras",
"Hong Kong": "Hong Kong",
"Host": "Host",
Expand Down Expand Up @@ -719,6 +722,9 @@
"No stdout outputs": "No stdout outputs",
"No version of %s": "Latest available version of \"%s\" is required, but nothing installed. Please install first \"%s\" and then retry.",
"Node.js": "Node.js",
"Node.js update failed: %s": "Node.js update failed: %s",
"Node.js update successful, restarting controller now!": "Node.js update successful, restarting controller now!",
"Node.js upgrade": "Node.js upgrade",
"Non-allowed duplicate entry \"%s\" in column \"%s\"": "Non-allowed duplicate entry \"%s\" in column \"%s\"",
"None": "None",
"Norfolk Island": "Norfolk Island",
Expand Down Expand Up @@ -776,6 +782,7 @@
"Path": "Path",
"Path to storage:": "Path to storage",
"Pause output": "Pause output",
"Performing this update will restart the js-controller afterwards!": "Performing this update will restart the js-controller afterwards! This will update your Node.js version to the latest available in your configured apt sources.",
"Permissions": "Permissions",
"Peru": "Peru",
"Philippines": "Philippines",
Expand Down Expand Up @@ -1182,6 +1189,7 @@
"You have unsaved changes": "You have unsaved changes",
"You must set the administrator password": "You must set the administrator password",
"You voted for %s on %s": "You voted for v%s on %s",
"Your are intend to edit ALL objects. Are you sure?": "Your are intend to edit ALL objects. Are you sure?",
"Your comment": "Your comment",
"Your communication with admin is not encrypted": "Your communication with admin is not encrypted",
"Your home": "Your home",
Expand Down Expand Up @@ -1586,9 +1594,5 @@
"write": "write",
"write operation": "write",
"wrongPassword": "Invalid username or password",
"yesterday": "yesterday",
"History instance not alive": "History instance not alive",
"History instance not selected": "History instance not selected",
"Click for more": "Click for more",
"Your are intend to edit ALL objects. Are you sure?": "Your are intend to edit ALL objects. Are you sure?"
"yesterday": "yesterday"
}
14 changes: 9 additions & 5 deletions packages/admin/src/src/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
"Clear log": "Borrar el log",
"Clear on disk permanent": "Delatar el log permanente del disco",
"Click do activate events again, or just wait one minute": "Haga clic en activar eventos nuevamente, o simplemente espere un minuto",
"Click for more": "Haga clic para más",
"Click on icon": "Haga clic en el icono para abrir un link",
"Click to clear all filters": "Haga clic para borrar todos los filtros",
"Click to copy %s": "Haga clic para copiar %s",
Expand Down Expand Up @@ -479,6 +480,8 @@
"Hide members": "Ocultar miembros",
"History data": "Datos del historial",
"History instance": "Instancia de historia",
"History instance not alive": "Instancia de historia no viva",
"History instance not selected": "Instancia de historial no seleccionada",
"Honduras": "Honduras",
"Hong Kong": "Hong Kong",
"Host": "Host",
Expand Down Expand Up @@ -719,6 +722,9 @@
"No stdout outputs": "Sin salidas estándar",
"No version of %s": "Se requiere la última versión disponible de \"%s\", pero no hay nada instalado. Instale primero \"%s\" y luego vuelva a intentarlo.",
"Node.js": "Node.js",
"Node.js update failed: %s": "Error en la actualización de Node.js: %s",
"Node.js update successful, restarting controller now!": "Actualización de Node.js exitosa, reiniciando el controlador ahora.",
"Node.js upgrade": "Actualización de Node.js",
"Non-allowed duplicate entry \"%s\" in column \"%s\"": "Entrada duplicada no permitida \"%s\" en la columna \"%s\"",
"None": "Ninguno",
"Norfolk Island": "Isla de Norfolk",
Expand Down Expand Up @@ -776,6 +782,7 @@
"Path": "Camino",
"Path to storage:": "Ruta para grabar:",
"Pause output": "Pausar la salida",
"Performing this update will restart the js-controller afterwards!": "¡Al realizar esta actualización se reiniciará el controlador js después! Esto actualizará su versión de Node.js a la última disponible en sus fuentes apt configuradas.",
"Permissions": "Permisos",
"Peru": "Perú",
"Philippines": "Filipinas",
Expand Down Expand Up @@ -1182,6 +1189,7 @@
"You have unsaved changes": "Tiene cambios sin guardar",
"You must set the administrator password": "Debe establecer la contraseña de administrador",
"You voted for %s on %s": "Votaste por v%s el %s",
"Your are intend to edit ALL objects. Are you sure?": "Su intención es editar TODOS los objetos. ¿Está seguro?",
"Your comment": "Tu comentario",
"Your communication with admin is not encrypted": "Su comunicación con el administrador no está encriptada",
"Your home": "Su casa",
Expand Down Expand Up @@ -1586,9 +1594,5 @@
"write": "escribir",
"write operation": "escribir",
"wrongPassword": "usuario o contraseña invalido",
"yesterday": "ayer",
"History instance not alive": "Instancia de historia no viva",
"History instance not selected": "Instancia de historial no seleccionada",
"Click for more": "Haga clic para más",
"Your are intend to edit ALL objects. Are you sure?": "Su intención es editar TODOS los objetos. ¿Está seguro?"
"yesterday": "ayer"
}
14 changes: 9 additions & 5 deletions packages/admin/src/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
"Clear log": "Effacer le journal",
"Clear on disk permanent": "Effacer sur le disque permanent",
"Click do activate events again, or just wait one minute": "Cliquez pour activer à nouveau les événements, ou attendez une minute",
"Click for more": "Cliquez pour en savoir plus",
"Click on icon": "Cliquez sur l'icône",
"Click to clear all filters": "Cliquez pour effacer tous les filtres",
"Click to copy %s": "Cliquez pour copier %s",
Expand Down Expand Up @@ -479,6 +480,8 @@
"Hide members": "Masquer les membres",
"History data": "Données historiques",
"History instance": "Instance historique",
"History instance not alive": "Instance historique non vivante",
"History instance not selected": "Instance d'historique non sélectionnée",
"Honduras": "Honduras",
"Hong Kong": "Hong Kong",
"Host": "Hôte",
Expand Down Expand Up @@ -719,6 +722,9 @@
"No stdout outputs": "Pas de sorties stdout",
"No version of %s": "La dernière version disponible de \"%s\" est requise, mais rien n'est installé. Veuillez d'abord installer \"%s\", puis réessayer.",
"Node.js": "Node.js",
"Node.js update failed: %s": "Échec de la mise à jour de Node.js : %s",
"Node.js update successful, restarting controller now!": "Mise à jour de Node.js réussie, redémarrage du contrôleur maintenant !",
"Node.js upgrade": "Mise à niveau de Node.js",
"Non-allowed duplicate entry \"%s\" in column \"%s\"": "Entrée en double non autorisée \"%s\" dans la colonne \"%s\"",
"None": "Aucun",
"Norfolk Island": "L'ile de Norfolk",
Expand Down Expand Up @@ -776,6 +782,7 @@
"Path": "Chemin",
"Path to storage:": "Chemin d'accès pour le stockage",
"Pause output": "Mettre en pause la sortie",
"Performing this update will restart the js-controller afterwards!": "Effectuer cette mise à jour redémarrera ensuite le contrôleur js ! Cela mettra à jour votre version de Node.js avec la dernière disponible dans vos sources apt configurées.",
"Permissions": "Autorisations",
"Peru": "Pérou",
"Philippines": "Philippines",
Expand Down Expand Up @@ -1182,6 +1189,7 @@
"You have unsaved changes": "Vous avez des changements non enregistrés",
"You must set the administrator password": "Vous devez définir le mot de passe administrateur",
"You voted for %s on %s": "Vous avez voté pour v%s en %s",
"Your are intend to edit ALL objects. Are you sure?": "Vous avez l’intention de modifier TOUS les objets. Es-tu sûr?",
"Your comment": "Votre commentaire",
"Your communication with admin is not encrypted": "Votre communication avec l'administrateur n'est pas chiffrée",
"Your home": "Le chez-soi",
Expand Down Expand Up @@ -1586,9 +1594,5 @@
"write": "écriture",
"write operation": "écrire",
"wrongPassword": "Nom d'utilisateur ou mot de passe invalide",
"yesterday": "hier",
"History instance not alive": "Instance historique non vivante",
"History instance not selected": "Instance d'historique non sélectionnée",
"Click for more": "Cliquez pour en savoir plus",
"Your are intend to edit ALL objects. Are you sure?": "Vous avez l’intention de modifier TOUS les objets. Es-tu sûr?"
"yesterday": "hier"
}
Loading

0 comments on commit 02b3c0c

Please sign in to comment.