9 Commits
push ... v1.0.3

18 changed files with 1038 additions and 176 deletions

54
.github/workflows/container.yml vendored Normal file
View File

@@ -0,0 +1,54 @@
name: Build and Push Container
on:
push:
tags:
- 'v*' # This will match tags like v1.0.0, v2.1.0, etc.
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max

View File

@@ -2,7 +2,7 @@
version: "2.1"
services:
eve-pi:
build: .
image: ghcr.io/calli-eve/eve-pi:latest
container_name: eve-pi
environment:
- EVE_SSO_CLIENT_ID=${EVE_SSO_CLIENT_ID}

191
package-lock.json generated
View File

@@ -11,6 +11,7 @@
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@fontsource/roboto": "^5.0.3",
"@hello-pangea/dnd": "^18.0.1",
"@mui/icons-material": "^5.11.16",
"@mui/material": "^5.13.5",
"@sentry/nextjs": "^8.2.1",
@@ -279,11 +280,12 @@
}
},
"node_modules/@babel/runtime": {
"version": "7.22.5",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.5.tgz",
"integrity": "sha512-ecjvYlnAaZ/KVneE/OdKYBYfgXV3Ptu6zQWmgEF7vwKhQnvVS6bjMD2XYgj+SNvQ1GfK/pjgokfPkC/2CO8CuA==",
"version": "7.27.0",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.27.0.tgz",
"integrity": "sha512-VtPOkrdPHZsKc/clNqyi9WUA8TINkZ4cGk63UUE3u4pmB2k+ZMQRDuIOagv8UVd6j7k0T3+RRIb7beKTebNbcw==",
"license": "MIT",
"dependencies": {
"regenerator-runtime": "^0.13.11"
"regenerator-runtime": "^0.14.0"
},
"engines": {
"node": ">=6.9.0"
@@ -534,6 +536,57 @@
"resolved": "https://registry.npmjs.org/@fontsource/roboto/-/roboto-5.0.3.tgz",
"integrity": "sha512-jbZDFwEFARDlo8TqG7th/xjhuq87GYfFpFb+uxuy+0Ng1bhRVgBRWlLj8+WIKhCTOr+h4QXbjpybLWFLUirOwQ=="
},
"node_modules/@hello-pangea/dnd": {
"version": "18.0.1",
"resolved": "https://registry.npmjs.org/@hello-pangea/dnd/-/dnd-18.0.1.tgz",
"integrity": "sha512-xojVWG8s/TGrKT1fC8K2tIWeejJYTAeJuj36zM//yEm/ZrnZUSFGS15BpO+jGZT1ybWvyXmeDJwPYb4dhWlbZQ==",
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.26.7",
"css-box-model": "^1.2.1",
"raf-schd": "^4.0.3",
"react-redux": "^9.2.0",
"redux": "^5.0.1"
},
"peerDependencies": {
"react": "^18.0.0 || ^19.0.0",
"react-dom": "^18.0.0 || ^19.0.0"
}
},
"node_modules/@hello-pangea/dnd/node_modules/@types/react": {
"version": "19.1.2",
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.2.tgz",
"integrity": "sha512-oxLPMytKchWGbnQM9O7D67uPa9paTNxO7jVoNMXgkkErULBPhPARCfkKL9ytcIJJRGjbsVwW4ugJzyFFvm/Tiw==",
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
"csstype": "^3.0.2"
}
},
"node_modules/@hello-pangea/dnd/node_modules/react-redux": {
"version": "9.2.0",
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.2.0.tgz",
"integrity": "sha512-ROY9fvHhwOD9ySfrF0wmvu//bKCQ6AeZZq1nJNtbDC+kk5DuSuNX/n6YWYF/SYy7bSba4D4FSz8DJeKY/S/r+g==",
"license": "MIT",
"dependencies": {
"@types/use-sync-external-store": "^0.0.6",
"use-sync-external-store": "^1.4.0"
},
"peerDependencies": {
"@types/react": "^18.2.25 || ^19",
"react": "^18.0 || ^19",
"redux": "^5.0.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"redux": {
"optional": true
}
}
},
"node_modules/@humanwhocodes/config-array": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz",
@@ -2604,6 +2657,12 @@
"lil-gui": "~0.17.0"
}
},
"node_modules/@types/use-sync-external-store": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.6.tgz",
"integrity": "sha512-zFDAD+tlpf2r4asuHEj0XH6pY6i0g5NeAHPn+15wk3BV6JA69eERFXC1gyGThDkVa1zCyKr5jox1+2LbV/AMLg==",
"license": "MIT"
},
"node_modules/@types/webxr": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.2.tgz",
@@ -3711,6 +3770,15 @@
"integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==",
"license": "MIT"
},
"node_modules/css-box-model": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/css-box-model/-/css-box-model-1.2.1.tgz",
"integrity": "sha512-a7Vr4Q/kd/aw96bnJG332W9V9LkJO69JRcaCYDUqjp6/z0w6VcZjgAcTbgFxEPfBgdnAwlh3iwu+hLopa+flJw==",
"license": "MIT",
"dependencies": {
"tiny-invariant": "^1.0.6"
}
},
"node_modules/csstype": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz",
@@ -7323,6 +7391,12 @@
}
]
},
"node_modules/raf-schd": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/raf-schd/-/raf-schd-4.0.3.tgz",
"integrity": "sha512-tQkJl2GRWh83ui2DiPTJz9wEiMN20syf+5oKfB03yYP7ioZcJwsIK8FjrtLwH1m7C7e+Tt2yYBlrOpdT+dyeIQ==",
"license": "MIT"
},
"node_modules/randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
@@ -7472,6 +7546,12 @@
"node": ">=8.10.0"
}
},
"node_modules/redux": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz",
"integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==",
"license": "MIT"
},
"node_modules/reflect.getprototypeof": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz",
@@ -7496,9 +7576,10 @@
}
},
"node_modules/regenerator-runtime": {
"version": "0.13.11",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg=="
"version": "0.14.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz",
"integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==",
"license": "MIT"
},
"node_modules/regexp.prototype.flags": {
"version": "1.5.4",
@@ -8668,6 +8749,12 @@
"resolved": "https://registry.npmjs.org/three/-/three-0.154.0.tgz",
"integrity": "sha512-Uzz8C/5GesJzv8i+Y2prEMYUwodwZySPcNhuJUdsVMH2Yn4Nm8qlbQe6qRN5fOhg55XB0WiLfTPBxVHxpE60ug=="
},
"node_modules/tiny-invariant": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz",
"integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==",
"license": "MIT"
},
"node_modules/tinycolor2": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.6.0.tgz",
@@ -8935,6 +9022,15 @@
"punycode": "^2.1.0"
}
},
"node_modules/use-sync-external-store": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.5.0.tgz",
"integrity": "sha512-Rb46I4cGGVBmjamjphe8L/UnvJD+uPPtTkNvX5mZgqdbavhI4EbgIWJiIHXJ8bc/i9EQGPRh4DwEURJ552Do0A==",
"license": "MIT",
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
}
},
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
@@ -9483,11 +9579,11 @@
}
},
"@babel/runtime": {
"version": "7.22.5",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.5.tgz",
"integrity": "sha512-ecjvYlnAaZ/KVneE/OdKYBYfgXV3Ptu6zQWmgEF7vwKhQnvVS6bjMD2XYgj+SNvQ1GfK/pjgokfPkC/2CO8CuA==",
"version": "7.27.0",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.27.0.tgz",
"integrity": "sha512-VtPOkrdPHZsKc/clNqyi9WUA8TINkZ4cGk63UUE3u4pmB2k+ZMQRDuIOagv8UVd6j7k0T3+RRIb7beKTebNbcw==",
"requires": {
"regenerator-runtime": "^0.13.11"
"regenerator-runtime": "^0.14.0"
}
},
"@babel/template": {
@@ -9683,6 +9779,39 @@
"resolved": "https://registry.npmjs.org/@fontsource/roboto/-/roboto-5.0.3.tgz",
"integrity": "sha512-jbZDFwEFARDlo8TqG7th/xjhuq87GYfFpFb+uxuy+0Ng1bhRVgBRWlLj8+WIKhCTOr+h4QXbjpybLWFLUirOwQ=="
},
"@hello-pangea/dnd": {
"version": "18.0.1",
"resolved": "https://registry.npmjs.org/@hello-pangea/dnd/-/dnd-18.0.1.tgz",
"integrity": "sha512-xojVWG8s/TGrKT1fC8K2tIWeejJYTAeJuj36zM//yEm/ZrnZUSFGS15BpO+jGZT1ybWvyXmeDJwPYb4dhWlbZQ==",
"requires": {
"@babel/runtime": "^7.26.7",
"css-box-model": "^1.2.1",
"raf-schd": "^4.0.3",
"react-redux": "^9.2.0",
"redux": "^5.0.1"
},
"dependencies": {
"@types/react": {
"version": "19.1.2",
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.2.tgz",
"integrity": "sha512-oxLPMytKchWGbnQM9O7D67uPa9paTNxO7jVoNMXgkkErULBPhPARCfkKL9ytcIJJRGjbsVwW4ugJzyFFvm/Tiw==",
"optional": true,
"peer": true,
"requires": {
"csstype": "^3.0.2"
}
},
"react-redux": {
"version": "9.2.0",
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.2.0.tgz",
"integrity": "sha512-ROY9fvHhwOD9ySfrF0wmvu//bKCQ6AeZZq1nJNtbDC+kk5DuSuNX/n6YWYF/SYy7bSba4D4FSz8DJeKY/S/r+g==",
"requires": {
"@types/use-sync-external-store": "^0.0.6",
"use-sync-external-store": "^1.4.0"
}
}
}
},
"@humanwhocodes/config-array": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz",
@@ -10970,6 +11099,11 @@
"lil-gui": "~0.17.0"
}
},
"@types/use-sync-external-store": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.6.tgz",
"integrity": "sha512-zFDAD+tlpf2r4asuHEj0XH6pY6i0g5NeAHPn+15wk3BV6JA69eERFXC1gyGThDkVa1zCyKr5jox1+2LbV/AMLg=="
},
"@types/webxr": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.2.tgz",
@@ -11740,6 +11874,14 @@
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
"integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
},
"css-box-model": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/css-box-model/-/css-box-model-1.2.1.tgz",
"integrity": "sha512-a7Vr4Q/kd/aw96bnJG332W9V9LkJO69JRcaCYDUqjp6/z0w6VcZjgAcTbgFxEPfBgdnAwlh3iwu+hLopa+flJw==",
"requires": {
"tiny-invariant": "^1.0.6"
}
},
"csstype": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz",
@@ -14130,6 +14272,11 @@
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="
},
"raf-schd": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/raf-schd/-/raf-schd-4.0.3.tgz",
"integrity": "sha512-tQkJl2GRWh83ui2DiPTJz9wEiMN20syf+5oKfB03yYP7ioZcJwsIK8FjrtLwH1m7C7e+Tt2yYBlrOpdT+dyeIQ=="
},
"randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
@@ -14244,6 +14391,11 @@
"picomatch": "^2.2.1"
}
},
"redux": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz",
"integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w=="
},
"reflect.getprototypeof": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz",
@@ -14261,9 +14413,9 @@
}
},
"regenerator-runtime": {
"version": "0.13.11",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg=="
"version": "0.14.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz",
"integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw=="
},
"regexp.prototype.flags": {
"version": "1.5.4",
@@ -15028,6 +15180,11 @@
"resolved": "https://registry.npmjs.org/three/-/three-0.154.0.tgz",
"integrity": "sha512-Uzz8C/5GesJzv8i+Y2prEMYUwodwZySPcNhuJUdsVMH2Yn4Nm8qlbQe6qRN5fOhg55XB0WiLfTPBxVHxpE60ug=="
},
"tiny-invariant": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz",
"integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg=="
},
"tinycolor2": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.6.0.tgz",
@@ -15201,6 +15358,12 @@
"punycode": "^2.1.0"
}
},
"use-sync-external-store": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.5.0.tgz",
"integrity": "sha512-Rb46I4cGGVBmjamjphe8L/UnvJD+uPPtTkNvX5mZgqdbavhI4EbgIWJiIHXJ8bc/i9EQGPRh4DwEURJ552Do0A==",
"requires": {}
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",

View File

@@ -13,6 +13,7 @@
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@fontsource/roboto": "^5.0.3",
"@hello-pangea/dnd": "^18.0.1",
"@mui/icons-material": "^5.11.16",
"@mui/material": "^5.13.5",
"@sentry/nextjs": "^8.2.1",

View File

@@ -1,40 +1,163 @@
import { AccessToken } from "@/types";
import { Box, Stack, Typography, useTheme } from "@mui/material";
import { Box, Stack, Typography, useTheme, Paper, IconButton } from "@mui/material";
import { CharacterRow } from "../Characters/CharacterRow";
import { PlanetaryInteractionRow } from "../PlanetaryInteraction/PlanetaryInteractionRow";
import { SessionContext } from "@/app/context/Context";
import { useContext } from "react";
import { useContext, useState } from "react";
import { PlanRow } from "./PlanRow";
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
import { planetCalculations } from "@/planets";
import { EvePraisalResult } from "@/eve-praisal";
import { STORAGE_IDS } from "@/const";
interface AccountTotals {
monthlyEstimate: number;
storageValue: number;
}
const calculateAccountTotals = (characters: AccessToken[], piPrices: EvePraisalResult | undefined): AccountTotals => {
let totalMonthlyEstimate = 0;
let totalStorageValue = 0;
characters.forEach((character) => {
character.planets.forEach((planet) => {
const { localExports } = planetCalculations(planet);
const planetConfig = character.planetConfig.find(p => p.planetId === planet.planet_id);
// Calculate monthly estimate
if (!planetConfig?.excludeFromTotals) {
localExports.forEach((exportItem) => {
const valueInMillions = (((piPrices?.appraisal.items.find(
(a) => a.typeID === exportItem.typeId,
)?.prices.sell.min ?? 0) *
exportItem.amount) /
1000000) *
24 *
30;
totalMonthlyEstimate += valueInMillions;
});
}
if (!planetConfig?.excludeFromTotals) {
planet.info.pins
.filter(pin => STORAGE_IDS().some(storage => storage.type_id === pin.type_id))
.forEach(storage => {
storage.contents?.forEach(content => {
const valueInMillions = (piPrices?.appraisal.items.find(
(a) => a.typeID === content.type_id,
)?.prices.sell.min ?? 0) * content.amount / 1000000;
totalStorageValue += valueInMillions;
});
});
}
});
});
return {
monthlyEstimate: totalMonthlyEstimate,
storageValue: totalStorageValue
};
};
export const AccountCard = ({ characters }: { characters: AccessToken[] }) => {
const theme = useTheme();
const [isCollapsed, setIsCollapsed] = useState(false);
const { planMode, piPrices } = useContext(SessionContext);
const { monthlyEstimate, storageValue } = calculateAccountTotals(characters, piPrices);
const { planMode } = useContext(SessionContext);
return (
<Box
<Paper
elevation={2}
sx={{
padding: 1,
borderBottom: theme.custom.compactMode ? "" : "solid 1px gray",
padding: theme.custom.compactMode ? theme.spacing(1) : theme.spacing(2),
margin: theme.spacing(1),
display: 'flex',
alignItems: 'flex-start',
gap: 1,
backgroundColor: theme.palette.background.paper,
transition: 'all 0.2s ease-in-out',
cursor: 'grab',
'&:hover': {
boxShadow: theme.shadows[4],
},
'&:active': {
boxShadow: theme.shadows[8],
cursor: 'grabbing',
},
}}
>
<Typography style={{ fontSize: "0.8rem" }} paddingLeft={2}>
{characters[0].account !== "-"
? `Account: ${characters[0].account}`
: "No account name"}
</Typography>
{characters.map((c) => (
<Stack
key={c.character.characterId}
direction="row"
alignItems="flex-start"
<Box sx={{ flex: 1 }}>
<Box
sx={{
backgroundColor: theme.palette.background.default,
borderRadius: 1,
padding: theme.spacing(1),
marginBottom: theme.spacing(2),
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
}}
>
<CharacterRow character={c} />
{planMode ? (
<PlanRow character={c} />
) : (
<PlanetaryInteractionRow character={c} />
)}
</Stack>
))}
</Box>
<Box>
<Typography
sx={{
fontSize: "0.9rem",
fontWeight: 500,
color: theme.palette.text.primary,
}}
>
{characters.length > 0 && characters[0].account !== "-"
? `Account: ${characters[0].account}`
: "No account name"}
</Typography>
<Typography
sx={{
fontSize: "0.8rem",
color: theme.palette.text.secondary,
}}
>
Monthly Estimate: {monthlyEstimate >= 1000
? `${(monthlyEstimate / 1000).toFixed(2)} B`
: `${monthlyEstimate.toFixed(2)} M`} ISK
</Typography>
<Typography
sx={{
fontSize: "0.8rem",
color: theme.palette.text.secondary,
}}
>
Storage Value: {storageValue >= 1000
? `${(storageValue / 1000).toFixed(2)} B`
: `${storageValue.toFixed(2)} M`} ISK
</Typography>
</Box>
<IconButton
size="small"
onClick={() => setIsCollapsed(!isCollapsed)}
sx={{
transform: isCollapsed ? 'rotate(-90deg)' : 'rotate(0deg)',
transition: 'transform 0.2s ease-in-out'
}}
>
{isCollapsed ? <KeyboardArrowUpIcon /> : <KeyboardArrowDownIcon />}
</IconButton>
</Box>
{!isCollapsed && characters.map((c) => (
<Stack
key={c.character.characterId}
direction="row"
alignItems="flex-start"
>
<CharacterRow character={c} />
{planMode ? (
<PlanRow character={c} />
) : (
<PlanetaryInteractionRow character={c} />
)}
</Stack>
))}
</Box>
</Paper>
);
};

View File

@@ -1,4 +1,4 @@
import { Button, Dialog, DialogActions, DialogTitle } from "@mui/material";
import { Button, Dialog, DialogActions, DialogTitle, Box } from "@mui/material";
import { AccessToken, CharacterUpdate } from "../../../types";
import { useEffect, useState, KeyboardEvent } from "react";
import TextField from "@mui/material/TextField";
@@ -34,7 +34,9 @@ export const CharacterDialog = ({
const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
if (event.key === "Enter") {
closeDialog();
character && updateCharacter(character, { account, comment });
if (character) {
updateCharacter(character, { account, comment });
}
}
};
@@ -44,16 +46,27 @@ export const CharacterDialog = ({
onClose={closeDialog}
fullWidth={true}
>
<DialogTitle>{character && character.character.name}</DialogTitle>
<TextField
id="outlined-basic"
label="Account name"
variant="outlined"
value={account ?? ""}
sx={{ margin: 1 }}
onChange={(event) => setAccount(event.target.value)}
onKeyDown={handleKeyDown}
/>
<DialogTitle>{character?.character?.name}</DialogTitle>
<Box sx={{ display: 'flex', alignItems: 'center', margin: 1 }}>
<TextField
id="outlined-basic"
label="Account name"
variant="outlined"
value={account ?? ""}
sx={{ flex: 1 }}
onChange={(event) => setAccount(event.target.value)}
onKeyDown={handleKeyDown}
/>
<Button
onClick={() => {
setAccount("-");
}}
variant="outlined"
sx={{ ml: 1 }}
>
Clear account
</Button>
</Box>
<TextField
id="outlined-basic"
label="System"
@@ -77,6 +90,7 @@ export const CharacterDialog = ({
<DialogActions>
<Button
onClick={() => {
console.log("Saving character", character, { account, comment, system });
character &&
updateCharacter(character, { account, comment, system });
closeDialog();

View File

@@ -11,6 +11,7 @@ import { AccessToken } from "@/types";
import { CharacterContext, SessionContext } from "../context/Context";
import ResponsiveAppBar from "./AppBar/AppBar";
import { Summary } from "./Summary/Summary";
import { DragDropContext, Droppable, Draggable, DropResult } from "@hello-pangea/dnd";
interface Grouped {
[key: string]: AccessToken[];
@@ -38,7 +39,41 @@ declare module "@mui/material/styles" {
}
export const MainGrid = () => {
const { characters } = useContext(CharacterContext);
const { characters, updateCharacter } = useContext(CharacterContext);
const [accountOrder, setAccountOrder] = useState<string[]>([]);
// Initialize account order when characters change
useEffect(() => {
const currentAccounts = Object.keys(
characters.reduce<Grouped>((group, character) => {
const { account } = character;
group[account ?? ""] = group[account ?? ""] ?? [];
group[account ?? ""].push(character);
return group;
}, {})
);
const savedOrder = localStorage.getItem('accountOrder');
if (savedOrder) {
try {
const parsedOrder = JSON.parse(savedOrder);
const validOrder = parsedOrder.filter((account: string) => currentAccounts.includes(account));
const newAccounts = currentAccounts.filter(account => !validOrder.includes(account));
setAccountOrder([...validOrder, ...newAccounts]);
} catch (e) {
setAccountOrder(currentAccounts);
}
} else {
setAccountOrder(currentAccounts);
}
}, [characters]);
useEffect(() => {
if (accountOrder.length > 0) {
localStorage.setItem('accountOrder', JSON.stringify(accountOrder));
}
}, [accountOrder]);
const groupByAccount = characters.reduce<Grouped>((group, character) => {
const { account } = character;
group[account ?? ""] = group[account ?? ""] ?? [];
@@ -79,24 +114,68 @@ export const MainGrid = () => {
);
}, [compactMode]);
const handleDragEnd = (result: DropResult) => {
if (!result.destination) return;
const items = Array.from(accountOrder);
const [reorderedItem] = items.splice(result.source.index, 1);
items.splice(result.destination.index, 0, reorderedItem);
setAccountOrder(items);
};
const DragDropContextComponent = DragDropContext as any;
const DroppableComponent = Droppable as any;
const DraggableComponent = Draggable as any;
return (
<ThemeProvider theme={darkTheme}>
<CssBaseline />
<Box sx={{ flexGrow: 1 }}>
<ResponsiveAppBar />
{compactMode ? <></> : <Summary characters={characters} />}
<Grid container spacing={1}>
{Object.values(groupByAccount).map((g, id) => (
<Grid
item
xs={12}
sm={compactMode ? 6 : 12}
key={`account-${id}-${g[0].account}`}
>
<AccountCard characters={g} />
</Grid>
))}
</Grid>
<DragDropContextComponent onDragEnd={handleDragEnd}>
<DroppableComponent droppableId="accounts">
{(provided: any) => (
<Grid
container
spacing={1}
sx={{ padding: 1 }}
{...provided.droppableProps}
ref={provided.innerRef}
>
{accountOrder.map((account, index) => (
<DraggableComponent
key={account}
draggableId={account}
index={index}
>
{(provided: any) => (
<Grid
item
xs={12}
sm={compactMode ? 6 : 12}
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
sx={{
'& > *': {
width: '100%',
},
}}
>
{groupByAccount[account] && groupByAccount[account].length > 0 && (
<AccountCard characters={groupByAccount[account]} />
)}
</Grid>
)}
</DraggableComponent>
))}
{provided.placeholder}
</Grid>
)}
</DroppableComponent>
</DragDropContextComponent>
</Box>
</ThemeProvider>
);

View File

@@ -3,8 +3,6 @@ import { planetCalculations } from "@/planets";
import { AccessToken, PlanetWithInfo } from "@/types";
import {
Card,
Checkbox,
FormControlLabel,
Table,
TableBody,
TableCell,
@@ -20,12 +18,6 @@ import Image from "next/image";
import { ColorContext, SessionContext } from "@/app/context/Context";
import { useContext } from "react";
export type PlanetConfig = {
characterId: number;
planetId: number;
excludeFromTotals: boolean;
};
export const PlanetConfigDialog = ({
planet,
character,
@@ -35,14 +27,9 @@ export const PlanetConfigDialog = ({
}) => {
const theme = useTheme();
const { colors } = useContext(ColorContext);
const { piPrices, readPlanetConfig, updatePlanetConfig } =
useContext(SessionContext);
const { piPrices } = useContext(SessionContext);
const { extractors, localProduction, localImports, localExports } =
planetCalculations(planet);
const planetConfig = readPlanetConfig({
characterId: character.character.characterId,
planetId: planet.planet_id,
});
return (
<Card style={{ padding: "1rem", margin: "1rem" }}>
@@ -189,23 +176,6 @@ export const PlanetConfigDialog = ({
</TableRow>
</TableBody>
</Table>
<Card style={{ marginTop: "1rem" }}>
<Typography>Planet configuration</Typography>
<FormControlLabel
control={
<Checkbox
checked={planetConfig.excludeFromTotals}
onChange={() =>
updatePlanetConfig({
...planetConfig,
excludeFromTotals: !planetConfig.excludeFromTotals,
})
}
/>
}
label="Consumed by production chain"
/>
</Card>
</Card>
);
};

View File

@@ -65,6 +65,7 @@ export interface ProductionNode {
quantity: number;
}>;
cycleTime: number;
factoryCount: number;
}
export interface ProductionChainBalance {

View File

@@ -1,7 +1,6 @@
import React from 'react';
import { Box, Paper, Typography, Stack } from '@mui/material';
import { Line } from 'react-chartjs-2';
import { useTheme } from '@mui/material';
import { getProgramOutputPrediction, ProductionNode } from './ExtractionSimulation';
import { PI_TYPES_MAP } from '@/const';
import { ProductionChainVisualization } from './ProductionChainVisualization';
@@ -15,6 +14,8 @@ import {
Tooltip,
Legend
} from 'chart.js';
import { DateTime } from 'luxon';
import Countdown from 'react-countdown';
ChartJS.register(
CategoryScale,
@@ -43,6 +44,7 @@ export const ExtractionSimulationDisplay: React.FC<ExtractionSimulationDisplayPr
extractors,
productionNodes
}) => {
const CYCLE_TIME = 30 * 60; // 30 minutes in seconds
// Calculate program duration and cycles for each extractor
@@ -57,6 +59,7 @@ export const ExtractionSimulationDisplay: React.FC<ExtractionSimulationDisplayPr
};
});
const maxCycles = Math.max(...extractorPrograms.map(e => e.cycles));
// Get output predictions for each extractor
@@ -156,10 +159,14 @@ export const ExtractionSimulationDisplay: React.FC<ExtractionSimulationDisplayPr
const installedSchematicIds = Array.from(new Set(productionNodes.map(node => node.schematicId)));
// Create factories array with correct counts
const factories = installedSchematicIds.map(schematicId => ({
schematic_id: schematicId,
count: productionNodes.filter(node => node.schematicId === schematicId).length
}));
const factories = installedSchematicIds.map(schematicId => {
const node = productionNodes.find(n => n.schematicId === schematicId);
if (!node) return { schematic_id: schematicId, count: 0 };
return {
schematic_id: schematicId,
count: node.factoryCount
};
});
return (
<Box>
@@ -191,6 +198,12 @@ export const ExtractionSimulationDisplay: React.FC<ExtractionSimulationDisplayPr
<Typography variant="body2" component="div" sx={{ pl: 2 }}>
Expiry Time: {new Date(expiryTime).toLocaleString()}
</Typography>
<Typography variant="body2" component="div" sx={{ pl: 2 }}>
Factory Count: {factories.find(f => f.schematic_id === typeId)?.count ?? 0}
</Typography>
<Typography variant="body2" component="div" sx={{ pl: 2 }}>
Expires in: <Countdown overtime={true} date={DateTime.fromISO(expiryTime).toMillis()} />
</Typography>
</Stack>
))}
</Box>
@@ -204,7 +217,8 @@ export const ExtractionSimulationDisplay: React.FC<ExtractionSimulationDisplayPr
extractors={extractors.map(e => ({
typeId: e.typeId,
baseValue: e.baseValue,
cycleTime: CYCLE_TIME
cycleTime: CYCLE_TIME,
expiryTime: e.expiryTime
}))}
factories={factories}
extractorTotals={extractorTotals}

View File

@@ -0,0 +1,207 @@
import React from 'react';
import { Box, Paper, Typography, Stack } from '@mui/material';
import { Line } from 'react-chartjs-2';
import { getProgramOutputPrediction } from './ExtractionSimulation';
import { PI_TYPES_MAP } from '@/const';
import {
Chart as ChartJS,
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend
} from 'chart.js';
import { DateTime } from 'luxon';
import Countdown from 'react-countdown';
ChartJS.register(
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend
);
interface ExtractorConfig {
typeId: number;
baseValue: number;
cycleTime: number;
installTime: string;
expiryTime: string;
}
interface ExtractionSimulationTooltipProps {
extractors: ExtractorConfig[];
}
export const ExtractionSimulationTooltip: React.FC<ExtractionSimulationTooltipProps> = ({
extractors
}) => {
const CYCLE_TIME = 30 * 60; // 30 minutes in seconds
// Calculate program duration and cycles for each extractor
const extractorPrograms = extractors.map(extractor => {
const installDate = new Date(extractor.installTime);
const expiryDate = new Date(extractor.expiryTime);
const programDuration = (expiryDate.getTime() - installDate.getTime()) / 1000; // Convert to seconds
return {
...extractor,
programDuration,
cycles: Math.floor(programDuration / CYCLE_TIME)
};
});
const maxCycles = Math.max(...extractorPrograms.map(e => e.cycles));
// Get output predictions for each extractor
const extractorOutputs = extractorPrograms.map(extractor => ({
typeId: extractor.typeId,
cycleTime: CYCLE_TIME,
cycles: extractor.cycles,
prediction: getProgramOutputPrediction(
extractor.baseValue,
CYCLE_TIME,
extractor.cycles
)
}));
// Create datasets for the chart
const datasets = extractorOutputs.map((output, index) => {
const hue = (360 / extractors.length) * index;
return {
label: `${PI_TYPES_MAP[output.typeId]?.name ?? `Resource ${output.typeId}`}`,
data: output.prediction,
borderColor: `hsl(${hue}, 70%, 50%)`,
backgroundColor: `hsl(${hue}, 70%, 80%)`,
tension: 0.4
};
});
const chartData = {
labels: Array.from({ length: maxCycles }, (_, i) => {
return (i % 4 === 0) ? `Cycle ${i + 1}` : '';
}),
datasets
};
const chartOptions = {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'top' as const,
},
title: {
display: true,
text: 'Extraction Output Prediction'
},
tooltip: {
callbacks: {
title: (context: any) => `Cycle ${context[0].dataIndex + 1}`,
label: (context: any) => `Output: ${context.raw.toFixed(1)} units`
}
}
},
scales: {
y: {
beginAtZero: true,
title: {
display: true,
text: 'Units per Cycle'
}
},
x: {
ticks: {
autoSkip: true,
maxTicksLimit: 24
}
}
}
};
return (
<Paper sx={{ p: 1, bgcolor: 'background.paper', minWidth: 800 }}>
<Stack direction="row" spacing={2} sx={{ width: '100%' }}>
<Box sx={{ flex: 1, minWidth: 0 }}>
<div style={{ height: '200px' }}>
<Line data={chartData} options={chartOptions} />
</div>
</Box>
<Box sx={{ flex: 1, minWidth: 0 }}>
<Stack spacing={1}>
{extractorPrograms.map(({ typeId, cycleTime, cycles, installTime, expiryTime }) => {
const prediction = getProgramOutputPrediction(
extractors.find(e => e.typeId === typeId)?.baseValue || 0,
CYCLE_TIME,
cycles
);
const totalOutput = prediction.reduce((sum, val) => sum + val, 0);
return (
<Paper key={typeId} sx={{ p: 1, bgcolor: 'background.default' }}>
<Typography variant="subtitle2">
{PI_TYPES_MAP[typeId]?.name}
</Typography>
<Stack spacing={0.5}>
<Typography variant="body2">
Total Output: {totalOutput.toFixed(1)} units per program
</Typography>
<Typography variant="body2">
Cycle Time: {(cycleTime / 60).toFixed(1)} minutes
</Typography>
<Typography variant="body2">
Program Cycles: {cycles}
</Typography>
<Typography variant="body2">
Average per Cycle: {(totalOutput / cycles).toFixed(1)} units
</Typography>
<Typography variant="body2">
Expires in: <Countdown overtime={true} date={DateTime.fromISO(expiryTime).toMillis()} />
</Typography>
</Stack>
</Paper>
);
})}
{extractors.length === 2 && (
<Paper sx={{ p: 1, bgcolor: 'background.default' }}>
<Typography variant="subtitle2" color="error">
Balance
</Typography>
<Stack spacing={0.5}>
{extractors.map((extractor, index) => {
const averagePerHour = (extractor.baseValue * 3600) / extractor.cycleTime;
return (
<Typography key={index} variant="body2">
{PI_TYPES_MAP[extractor.typeId]?.name}: {averagePerHour.toFixed(1)} u/h
</Typography>
);
})}
<Typography
variant="body2"
color="error"
sx={{
mt: 1,
fontWeight: 'bold',
borderTop: '1px solid',
borderColor: 'divider',
pt: 1
}}
>
Difference: {Math.abs(
(extractors[0].baseValue * 3600 / extractors[0].cycleTime) -
(extractors[1].baseValue * 3600 / extractors[1].cycleTime)
).toFixed(1)} u/h
</Typography>
</Stack>
</Paper>
)}
</Stack>
</Box>
</Stack>
</Paper>
);
};

View File

@@ -4,7 +4,7 @@ import { planetCalculations } from "@/planets";
import { AccessToken, PlanetWithInfo } from "@/types";
import CloseIcon from "@mui/icons-material/Close";
import MoreVertIcon from '@mui/icons-material/MoreVert';
import { Button, Tooltip, Typography, useTheme, Menu, MenuItem, IconButton } from "@mui/material";
import { Button, Tooltip, Typography, useTheme, Menu, MenuItem, IconButton, Checkbox, FormControlLabel } from "@mui/material";
import AppBar from "@mui/material/AppBar";
import Dialog from "@mui/material/Dialog";
import Slide from "@mui/material/Slide";
@@ -20,6 +20,7 @@ import { PlanetConfigDialog } from "../PlanetConfig/PlanetConfigDialog";
import PinsCanvas3D from "./PinsCanvas3D";
import { alertModeVisibility, timeColor } from "./timeColors";
import { ExtractionSimulationDisplay } from './ExtractionSimulationDisplay';
import { ExtractionSimulationTooltip } from './ExtractionSimulationTooltip';
import { ProductionNode } from './ExtractionSimulation';
import { Collapse, Box, Stack } from "@mui/material";
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
@@ -72,14 +73,15 @@ export const PlanetTableRow = ({
setPlanetConfigOpen(false);
};
const { piPrices, alertMode } = useContext(SessionContext);
const { piPrices, alertMode, updatePlanetConfig, readPlanetConfig, balanceThreshold } = useContext(SessionContext);
const planetInfo = planet.info;
const planetInfoUniverse = planet.infoUniverse;
const { expired, extractors, localProduction, localImports, localExports } =
planetCalculations(planet);
const planetConfig = character.planetConfig.find(
(p) => p.planetId === planet.planet_id,
);
const planetConfig = readPlanetConfig({
characterId: character.character.characterId,
planetId: planet.planet_id,
});
const { colors } = useContext(ColorContext);
// Convert local production to ProductionNode array for simulation
const productionNodes: ProductionNode[] = Array.from(localProduction).map(([schematicId, schematic]) => ({
@@ -94,18 +96,25 @@ export const PlanetTableRow = ({
typeId: output.type_id,
quantity: output.quantity
})),
cycleTime: schematic.cycle_time
cycleTime: schematic.cycle_time,
factoryCount: schematic.count || 1
}));
// Convert Map to Array for schematic IDs
const installedSchematicIds = Array.from(localProduction.values()).map(p => p.schematic_id);
// Get extractor head types safely
const extractedTypeIds = extractors
.map(e => e.extractor_details?.product_type_id)
.filter((id): id is number => id !== undefined);
// Calculate extractor averages and check for large differences
const extractorAverages = extractors
.filter(e => e.extractor_details?.product_type_id && e.extractor_details?.qty_per_cycle)
.map(e => {
const cycleTime = e.extractor_details?.cycle_time || 3600;
const qtyPerCycle = e.extractor_details?.qty_per_cycle || 0;
return {
typeId: e.extractor_details!.product_type_id!,
averagePerHour: (qtyPerCycle * 3600) / cycleTime
};
});
const hasLargeExtractorDifference = extractorAverages.length === 2 &&
Math.abs(extractorAverages[0].averagePerHour - extractorAverages[1].averagePerHour) > balanceThreshold;
// Get storage facilities
const storageFacilities = planetInfo.pins.filter(pin =>
STORAGE_IDS().some(storage => storage.type_id === pin.type_id)
);
@@ -116,23 +125,36 @@ export const PlanetTableRow = ({
const storageType = PI_TYPES_MAP[pin.type_id].name;
const storageCapacity = STORAGE_CAPACITIES[pin.type_id] || 0;
// Calculate total volume of stored products for this specific pin
const totalVolume = (pin.contents || [])
.reduce((sum: number, item: any) => {
const volume = PI_PRODUCT_VOLUMES[item.type_id] || 0;
return sum + (item.amount * volume);
}, 0);
const totalValue = (pin.contents || [])
.reduce((sum: number, item: any) => {
const price = piPrices?.appraisal.items.find((a) => a.typeID === item.type_id)?.prices.sell.min ?? 0;
return sum + (item.amount * price);
}, 0);
const fillRate = storageCapacity > 0 ? (totalVolume / storageCapacity) * 100 : 0;
return {
type: storageType,
capacity: storageCapacity,
used: totalVolume,
fillRate: fillRate
fillRate: fillRate,
value: totalValue
};
};
const handleExcludeChange = (event: React.ChangeEvent<HTMLInputElement>) => {
updatePlanetConfig({
...planetConfig,
excludeFromTotals: event.target.checked,
});
};
return (
<>
<TableRow
@@ -154,7 +176,52 @@ export const PlanetTableRow = ({
height={theme.custom.cardImageSize / 6}
style={{ marginRight: "5px" }}
/>
{planetInfoUniverse?.name}
<Tooltip
placement="right"
title={
<ExtractionSimulationTooltip
extractors={extractors
.filter(e => e.extractor_details?.product_type_id && e.extractor_details?.qty_per_cycle)
.map(e => ({
typeId: e.extractor_details!.product_type_id!,
baseValue: e.extractor_details!.qty_per_cycle!,
cycleTime: e.extractor_details!.cycle_time || 3600,
installTime: e.install_time ?? "",
expiryTime: e.expiry_time ?? ""
}))}
/>
}
componentsProps={{
tooltip: {
sx: {
bgcolor: 'background.paper',
'& .MuiTooltip-arrow': {
color: 'background.paper',
},
maxWidth: 'none',
width: 'fit-content'
}
}
}}
>
<Stack spacing={0}>
<Typography
fontSize={theme.custom.smallText}
color={hasLargeExtractorDifference ? 'error' : 'inherit'}
>
{planetInfoUniverse?.name}
</Typography>
{hasLargeExtractorDifference && (
<Typography
fontSize={theme.custom.smallText}
color="error"
sx={{ opacity: 0.7 }}
>
off-balance
</Typography>
)}
</Stack>
</Tooltip>
</div>
</Tooltip>
</TableCell>
@@ -233,12 +300,17 @@ export const PlanetTableRow = ({
<TableCell>
<div style={{ display: "flex", flexDirection: "column" }}>
{localExports.map((exports) => (
<Typography
<FormControlLabel
key={`export-excluded-${character.character.characterId}-${planet.planet_id}-${exports.typeId}`}
fontSize={theme.custom.smallText}
>
{planetConfig?.excludeFromTotals ? "ex" : ""}
</Typography>
control={
<Checkbox
checked={planetConfig.excludeFromTotals}
onChange={handleExcludeChange}
size="small"
/>
}
label=""
/>
))}
</div>
</TableCell>
@@ -319,6 +391,11 @@ export const PlanetTableRow = ({
<Typography fontSize={theme.custom.smallText} style={{ color }}>
{fillRate.toFixed(1)}%
</Typography>
{storageInfo.value > 0 && (
<Typography fontSize={theme.custom.smallText} style={{ marginLeft: "5px" }}>
({Math.round(storageInfo.value / 1000000)}M)
</Typography>
)}
</div>
);
})}

View File

@@ -1,7 +1,9 @@
import React from 'react';
import { Box, Paper, Typography, Grid, Stack, Divider } from '@mui/material';
import { Box, Paper, Typography, Grid, Stack, Divider, Tooltip } from '@mui/material';
import { EVE_IMAGE_URL } from '@/const';
import { PI_TYPES_MAP } from '@/const';
import { DateTime } from 'luxon';
import Countdown from 'react-countdown';
interface Factory {
schematic_id: number;
@@ -29,6 +31,7 @@ interface ProductionChainVisualizationProps {
typeId: number;
baseValue: number;
cycleTime: number;
expiryTime: string;
}>;
factories: Factory[];
extractorTotals: Map<number, number>;
@@ -39,8 +42,10 @@ export const ProductionChainVisualization: React.FC<ProductionChainVisualization
extractedTypeIds,
factories,
extractorTotals,
productionNodes
productionNodes,
extractors
}) => {
// Get all type IDs involved in the production chain
const allTypeIds = new Set<number>();
const requiredInputs = new Set<number>();
@@ -214,9 +219,15 @@ export const ProductionChainVisualization: React.FC<ProductionChainVisualization
// Get factory count for a type
const getFactoryCount = (typeId: number): number => {
const node = nodesByOutput.get(typeId);
if (!node) return 0;
return factories.find(f => f.schematic_id === node.schematicId)?.count ?? 0;
// First find the node that produces this type
const producingNode = productionNodes.find(node =>
node.outputs.some(output => output.typeId === typeId)
);
if (!producingNode) return 0;
// Then find the factory count for this schematic
return factories.find(f => f.schematic_id === producingNode.schematicId)?.count ?? 0;
};
// Get input requirements for a type
@@ -232,6 +243,11 @@ export const ProductionChainVisualization: React.FC<ProductionChainVisualization
return node?.cycleTime;
};
// Get extractor expiry time for a type
const getExtractorExpiryTime = (typeId: number): string | undefined => {
return extractors.find(e => e.typeId === typeId)?.expiryTime;
};
return (
<Paper sx={{ p: 2, my: 2 }}>
<Typography variant="h6" gutterBottom>
@@ -258,6 +274,7 @@ export const ProductionChainVisualization: React.FC<ProductionChainVisualization
const consumption = consumptionTotals.get(typeId) ?? 0;
const inputs = getInputRequirements(typeId);
const cycleTime = getSchematicCycleTime(typeId);
const expiryTime = getExtractorExpiryTime(typeId);
return (
<Grid item key={typeId} xs={12} sm={6} md={4}>
@@ -292,19 +309,49 @@ export const ProductionChainVisualization: React.FC<ProductionChainVisualization
</Box>
</Box>
<Stack spacing={0.5}>
{production > 0 && (
<>
<Typography variant="caption" color="success.main">
Production: {production.toFixed(1)} units total
{factoryCount > 0 && (
<Typography variant="caption" color="info.main">
Factories: {factoryCount}
</Typography>
)}
{inputs.length > 0 && (
<Box>
<Typography variant="caption" color="text.secondary">
Inputs:
</Typography>
</>
{inputs.map(input => (
<Typography
key={input.typeId}
variant="caption"
sx={{ display: 'block', ml: 1 }}
>
{PI_TYPES_MAP[input.typeId]?.name}: {input.quantity * factoryCount}/cycle
</Typography>
))}
</Box>
)}
{expiryTime && (
<Box>
<Typography variant="caption" color="text.secondary">
Extractor expires in:
</Typography>
<Typography variant="caption" sx={{ ml: 1 }}>
<Countdown
overtime={true}
date={DateTime.fromISO(expiryTime).toMillis()}
/>
</Typography>
</Box>
)}
{production > 0 && (
<Typography variant="caption" color="success.main">
Production: {production.toFixed(1)} units total
</Typography>
)}
{consumption > 0 && (
<>
<Typography variant="caption" color="error.main">
Consumption: {consumption.toFixed(1)} units total
</Typography>
</>
<Typography variant="caption" color="error.main">
Consumption: {consumption.toFixed(1)} units total
</Typography>
)}
{isImported && (
<>

View File

@@ -1,6 +1,7 @@
import {
ColorContext,
ColorSelectionType,
SessionContext,
} from "@/app/context/Context";
import {
Button,
@@ -10,14 +11,16 @@ import {
DialogTitle,
Tooltip,
Typography,
TextField,
Box,
} from "@mui/material";
import { ColorChangeHandler, ColorResult, CompactPicker } from "react-color";
import React from "react";
import { useContext } from "react";
import React, { useState, useContext } from "react";
export const SettingsButton = () => {
const { colors, setColors } = useContext(ColorContext);
const [open, setOpen] = React.useState(false);
const { balanceThreshold, setBalanceThreshold } = useContext(SessionContext);
const [open, setOpen] = useState(false);
const handleClickOpen = () => {
setOpen(true);
@@ -26,6 +29,7 @@ export const SettingsButton = () => {
const handleClose = () => {
setOpen(false);
};
const handleColorSelection = (key: string, currentColors: ColorSelectionType) => (selection: ColorResult) => {
console.log(key, selection.hex)
setColors({
@@ -34,20 +38,44 @@ export const SettingsButton = () => {
})
};
const handleBalanceThresholdChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const value = parseInt(event.target.value);
if (!isNaN(value) && value >= 0 && value <= 100000) {
setBalanceThreshold(value);
}
};
return (
<Tooltip title="Toggle settings dialog">
<>
<Button onClick={handleClickOpen}>Settings</Button>
<Button onClick={handleClickOpen} color="inherit">
Settings
</Button>
<Dialog
open={open}
onClose={handleClose}
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
<DialogTitle id="alert-dialog-title">
{"Override default timer colors"}
{"Settings"}
</DialogTitle>
<DialogContent style={{ paddingTop: "1rem" }}>
<Box sx={{ mt: 2 }}>
<Typography variant="subtitle1">Balance Threshold</Typography>
<TextField
type="number"
value={balanceThreshold}
onChange={handleBalanceThresholdChange}
fullWidth
margin="normal"
inputProps={{ min: 0, max: 100000 }}
helperText="Set the threshold for balance alerts (0-100,000)"
error={balanceThreshold < 0 || balanceThreshold > 100000}
/>
</Box>
{Object.keys(colors).map((key) => {
return (
<div key={`color-row-${key}`}>
@@ -59,6 +87,7 @@ export const SettingsButton = () => {
</div>
);
})}
</DialogContent>
<DialogActions>
<Button onClick={handleClose}>Close</Button>

View File

@@ -1,7 +1,6 @@
import { EvePraisalResult } from "@/eve-praisal";
import { AccessToken, CharacterUpdate } from "@/types";
import { AccessToken, CharacterUpdate, PlanetConfig } from "@/types";
import { Dispatch, SetStateAction, createContext } from "react";
import { PlanetConfig } from "../components/PlanetConfig/PlanetConfigDialog";
export const CharacterContext = createContext<{
characters: AccessToken[];
@@ -36,6 +35,8 @@ export const SessionContext = createContext<{
characterId: number;
planetId: number;
}) => PlanetConfig;
balanceThreshold: number;
setBalanceThreshold: Dispatch<SetStateAction<number>>;
}>({
sessionReady: false,
refreshSession: () => {},
@@ -59,6 +60,8 @@ export const SessionContext = createContext<{
}) => {
return { characterId, planetId, excludeFromTotals: true };
},
balanceThreshold: 1000,
setBalanceThreshold: () => {},
});
export type ColorSelectionType = {
defaultColor: string;

View File

@@ -17,7 +17,7 @@ import {
import { useSearchParams } from "next/navigation";
import { EvePraisalResult, fetchAllPrices } from "@/eve-praisal";
import { getPlanet, getPlanetUniverse, getPlanets } from "@/planets";
import { PlanetConfig } from "./components/PlanetConfig/PlanetConfigDialog";
import { PlanetConfig } from "@/types";
const Home = () => {
const searchParams = useSearchParams();
@@ -29,6 +29,7 @@ const Home = () => {
const [piPrices, setPiPrices] = useState<EvePraisalResult | undefined>(
undefined,
);
const [balanceThreshold, setBalanceThreshold] = useState(1000);
const [colors, setColors] = useState<ColorSelectionType>(defaultColors);
const [alertMode, setAlertMode] = useState(false);
@@ -199,6 +200,17 @@ const Home = () => {
setAlertMode(JSON.parse(storedAlertMode));
}, []);
useEffect(() => {
const storedBalanceThreshold = localStorage.getItem("balanceThreshold");
if (storedBalanceThreshold) {
setBalanceThreshold(parseInt(storedBalanceThreshold));
}
}, []);
useEffect(() => {
localStorage.setItem("balanceThreshold", balanceThreshold.toString());
}, [balanceThreshold]);
useEffect(() => {
localStorage.setItem("compactMode", compactMode ? "true" : "false");
}, [compactMode]);
@@ -264,6 +276,8 @@ const Home = () => {
toggleAlertMode,
updatePlanetConfig,
readPlanetConfig,
balanceThreshold,
setBalanceThreshold,
}}
>
<CharacterContext.Provider

View File

@@ -51,7 +51,7 @@ export const getPlanetUniverse = async (
export const planetCalculations = (planet: PlanetWithInfo) => {
const planetInfo = planet.info;
type SchematicId = number;
const extractors: PlanetInfo["pins"] = planetInfo.pins.filter((p) =>
const extractors = planetInfo.pins.filter((p) =>
EXTRACTOR_TYPE_IDS.some((e) => e === p.type_id),
);
const localProduction = planetInfo.pins
@@ -61,10 +61,19 @@ export const planetCalculations = (planet: PlanetWithInfo) => {
const schematic = PI_SCHEMATICS.find(
(s) => s.schematic_id == f.schematic_id,
);
if (schematic) acc.set(f.schematic_id, schematic);
if (schematic) {
const existing = acc.get(f.schematic_id);
if (existing) {
// If we already have this schematic, increment its count
existing.count = (existing.count || 0) + 1;
} else {
// First time seeing this schematic, set count to 1
acc.set(f.schematic_id, { ...schematic, count: 1 });
}
}
}
return acc;
}, new Map<SchematicId, (typeof PI_SCHEMATICS)[number]>());
}, new Map<SchematicId, (typeof PI_SCHEMATICS)[number] & { count: number }>());
const locallyProduced = Array.from(localProduction)
.flatMap((p) => p[1].outputs)

View File

@@ -1,6 +1,3 @@
import { PlanetConfig } from "./app/components/PlanetConfig/PlanetConfigDialog";
import { Api } from "./esi-api";
export interface AccessToken {
access_token: string;
expires_at: number;
@@ -20,10 +17,50 @@ export interface Character {
characterId: number;
}
export interface Planet {
planet_id: number;
solar_system_id: number;
planet_type: "temperate" | "barren" | "oceanic" | "ice" | "gas" | "lava" | "storm" | "plasma";
last_update: string;
num_pins: number;
owner_id: number;
upgrade_level: number;
}
export interface PlanetInfo {
links: Array<{
destination_pin_id: number;
link_level: number;
source_pin_id: number;
}>;
pins: Pin[];
routes: Array<{
content_type_id: number;
destination_pin_id: number;
quantity: number;
route_id: number;
source_pin_id: number;
waypoints?: number[];
}>;
}
export interface PlanetInfoUniverse {
name: string;
planet_id: number;
system_id: number;
type_id: number;
position: {
x: number;
y: number;
z: number;
};
}
export interface PlanetWithInfo extends Planet {
info: PlanetInfo;
infoUniverse: PlanetInfoUniverse;
}
export interface CharacterPlanets {
name: string;
characterId: number;
@@ -38,31 +75,51 @@ export interface CharacterUpdate {
system?: string;
}
export type Planet = EsiType<"v1", "getCharactersCharacterIdPlanets">[number];
export type PlanetInfoUniverse = EsiType<"v1", "getUniversePlanetsPlanetId">;
export type PlanetInfo = EsiType<
"v3",
"getCharactersCharacterIdPlanetsPlanetId"
>;
export interface Env {
EVE_SSO_CALLBACK_URL: string;
EVE_SSO_CLIENT_ID: string;
}
type EsiApiVersionType = keyof InstanceType<typeof Api<unknown>>;
type EsiApiPathType<V extends EsiApiVersionType> = keyof InstanceType<
typeof Api<unknown>
>[V];
type EsiApiResponseType<
V extends EsiApiVersionType,
T extends EsiApiPathType<V>,
> = Awaited<ReturnType<InstanceType<typeof Api<unknown>>[V][T]>>;
export type EsiType<
V extends EsiApiVersionType,
T extends EsiApiPathType<V>,
> = EsiApiResponseType<V, T> extends { data: any }
? EsiApiResponseType<V, T>["data"]
: never;
export interface EvePraisalResult {
appraisal: {
items: Array<{
typeID: number;
prices: {
sell: {
min: number;
};
};
}>;
};
}
export interface Pin {
pin_id: number;
type_id: number;
schematic_id?: number;
expiry_time?: string;
install_time?: string;
latitude: number;
longitude: number;
extractor_details?: {
cycle_time?: number;
head_radius?: number;
heads: Array<{
head_id: number;
latitude: number;
longitude: number;
}>;
product_type_id?: number;
qty_per_cycle?: number;
};
contents?: Array<{
type_id: number;
amount: number;
}>;
}
export interface PlanetConfig {
characterId: number;
planetId: number;
excludeFromTotals: boolean;
}