Compare commits
10 Commits
cc76765278
...
82877b8870
Author | SHA1 | Date | |
---|---|---|---|
82877b8870 | |||
![]() |
470935fe9d | ||
![]() |
7ce238c9c7 | ||
![]() |
6523000e69 | ||
![]() |
b993b28840 | ||
![]() |
c036bc10e1 | ||
![]() |
b743193f46 | ||
![]() |
02ebaf6e35 | ||
![]() |
3a0843e54c | ||
![]() |
e43bd91bef |
@@ -2,9 +2,9 @@
|
||||
|
||||
Simple tool to track your PI planet extractors. Login with your characters and enjoy the PI!
|
||||
|
||||
Any questions, feedback or suggestions are welcome at [EVE PI Discord](https://discord.gg/GPtw5kfuJu)
|
||||
Any questions, feedback or suggestions are welcome at [EVE PI Discord](https://discord.gg/bCdXzU8PHK)
|
||||
|
||||
## [Avanto hosted PI tool](https://pi.avanto.tk)
|
||||
## [Hosted PI tool](https://pi.calli.fi)
|
||||
|
||||

|
||||

|
||||
|
@@ -376,6 +376,24 @@ export const AccountCard = ({ characters, isCollapsed: propIsCollapsed }: { char
|
||||
>
|
||||
Extractors: {runningExtractors}/{totalExtractors}
|
||||
</Typography>
|
||||
<Divider orientation="vertical" flexItem sx={{ height: 16, borderColor: theme.palette.divider }} />
|
||||
<Typography
|
||||
sx={{
|
||||
fontSize: "0.8rem",
|
||||
color: Object.values(planetDetails).some(d => d.alertState.hasLowStorage) ? theme.palette.error.main : theme.palette.text.secondary,
|
||||
}}
|
||||
>
|
||||
Storage Alerts: {Object.values(planetDetails).filter(d => d.alertState.hasLowStorage).length}
|
||||
</Typography>
|
||||
<Divider orientation="vertical" flexItem sx={{ height: 16, borderColor: theme.palette.divider }} />
|
||||
<Typography
|
||||
sx={{
|
||||
fontSize: "0.8rem",
|
||||
color: Object.values(planetDetails).some(d => d.alertState.hasLargeExtractorDifference) ? theme.palette.error.main : theme.palette.text.secondary,
|
||||
}}
|
||||
>
|
||||
Balance Alerts: {Object.values(planetDetails).filter(d => d.alertState.hasLargeExtractorDifference).length}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Box>
|
||||
<IconButton
|
||||
|
@@ -4,7 +4,7 @@ export const DiscordButton = () => {
|
||||
<Box>
|
||||
<Tooltip title="Come nerd out in discord about PI and this tool">
|
||||
<Button
|
||||
href="https://discord.gg/GPtw5kfuJu"
|
||||
href="https://discord.gg/bCdXzU8PHK"
|
||||
target="_blank"
|
||||
style={{ width: "100%" }}
|
||||
sx={{ color: "white", display: "block" }}
|
||||
|
@@ -48,7 +48,7 @@ declare module "@mui/material/styles" {
|
||||
}
|
||||
|
||||
export const MainGrid = () => {
|
||||
const { characters, updateCharacter } = useContext(CharacterContext);
|
||||
const { characters } = useContext(CharacterContext);
|
||||
const { compactMode, toggleCompactMode, alertMode, toggleAlertMode, planMode, togglePlanMode, extractionTimeMode, toggleExtractionTimeMode } = useContext(SessionContext);
|
||||
const [accountOrder, setAccountOrder] = useState<string[]>([]);
|
||||
const [allCollapsed, setAllCollapsed] = useState(false);
|
||||
@@ -170,7 +170,7 @@ export const MainGrid = () => {
|
||||
size="small"
|
||||
style={{
|
||||
backgroundColor: compactMode
|
||||
? "rgba(144, 202, 249, 0.08)"
|
||||
? "rgba(144, 202, 249, 0.16)"
|
||||
: "inherit",
|
||||
}}
|
||||
onClick={toggleCompactMode}
|
||||
@@ -183,7 +183,7 @@ export const MainGrid = () => {
|
||||
size="small"
|
||||
style={{
|
||||
backgroundColor: alertMode
|
||||
? "rgba(144, 202, 249, 0.08)"
|
||||
? "rgba(144, 202, 249, 0.16)"
|
||||
: "inherit",
|
||||
}}
|
||||
onClick={toggleAlertMode}
|
||||
@@ -196,7 +196,7 @@ export const MainGrid = () => {
|
||||
size="small"
|
||||
style={{
|
||||
backgroundColor: planMode
|
||||
? "rgba(144, 202, 249, 0.08)"
|
||||
? "rgba(144, 202, 249, 0.16)"
|
||||
: "inherit",
|
||||
}}
|
||||
onClick={togglePlanMode}
|
||||
@@ -209,7 +209,7 @@ export const MainGrid = () => {
|
||||
size="small"
|
||||
style={{
|
||||
backgroundColor: extractionTimeMode
|
||||
? "rgba(144, 202, 249, 0.08)"
|
||||
? "rgba(144, 202, 249, 0.16)"
|
||||
: "inherit",
|
||||
}}
|
||||
onClick={toggleExtractionTimeMode}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { ColorContext, SessionContext } from "@/app/context/Context";
|
||||
import { PI_TYPES_MAP, STORAGE_IDS, STORAGE_CAPACITIES, PI_PRODUCT_VOLUMES, EVE_IMAGE_URL, PI_SCHEMATICS, LAUNCHPAD_IDS } from "@/const";
|
||||
import { planetCalculations } from "@/planets";
|
||||
import { PI_TYPES_MAP, EVE_IMAGE_URL, LAUNCHPAD_IDS } from "@/const";
|
||||
import { AccessToken, PlanetWithInfo } from "@/types";
|
||||
import { PlanetCalculations, StorageInfo } from "@/types/planet";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
@@ -419,50 +418,55 @@ export const PlanetTableRow = ({
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{planetDetails.storageInfo.map((storage: StorageInfo) => {
|
||||
const isLaunchpad = LAUNCHPAD_IDS.includes(storage.type_id);
|
||||
const fillRate = storage.fillRate;
|
||||
const color = fillRate > 90 ? '#ff0000' : fillRate > 80 ? '#ffa500' : fillRate > 60 ? '#ffd700' : 'inherit';
|
||||
const contents = planet.info.pins.find(p => p.type_id === storage.type_id)?.contents || [];
|
||||
|
||||
return (
|
||||
<React.Fragment key={`storage-${character.character.characterId}-${planet.planet_id}-${storage.type}`}>
|
||||
<TableRow>
|
||||
<TableCell>{isLaunchpad ? 'Launchpad' : 'Storage'}</TableCell>
|
||||
<TableCell align="right">{storage.capacity.toFixed(1)} m³</TableCell>
|
||||
<TableCell align="right">{storage.used.toFixed(1)} m³</TableCell>
|
||||
<TableCell align="right" sx={{ color }}>{fillRate.toFixed(1)}%</TableCell>
|
||||
<TableCell align="right">
|
||||
{storage.value > 0 ? (
|
||||
storage.value >= 1000000000
|
||||
? `${(storage.value / 1000000000).toFixed(2)} B`
|
||||
: `${(storage.value / 1000000).toFixed(0)} M`
|
||||
) : '-'} ISK
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{contents.length > 0 && (
|
||||
{planetDetails.storageInfo
|
||||
.map(storage => ({
|
||||
...storage,
|
||||
isLaunchpad: LAUNCHPAD_IDS.includes(storage.type_id)
|
||||
}))
|
||||
.sort((a, b) => (b.isLaunchpad ? 1 : 0) - (a.isLaunchpad ? 1 : 0))
|
||||
.map((storage, idx) => {
|
||||
const fillRate = storage.fillRate;
|
||||
const color = fillRate > 90 ? '#ff0000' : fillRate > 80 ? '#ffa500' : fillRate > 60 ? '#ffd700' : 'inherit';
|
||||
const contents = planet.info.pins.find(p => p.type_id === storage.type_id)?.contents || [];
|
||||
|
||||
return (
|
||||
<React.Fragment key={`storage-${character.character.characterId}-${planet.planet_id}-${storage.type}-${idx}`}>
|
||||
<TableRow>
|
||||
<TableCell colSpan={5} sx={{ pt: 0, pb: 0 }}>
|
||||
<Table size="small">
|
||||
<TableBody>
|
||||
{contents.map(content => (
|
||||
<TableRow key={content.type_id}>
|
||||
<TableCell sx={{ pl: 2 }}>
|
||||
{PI_TYPES_MAP[content.type_id]?.name}
|
||||
</TableCell>
|
||||
<TableCell align="right" colSpan={4}>
|
||||
{content.amount.toFixed(1)} units
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<TableCell>{storage.isLaunchpad ? 'Launchpad' : 'Storage'}</TableCell>
|
||||
<TableCell align="right">{storage.capacity.toFixed(1)} m³</TableCell>
|
||||
<TableCell align="right">{storage.used.toFixed(1)} m³</TableCell>
|
||||
<TableCell align="right" sx={{ color }}>{fillRate.toFixed(1)}%</TableCell>
|
||||
<TableCell align="right">
|
||||
{storage.value > 0 ? (
|
||||
storage.value >= 1000000000
|
||||
? `${(storage.value / 1000000000).toFixed(2)} B`
|
||||
: `${(storage.value / 1000000).toFixed(0)} M`
|
||||
) : '-'} ISK
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
</React.Fragment>
|
||||
);
|
||||
})}
|
||||
{contents.length > 0 && (
|
||||
<TableRow>
|
||||
<TableCell colSpan={5} sx={{ pt: 0, pb: 0 }}>
|
||||
<Table size="small">
|
||||
<TableBody>
|
||||
{contents.map((content, idy) => (
|
||||
<TableRow key={`content-${character.character.characterId}-${planet.planet_id}-${storage.type}-${content.type_id}-${idx}-${idy}`}>
|
||||
<TableCell sx={{ pl: 2 }}>
|
||||
{PI_TYPES_MAP[content.type_id]?.name}
|
||||
</TableCell>
|
||||
<TableCell align="right" colSpan={4}>
|
||||
{content.amount.toFixed(1)} units
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
</React.Fragment>
|
||||
);
|
||||
})}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</Box>
|
||||
@@ -482,27 +486,32 @@ export const PlanetTableRow = ({
|
||||
>
|
||||
<div style={{ display: "flex", flexDirection: "column" }}>
|
||||
{planetDetails.storageInfo.length === 0 &&<Typography fontSize={theme.custom.smallText}>No storage</Typography>}
|
||||
{planetDetails.storageInfo.map((storage: StorageInfo) => {
|
||||
const isLaunchpad = LAUNCHPAD_IDS.includes(storage.type_id);
|
||||
const fillRate = storage.fillRate;
|
||||
const color = fillRate > 90 ? '#ff0000' : fillRate > 80 ? '#ffa500' : fillRate > 60 ? '#ffd700' : 'inherit';
|
||||
|
||||
return (
|
||||
<div key={`storage-${character.character.characterId}-${planet.planet_id}-${storage.type}`} style={{ display: "flex", alignItems: "center" }}>
|
||||
<Typography fontSize={theme.custom.smallText} style={{ marginRight: "5px" }}>
|
||||
{isLaunchpad ? 'L' : 'S'}
|
||||
</Typography>
|
||||
<Typography fontSize={theme.custom.smallText} style={{ color }}>
|
||||
{fillRate.toFixed(1)}%
|
||||
</Typography>
|
||||
{storage.value > 0 && (
|
||||
<Typography fontSize={theme.custom.smallText} style={{ marginLeft: "5px" }}>
|
||||
({Math.round(storage.value / 1000000)}M)
|
||||
{planetDetails.storageInfo
|
||||
.map(storage => ({
|
||||
...storage,
|
||||
isLaunchpad: LAUNCHPAD_IDS.includes(storage.type_id)
|
||||
}))
|
||||
.sort((a, b) => (b.isLaunchpad ? 1 : 0) - (a.isLaunchpad ? 1 : 0))
|
||||
.map((storage, idx) => {
|
||||
const fillRate = storage.fillRate;
|
||||
const color = fillRate > 90 ? '#ff0000' : fillRate > 80 ? '#ffa500' : fillRate > 60 ? '#ffd700' : 'inherit';
|
||||
|
||||
return (
|
||||
<div key={`storage-${character.character.characterId}-${planet.planet_id}-${storage.type}-${idx}`} style={{ display: "flex", alignItems: "center" }}>
|
||||
<Typography fontSize={theme.custom.smallText} style={{ marginRight: "5px" }}>
|
||||
{storage.isLaunchpad ? 'L' : 'S'}
|
||||
</Typography>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
<Typography fontSize={theme.custom.smallText} style={{ color }}>
|
||||
{fillRate.toFixed(1)}%
|
||||
</Typography>
|
||||
{storage.value > 0 && (
|
||||
<Typography fontSize={theme.custom.smallText} style={{ marginLeft: "5px" }}>
|
||||
({Math.round(storage.value / 1000000)}M)
|
||||
</Typography>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</Tooltip>
|
||||
</TableCell>
|
||||
|
@@ -19,6 +19,21 @@ import { EvePraisalResult, fetchAllPrices } from "@/eve-praisal";
|
||||
import { getPlanet, getPlanetUniverse, getPlanets } from "@/planets";
|
||||
import { PlanetConfig } from "@/types";
|
||||
|
||||
// Add batch processing utility
|
||||
const processInBatches = async <T, R>(
|
||||
items: T[],
|
||||
batchSize: number,
|
||||
processFn: (item: T) => Promise<R>
|
||||
): Promise<R[]> => {
|
||||
const results: R[] = [];
|
||||
for (let i = 0; i < items.length; i += batchSize) {
|
||||
const batch = items.slice(i, i + batchSize);
|
||||
const batchResults = await Promise.all(batch.map(processFn));
|
||||
results.push(...batchResults);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
const Home = () => {
|
||||
const searchParams = useSearchParams();
|
||||
const [characters, setCharacters] = useState<AccessToken[]>([]);
|
||||
@@ -63,15 +78,13 @@ const Home = () => {
|
||||
};
|
||||
|
||||
const refreshSession = async (characters: AccessToken[]) => {
|
||||
return Promise.all(
|
||||
characters.map((c) => {
|
||||
try {
|
||||
return refreshToken(c);
|
||||
} catch {
|
||||
return { ...c, needsLogin: true };
|
||||
}
|
||||
}),
|
||||
);
|
||||
return processInBatches(characters, 50, async (c) => {
|
||||
try {
|
||||
return await refreshToken(c);
|
||||
} catch {
|
||||
return { ...c, needsLogin: true };
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const handleCallback = async (
|
||||
@@ -107,24 +120,24 @@ const Home = () => {
|
||||
const initializeCharacterPlanets = (
|
||||
characters: AccessToken[],
|
||||
): Promise<AccessToken[]> =>
|
||||
Promise.all(
|
||||
characters.map(async (c) => {
|
||||
if (c.needsLogin || c.character === undefined)
|
||||
return { ...c, planets: [] };
|
||||
const planets = await getPlanets(c);
|
||||
const planetsWithInfo: PlanetWithInfo[] = await Promise.all(
|
||||
planets.map(async (p) => ({
|
||||
...p,
|
||||
info: await getPlanet(c, p),
|
||||
infoUniverse: await getPlanetUniverse(p),
|
||||
})),
|
||||
);
|
||||
return {
|
||||
...c,
|
||||
planets: planetsWithInfo,
|
||||
};
|
||||
}),
|
||||
);
|
||||
processInBatches(characters, 50, async (c) => {
|
||||
if (c.needsLogin || c.character === undefined)
|
||||
return { ...c, planets: [] };
|
||||
const planets = await getPlanets(c);
|
||||
const planetsWithInfo: PlanetWithInfo[] = await processInBatches(
|
||||
planets,
|
||||
3,
|
||||
async (p) => ({
|
||||
...p,
|
||||
info: await getPlanet(c, p),
|
||||
infoUniverse: await getPlanetUniverse(p),
|
||||
})
|
||||
);
|
||||
return {
|
||||
...c,
|
||||
planets: planetsWithInfo,
|
||||
};
|
||||
});
|
||||
|
||||
const saveCharacters = (characters: AccessToken[]): AccessToken[] => {
|
||||
localStorage.setItem("characters", JSON.stringify(characters));
|
||||
|
Reference in New Issue
Block a user