Skip to content
Snippets Groups Projects
Commit 3eb9b0b7 authored by Bob Mottram's avatar Bob Mottram
Browse files

Categories for apps to be added

parent 1af181e2
No related branches found
No related tags found
No related merge requests found
......@@ -393,45 +393,31 @@ function web_admin_create_users {
chown www-data:www-data "$users_file"
}
function web_admin_create_add_apps {
web_admin_get_hostname
function get_app_categories {
APP_CATEGORY=()
APP_CATEGORY+=("chat")
APP_CATEGORY+=("media")
APP_CATEGORY+=("office")
APP_CATEGORY+=("social")
APP_CATEGORY+=("sync")
APP_CATEGORY+=("publishing")
APP_CATEGORY+=("other")
}
appslist_add_filename="$webadmin_install_dir/apps_add.html"
if [ -f "$webadmin_install_dir/.setupscreenactive" ]; then
if [ ! -f "$webadmin_install_dir/.running_install_command" ]; then
if [ -f "$appslist_add_filename" ]; then
rm "$appslist_add_filename"
fi
if [ ! -d "$INSTALL_DIR/tempwebadmin" ]; then
mkdir -p "$INSTALL_DIR/tempwebadmin"
fi
mv "$webadmin_install_dir/app_add_"*.html "$INSTALL_DIR/tempwebadmin"
return
fi
fi
function web_admin_create_add_apps_category {
# This counter is used to enforce 4 icon rows
available_apps_ctr=0
read_config_param DDNS_PROVIDER
read_config_param ONION_ONLY
apps_add_template_filename="$webadmin_install_dir/apps_add_template.html"
pending_installs="$webadmin_install_dir/pending_installs.txt"
icons_dir="$webadmin_install_dir/icons"
app_add_template_filename="$webadmin_install_dir/app_add_template.html"
FILES="/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*"
# Index within the array of all apps
app_index=0
if [ ! -d "$icons_dir" ]; then
mkdir -p "$icons_dir"
fi
# shellcheck disable=SC2086
category_str="$(tr '[:lower:]' '[:upper:]' <<< ${category:0:1})${category:1}"
translated_category=$(web_admin_translate_text "$category_str")
if [ ! -f "$apps_add_template_filename" ]; then
return
fi
cp "$apps_add_template_filename" "$appslist_add_filename"
sed -i '/<\/div>/d' "$appslist_add_filename"
sed -i '/<\/body>/d' "$appslist_add_filename"
sed -i '/<\/html>/d' "$appslist_add_filename"
apps_header_str="<fieldset class=\"field_set\"><legend class=\"category\">$translated_category</legend>"
echo " $apps_header_str" >> "$appslist_filename"
available_apps_ctr=0
app_index=0
for filename in $FILES
do
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
......@@ -467,6 +453,21 @@ function web_admin_create_add_apps {
if [ ! $app_is_installed ]; then
app_filename="/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"
if [ -f "$app_filename" ]; then
# does this app have a category?
if ! grep -q 'APP_CATEGORY=' "$app_filename"; then
if [[ "$category" != 'other' ]]; then
app_index=$((app_index+1))
continue
fi
fi
# Does this app belong in the current category?
if ! grep -q "APP_CATEGORY=$category" "$app_filename"; then
app_index=$((app_index+1))
continue
fi
if grep -q "VARIANTS=''" "$app_filename"; then
continue
fi
......@@ -598,9 +599,59 @@ function web_admin_create_add_apps {
echo ' </div>';
echo ' </div>'; } >> "$appslist_add_filename"
done
echo ' </div>' >> "$appslist_add_filename"
{ echo ' </div>';
echo ' </fieldset>'; } >> "$appslist_add_filename"
else
# remove the header for this category
sed -i "/$apps_header_str/d" "$appslist_add_filename"
fi
}
function web_admin_create_add_apps {
web_admin_get_hostname
appslist_add_filename="$webadmin_install_dir/apps_add.html"
if [ -f "$webadmin_install_dir/.setupscreenactive" ]; then
if [ ! -f "$webadmin_install_dir/.running_install_command" ]; then
if [ -f "$appslist_add_filename" ]; then
rm "$appslist_add_filename"
fi
if [ ! -d "$INSTALL_DIR/tempwebadmin" ]; then
mkdir -p "$INSTALL_DIR/tempwebadmin"
fi
mv "$webadmin_install_dir/app_add_"*.html "$INSTALL_DIR/tempwebadmin"
return
fi
fi
read_config_param DDNS_PROVIDER
read_config_param ONION_ONLY
apps_add_template_filename="$webadmin_install_dir/apps_add_template.html"
pending_installs="$webadmin_install_dir/pending_installs.txt"
icons_dir="$webadmin_install_dir/icons"
app_add_template_filename="$webadmin_install_dir/app_add_template.html"
FILES="/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*"
if [ ! -d "$icons_dir" ]; then
mkdir -p "$icons_dir"
fi
if [ ! -f "$apps_add_template_filename" ]; then
return
fi
cp "$apps_add_template_filename" "$appslist_add_filename"
sed -i '/<\/div>/d' "$appslist_add_filename"
sed -i '/<\/body>/d' "$appslist_add_filename"
sed -i '/<\/html>/d' "$appslist_add_filename"
get_app_categories
# shellcheck disable=SC2068,SC2034
for category in ${APP_CATEGORY[@]}
do
web_admin_create_add_apps_category
done
{ echo ' </div>';
echo ' <br><br>';
echo ' </body>';
......@@ -609,17 +660,6 @@ function web_admin_create_add_apps {
chown -R www-data:www-data "$webadmin_install_dir"
}
function get_app_categories {
APP_CATEGORY=()
APP_CATEGORY+=("chat")
APP_CATEGORY+=("media")
APP_CATEGORY+=("office")
APP_CATEGORY+=("social")
APP_CATEGORY+=("sync")
APP_CATEGORY+=("publishing")
APP_CATEGORY+=("other")
}
function web_admin_create_installed_apps_category {
# This counter is used to enforce 4 icon rows
installed_apps_ctr=0
......
......@@ -34,6 +34,19 @@
min-width : 220px;
}
.category {
text-align: left;
color: #72a7cf;
font-size: 130%;
padding-top: 2%;
padding-bottom: 2%;
}
.field_set{
border-color: #cfdde7;
border-style: solid;
}
.header {
text-align: center;
padding: 32px;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment