From e50cf3a5455b7fe0ccb8095ed56056342833efb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 7 Nov 2024 09:26:42 +0100 Subject: [PATCH] add config panel --- conf/config.js | 6 +++--- config_panel.toml | 42 ++++++++++++++++++++++++++++++++++++++++++ scripts/install | 16 ++++++++++++++++ scripts/upgrade | 25 +++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 config_panel.toml diff --git a/conf/config.js b/conf/config.js index 47fe7cc..0af4b36 100644 --- a/conf/config.js +++ b/conf/config.js @@ -156,7 +156,7 @@ const conf = convict({ max_file_size: { format: Number, default: 1024 * 1024 * 1024 * 2.5, - env: 'MAX_FILE_SIZE' + env: '__MAX_FILE_SIZE__' }, l10n_dev: { format: Boolean, @@ -171,12 +171,12 @@ const conf = convict({ custom_title: { format: String, default: 'Send', - env: 'CUSTOM_TITLE' + env: '__CUSTOM_TITLE__' }, custom_description: { format: String, default: 'Encrypt and send files with a link that automatically expires to ensure your important documents don’t stay online forever.', - env: 'CUSTOM_DESCRIPTION' + env: '__CUSTOM_DESCRIPTION__' }, detect_base_url: { format: Boolean, diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..6170feb --- /dev/null +++ b/config_panel.toml @@ -0,0 +1,42 @@ +version = "1.0" + +[main] +name.en = "Send configuration" +name.fr = "Configuration de Send" +services = ["__APP__"] + + [main.config] + name.en = "Configuration Options" + name.fr = "Options de configuration" + + [main.config.max_file_size] + ask.en = "Max File Size" + ask.fr = "Taille maximale du fichier" + type = "number" + default = "2684354560" + help.en = "Define the maximum file size limit" + help.fr = "Définir la limite de taille maximale du fichier" + bind = ":__INSTALL_DIR__/server/config.js" + + [main.config.max_download] + ask.en = "Max download" + ask.fr = "Téléchargement maximal" + type = "number" + default = "100" + help.en = "Define the maximum download limit" + help.fr = "Définir la limite maximale du nombre de téléchargement" + bind = ":__INSTALL_DIR__/server/config.js" + + [main.config.custom_title] + ask.en = "Custom Title" + ask.fr = "Titre personnalisé" + type = "string" + help = "Add a custom title for Send" + bind = ":__INSTALL_DIR__/server/config.js" + + [main.config.custom_description] + ask.en = "Custom Description" + ask.fr = "Description personnalisée" + type = "string" + help = "Add a custom description for Send" + bind = ":__INSTALL_DIR__/server/config.js" diff --git a/scripts/install b/scripts/install index 056a1a5..49f7a74 100644 --- a/scripts/install +++ b/scripts/install @@ -3,6 +3,22 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# INITIALIZE AND STORE SETTINGS +#================================================= + +custom_title="Send" +ynh_app_setting_set --key=custom_title --value="$custom_title" + +custom_description="Encrypt and send files with a link that automatically expires to ensure your important documents don’t stay online forever." +ynh_app_setting_set --key=custom_description --value="$custom_description" + +max_file_size="2684354560" +ynh_app_setting_set --key=cmax_file_size --value="$max_file_size" + +max_download="100" +ynh_app_setting_set --key=max_download --value="$max_download" + #================================================= # INSTALL DEPENDENCIES #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 2aba8b3..c4d752f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -3,6 +3,31 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression "Ensuring downward compatibility..." + +if [ -z ${custom_title:-} ]; then + custom_title=Send + ynh_app_setting_set --key=custom_title --value="$custom_title" +fi + +if [ -z ${custom_description:-} ]; then + custom_description="Encrypt and send files with a link that automatically expires to ensure your important documents don’t stay online forever." + ynh_app_setting_set --key=custom_description --value="$custom_description" +fi + +if [ -z ${max_file_size:-} ]; then + max_file_size="2684354560" + ynh_app_setting_set --key=cmax_file_size --value="$max_file_size" +fi + +if [ -z ${max_download:-} ]; then + max_download="100" + ynh_app_setting_set --key=max_download --value="$max_download" +fi + #================================================= # STOP SYSTEMD SERVICE #=================================================