mirror of
https://github.com/YunoHost/test_apps.git
synced 2024-09-03 20:06:29 +02:00
[enh] New config panel test
This commit is contained in:
parent
2403d99912
commit
9e5167bf05
3 changed files with 124 additions and 65 deletions
|
@ -1,11 +1,10 @@
|
|||
version = "0.1"
|
||||
name = "Configuration panel"
|
||||
version = "1.0"
|
||||
|
||||
[main]
|
||||
name = "Main panel"
|
||||
|
||||
services = ["nginx"]
|
||||
[main.components]
|
||||
name = "Components"
|
||||
name = ""
|
||||
|
||||
[main.components.boolean]
|
||||
ask = "Put a boolean"
|
||||
|
@ -20,13 +19,13 @@ name = "Main panel"
|
|||
[main.components.range]
|
||||
ask = "Put a range"
|
||||
type = "range"
|
||||
min = 1
|
||||
min = 0
|
||||
max = 100
|
||||
step = 10
|
||||
|
||||
[main.components.str]
|
||||
ask = "Put a string with yunohost word"
|
||||
ask = "Put a string"
|
||||
type = "string"
|
||||
pattern = "yunohost"
|
||||
|
||||
[main.components.text]
|
||||
ask = "Put a text"
|
||||
|
@ -63,8 +62,9 @@ name = "Main panel"
|
|||
[main.components.select]
|
||||
ask = "Choose an option"
|
||||
type = "select"
|
||||
choices = ["option1", "option2", "option3"]
|
||||
default = "option1"
|
||||
choices.option1 = "Plop1"
|
||||
choices.option2 = "Plop2"
|
||||
choices.option3 = "Plop3"
|
||||
|
||||
[main.components.domain]
|
||||
ask = "Put a domain"
|
||||
|
@ -75,32 +75,47 @@ name = "Main panel"
|
|||
type = "user"
|
||||
|
||||
[main.components.tags]
|
||||
ask = "Put some tags"
|
||||
ask = "Put some emails"
|
||||
type = "tags"
|
||||
placeholder = "Enter some emails separated by commas"
|
||||
limit = 3
|
||||
pattern.regexp = '^.+@.+$'
|
||||
pattern.error = 'An email is required for this field'
|
||||
|
||||
# [main.components.file]
|
||||
# ask = "Put a file"
|
||||
# type = "file"
|
||||
# accept = ".cube"
|
||||
[main.components.tags2]
|
||||
ask = "Put some tags from a list"
|
||||
type = "tags"
|
||||
choices = ['table', 'chair', 'bed', 'desk']
|
||||
placeholder = "Add some tags"
|
||||
icon = "bed"
|
||||
|
||||
[main.components.file]
|
||||
ask = "Put a file"
|
||||
type = "file"
|
||||
|
||||
[main.messages]
|
||||
name = "Read only components"
|
||||
|
||||
[main.messages.success]
|
||||
ask = "This is a success message"
|
||||
type = "success"
|
||||
type = "alert"
|
||||
style = "success"
|
||||
icon = "beer"
|
||||
|
||||
[main.messages.info]
|
||||
ask = "This is an info message"
|
||||
type = "info"
|
||||
type = "alert"
|
||||
style = "info"
|
||||
|
||||
[main.messages.warning]
|
||||
ask = "This is an warning message"
|
||||
type = "warning"
|
||||
type = "alert"
|
||||
style = "warning"
|
||||
|
||||
[main.messages.danger]
|
||||
ask = "This is a danger message"
|
||||
type = "danger"
|
||||
type = "alert"
|
||||
style = "danger"
|
||||
|
||||
[main.messages.display_text]
|
||||
ask = "This is a simple text"
|
||||
|
@ -113,10 +128,11 @@ name = "Main panel"
|
|||
[main.generic]
|
||||
name = "Generic options"
|
||||
|
||||
[main.generic.default]
|
||||
ask = "This is a question with a default value"
|
||||
[main.generic.pattern]
|
||||
ask = "This is a question with a pattern validation"
|
||||
type = "string"
|
||||
default = "Camille"
|
||||
pattern.regexp = '^[A-F]\d\d$'
|
||||
pattern.error = "Provide a room like F12 : one uppercase and 2 numbers"
|
||||
|
||||
[main.generic.example]
|
||||
ask = "This is a question with an example value"
|
||||
|
@ -133,16 +149,26 @@ name = "Main panel"
|
|||
type = "string"
|
||||
help = "You can feel this question with your keyboard (yes i know it's very useful)"
|
||||
|
||||
[main.generic.helpLink]
|
||||
[main.generic.helplink]
|
||||
ask = "Here we add an help link"
|
||||
type = "string"
|
||||
type = "select"
|
||||
choices.question = "Display next question"
|
||||
choices.section = "Display next section"
|
||||
helpLink.href = "https://yunohost.org/doc"
|
||||
helpLink.text = "Yunohost Doc"
|
||||
|
||||
[main.generic.visibleIf]
|
||||
[main.generic.visibleif]
|
||||
ask = "Display if helpLink question is filled"
|
||||
type = "string"
|
||||
visibleIf = "helplink == 'question'"
|
||||
|
||||
[main.ifsection]
|
||||
name = "Section displayed only if helplink is filled"
|
||||
visibleIf = "helplink == 'section'"
|
||||
|
||||
[main.ifsection.sub]
|
||||
ask = "Display if helpLink question is filled"
|
||||
type = "string"
|
||||
visibleIf = "helpLink == 'plop'"
|
||||
|
||||
[source]
|
||||
name = "Source section"
|
||||
|
@ -154,58 +180,63 @@ name = "Source section"
|
|||
ask = "Save app settings arg1"
|
||||
type = "string"
|
||||
|
||||
[source.yml]
|
||||
[source.variable]
|
||||
name = "YAML"
|
||||
|
||||
[source.yml.arg2]
|
||||
[source.variable.arg2]
|
||||
ask = "Save arg2 in YAML"
|
||||
type = "string"
|
||||
source = "__FINALPATH__/test.yml"
|
||||
source = ":__FINALPATH__/test.yml"
|
||||
|
||||
[source.json]
|
||||
name = "JSON"
|
||||
|
||||
[source.json.arg3]
|
||||
[source.variable.arg3]
|
||||
ask = "Save arg3 in JSON"
|
||||
type = "string"
|
||||
source = "__FINALPATH__/test.json"
|
||||
source = ":__FINALPATH__/test.json"
|
||||
|
||||
[source.ini]
|
||||
name = "INI"
|
||||
|
||||
[source.ini.arg4]
|
||||
[source.variable.arg4]
|
||||
ask = "Save arg4 in INI"
|
||||
type = "string"
|
||||
source = "__FINALPATH__/test.ini"
|
||||
source = ":__FINALPATH__/test.ini"
|
||||
|
||||
[source.php]
|
||||
name = "PHP"
|
||||
|
||||
[source.php.arg5]
|
||||
[source.variable.arg5]
|
||||
ask = "Save arg5 in PHP file"
|
||||
type = "string"
|
||||
source = "__FINALPATH__/test.php"
|
||||
source = ":__FINALPATH__/test.php"
|
||||
|
||||
[source.python]
|
||||
name = "Python"
|
||||
|
||||
[source.python.arg6]
|
||||
[source.variable.arg6]
|
||||
ask = "Save arg6 in python file"
|
||||
type = "string"
|
||||
source = "__FINALPATH__/test.py"
|
||||
source = ":__FINALPATH__/test.py"
|
||||
|
||||
# [source.file]
|
||||
# name = "File"
|
||||
#
|
||||
# [source.file.arg7]
|
||||
# ask = "Save a cube file"
|
||||
# type = "file"
|
||||
# accept = ".cube"
|
||||
# source = "__FINALPATH__/test.cube"
|
||||
[source.file]
|
||||
name = "File"
|
||||
|
||||
[source.file.arg7]
|
||||
ask = "Save a cube file"
|
||||
type = "file"
|
||||
accept = ".cube"
|
||||
source = "__FINALPATH__/test.cube"
|
||||
|
||||
[source.file.arg7b]
|
||||
ask = "Nginx file"
|
||||
type = "text"
|
||||
source = "__FINALPATH__/nginx.conf"
|
||||
|
||||
[source.function]
|
||||
name = "Save with a bash function"
|
||||
name = "Bash function"
|
||||
|
||||
[source.function.arg8]
|
||||
ask = "Custom validate and save arg8 password"
|
||||
ask = "Custom validator and setter for arg8 password"
|
||||
type = "password"
|
||||
source = ""
|
||||
|
||||
[source.function.arg9]
|
||||
ask = "Custom getter arg9"
|
||||
type = "markdown"
|
||||
source = ""
|
||||
|
||||
[source.function.alert]
|
||||
ask = "Custom getter alert"
|
||||
type = "alert"
|
||||
style = "info"
|
||||
source = ""
|
||||
|
|
|
@ -20,16 +20,42 @@ final_path=$(ynh_app_setting_get $app final_path)
|
|||
# SPECIFIC GETTERS FOR TOML SHORT KEY
|
||||
#=================================================
|
||||
|
||||
get__arg8() {
|
||||
echo ""
|
||||
get__arg9() {
|
||||
cat << EOF
|
||||
ask:
|
||||
en: |
|
||||
### Files in $final_path
|
||||
|
||||
| Name | weight |
|
||||
| ---- | ------ |
|
||||
EOF
|
||||
for file in $final_path/* ; do
|
||||
echo " | $file | $(du -sh $file | cut -f1) |"
|
||||
done
|
||||
}
|
||||
|
||||
get__alert() {
|
||||
if [ -f "/sys/class/net/tun0/operstate" ] && [ "$(cat /sys/class/net/tun0/operstate)" == "up" ]
|
||||
then
|
||||
cat << EOF
|
||||
style: success
|
||||
ask:
|
||||
en: Your VPN is running :)
|
||||
EOF
|
||||
else
|
||||
cat << EOF
|
||||
style: danger
|
||||
ask:
|
||||
en: Your VPN is down
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
|
||||
#=================================================
|
||||
validate__arg8() {
|
||||
[[ "${#arg8}" -lt 8 ]] &&
|
||||
echo 'Too short password'
|
||||
if [[ "${#arg8}" -lt 8 ]]; then echo 'Too short password'; fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
@ -39,6 +65,7 @@ set__arg8() {
|
|||
if [ -z "${arg8}" ]
|
||||
then
|
||||
python -c "import crypt; print(crypt.crypt(\"${arg8}\", \"\$6\$saltsalt\$\"))" > $final_path/password
|
||||
ynh_print_info "The hash of your password has been registered in $final_path/password"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -47,7 +74,7 @@ set__arg8() {
|
|||
#=================================================
|
||||
ynh_panel_apply() {
|
||||
_ynh_panel_apply
|
||||
systemctl restart nginx
|
||||
systemctl reload nginx
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -4,7 +4,8 @@ set -eux
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
mkdir -p /var/www/$app
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
mkdir -p $final_path
|
||||
|
||||
cp ../conf/* /var/www/$app/
|
||||
|
|
Loading…
Add table
Reference in a new issue