Add number of signatures to display on region map

This commit is contained in:
2025-06-14 17:26:28 +02:00
parent 7ee12606c1
commit 98e260977c
2 changed files with 64 additions and 34 deletions

View File

@@ -1,4 +1,3 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { getSecurityColor } from '../utils/securityColors'; import { getSecurityColor } from '../utils/securityColors';
@@ -9,6 +8,7 @@ interface MapNodeProps {
onClick: () => void; onClick: () => void;
type: 'region' | 'system'; type: 'region' | 'system';
security?: number; security?: number;
signatures?: number;
} }
export const MapNode: React.FC<MapNodeProps> = ({ export const MapNode: React.FC<MapNodeProps> = ({
@@ -17,7 +17,8 @@ export const MapNode: React.FC<MapNodeProps> = ({
position, position,
onClick, onClick,
type, type,
security security,
signatures
}) => { }) => {
const [isHovered, setIsHovered] = useState(false); const [isHovered, setIsHovered] = useState(false);
@@ -66,8 +67,7 @@ export const MapNode: React.FC<MapNodeProps> = ({
stroke="#ffffff" stroke="#ffffff"
strokeWidth="1.5" strokeWidth="1.5"
filter="url(#glow)" filter="url(#glow)"
className={`transition-all duration-300 ${ className={`transition-all duration-300 ${isHovered ? 'drop-shadow-lg' : ''
isHovered ? 'drop-shadow-lg' : ''
}`} }`}
/> />
@@ -116,8 +116,7 @@ export const MapNode: React.FC<MapNodeProps> = ({
r={nodeSize} r={nodeSize}
fill={nodeColor} fill={nodeColor}
filter="url(#glow)" filter="url(#glow)"
className={`transition-all duration-300 ${ className={`transition-all duration-300 ${isHovered ? 'drop-shadow-lg' : ''
isHovered ? 'drop-shadow-lg' : ''
}`} }`}
/> />
@@ -142,7 +141,20 @@ export const MapNode: React.FC<MapNodeProps> = ({
} pointer-events-none select-none`} } pointer-events-none select-none`}
style={{ textShadow: '2px 2px 4px rgba(0,0,0,0.8)' }} style={{ textShadow: '2px 2px 4px rgba(0,0,0,0.8)' }}
> >
{name} {security.toFixed(1)} {name} {security !== undefined && (
<tspan fill={getSecurityColor(security)}>{security.toFixed(1)}</tspan>
)}
</text>
<text
x="0"
y={textOffset + 15}
textAnchor="middle"
fill="#a3a3a3"
fontSize="12"
className="pointer-events-none select-none"
style={{ textShadow: '1px 1px 2px rgba(0,0,0,0.8)' }}
>
{signatures !== undefined && `📡 ${signatures}`}
</text> </text>
</g> </g>
); );

View File

@@ -7,11 +7,15 @@ import { ArrowLeft } from 'lucide-react';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { getSecurityColor } from '../utils/securityColors'; import { getSecurityColor } from '../utils/securityColors';
const pocketbaseUrl = `https://evebase.site.quack-lab.dev/api/collections/regionview/records`;
// const pocketbaseUrl = `https://evebase.site.quack-lab.dev/api/collections/regionview/records?filter=(sysregion%3D'${encodedSystem}')`;
interface SolarSystem { interface SolarSystem {
solarSystemName: string; solarSystemName: string;
x: number; x: number;
y: number; y: number;
security: number; security: number;
signatures: number;
connectedSystems: string[]; connectedSystems: string[];
} }
@@ -32,7 +36,20 @@ const fetchRegionData = async (regionName: string): Promise<SolarSystem[]> => {
if (!response.ok) { if (!response.ok) {
throw new Error('Failed to fetch region data'); throw new Error('Failed to fetch region data');
} }
return response.json(); const systems = await response.json();
const regionSignatures = await fetch(`${pocketbaseUrl}?filter=(sysregion%3D'${regionName}')`);
const regionSignaturesJson = await regionSignatures.json();
console.log(regionSignaturesJson);
if (regionSignaturesJson.items.length > 0) {
for (const systemSigs of regionSignaturesJson.items) {
const system = systems.find(s => s.solarSystemName === systemSigs.sysname);
if (system) {
system.signatures = systemSigs.sigcount;
}
}
}
return systems;
}; };
export const RegionMap: React.FC<{ regionName: string }> = ({ regionName }) => { export const RegionMap: React.FC<{ regionName: string }> = ({ regionName }) => {
@@ -255,6 +272,7 @@ export const RegionMap: React.FC<{ regionName: string }> = ({ regionName }) => {
onClick={() => handleSystemClick(system.solarSystemName)} onClick={() => handleSystemClick(system.solarSystemName)}
type="system" type="system"
security={system.security} security={system.security}
signatures={system.signatures}
/> />
))} ))}
</svg> </svg>