From 3b8a10944220850226db52de1ae6191c0fde10f4 Mon Sep 17 00:00:00 2001 From: Gizmotronn Date: Mon, 6 Jan 2025 21:52:49 +0800 Subject: [PATCH] =?UTF-8?q?=EF=B8=8F=F0=9F=9A=98=F0=9F=8F=AE=20=E2=86=9D?= =?UTF-8?q?=20[SSC-67]:=20Trying=20annotation=20for=20PH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Data/ZoodexDataSources.tsx | 4 +- .../Annotating/Annotator.tsx | 46 +++-- components/Projects/Satellite/PlanetFour.tsx | 12 +- components/Projects/Telescopes/Transiting.tsx | 195 ++++-------------- constants/Structures/Properties.tsx | 2 +- types/Annotation.tsx | 24 +++ 6 files changed, 96 insertions(+), 187 deletions(-) diff --git a/components/Data/ZoodexDataSources.tsx b/components/Data/ZoodexDataSources.tsx index 0feeb33e..4ce49580 100644 --- a/components/Data/ZoodexDataSources.tsx +++ b/components/Data/ZoodexDataSources.tsx @@ -3,7 +3,7 @@ import { CameraIcon, CloudDrizzleIcon, DogIcon, MicroscopeIcon, SunDimIcon, TelescopeIcon, TestTube } from 'lucide-react'; import { BurrowingOwlIcon } from '../../content/Icons/BurrowingOwl'; import { FishIcon } from '../../content/Icons/FishIcon'; -import { StarterTelescope } from '../Projects/Telescopes/Transiting'; +import { StarterTelescopeTess } from '../Projects/Telescopes/Transiting'; import { DailyMinorPlanet } from '../Projects/Telescopes/DailyMinorPlanet'; import { PlanetFourProject } from '../Projects/Satellite/PlanetFour'; import { TelescopeSunspotDetector } from '../Projects/Telescopes/Sunspots'; @@ -117,7 +117,7 @@ export const telescopeDataSources = [ activeStructure: 3103, researched: 'telescope-tess', techId: 1, - dynamicComponent: + dynamicComponent: } ] }, diff --git a/components/Projects/(classifications)/Annotating/Annotator.tsx b/components/Projects/(classifications)/Annotating/Annotator.tsx index c24fc904..d8a03316 100644 --- a/components/Projects/(classifications)/Annotating/Annotator.tsx +++ b/components/Projects/(classifications)/Annotating/Annotator.tsx @@ -10,8 +10,10 @@ import ClassificationForm from '../PostForm'; import { AI4MCATEGORIES, P4CATEGORIES, + PHCATEGORIES, type AI4MCategory, type P4Category, + type PHCategory, type DrawingObject, type Tool, type CategoryConfig, @@ -25,7 +27,7 @@ interface ImageAnnotatorProps { missionNumber: number; assetMentioned: string | string[]; structureItemId?: number; - annotationType: 'AI4M' | 'P4'; + annotationType: 'AI4M' | 'P4' | 'PH' | 'Custom'; }; export default function ImageAnnotator({ @@ -50,9 +52,14 @@ export default function ImageAnnotator({ const [uploads, setUploads] = useState([]); const canvasRef = useRef(null); const imageRef = useRef(null); - const CATEGORY_CONFIG = annotationType === 'AI4M' - ? AI4MCATEGORIES as Record - : P4CATEGORIES as Record; + const CATEGORY_CONFIG: Record = + annotationType === 'AI4M' + ? AI4MCATEGORIES + : annotationType === 'P4' + ? P4CATEGORIES + : annotationType === 'PH' + ? PHCATEGORIES + : {} as Record; const addMedia = async () => { if (!canvasRef.current || !session) return; @@ -109,20 +116,23 @@ export default function ImageAnnotator({ {selectedImage && (
- + + - {!selectedAnomaly && ( - - )} - {selectedAnomaly && ( - - )} + {!selectedAnomaly && ( + + )} + {selectedAnomaly && ( + + )}
); }; \ No newline at end of file diff --git a/components/Projects/Telescopes/Transiting.tsx b/components/Projects/Telescopes/Transiting.tsx index 7da90716..94ac819d 100644 --- a/components/Projects/Telescopes/Transiting.tsx +++ b/components/Projects/Telescopes/Transiting.tsx @@ -5,6 +5,8 @@ import { useSession, useSupabaseClient } from '@supabase/auth-helpers-react'; import { useActivePlanet } from '@/context/ActivePlanet'; import ClassificationForm from '@/components/Projects/(classifications)/PostForm'; import { planetClassificationConfig } from '@/components/Projects/(classifications)/FormConfigurations'; +import PreferredTerrestrialClassifications from '@/components/Structures/Missions/PickPlanet'; +import ImageAnnotator from '../(classifications)/Annotating/Annotator'; export interface Anomaly { id: bigint; @@ -12,167 +14,11 @@ export interface Anomaly { avatar_url?: string; }; -export function StarterTelescope() { - const supabase = useSupabaseClient(); - const session = useSession(); - const { activePlanet } = useActivePlanet(); - - const [anomalies, setAnomalies] = useState([]); - const [selectedAnomaly, setSelectedAnomaly] = useState(null); - const [userChoice, setUserChoice] = useState(null); - const [imageUrl, setImageUrl] = useState(null); - const [configuration, setConfiguration] = useState(null); - const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); - const [hasMission3000001, setHasMission3000001] = useState(null); - const [missionLoading, setMissionLoading] = useState(true); - - useEffect(() => { - const checkTutorialMission = async () => { - if (!session) return; - try { - const { data: missionData, error: missionError } = await supabase - .from('missions') - .select('id') - .eq('user', session.user.id) - .eq('mission', 3000001); - if (missionError) throw missionError; - setHasMission3000001(missionData && missionData.length > 0); - } catch (error: any) { - console.error('Error checking user mission: ', error.message || error); - setHasMission3000001(false); - } finally { - setMissionLoading(false); - } - }; - checkTutorialMission(); - }, [session, supabase]); - - useEffect(() => { - const fetchStructureConfiguration = async () => { - if (!session) return; - try { - const { data: inventoryData, error: inventoryError } = await supabase - .from('inventory') - .select('configuration') - .eq('item', 3103) - .eq('anomaly', activePlanet.id) - .eq('owner', session.user.id) - .order('id', { ascending: true }) - .limit(1) - .single(); - if (inventoryError) throw inventoryError; - setConfiguration(inventoryData?.configuration || null); - } catch (error: any) { - console.error('Error fetching structure config:', error.message); - setError('Error fetching structure configuration: ' + (error.message || JSON.stringify(error))); - } - }; - fetchStructureConfiguration(); - }, [session, supabase, activePlanet]); - - useEffect(() => { - const fetchAnomalies = async () => { - if (!session || !userChoice) { - setLoading(false); - return; - } - try { - const { data: anomalyData, error: anomalyError } = await supabase - .from("anomalies") - .select("*") - .eq("anomalySet", userChoice); - if (anomalyError) throw anomalyError; - - setAnomalies(anomalyData || []); - console.log("Fetched anomalies:", anomalyData); - - if (anomalyData?.length > 0) { - const randomAnomaly = anomalyData[Math.floor(Math.random() * anomalyData.length)]; - console.log("Random anomaly selected:", randomAnomaly); - - const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL || 'https://your-default-supabase-url.com'; - if (randomAnomaly?.id) { - const constructedUrl = `${supabaseUrl}/storage/v1/object/public/anomalies/${randomAnomaly.id}/Binned.png`; - console.log("Constructed image URL:", constructedUrl); - setImageUrl(constructedUrl); - } else { - console.error("Random anomaly ID is null or undefined."); - } - setSelectedAnomaly(randomAnomaly); - } else { - console.log("No anomalies found."); - setSelectedAnomaly(null); - } - } catch (error: any) { - console.error("Error fetching anomalies:", error.message || error); - } finally { - setLoading(false); - } - }; - fetchAnomalies(); - }, [session, supabase, userChoice]); - - - const handleChoice = (choice: string) => { - setUserChoice(choice); - }; - - if (error) return

{error}

; - if (missionLoading || hasMission3000001 === null) return
Loading...
; - if (!configuration) { - return ( -
-

Fetching structure configuration...

-
- ); - } - if (!hasMission3000001) { - return ( -
- -
- ); - } - if (!userChoice) { - return ( -
-

Choose a target to observe using your Telescope:

- {configuration["missions unlocked"]?.map((missionId: string) => ( - - )) ||

No missions unlocked.

} -
- ); - } - if (loading) return

Loading...

; - if (!anomalies.length) return

No anomaly found.

; +interface SelectedAnomProps { + anomalyid?: number; +}; - return ( -
-
- {selectedAnomaly?.avatar_url && Anomaly Avatar} - {imageUrl && Anomaly Binned Image} - {selectedAnomaly && ( - - )} -
-
- ); -}; - -export function StarterTelescopeTess() { +export function StarterTelescopeTess({ anomalyid }: SelectedAnomProps) { const supabase = useSupabaseClient(); const session = useSession(); const { activePlanet } = useActivePlanet(); @@ -277,6 +123,35 @@ export function StarterTelescopeTess() { ); + + // return ( + //
+ //
+ // {selectedAnomaly?.avatar_url && Anomaly Avatar} + // {imageUrl && selectedAnomaly && ( + // + // )} + // {/* {imageUrl && Anomaly Binned Image} + // {selectedAnomaly && ( + // + // )} */} + //
+ //
+ // ); }; interface TelescopeProps { diff --git a/constants/Structures/Properties.tsx b/constants/Structures/Properties.tsx index e18e83a7..a7e12fcc 100644 --- a/constants/Structures/Properties.tsx +++ b/constants/Structures/Properties.tsx @@ -3,7 +3,7 @@ import React from "react"; import AutomatonUpgrade from "@/components/Structures/Config/AutomatonUpgradeBox"; import AllAutomatonsOnActivePlanet from "@/components/Structures/Auto/AllAutomatons"; -import { StarterTelescope, StarterTelescopeTess } from "@/components/Projects/Telescopes/Transiting"; +import { StarterTelescopeTess } from "@/components/Projects/Telescopes/Transiting"; import { StarterLidar } from "@/components/Projects/Lidar/Clouds"; import { BarChart, BeanIcon, BookAIcon, BookAudioIcon, BookCopy, BookDashedIcon, BriefcaseIcon, CameraIcon, CameraOffIcon, CaravanIcon, CloudCogIcon, CloudDrizzleIcon, CogIcon, ConstructionIcon, DogIcon, DotSquare, EarthIcon, GemIcon, GlassesIcon, HeartIcon, LockIcon, LucideSalad, MehIcon, MicroscopeIcon, MoonStarIcon, PenBox, PhoneIcon, PickaxeIcon, PowerIcon, RssIcon, SaladIcon, StarIcon, SunIcon, SwitchCamera, TelescopeIcon, TestTubeDiagonal, TestTubeDiagonalIcon, TreePalmIcon, WebcamIcon } from "lucide-react"; import StructureRepair from "@/components/Structures/Config/RepairStructure"; diff --git a/types/Annotation.tsx b/types/Annotation.tsx index 324e1ec1..1d6f42ef 100644 --- a/types/Annotation.tsx +++ b/types/Annotation.tsx @@ -28,6 +28,30 @@ export const P4CATEGORIES: Record = { }, }; +export type PHCategory = 'Noise' | 'Clear dip' | 'Missing' | 'Custom/Other'; +export const PHCATEGORIES: Record = { + Noise: { + name: 'Noise', + color: '#00BCD4', + description: 'Noise (random or irrelevant data)' + }, + 'Clear dip': { + name: 'Clear dip', + color: '#4CAF50', + description: 'Clear dip (a clear dip in the light)' + }, + Missing: { + name: 'Missing', + color: '#FFC107', + description: 'Missing (missing data/empty spot)' + }, + 'Custom/Other': { + name: 'Custom/Other', + color: '#FF0000', + description: 'Custom or other annotation' + }, +}; + export type AI4MCategory = 'sand' | 'consolidated-soil' | 'bedrock' | 'big-rocks' | 'custom'; export const AI4MCATEGORIES: Record = { sand: {