diff --git a/backend/galacticPathFinder/settings.py b/backend/galacticPathFinder/settings.py index 9424bf6..b4ad0b9 100644 --- a/backend/galacticPathFinder/settings.py +++ b/backend/galacticPathFinder/settings.py @@ -71,7 +71,7 @@ TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [os.path.join(BASE_DIR, "templates")], + "DIRS": [os.path.join(BASE_DIR, 'frontend', 'build')], "APP_DIRS": True, "OPTIONS": { "context_processors": [ @@ -132,7 +132,10 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/5.0/howto/static-files/ -STATIC_URL = "static/" +STATIC_URL = '/static/' +STATICFILES_DIRS = [ + os.path.join(BASE_DIR, 'frontend', 'build', 'static'), +] # Default primary key field type # https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field diff --git a/backend/galacticPathFinder/urls.py b/backend/galacticPathFinder/urls.py index 0f70cc2..a383f19 100644 --- a/backend/galacticPathFinder/urls.py +++ b/backend/galacticPathFinder/urls.py @@ -16,6 +16,7 @@ """ from django.contrib import admin from django.urls import path, re_path, include +from django.views.generic import TemplateView from rest_framework.schemas import get_schema_view from rest_framework import permissions from drf_yasg.views import get_schema_view @@ -46,5 +47,7 @@ schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui", ), - path("redoc/", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc") + path("redoc/", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"), + # Catch-all route to serve the React app's index.html + re_path(r"^(?!admin|graphtraversal|swagger|redoc).*", TemplateView.as_view(template_name="index.html")), ] diff --git a/frontend/src/components/mapGrid/MapGrid.tsx b/frontend/src/components/mapGrid/MapGrid.tsx index 1e6ecf8..7158daf 100644 --- a/frontend/src/components/mapGrid/MapGrid.tsx +++ b/frontend/src/components/mapGrid/MapGrid.tsx @@ -133,6 +133,30 @@ const MapGrid = () => { ?.isExplored; }; + // Handle scroll to adjust grid size + const handleScroll = (event: Event) => { + const wheelEvent = event as WheelEvent; + if (wheelEvent.deltaY < 0) { + // Scrolling up - zooming in + mapSizeSliderSignal.value = Math.max(20, mapSizeSliderSignal.value - 2); + } else { + // Scrolling down - zooming out + mapSizeSliderSignal.value = Math.min(70, mapSizeSliderSignal.value + 2); + } + }; + + useEffect(() => { + const gridContainer = document.querySelector(".grid-container"); + if (gridContainer) { + gridContainer.addEventListener("wheel", handleScroll); + } + return () => { + if (gridContainer) { + gridContainer.removeEventListener("wheel", handleScroll); + } + }; + }, []); + return (