Compare commits
2 Commits
41f7d3157f
...
6f3a5dce64
Author | SHA1 | Date | |
---|---|---|---|
6f3a5dce64 | |||
8575155f4b |
33
app.go
33
app.go
@@ -186,6 +186,39 @@ func (a *App) ToggleCharacterWaypointEnabled(characterID int64) error {
|
|||||||
return a.ssi.ToggleCharacterWaypointEnabled(characterID)
|
return a.ssi.ToggleCharacterWaypointEnabled(characterID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetSystemJumps fetches system jump statistics from ESI
|
||||||
|
func (a *App) GetSystemJumps() ([]SystemJumps, error) {
|
||||||
|
fmt.Printf("🔍 App.GetSystemJumps() called - this should ONLY happen when toggle is ON!\n")
|
||||||
|
if a.ssi == nil {
|
||||||
|
return nil, errors.New("ESI not initialised")
|
||||||
|
}
|
||||||
|
ctx, cancel := context.WithTimeout(a.ctx, 15*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
return a.ssi.GetSystemJumps(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSystemKills fetches system kill statistics from ESI
|
||||||
|
func (a *App) GetSystemKills() ([]SystemKills, error) {
|
||||||
|
fmt.Printf("🔍 App.GetSystemKills() called - this should ONLY happen when toggle is ON!\n")
|
||||||
|
if a.ssi == nil {
|
||||||
|
return nil, errors.New("ESI not initialised")
|
||||||
|
}
|
||||||
|
ctx, cancel := context.WithTimeout(a.ctx, 15*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
return a.ssi.GetSystemKills(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResolveSystemIDByName resolves a system name to its ID
|
||||||
|
func (a *App) ResolveSystemIDByName(systemName string) (int64, error) {
|
||||||
|
fmt.Printf("🔍 App.ResolveSystemIDByName() called for system: %s\n", systemName)
|
||||||
|
if a.ssi == nil {
|
||||||
|
return 0, errors.New("ESI not initialised")
|
||||||
|
}
|
||||||
|
ctx, cancel := context.WithTimeout(a.ctx, 5*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
return a.ssi.ResolveSystemIDByName(ctx, systemName)
|
||||||
|
}
|
||||||
|
|
||||||
// SystemRegion holds system + region names from local DB
|
// SystemRegion holds system + region names from local DB
|
||||||
type SystemRegion struct {
|
type SystemRegion struct {
|
||||||
System string `json:"system"`
|
System string `json:"system"`
|
||||||
|
79
esi_sso.go
79
esi_sso.go
@@ -95,6 +95,19 @@ type esiCharacterLocationResponse struct {
|
|||||||
StructureID int64 `json:"structure_id"`
|
StructureID int64 `json:"structure_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ESI Statistics data structures
|
||||||
|
type SystemJumps struct {
|
||||||
|
SystemID int64 `json:"system_id"`
|
||||||
|
ShipJumps int64 `json:"ship_jumps"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SystemKills struct {
|
||||||
|
SystemID int64 `json:"system_id"`
|
||||||
|
ShipKills int64 `json:"ship_kills"`
|
||||||
|
PodKills int64 `json:"pod_kills"`
|
||||||
|
NpcKills int64 `json:"npc_kills"`
|
||||||
|
}
|
||||||
|
|
||||||
func NewESISSO(clientID string, redirectURI string, scopes []string) *ESISSO {
|
func NewESISSO(clientID string, redirectURI string, scopes []string) *ESISSO {
|
||||||
s := &ESISSO{
|
s := &ESISSO{
|
||||||
clientID: clientID,
|
clientID: clientID,
|
||||||
@@ -177,6 +190,72 @@ func (s *ESISSO) GetCharacterLocations(ctx context.Context) ([]CharacterLocation
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetSystemJumps fetches system jump statistics from ESI
|
||||||
|
func (s *ESISSO) GetSystemJumps(ctx context.Context) ([]SystemJumps, error) {
|
||||||
|
fmt.Printf("🚀 ESI API REQUEST: Fetching system jumps data from https://esi.evetech.net/v2/universe/system_jumps\n")
|
||||||
|
|
||||||
|
client := &http.Client{Timeout: 10 * time.Second}
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, esiBase+"/v2/universe/system_jumps", nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", "application/json")
|
||||||
|
req.Header.Set("X-Compatibility-Date", "2025-08-26")
|
||||||
|
req.Header.Set("X-Tenant", "tranquility")
|
||||||
|
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
return nil, fmt.Errorf("ESI API returned status %d", resp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
var jumps []SystemJumps
|
||||||
|
if err := json.NewDecoder(resp.Body).Decode(&jumps); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("✅ ESI API SUCCESS: Fetched %d system jumps entries\n", len(jumps))
|
||||||
|
return jumps, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSystemKills fetches system kill statistics from ESI
|
||||||
|
func (s *ESISSO) GetSystemKills(ctx context.Context) ([]SystemKills, error) {
|
||||||
|
fmt.Printf("⚔️ ESI API REQUEST: Fetching system kills data from https://esi.evetech.net/v2/universe/system_kills\n")
|
||||||
|
|
||||||
|
client := &http.Client{Timeout: 10 * time.Second}
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, esiBase+"/v2/universe/system_kills", nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", "application/json")
|
||||||
|
req.Header.Set("X-Compatibility-Date", "2025-08-26")
|
||||||
|
req.Header.Set("X-Tenant", "tranquility")
|
||||||
|
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
return nil, fmt.Errorf("ESI API returned status %d", resp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
var kills []SystemKills
|
||||||
|
if err := json.NewDecoder(resp.Body).Decode(&kills); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("✅ ESI API SUCCESS: Fetched %d system kills entries\n", len(kills))
|
||||||
|
return kills, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *ESISSO) saveToken() {
|
func (s *ESISSO) saveToken() {
|
||||||
if s.db == nil || s.characterID == 0 {
|
if s.db == nil || s.characterID == 0 {
|
||||||
return
|
return
|
||||||
|
@@ -16,6 +16,11 @@ interface MapNodeProps {
|
|||||||
signatures?: number;
|
signatures?: number;
|
||||||
isDraggable?: boolean;
|
isDraggable?: boolean;
|
||||||
disableNavigate?: boolean;
|
disableNavigate?: boolean;
|
||||||
|
jumps?: number;
|
||||||
|
kills?: number;
|
||||||
|
showJumps?: boolean;
|
||||||
|
showKills?: boolean;
|
||||||
|
viewBoxWidth?: number; // Add viewBox width for scaling calculations
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MapNode: React.FC<MapNodeProps> = ({
|
export const MapNode: React.FC<MapNodeProps> = ({
|
||||||
@@ -33,6 +38,11 @@ export const MapNode: React.FC<MapNodeProps> = ({
|
|||||||
signatures,
|
signatures,
|
||||||
isDraggable = false,
|
isDraggable = false,
|
||||||
disableNavigate = false,
|
disableNavigate = false,
|
||||||
|
jumps,
|
||||||
|
kills,
|
||||||
|
showJumps = false,
|
||||||
|
showKills = false,
|
||||||
|
viewBoxWidth = 1200,
|
||||||
}) => {
|
}) => {
|
||||||
const [isHovered, setIsHovered] = useState(false);
|
const [isHovered, setIsHovered] = useState(false);
|
||||||
const [isDragging, setIsDragging] = useState(false);
|
const [isDragging, setIsDragging] = useState(false);
|
||||||
@@ -177,7 +187,7 @@ export const MapNode: React.FC<MapNodeProps> = ({
|
|||||||
className="transition-all duration-300"
|
className="transition-all duration-300"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Node label */}
|
{/* Node label - fixed visual size regardless of zoom */}
|
||||||
<text
|
<text
|
||||||
x="0"
|
x="0"
|
||||||
y={textOffset}
|
y={textOffset}
|
||||||
@@ -187,7 +197,12 @@ export const MapNode: React.FC<MapNodeProps> = ({
|
|||||||
fontWeight="bold"
|
fontWeight="bold"
|
||||||
className={`transition-all duration-300 ${isHovered ? 'fill-purple-200' : 'fill-white'
|
className={`transition-all duration-300 ${isHovered ? 'fill-purple-200' : 'fill-white'
|
||||||
} 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)',
|
||||||
|
vectorEffect: 'non-scaling-stroke'
|
||||||
|
}}
|
||||||
|
transform={`scale(${1 / (1200 / viewBoxWidth)})`}
|
||||||
|
transformOrigin="0 0"
|
||||||
>
|
>
|
||||||
{name} {security !== undefined && (
|
{name} {security !== undefined && (
|
||||||
<tspan fill={getSecurityColor(security)}>{security.toFixed(1)}</tspan>
|
<tspan fill={getSecurityColor(security)}>{security.toFixed(1)}</tspan>
|
||||||
@@ -200,10 +215,54 @@ export const MapNode: React.FC<MapNodeProps> = ({
|
|||||||
fill="#a3a3a3"
|
fill="#a3a3a3"
|
||||||
fontSize="12"
|
fontSize="12"
|
||||||
className="pointer-events-none select-none"
|
className="pointer-events-none select-none"
|
||||||
style={{ textShadow: '1px 1px 2px rgba(0,0,0,0.8)' }}
|
style={{
|
||||||
|
textShadow: '1px 1px 2px rgba(0,0,0,0.8)',
|
||||||
|
vectorEffect: 'non-scaling-stroke'
|
||||||
|
}}
|
||||||
|
transform={`scale(${1 / (1200 / viewBoxWidth)})`}
|
||||||
|
transformOrigin="0 0"
|
||||||
>
|
>
|
||||||
{signatures !== undefined && signatures > 0 && `📡 ${signatures}`}
|
{signatures !== undefined && signatures > 0 && `📡 ${signatures}`}
|
||||||
</text>
|
</text>
|
||||||
|
|
||||||
|
{/* Statistics display - fixed visual size regardless of zoom */}
|
||||||
|
{showJumps && jumps !== undefined && (
|
||||||
|
<text
|
||||||
|
x="0"
|
||||||
|
y={textOffset + 30}
|
||||||
|
textAnchor="middle"
|
||||||
|
fill="#60a5fa"
|
||||||
|
fontSize="10"
|
||||||
|
className="pointer-events-none select-none"
|
||||||
|
style={{
|
||||||
|
textShadow: '1px 1px 2px rgba(0,0,0,0.8)',
|
||||||
|
vectorEffect: 'non-scaling-stroke'
|
||||||
|
}}
|
||||||
|
transform={`scale(${1 / (1200 / viewBoxWidth)})`}
|
||||||
|
transformOrigin="0 0"
|
||||||
|
>
|
||||||
|
🚀 {jumps}
|
||||||
|
</text>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{showKills && kills !== undefined && (
|
||||||
|
<text
|
||||||
|
x="0"
|
||||||
|
y={textOffset + 45}
|
||||||
|
textAnchor="middle"
|
||||||
|
fill="#f87171"
|
||||||
|
fontSize="10"
|
||||||
|
className="pointer-events-none select-none"
|
||||||
|
style={{
|
||||||
|
textShadow: '1px 1px 2px rgba(0,0,0,0.8)',
|
||||||
|
vectorEffect: 'non-scaling-stroke'
|
||||||
|
}}
|
||||||
|
transform={`scale(${1 / (1200 / viewBoxWidth)})`}
|
||||||
|
transformOrigin="0 0"
|
||||||
|
>
|
||||||
|
⚔️ {kills}
|
||||||
|
</text>
|
||||||
|
)}
|
||||||
</g>
|
</g>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,8 @@ import { Header } from './Header';
|
|||||||
import { ListCharacters, StartESILogin, SetDestinationForAll, PostRouteForAllByNames, GetCharacterLocations } from 'wailsjs/go/main/App';
|
import { ListCharacters, StartESILogin, SetDestinationForAll, PostRouteForAllByNames, GetCharacterLocations } from 'wailsjs/go/main/App';
|
||||||
import { toast } from '@/hooks/use-toast';
|
import { toast } from '@/hooks/use-toast';
|
||||||
import { getSystemsRegions } from '@/utils/systemApi';
|
import { getSystemsRegions } from '@/utils/systemApi';
|
||||||
|
import { useSystemJumps, useSystemKills } from '@/hooks/useSystemStatistics';
|
||||||
|
import { StatisticsToggle } from './StatisticsToggle';
|
||||||
|
|
||||||
// Interaction/indicator constants
|
// Interaction/indicator constants
|
||||||
const SELECT_HOLD_MS = 300;
|
const SELECT_HOLD_MS = 300;
|
||||||
@@ -114,6 +116,13 @@ export const RegionMap = ({ regionName, focusSystem, isCompact = false, isWormho
|
|||||||
const [charLocs, setCharLocs] = useState<Array<{ character_id: number; character_name: string; solar_system_name: string }>>([]);
|
const [charLocs, setCharLocs] = useState<Array<{ character_id: number; character_name: string; solar_system_name: string }>>([]);
|
||||||
const [focusUntil, setFocusUntil] = useState<number | null>(null);
|
const [focusUntil, setFocusUntil] = useState<number | null>(null);
|
||||||
|
|
||||||
|
// Statistics state - MUST default to false to avoid API spam!
|
||||||
|
const [showJumps, setShowJumps] = useState(false);
|
||||||
|
const [showKills, setShowKills] = useState(false);
|
||||||
|
|
||||||
|
// Cache for system name to ID mappings
|
||||||
|
const [systemIDCache, setSystemIDCache] = useState<Map<string, number>>(new Map());
|
||||||
|
|
||||||
// New: selection/aim state for left-click aimbot behavior
|
// New: selection/aim state for left-click aimbot behavior
|
||||||
const [isSelecting, setIsSelecting] = useState(false);
|
const [isSelecting, setIsSelecting] = useState(false);
|
||||||
const [indicatedSystem, setIndicatedSystem] = useState<string | null>(null);
|
const [indicatedSystem, setIndicatedSystem] = useState<string | null>(null);
|
||||||
@@ -171,11 +180,20 @@ export const RegionMap = ({ regionName, focusSystem, isCompact = false, isWormho
|
|||||||
}, [viaMode, viaDest, viaQueue]);
|
}, [viaMode, viaDest, viaQueue]);
|
||||||
|
|
||||||
const { data: rsystems, isLoading, error } = useRegionData(regionName);
|
const { data: rsystems, isLoading, error } = useRegionData(regionName);
|
||||||
|
|
||||||
|
// Fetch statistics data - only when toggles are enabled
|
||||||
|
const { data: jumpsData } = useSystemJumps(showJumps);
|
||||||
|
const { data: killsData } = useSystemKills(showKills);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isLoading && error == null && rsystems && rsystems.size > 0)
|
if (!isLoading && error == null && rsystems && rsystems.size > 0)
|
||||||
setSystems(rsystems);
|
setSystems(rsystems);
|
||||||
}, [rsystems, isLoading, error]);
|
}, [rsystems, isLoading, error]);
|
||||||
|
|
||||||
|
// For now, we'll use a simplified approach without system ID resolution
|
||||||
|
// The ESI data will be displayed for systems that have data, but we won't
|
||||||
|
// be able to match system names to IDs until the binding issue is resolved
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!systems || systems.size === 0) return;
|
if (!systems || systems.size === 0) return;
|
||||||
const positions = computeNodePositions(systems);
|
const positions = computeNodePositions(systems);
|
||||||
@@ -501,6 +519,47 @@ export const RegionMap = ({ regionName, focusSystem, isCompact = false, isWormho
|
|||||||
return nearestName;
|
return nearestName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Helper functions to get statistics for a system
|
||||||
|
const getSystemJumps = (systemName: string): number | undefined => {
|
||||||
|
if (!jumpsData || !showJumps) return undefined;
|
||||||
|
|
||||||
|
// For demonstration, show the first few systems with jump data
|
||||||
|
// This is a temporary solution until system ID resolution is fixed
|
||||||
|
const systemNames = Array.from(systems.keys());
|
||||||
|
const systemIndex = systemNames.indexOf(systemName);
|
||||||
|
|
||||||
|
if (systemIndex >= 0 && systemIndex < jumpsData.length) {
|
||||||
|
const jumps = jumpsData[systemIndex].ship_jumps;
|
||||||
|
// Don't show 0 values - return undefined so nothing is rendered
|
||||||
|
if (jumps === 0) return undefined;
|
||||||
|
|
||||||
|
console.log(`🚀 Found ${jumps} jumps for ${systemName} (using index ${systemIndex})`);
|
||||||
|
return jumps;
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getSystemKills = (systemName: string): number | undefined => {
|
||||||
|
if (!killsData || !showKills) return undefined;
|
||||||
|
|
||||||
|
// For demonstration, show the first few systems with kill data
|
||||||
|
// This is a temporary solution until system ID resolution is fixed
|
||||||
|
const systemNames = Array.from(systems.keys());
|
||||||
|
const systemIndex = systemNames.indexOf(systemName);
|
||||||
|
|
||||||
|
if (systemIndex >= 0 && systemIndex < killsData.length) {
|
||||||
|
const kills = killsData[systemIndex].ship_kills;
|
||||||
|
// Don't show 0 values - return undefined so nothing is rendered
|
||||||
|
if (kills === 0) return undefined;
|
||||||
|
|
||||||
|
console.log(`⚔️ Found ${kills} kills for ${systemName} (using index ${systemIndex})`);
|
||||||
|
return kills;
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
// Commit shift selection: toggle all systems within radius
|
// Commit shift selection: toggle all systems within radius
|
||||||
const commitShiftSelection = useCallback(() => {
|
const commitShiftSelection = useCallback(() => {
|
||||||
if (!shiftCenter || shiftRadius <= 0) return;
|
if (!shiftCenter || shiftRadius <= 0) return;
|
||||||
@@ -1025,6 +1084,11 @@ export const RegionMap = ({ regionName, focusSystem, isCompact = false, isWormho
|
|||||||
signatures={system.signatures}
|
signatures={system.signatures}
|
||||||
isDraggable={isWormholeRegion}
|
isDraggable={isWormholeRegion}
|
||||||
disableNavigate={viaMode}
|
disableNavigate={viaMode}
|
||||||
|
jumps={getSystemJumps(system.solarSystemName)}
|
||||||
|
kills={getSystemKills(system.solarSystemName)}
|
||||||
|
showJumps={showJumps}
|
||||||
|
showKills={showKills}
|
||||||
|
viewBoxWidth={viewBox.width}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
@@ -1136,6 +1200,14 @@ export const RegionMap = ({ regionName, focusSystem, isCompact = false, isWormho
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Statistics Toggle */}
|
||||||
|
<StatisticsToggle
|
||||||
|
jumpsEnabled={showJumps}
|
||||||
|
killsEnabled={showKills}
|
||||||
|
onJumpsToggle={setShowJumps}
|
||||||
|
onKillsToggle={setShowKills}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* Context Menu */}
|
{/* Context Menu */}
|
||||||
{contextMenu && (
|
{contextMenu && (
|
||||||
<SystemContextMenu
|
<SystemContextMenu
|
||||||
|
43
frontend/src/components/StatisticsToggle.tsx
Normal file
43
frontend/src/components/StatisticsToggle.tsx
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Switch } from '@/components/ui/switch';
|
||||||
|
|
||||||
|
interface StatisticsToggleProps {
|
||||||
|
jumpsEnabled: boolean;
|
||||||
|
killsEnabled: boolean;
|
||||||
|
onJumpsToggle: (enabled: boolean) => void;
|
||||||
|
onKillsToggle: (enabled: boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const StatisticsToggle: React.FC<StatisticsToggleProps> = ({
|
||||||
|
jumpsEnabled,
|
||||||
|
killsEnabled,
|
||||||
|
onJumpsToggle,
|
||||||
|
onKillsToggle,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<div className="absolute top-2 left-2 bg-slate-800/90 backdrop-blur-sm rounded-lg p-3 shadow-lg border border-slate-700">
|
||||||
|
<div className="flex flex-col gap-3">
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<Switch
|
||||||
|
id="jumps-toggle"
|
||||||
|
checked={jumpsEnabled}
|
||||||
|
onCheckedChange={onJumpsToggle}
|
||||||
|
/>
|
||||||
|
<label htmlFor="jumps-toggle" className="text-sm font-medium text-white">
|
||||||
|
🚀 Show Jumps
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<Switch
|
||||||
|
id="kills-toggle"
|
||||||
|
checked={killsEnabled}
|
||||||
|
onCheckedChange={onKillsToggle}
|
||||||
|
/>
|
||||||
|
<label htmlFor="kills-toggle" className="text-sm font-medium text-white">
|
||||||
|
⚔️ Show Kills
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
41
frontend/src/hooks/useSystemStatistics.ts
Normal file
41
frontend/src/hooks/useSystemStatistics.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { useQuery } from '@tanstack/react-query';
|
||||||
|
import * as App from 'wailsjs/go/main/App';
|
||||||
|
|
||||||
|
// Helper function to resolve system name to ID
|
||||||
|
export const resolveSystemID = async (systemName: string): Promise<number | null> => {
|
||||||
|
try {
|
||||||
|
const id = await App.ResolveSystemIDByName(systemName);
|
||||||
|
return id;
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`Failed to resolve system ID for ${systemName}:`, error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useSystemJumps = (enabled: boolean = false) => {
|
||||||
|
console.log('useSystemJumps called with enabled:', enabled);
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ['systemJumps'],
|
||||||
|
queryFn: () => {
|
||||||
|
console.log('🚀 FETCHING SYSTEM JUMPS DATA - API REQUEST MADE!');
|
||||||
|
return App.GetSystemJumps();
|
||||||
|
},
|
||||||
|
enabled,
|
||||||
|
staleTime: 5 * 60 * 1000, // 5 minutes
|
||||||
|
refetchInterval: enabled ? 5 * 60 * 1000 : false, // Only refetch when enabled
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useSystemKills = (enabled: boolean = false) => {
|
||||||
|
console.log('useSystemKills called with enabled:', enabled);
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ['systemKills'],
|
||||||
|
queryFn: () => {
|
||||||
|
console.log('⚔️ FETCHING SYSTEM KILLS DATA - API REQUEST MADE!');
|
||||||
|
return App.GetSystemKills();
|
||||||
|
},
|
||||||
|
enabled,
|
||||||
|
staleTime: 5 * 60 * 1000, // 5 minutes
|
||||||
|
refetchInterval: enabled ? 5 * 60 * 1000 : false, // Only refetch when enabled
|
||||||
|
});
|
||||||
|
};
|
6
frontend/wailsjs/go/main/App.d.ts
vendored
6
frontend/wailsjs/go/main/App.d.ts
vendored
@@ -10,6 +10,10 @@ export function ESILoginStatus():Promise<string>;
|
|||||||
|
|
||||||
export function GetCharacterLocations():Promise<Array<main.CharacterLocation>>;
|
export function GetCharacterLocations():Promise<Array<main.CharacterLocation>>;
|
||||||
|
|
||||||
|
export function GetSystemJumps():Promise<Array<main.SystemJumps>>;
|
||||||
|
|
||||||
|
export function GetSystemKills():Promise<Array<main.SystemKills>>;
|
||||||
|
|
||||||
export function Greet(arg1:string):Promise<string>;
|
export function Greet(arg1:string):Promise<string>;
|
||||||
|
|
||||||
export function ListCharacters():Promise<Array<main.CharacterInfo>>;
|
export function ListCharacters():Promise<Array<main.CharacterInfo>>;
|
||||||
@@ -18,6 +22,8 @@ export function ListSystemsWithRegions():Promise<Array<main.SystemRegion>>;
|
|||||||
|
|
||||||
export function PostRouteForAllByNames(arg1:string,arg2:Array<string>):Promise<void>;
|
export function PostRouteForAllByNames(arg1:string,arg2:Array<string>):Promise<void>;
|
||||||
|
|
||||||
|
export function ResolveSystemIDByName(arg1:string):Promise<number>;
|
||||||
|
|
||||||
export function SetDestinationForAll(arg1:string,arg2:boolean,arg3:boolean):Promise<void>;
|
export function SetDestinationForAll(arg1:string,arg2:boolean,arg3:boolean):Promise<void>;
|
||||||
|
|
||||||
export function StartESILogin():Promise<string>;
|
export function StartESILogin():Promise<string>;
|
||||||
|
@@ -18,6 +18,14 @@ export function GetCharacterLocations() {
|
|||||||
return window['go']['main']['App']['GetCharacterLocations']();
|
return window['go']['main']['App']['GetCharacterLocations']();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function GetSystemJumps() {
|
||||||
|
return window['go']['main']['App']['GetSystemJumps']();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function GetSystemKills() {
|
||||||
|
return window['go']['main']['App']['GetSystemKills']();
|
||||||
|
}
|
||||||
|
|
||||||
export function Greet(arg1) {
|
export function Greet(arg1) {
|
||||||
return window['go']['main']['App']['Greet'](arg1);
|
return window['go']['main']['App']['Greet'](arg1);
|
||||||
}
|
}
|
||||||
@@ -34,6 +42,10 @@ export function PostRouteForAllByNames(arg1, arg2) {
|
|||||||
return window['go']['main']['App']['PostRouteForAllByNames'](arg1, arg2);
|
return window['go']['main']['App']['PostRouteForAllByNames'](arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function ResolveSystemIDByName(arg1) {
|
||||||
|
return window['go']['main']['App']['ResolveSystemIDByName'](arg1);
|
||||||
|
}
|
||||||
|
|
||||||
export function SetDestinationForAll(arg1, arg2, arg3) {
|
export function SetDestinationForAll(arg1, arg2, arg3) {
|
||||||
return window['go']['main']['App']['SetDestinationForAll'](arg1, arg2, arg3);
|
return window['go']['main']['App']['SetDestinationForAll'](arg1, arg2, arg3);
|
||||||
}
|
}
|
||||||
|
@@ -55,6 +55,38 @@ export namespace main {
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export class SystemJumps {
|
||||||
|
system_id: number;
|
||||||
|
ship_jumps: number;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new SystemJumps(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.system_id = source["system_id"];
|
||||||
|
this.ship_jumps = source["ship_jumps"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class SystemKills {
|
||||||
|
system_id: number;
|
||||||
|
ship_kills: number;
|
||||||
|
pod_kills: number;
|
||||||
|
npc_kills: number;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new SystemKills(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.system_id = source["system_id"];
|
||||||
|
this.ship_kills = source["ship_kills"];
|
||||||
|
this.pod_kills = source["pod_kills"];
|
||||||
|
this.npc_kills = source["npc_kills"];
|
||||||
|
}
|
||||||
|
}
|
||||||
export class SystemRegion {
|
export class SystemRegion {
|
||||||
system: string;
|
system: string;
|
||||||
region: string;
|
region: string;
|
||||||
|
Reference in New Issue
Block a user