add file browser component and widget
This commit is contained in:
107
examples/file_browser_demo/run-demo.sh
Executable file
107
examples/file_browser_demo/run-demo.sh
Executable file
@@ -0,0 +1,107 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Run File Browser Demo Script
|
||||
# This script starts both the mock server and the WASM demo
|
||||
|
||||
set -e
|
||||
|
||||
echo "🎯 File Browser Demo Launcher"
|
||||
echo "=============================="
|
||||
echo ""
|
||||
|
||||
# Function to cleanup background processes
|
||||
cleanup() {
|
||||
echo ""
|
||||
echo "🧹 Cleaning up..."
|
||||
if [ ! -z "$MOCK_SERVER_PID" ]; then
|
||||
kill $MOCK_SERVER_PID 2>/dev/null || true
|
||||
echo "✅ Mock server stopped"
|
||||
fi
|
||||
if [ ! -z "$TRUNK_PID" ]; then
|
||||
kill $TRUNK_PID 2>/dev/null || true
|
||||
echo "✅ Trunk dev server stopped"
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Set up signal handlers
|
||||
trap cleanup SIGINT SIGTERM
|
||||
|
||||
# Check dependencies
|
||||
echo "🔍 Checking dependencies..."
|
||||
|
||||
if ! command -v cargo &> /dev/null; then
|
||||
echo "❌ Error: Rust/Cargo is not installed"
|
||||
echo "Please install Rust from https://rustup.rs/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v trunk &> /dev/null; then
|
||||
echo "❌ Error: Trunk is not installed"
|
||||
echo "Please install Trunk: cargo install trunk"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Dependencies OK"
|
||||
echo ""
|
||||
|
||||
# Start mock server in background
|
||||
echo "🚀 Starting mock server..."
|
||||
cd "$(dirname "$0")/mock-server"
|
||||
cargo build --release
|
||||
cargo run --release &
|
||||
MOCK_SERVER_PID=$!
|
||||
cd ..
|
||||
|
||||
# Wait a moment for server to start
|
||||
sleep 2
|
||||
|
||||
# Check if mock server is running
|
||||
if ! curl -s http://localhost:3001/health > /dev/null; then
|
||||
echo "❌ Error: Mock server failed to start"
|
||||
cleanup
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Mock server running on http://localhost:3001"
|
||||
echo ""
|
||||
|
||||
# Start trunk dev server
|
||||
echo "🌐 Starting WASM demo..."
|
||||
echo "Building and serving on http://localhost:8080"
|
||||
echo ""
|
||||
echo "📋 Demo Features:"
|
||||
echo " • File/directory listing with navigation"
|
||||
echo " • Create new directories"
|
||||
echo " • Upload files with progress tracking"
|
||||
echo " • Download files"
|
||||
echo " • Delete files and directories"
|
||||
echo " • Responsive Bootstrap UI"
|
||||
echo ""
|
||||
echo "💡 Use Ctrl+C to stop both servers"
|
||||
echo ""
|
||||
|
||||
trunk serve --port 8080 &
|
||||
TRUNK_PID=$!
|
||||
|
||||
# Wait for trunk to start
|
||||
sleep 3
|
||||
|
||||
# Open browser (optional)
|
||||
if command -v open &> /dev/null; then
|
||||
echo "🌍 Opening browser..."
|
||||
open http://localhost:8080
|
||||
elif command -v xdg-open &> /dev/null; then
|
||||
echo "🌍 Opening browser..."
|
||||
xdg-open http://localhost:8080
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "🎉 Demo is ready!"
|
||||
echo " 📱 Frontend: http://localhost:8080"
|
||||
echo " 🔧 Backend: http://localhost:3001"
|
||||
echo ""
|
||||
echo "Press Ctrl+C to stop all servers"
|
||||
|
||||
# Wait for user to stop
|
||||
wait
|
Reference in New Issue
Block a user