Files
TimeTracker/docker/fix-docker-permissions.sh
Dries Peeters d230a41e8a feat: enhance web interface layout and fix logo import circular dependency
- Improve web interface layout for better user-friendliness and mobile responsiveness
  * Update CSS variables for consistent spacing and component sizing
  * Enhance card layouts with improved padding, borders, and shadows
  * Optimize button and form element dimensions for better touch targets
  * Add hover effects and animations for improved user interaction
  * Implement responsive grid system with mobile-first approach

- Refactor mobile JavaScript to prevent duplicate initialization
  * Consolidate mobile enhancements into dedicated utility classes
  * Add initialization guards to prevent double loading
  * Implement MobileUtils and MobileNavigation classes
  * Remove duplicate event listeners and mobile enhancements

- Fix circular import issue in logo handling
  * Replace problematic 'from app import app' with Flask's current_app
  * Add error handling for cases where current_app is unavailable
  * Improve logo path resolution with fallback mechanisms
  * Fix settings model to use proper Flask context

- Clean up template code and remove duplication
  * Remove duplicate mobile enhancements from base template
  * Clean up dashboard template JavaScript
  * Centralize all mobile functionality in mobile.js
  * Add proper error handling and debugging

- Update CSS variables and spacing system
  * Introduce --section-spacing and --card-spacing variables
  * Add mobile-specific spacing variables
  * Improve border-radius and shadow consistency
  * Enhance typography and visual hierarchy

This commit resolves the double loading issue and logo import errors while
significantly improving the overall user experience and mobile responsiveness
of the web interface.
2025-08-30 10:09:06 +02:00

126 lines
4.0 KiB
Bash

#!/bin/bash
# Fix Docker container permission issues for file uploads
# This script should be run INSIDE your Docker container
echo "=== Fixing Docker Container Permissions ==="
# Get current user info
echo "Current user: $(whoami)"
echo "Current UID: $(id -u)"
echo "Current GID: $(id -g)"
echo "Current working directory: $(pwd)"
# Define the upload directories
UPLOAD_DIRS=(
"/app/app/static/uploads"
"/app/app/static/uploads/logos"
"/app/static/uploads"
"/app/static/uploads/logos"
)
# Step 1: Create directories with proper permissions
echo -e "\n1. Creating upload directories..."
for dir in "${UPLOAD_DIRS[@]}"; do
if [ ! -d "$dir" ]; then
echo "Creating directory: $dir"
mkdir -p "$dir"
else
echo "Directory exists: $dir"
fi
done
# Step 2: Set very permissive permissions (777 for testing)
echo -e "\n2. Setting permissive permissions..."
for dir in "${UPLOAD_DIRS[@]}"; do
if [ -d "$dir" ]; then
echo "Setting 777 permissions for: $dir"
chmod -R 777 "$dir"
fi
done
# Step 3: Try to change ownership to current user
echo -e "\n3. Changing ownership to current user..."
CURRENT_USER=$(whoami)
CURRENT_UID=$(id -u)
CURRENT_GID=$(id -g)
for dir in "${UPLOAD_DIRS[@]}"; do
if [ -d "$dir" ]; then
echo "Changing ownership of $dir to $CURRENT_USER:$CURRENT_USER"
chown -R "$CURRENT_USER:$CURRENT_USER" "$dir" 2>/dev/null || echo " - chown failed, trying with UID"
# If chown fails, try with UID
chown -R "$CURRENT_UID:$CURRENT_GID" "$dir" 2>/dev/null || echo " - chown with UID also failed"
fi
done
# Step 4: Test write permissions
echo -e "\n4. Testing write permissions..."
TEST_SUCCESS=true
for dir in "${UPLOAD_DIRS[@]}"; do
if [ -d "$dir" ]; then
TEST_FILE="$dir/test_permissions.tmp"
if echo "test" > "$TEST_FILE" 2>/dev/null; then
rm -f "$TEST_FILE"
echo "✓ Write permission test passed for: $dir"
else
echo "✗ Write permission test failed for: $dir"
TEST_SUCCESS=false
fi
fi
done
# Step 5: Show current permissions and ownership
echo -e "\n5. Current directory status:"
for dir in "${UPLOAD_DIRS[@]}"; do
if [ -d "$dir" ]; then
echo -e "\nDirectory: $dir"
ls -la "$dir" | head -5
echo "Permissions: $(stat -c "%a" "$dir")"
echo "Owner: $(stat -c "%U:%G" "$dir")"
fi
done
# Step 6: Alternative approach - try to fix parent directories
echo -e "\n6. Fixing parent directory permissions..."
PARENT_DIRS=("/app/app/static" "/app/static")
for parent_dir in "${PARENT_DIRS[@]}"; do
if [ -d "$parent_dir" ]; then
echo "Setting 755 permissions for parent: $parent_dir"
chmod 755 "$parent_dir"
chown "$CURRENT_USER:$CURRENT_USER" "$parent_dir" 2>/dev/null || echo " - chown failed for parent"
fi
done
# Final test
echo -e "\n7. Final permission test..."
if $TEST_SUCCESS; then
echo "=== Permission fix completed successfully! ==="
echo "The application should now be able to upload logo files."
echo -e "\nTry uploading a logo file now. If it still fails, you may need to:"
echo "1. Restart the Docker container"
echo "2. Check Docker volume mount permissions"
echo "3. Run the container with proper user mapping"
else
echo "=== Some permission tests failed ==="
echo -e "\nTrying alternative approach..."
# Try to run as root if possible
if [ "$(id -u)" -eq 0 ]; then
echo "Running as root, setting permissions..."
for dir in "${UPLOAD_DIRS[@]}"; do
if [ -d "$dir" ]; then
chmod -R 777 "$dir"
chown -R 1000:1000 "$dir" 2>/dev/null || echo " - chown to 1000:1000 failed"
fi
done
else
echo "Not running as root. You may need to:"
echo "1. Run this script as root (sudo)"
echo "2. Restart the container with proper user mapping"
echo "3. Check Docker volume permissions"
fi
fi
echo -e "\n=== Permission fix script completed ==="