1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nodered_ynh.git synced 2024-09-03 19:46:25 +02:00

Merge pull request #48 from fflorent/testing

Add file for user specific settings
This commit is contained in:
tituspijean 2021-12-26 17:41:38 +01:00 committed by GitHub
commit aa42d6c069
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 111 additions and 3 deletions

View file

@ -1,3 +1,11 @@
// CAUTION: DO NOT EDIT THIS FILE. Rather go to and edit `__FINALPATH__/settings.user.js`
const getUserSettings = require('./settings.user');
/** /**
* This is the default settings file provided by Node-RED. * This is the default settings file provided by Node-RED.
* *
@ -20,7 +28,7 @@
* *
**/ **/
module.exports = { const defaultSettings = Object.freeze({
/******************************************************************************* /*******************************************************************************
* Flow File and User Directory Settings * Flow File and User Directory Settings
@ -483,4 +491,9 @@ module.exports = {
// * - reason: if result is false, the HTTP reason string to return // * - reason: if result is false, the HTTP reason string to return
// */ // */
//}, //},
} });
module.exports = {
...defaultSettings,
...getUserSettings(defaultSettings),
};

46
conf/settings.user.js Normal file
View file

@ -0,0 +1,46 @@
/**
*
* This is where you you can as a user define and even override the default settings.
* This file will remain untouched by the yunohost package accross upgrades.
*
* It can contain any valid JavaScript code that will get run when Node-RED
* is started.
*
* Lines that start with // are commented out.
* Each entry should be separated from the entries above and below by a comma ','
*
* For more information about individual settings, refer to the documentation:
* https://nodered.org/docs/user-guide/runtime/configuration
*
* The settings are split into the following sections:
* - Flow File and User Directory Settings
* - Security
* - Server Settings
* - Runtime Settings
* - Editor Settings
* - Node Settings
*
**/
module.exports = (defaultSettings) => ({
/**
* Put here your own config, it will override the ones in settings.js
*
* Example:
* ```js
* module.exports = (defaultSettings) => ({
* lang: "de", // define the language as "de"
* exportGlobalContextKeys: true, // override the `exportGlobalContextKeys` value
*
*
* logging: { // replace the default logging option
* ...defaultSettings.logging, // this will reinject the default settings in logging
* console: {
* ...defaultSettings.logging.level, // this will reinject the default settings in logging.console
* level: "debug", // but here, we override the "info" level by "debug"
* },
* },
* });
* ```
*/
});

View file

@ -8,3 +8,22 @@ It provides a browser-based editor that makes it easy to wire together flows usi
- On-click deployment of the flows - On-click deployment of the flows
- Over 225,000 modules available - Over 225,000 modules available
- Custom JavaScript functions can be written - Custom JavaScript functions can be written
### Override the default settings
From the installation directory, go edit the `data/settings.user.js`. For example:
```js
module.exports = (defaultSettings) => ({
lang: "de", // define the language as "de"
exportGlobalContextKeys: true, // override the `exportGlobalContextKeys` value
logging: { // replace the default logging option ...defaultSettings.logging, // this will reinject the default settings in logging
console: {
...defaultSettings.logging.level, // this will reinject the default settings in logging.console
level: "debug", // but here, we override the "info" level by "debug"
},
},
});
```
You can check the default settings Yunohost generates at `data/settings.js` and find the documentation for configuring Node-RED here: https://nodered.org/docs/user-guide/runtime/configuration

View file

@ -8,3 +8,25 @@ Il propose un éditeur accessible dans le navigateur, qui facilite l'ébauche de
- Déploiement des flux en un clic - Déploiement des flux en un clic
- Plus de 225 000 modules disponibles - Plus de 225 000 modules disponibles
- Fonctions personnalisées en JavaScript - Fonctions personnalisées en JavaScript
### Surcharger la configuration par défaut
Depuis le répertoire d'installation, éditer le fichier `data/settings.user.js`. Par exemple
```js
module.exports = (defaultSettings) => ({
lang: "de", // définit la langue de l'IHM comme allemande
exportGlobalContextKeys: true, // surcharger la valeur de `exportGlobalContextKeys`
logging: { // remplacer l'option par défaut pour la journalisation (logging)
...defaultSettings.logging, // cela réinjectera les paramètres par défaut dans `logging`
console: {
...defaultSettings.logging.level, // cela réinjectera les paramètres par défaut dans `logging.console`
level: "debug", // mais isi, nous surchargeons le niveau "info" par "debug"
},
},
});
```
Vous pouvez consulter les paramètres par défaut générez par Yunohost dans `data/settings.js` et trouver la documentation pour configurer Node-RED ici: https://nodered.org/docs/user-guide/runtime/configuration

View file

@ -6,7 +6,7 @@
"en": "Flow-based programming for the Internet of Things", "en": "Flow-based programming for the Internet of Things",
"fr": "Programmation par flux de données pour l'Internet des objets" "fr": "Programmation par flux de données pour l'Internet des objets"
}, },
"version": "2.1.4~ynh1", "version": "2.1.4~ynh2",
"url": "https://nodered.org", "url": "https://nodered.org",
"upstream": { "upstream": {
"license": "Apache-2.0", "license": "Apache-2.0",

View file

@ -107,6 +107,7 @@ ynh_add_nginx_config
# Set up the settings file # Set up the settings file
mkdir -p $final_path/data mkdir -p $final_path/data
ynh_add_config --template="../conf/settings.js" --destination="$final_path/data/settings.js" ynh_add_config --template="../conf/settings.js" --destination="$final_path/data/settings.js"
ynh_add_config --template="../conf/settings.user.js" --destination="$final_path/data/settings.user.js"
# Small hack to have the "/" path answer with a 200 code to satisfy the CI # Small hack to have the "/" path answer with a 200 code to satisfy the CI
if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] ; then if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] ; then
@ -120,6 +121,8 @@ fi
chmod 750 "$final_path" chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app: "$final_path" chown -R $app: "$final_path"
# make settings.js readonly
chmod a-w "$final_path/data/settings.js"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD

View file

@ -175,6 +175,9 @@ ynh_add_nginx_config
# Set up the settings file # Set up the settings file
ynh_add_config --template="../conf/settings.js" --destination="$final_path/data/settings.js" ynh_add_config --template="../conf/settings.js" --destination="$final_path/data/settings.js"
if [[ ! -f "$final_path/data/settings.user.js" ]] ; then
ynh_add_config --template="../conf/settings.user.js" --destination="$final_path/data/settings.user.js"
fi
# Small hack to have the "/" path answer with a 200 code to satisfy the CI # Small hack to have the "/" path answer with a 200 code to satisfy the CI
if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] ; then if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] ; then
@ -207,6 +210,8 @@ ynh_add_systemd_config
chmod 750 "$final_path" chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app: "$final_path" chown -R $app: "$final_path"
# make settings.js readonly
chmod a-w "$final_path/data/settings.js"
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL