Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker node red integration #1809

Merged
merged 32 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2553d2d
Initialize Service
callemand Jun 1, 2023
2ae6f4b
Add setup screen
callemand Jun 2, 2023
91fae9c
Add service to enable and install node-red
callemand Jun 8, 2023
12b334b
Fix dependencies
callemand Jun 8, 2023
638fd5f
Add TU
callemand Jun 9, 2023
57801f8
Fix TU
callemand Jun 9, 2023
d3004e4
Add Password "eye" and hide config when service is not started
callemand Jun 9, 2023
27a4b86
prettier
callemand Jun 9, 2023
c88416f
Fix test
callemand Jun 27, 2023
231efc6
Fix test
callemand Jun 27, 2023
5591142
Update saveConfiguration.test.js
callemand Jun 27, 2023
55b79ac
Fix url and enable nodered
callemand Jul 11, 2023
b9d2478
fix eslint and prettier
callemand Jul 11, 2023
f1e95d4
Fix test
callemand Jul 11, 2023
18069a9
Fixing review
callemand Sep 4, 2023
71e739f
Fix test
callemand Sep 4, 2023
db32d83
Fix review
callemand Sep 5, 2023
a8f1477
Move button
callemand Sep 6, 2023
7e43cc8
Change UX
callemand Sep 8, 2023
55174d1
Fix eslint
callemand Sep 8, 2023
c1c285b
Fix after review
callemand Sep 11, 2023
c63f917
Fix test
callemand Sep 11, 2023
18d7209
Fix review
callemand Sep 11, 2023
9447232
Fix review
callemand Sep 12, 2023
3d62c5c
Fix folder binding
callemand Sep 19, 2023
1e96ec8
Add some logs for debug
callemand Sep 27, 2023
2e04d79
Add logs
callemand Sep 27, 2023
e91656f
Remove logs
callemand Sep 27, 2023
6210b4e
Fix test
callemand Sep 27, 2023
d379b5b
Fix button display
callemand Sep 28, 2023
f5258bb
Fix save config before start
callemand Sep 28, 2023
7921c55
Add warning message for backup
callemand Oct 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added front/src/assets/integrations/cover/node-red.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions front/src/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ import MELCloudEditPage from '../routes/integration/all/melcloud/edit-page';
import MELCloudSetupPage from '../routes/integration/all/melcloud/setup-page';
import MELCloudDiscoverPage from '../routes/integration/all/melcloud/discover-page';

// NodeRed integration
import NodeRedPage from '../routes/integration/all/node-red/setup-page';

const defaultState = getDefaultState();
const store = createStore(defaultState);

Expand Down Expand Up @@ -249,6 +252,9 @@ const AppRouter = connect(
<Zigbee2mqttSettingsPage path="/dashboard/integration/device/zigbee2mqtt/settings" />
<Zigbee2mqttSetupPage path="/dashboard/integration/device/zigbee2mqtt/setup" />
<Zigbee2mqttEditPage path="/dashboard/integration/device/zigbee2mqtt/edit/:deviceSelector" />

<NodeRedPage path="/dashboard/integration/device/node-red" />

<XiaomiPage path="/dashboard/integration/device/xiaomi" />
<EditXiaomiPage path="/dashboard/integration/device/xiaomi/edit/:deviceSelector" />
<TasmotaPage path="/dashboard/integration/device/tasmota" />
Expand Down
36 changes: 36 additions & 0 deletions front/src/config/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,42 @@
"saveError": "There was an error saving the device.",
"documentation": "Zigbee2mqtt documentation"
},
"nodeRed": {
"title": "Node-RED",
"description": "Control your devices with Node-RED.",
"setupTab": "Setup",
"documentation": "Node-RED documentation",

"status": {
"notInstalled": "Node-RED server failed to install.",
"notRunning": "Node-RED server failed to start.",
"running": "Node-RED successfully started.",
"notEnabled": "Node-RED is not activated.",
"nonDockerEnv": "Gladys is not running on Docker, you cannot install a Node-RED server from here.",
"invalidDockerNetwork": "Gladys is under custom installation, to install server from here, Gladys container should be configured with \"host\" network mode."
},
"setup": {
"title": "Node-RED configuration",
"description": "This service uses docker container. Enable Node-RED for deploying this container.\nLearn more on the node-red documentation page",
"descriptionBackup": "For the moment, Node-RED is not backup into Gladys Plus.\nIf you want a backup for Node-RED, please follow this <a href=\"https://community.gladysassistant.com/t/mini-tuto-backup-par-email-des-flows-node-red/8402\" target=\"_blank\" rel=\"noopener noreferrer\">docs</a>",
"error": "An error occured while starting Node-RED.",
"enableLabel": "Node-RED activation",
"enableNodeRed": "Enable",
"disableNodeRed": "Disable",
"confirmDisableLabel": "Are you sur you to disable Node-RED ?",
"confirmDisableCancelButton": "Cancel",
"activationNodeRed": "Activating...",
"serviceStatus": "Node-RED Service Status",
"containersStatus": "Containers related to Node-RED",
"status": "Status",
"node-red": "Node-RED",
"gladys": "Gladys",
"usernameLabel": "Username",
"passwordLabel": "Password",
"urlLabel": "Node-RED interface url: <a href=\"{{nodeRedUrl}}\" target=\"_blank\">{{nodeRedUrl}}</a> (Not accessible from Gladys Plus)"
}
},

"googleHome": {
"title": "Google Home",
"description": "Control your Gladys device with your voice in Google Home",
Expand Down
35 changes: 35 additions & 0 deletions front/src/config/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,41 @@
"saveError": "Une erreur s'est produite lors de la sauvegarde.",
"documentation": "Documentation Zigbee2mqtt"
},
"nodeRed": {
"title": "Node-RED",
"description": "Contrôlez vos appareils via Node-RED.",
"setupTab": "Configuration",
"documentation": "Documentation Node-RED",
"status": {
"notInstalled": "Le serveur Node-RED n'a pas pu être installé.",
"notRunning": "Le serveur Node-RED n'a pas démarré.",
"running": "Node-RED démarré avec succès.",
"notEnabled": "Node-RED n'est pas activé.",
"nonDockerEnv": "Gladys ne s'exécute actuellement pas dans Docker, il est impossible d'activer Node-RED depuis Gladys.",
"invalidDockerNetwork": "Gladys est basée sur une installation personalisée, pour installer Node-RED depuis cette page, le conteneur Docker de Gladys doit être démarré avec l'option \"network=host\"."
},
"setup": {
"title": "Configuration du service Node-RED",
"description": "Ce service utilise un container Docker. Activez Node-RED pour déployer ce container.\nPour en savoir plus, rendez-vous sur la page de documentation Node-RED.",
"descriptionBackup": "Pour le moment, Node-RED n'est pas sauvegardé dans Gladys Plus.\nSi vous souhaitez une sauvegarde pour Node-RED, veuillez suivre cette <a href=\"https://community.gladysassistant.com/t/mini-tuto-backup-par-email-des-flows-node-red/8402\" target=\"_blank\" rel=\"noopener noreferrer\">documentation</a>",
"error": "Une erreur s'est produite au démarrage du service Node-RED.",
"enableLabel": "Activation du service Node-RED",
"enableNodeRed": "Activer",
"disableNodeRed": "Désactiver",
"confirmDisableLabel": "Etes-vous sûr de vouloir désactiver Node-RED ?",
"confirmDisableCancelButton": "Annuler",
"activationNodeRed": "Activation...",
"serviceStatus": "Etat du service Node-RED",
"containersStatus": "Conteneurs liés à Node-RED",
"status": "Status",
"node-red": "Node-RED",
"gladys": "Gladys",
"usernameLabel": "Nom d'utilisateur",
"passwordLabel": "Mot de passe",
"urlLabel": "Url de l'interface Node-RED : <a href=\"{{nodeRedUrl}}\" target=\"_blank\">{{nodeRedUrl}}</a> (Pas accessible depuis Gladys Plus)"
}
},

"googleHome": {
"title": "Google Home",
"description": "Contrôlez vos appareils Gladys à la voix dans Google Home",
Expand Down
5 changes: 5 additions & 0 deletions front/src/config/integrations/devices.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,10 @@
"key": "melcloud",
"link": "melcloud",
"img": "/assets/integrations/cover/melcloud.jpg"
},
{
"key": "nodeRed",
"link": "node-red",
"img": "/assets/integrations/cover/node-red.jpg"
}
]
50 changes: 50 additions & 0 deletions front/src/routes/integration/all/node-red/NodeRedPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Text } from 'preact-i18n';
import { Link } from 'preact-router/match';
import DeviceConfigurationLink from '../../../../components/documentation/DeviceConfigurationLink';

const NodeRedPage = ({ children, user }) => (
<div class="page">
<div class="page-main">
<div class="my-3 my-md-5">
<div class="container">
<div class="row">
<div class="col-lg-3">
<h3 class="page-title mb-5">
<Text id="integration.nodeRed.title" />
</h3>
<div>
<div class="list-group list-group-transparent mb-0">
<Link
href="/dashboard/integration/device/node-red"
activeClassName="active"
class="list-group-item list-group-item-action d-flex align-items-center"
>
<span class="icon mr-3">
<i class="fe fe-sliders" />
</span>
<Text id="integration.nodeRed.setupTab" />
</Link>

<DeviceConfigurationLink
user={user}
documentKey="node-red"
linkClass="list-group-item list-group-item-action d-flex align-items-center"
>
<span class="icon mr-3">
<i class="fe fe-book-open" />
</span>
<Text id="integration.nodeRed.documentation" />
</DeviceConfigurationLink>
</div>
</div>
</div>

<div class="col-lg-9">{children}</div>
</div>
</div>
</div>
</div>
</div>
);

export default NodeRedPage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Component } from 'preact';
import { Text } from 'preact-i18n';
import { RequestStatus } from '../../../../../utils/consts';
import style from './style.css';
import classNames from 'classnames/bind';

let cx = classNames.bind(style);

class CheckStatus extends Component {
render({ nodeRedEnabled, nodeRedExist, nodeRedRunning, dockerBased, networkModeValid, nodeRedStatus }, {}) {
let textLabel = null;
if (nodeRedStatus === RequestStatus.Getting) {
textLabel = 'integration.nodeRed.setup.activationNodeRed';
} else if (!dockerBased) {
textLabel = 'integration.nodeRed.status.nonDockerEnv';
} else if (!networkModeValid) {
textLabel = 'integration.nodeRed.status.invalidDockerNetwork';
} else if (nodeRedEnabled) {
if (!nodeRedExist) {
textLabel = 'integration.nodeRed.status.notInstalled';
} else if (!nodeRedRunning) {
textLabel = 'integration.nodeRed.status.notRunning';
} else {
textLabel = 'integration.nodeRed.status.running';
}
} else {
textLabel = 'integration.nodeRed.status.notEnabled';
}

return (
<div>
<div
class={cx('d-flex', 'flex-row', 'flex-wrap', 'justify-content-between', 'mr-0', 'ml-0', 'alert', {
'alert-success': nodeRedEnabled && nodeRedExist && nodeRedRunning,
'alert-warning': nodeRedEnabled && nodeRedExist && !nodeRedRunning,
'alert-danger': (nodeRedEnabled && !nodeRedExist) || !dockerBased || !networkModeValid,
'alert-info': !nodeRedEnabled
})}
>
<div class={cx(style.textAlignMiddleContainer)}>
<span class={cx(style.textAlignMiddle)}>
<Text id={textLabel} />
</span>
</div>
</div>
</div>
);
}
}

export default CheckStatus;
Loading
Loading