Implement planet exclusion from totals calculations
This commit is contained in:
@@ -2,4 +2,5 @@
|
|||||||
EVE_SSO_CLIENT_ID=Client ID
|
EVE_SSO_CLIENT_ID=Client ID
|
||||||
EVE_SSO_SECRET=Secret Key
|
EVE_SSO_SECRET=Secret Key
|
||||||
EVE_SSO_CALLBACK_URL=Callback URL (This should be the domain you are hosting at or if run locally it should be http://localhost:3000)
|
EVE_SSO_CALLBACK_URL=Callback URL (This should be the domain you are hosting at or if run locally it should be http://localhost:3000)
|
||||||
NEXT_PUBLIC_PRAISAL_URL=https://praisal.avanto.tk/appraisal/structured.json?persist=no
|
NEXT_PUBLIC_PRAISAL_URL=https://praisal.avanto.tk/appraisal/structured.json?persist=no
|
||||||
|
SENTRY_AUTH_TOKEN=Sentry token for error reporting.
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { SessionContext, ColorContext } from "@/app/context/Context";
|
import { ColorContext, SessionContext } from "@/app/context/Context";
|
||||||
import { PI_TYPES_MAP } from "@/const";
|
import { PI_TYPES_MAP } from "@/const";
|
||||||
import { AccessToken, PlanetWithInfo } from "@/types";
|
|
||||||
import { planetCalculations } from "@/planets";
|
import { planetCalculations } from "@/planets";
|
||||||
|
import { AccessToken, PlanetWithInfo } from "@/types";
|
||||||
import CloseIcon from "@mui/icons-material/Close";
|
import CloseIcon from "@mui/icons-material/Close";
|
||||||
import { Button, Tooltip, Typography, useTheme } from "@mui/material";
|
import { Button, Tooltip, Typography, useTheme } from "@mui/material";
|
||||||
import AppBar from "@mui/material/AppBar";
|
import AppBar from "@mui/material/AppBar";
|
||||||
@@ -16,9 +16,9 @@ import { DateTime } from "luxon";
|
|||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import React, { forwardRef, useContext, useState } from "react";
|
import React, { forwardRef, useContext, useState } from "react";
|
||||||
import Countdown from "react-countdown";
|
import Countdown from "react-countdown";
|
||||||
import PinsCanvas3D from "./PinsCanvas3D";
|
|
||||||
import { timeColor, alertModeVisibility } from "./timeColors";
|
|
||||||
import { PlanetConfigDialog } from "../PlanetConfig/PlanetConfigDialog";
|
import { PlanetConfigDialog } from "../PlanetConfig/PlanetConfigDialog";
|
||||||
|
import PinsCanvas3D from "./PinsCanvas3D";
|
||||||
|
import { alertModeVisibility, timeColor } from "./timeColors";
|
||||||
|
|
||||||
const Transition = forwardRef(function Transition(
|
const Transition = forwardRef(function Transition(
|
||||||
props: TransitionProps & {
|
props: TransitionProps & {
|
||||||
@@ -62,6 +62,7 @@ export const PlanetTableRow = ({
|
|||||||
const planetInfoUniverse = planet.infoUniverse;
|
const planetInfoUniverse = planet.infoUniverse;
|
||||||
const { expired, extractors, localProduction, localImports, localExports } =
|
const { expired, extractors, localProduction, localImports, localExports } =
|
||||||
planetCalculations(planet);
|
planetCalculations(planet);
|
||||||
|
const planetConfig = character.planetConfig.find(p => p.planetId === planet.planet_id)
|
||||||
const { colors } = useContext(ColorContext);
|
const { colors } = useContext(ColorContext);
|
||||||
return (
|
return (
|
||||||
<TableRow
|
<TableRow
|
||||||
@@ -159,6 +160,18 @@ export const PlanetTableRow = ({
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<div style={{ display: "flex", flexDirection: "column" }}>
|
||||||
|
{localExports.map((exports) => (
|
||||||
|
<Typography
|
||||||
|
key={`export-excluded-${character.character.characterId}-${planet.planet_id}-${exports.typeId}`}
|
||||||
|
fontSize={theme.custom.smallText}
|
||||||
|
>
|
||||||
|
{planetConfig?.excludeFromTotals ? 'ex' : ''}
|
||||||
|
</Typography>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<div style={{ display: "flex", flexDirection: "column" }}>
|
<div style={{ display: "flex", flexDirection: "column" }}>
|
||||||
{localExports.map((exports) => (
|
{localExports.map((exports) => (
|
||||||
|
@@ -77,6 +77,11 @@ const PlanetaryIteractionTable = ({
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
<TableCell width="2%">
|
||||||
|
<Tooltip title="Is planet ecluded from totals">
|
||||||
|
<Typography fontSize={theme.custom.smallText}>Excluded</Typography>
|
||||||
|
</Tooltip>
|
||||||
|
</TableCell>
|
||||||
<TableCell width="2%">
|
<TableCell width="2%">
|
||||||
<Tooltip title="How many units per hour factories are producing">
|
<Tooltip title="How many units per hour factories are producing">
|
||||||
<Typography fontSize={theme.custom.smallText}>u/h</Typography>
|
<Typography fontSize={theme.custom.smallText}>u/h</Typography>
|
||||||
|
@@ -40,9 +40,10 @@ const displayValue = (valueInMillions: number): string =>
|
|||||||
: `${valueInMillions.toFixed(2)} M`;
|
: `${valueInMillions.toFixed(2)} M`;
|
||||||
|
|
||||||
export const Summary = ({ characters }: { characters: AccessToken[] }) => {
|
export const Summary = ({ characters }: { characters: AccessToken[] }) => {
|
||||||
const { piPrices, alertMode } = useContext(SessionContext);
|
const { piPrices } = useContext(SessionContext);
|
||||||
const exports = characters.flatMap((char) => {
|
const exports = characters.flatMap((char) => {
|
||||||
return char.planets.flatMap((planet) => {
|
return char.planets.filter(p => !char.planetConfig.some(c => c.planetId == p.planet_id && c.excludeFromTotals))
|
||||||
|
.flatMap((planet) => {
|
||||||
const { localExports } = planetCalculations(planet);
|
const { localExports } = planetCalculations(planet);
|
||||||
return localExports;
|
return localExports;
|
||||||
});
|
});
|
||||||
|
@@ -145,7 +145,18 @@ const Home = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updatePlanetConfig = (config: PlanetConfig) => {
|
const updatePlanetConfig = (config: PlanetConfig) => {
|
||||||
console.log("poop");
|
const charactersToSave = characters.map((c) => {
|
||||||
|
if (c.character.characterId === config.characterId) {
|
||||||
|
return {
|
||||||
|
...c,
|
||||||
|
planetConfig: [...c.planetConfig.filter(p => p.planetId !== config.planetId), config]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return c;
|
||||||
|
});
|
||||||
|
setCharacters(charactersToSave);
|
||||||
|
saveCharacters(charactersToSave);
|
||||||
};
|
};
|
||||||
|
|
||||||
const readPlanetConfig = ({
|
const readPlanetConfig = ({
|
||||||
@@ -157,7 +168,7 @@ const Home = () => {
|
|||||||
}): PlanetConfig => {
|
}): PlanetConfig => {
|
||||||
const defaultConfig = { planetId, characterId, excludeFromTotals: false };
|
const defaultConfig = { planetId, characterId, excludeFromTotals: false };
|
||||||
|
|
||||||
return defaultConfig;
|
return characters.find(c => c.character.characterId === characterId)?.planetConfig.find(p => p.planetId === planetId) ?? defaultConfig
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@@ -34,7 +34,6 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
headers,
|
headers,
|
||||||
}).then((res) => res.json());
|
}).then((res) => res.json());
|
||||||
const character = extractCharacterFromToken(response);
|
const character = extractCharacterFromToken(response);
|
||||||
|
|
||||||
const token: AccessToken = {
|
const token: AccessToken = {
|
||||||
access_token: response.access_token,
|
access_token: response.access_token,
|
||||||
token_type: response.token_type,
|
token_type: response.token_type,
|
||||||
@@ -49,6 +48,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
comment: accessToken.comment,
|
comment: accessToken.comment,
|
||||||
system: accessToken.system,
|
system: accessToken.system,
|
||||||
planets: [],
|
planets: [],
|
||||||
|
planetConfig: accessToken.planetConfig ?? [],
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("Refresh", character.name, character.characterId);
|
console.log("Refresh", character.name, character.characterId);
|
||||||
|
@@ -50,6 +50,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
comment: "",
|
comment: "",
|
||||||
system: "",
|
system: "",
|
||||||
planets: [],
|
planets: [],
|
||||||
|
planetConfig: [],
|
||||||
};
|
};
|
||||||
res.json(token);
|
res.json(token);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import { PlanetConfig } from "./app/components/PlanetConfig/PlanetConfigDialog";
|
||||||
import { Api } from "./esi-api";
|
import { Api } from "./esi-api";
|
||||||
|
|
||||||
export interface AccessToken {
|
export interface AccessToken {
|
||||||
@@ -11,6 +12,7 @@ export interface AccessToken {
|
|||||||
comment: string;
|
comment: string;
|
||||||
system: string;
|
system: string;
|
||||||
planets: PlanetWithInfo[];
|
planets: PlanetWithInfo[];
|
||||||
|
planetConfig: PlanetConfig[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Character {
|
export interface Character {
|
||||||
|
Reference in New Issue
Block a user