Compare commits

..

2 Commits

Author SHA1 Message Date
achichenkov
ba5b2fb8d9 fix(Map): removed unnecessary hooks styles 2025-02-08 20:45:42 +03:00
achichenkov
deb47b66f6 fix(Map): Fixed a lot of design and architect issues after last million PRs 2025-02-08 20:33:27 +03:00
100 changed files with 1644 additions and 4216 deletions

View File

@@ -1,12 +1,7 @@
{
"name": "wanderer-dev",
"dockerComposeFile": ["./docker-compose.yml"],
"extensions": [
"jakebecker.elixir-ls",
"JakeBecker.elixir-ls",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
],
"extensions": ["jakebecker.elixir-ls"],
"service": "wanderer",
"workspaceFolder": "/app",
"shutdownAction": "stopCompose",

View File

@@ -7,5 +7,4 @@ export EVE_CLIENT_WITH_WALLET_SECRET="<EVE_CLIENT_WITH_WALLET_SECRET>"
export GIT_SHA="1111"
export WANDERER_INVITES="false"
export WANDERER_PUBLIC_API_DISABLED="false"
export WANDERER_CHARACTER_API_DISABLED="false"
export WANDERER_ZKILL_PRELOAD_DISABLED="false"

View File

@@ -1,6 +1,8 @@
name: Build
on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
push:
branches:
- main
@@ -39,28 +41,8 @@ jobs:
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
manual-approval:
name: Manual Approval
runs-on: ubuntu-latest
needs: deploy-test
if: success()
permissions:
issues: write
steps:
- name: Await Manual Approval
uses: trstringer/manual-approval@v1
with:
secret: ${{ github.TOKEN }}
approvers: DmitryPopov
minimum-approvals: 1
issue-title: "Manual Approval Required for Release"
issue-body: "Please approve or deny the deployment."
build:
name: 🛠 Build
needs: manual-approval
runs-on: ubuntu-22.04
if: ${{ (github.ref == 'refs/heads/main') && github.event_name == 'push' }}
permissions:
@@ -158,6 +140,7 @@ jobs:
platform:
- linux/amd64
- linux/arm64
- linux/arm64/v8
steps:
- name: Prepare
run: |

View File

@@ -2,245 +2,6 @@
<!-- changelog -->
## [v1.53.1](https://github.com/wanderer-industries/wanderer/compare/v1.53.0...v1.53.1) (2025-02-26)
### Bug Fixes:
* Core: Fixed map ACLs add/remove behaviour
## [v1.53.0](https://github.com/wanderer-industries/wanderer/compare/v1.52.8...v1.53.0) (2025-02-26)
### Features:
* Auto-set connection EOL status and ship size when linking/editing signatures (#194)
* Automatically set connection EOL status and ship size type when linking/updating signatures
## [v1.52.8](https://github.com/wanderer-industries/wanderer/compare/v1.52.7...v1.52.8) (2025-02-26)
### Bug Fixes:
* Map: Added delete systems hotkey
## [v1.52.7](https://github.com/wanderer-industries/wanderer/compare/v1.52.6...v1.52.7) (2025-02-24)
### Bug Fixes:
* update news image link (#204)
* Map: Block map events for old client versions
## [v1.52.6](https://github.com/wanderer-industries/wanderer/compare/v1.52.5...v1.52.6) (2025-02-23)
### Bug Fixes:
* Map: Fixed delete systems on map changes
## [v1.52.5](https://github.com/wanderer-industries/wanderer/compare/v1.52.4...v1.52.5) (2025-02-22)
### Bug Fixes:
* Map: Fixed delete system on signature deletion
* Map: Fixed delete system on signature deletion
## [v1.52.4](https://github.com/wanderer-industries/wanderer/compare/v1.52.3...v1.52.4) (2025-02-21)
### Bug Fixes:
* signature paste for russian lang
## [v1.52.3](https://github.com/wanderer-industries/wanderer/compare/v1.52.2...v1.52.3) (2025-02-21)
### Bug Fixes:
* remove signature expiration (#196)
## [v1.52.2](https://github.com/wanderer-industries/wanderer/compare/v1.52.1...v1.52.2) (2025-02-21)
### Bug Fixes:
* prevent constant full signature widget rerender (#195)
## [v1.52.1](https://github.com/wanderer-industries/wanderer/compare/v1.52.0...v1.52.1) (2025-02-20)
### Bug Fixes:
* proper virtual scroller usage (#192)
* restore delete key functionality for nodes (#191)
## [v1.52.0](https://github.com/wanderer-industries/wanderer/compare/v1.51.3...v1.52.0) (2025-02-19)
### Features:
* Map: Added map characters view
## [v1.51.3](https://github.com/wanderer-industries/wanderer/compare/v1.51.2...v1.51.3) (2025-02-19)
### Bug Fixes:
* pending deletion working again (#185)
## [v1.51.2](https://github.com/wanderer-industries/wanderer/compare/v1.51.1...v1.51.2) (2025-02-18)
## [v1.51.1](https://github.com/wanderer-industries/wanderer/compare/v1.51.0...v1.51.1) (2025-02-18)
## [v1.51.0](https://github.com/wanderer-industries/wanderer/compare/v1.50.0...v1.51.0) (2025-02-17)
### Features:
* add undo deletion for signatures (#155)
* add undo for signature deletion and addition
## [v1.50.0](https://github.com/wanderer-industries/wanderer/compare/v1.49.0...v1.50.0) (2025-02-17)
### Features:
* allow addition of characters to acl without preregistration (#176)
## [v1.49.0](https://github.com/wanderer-industries/wanderer/compare/v1.48.1...v1.49.0) (2025-02-15)
### Features:
* add api for acl management (#171)
## [v1.48.1](https://github.com/wanderer-industries/wanderer/compare/v1.48.0...v1.48.1) (2025-02-13)
## [v1.48.0](https://github.com/wanderer-industries/wanderer/compare/v1.47.6...v1.48.0) (2025-02-12)
### Features:
* autosize local character tooltip and increase hover target (#165)
## [v1.47.6](https://github.com/wanderer-industries/wanderer/compare/v1.47.5...v1.47.6) (2025-02-12)
## [v1.47.5](https://github.com/wanderer-industries/wanderer/compare/v1.47.4...v1.47.5) (2025-02-12)
### Bug Fixes:
* sync kills count bookmark and the kills widget (#160)
* lazy load kills widget
## [v1.47.4](https://github.com/wanderer-industries/wanderer/compare/v1.47.3...v1.47.4) (2025-02-11)
## [v1.47.3](https://github.com/wanderer-industries/wanderer/compare/v1.47.2...v1.47.3) (2025-02-11)
## [v1.47.2](https://github.com/wanderer-industries/wanderer/compare/v1.47.1...v1.47.2) (2025-02-11)
### Bug Fixes:
* lazy load kills widget (#157)
* lazy load kills widget
* updates for eslint and pr feedback
## [v1.47.1](https://github.com/wanderer-industries/wanderer/compare/v1.47.0...v1.47.1) (2025-02-09)
### Bug Fixes:
* Connections: Fixed connections auto-refresh after update
## [v1.47.0](https://github.com/wanderer-industries/wanderer/compare/v1.46.1...v1.47.0) (2025-02-09)
### Features:
* Map: Added check for active map subscription to using Map APIs
## [v1.46.1](https://github.com/wanderer-industries/wanderer/compare/v1.46.0...v1.46.1) (2025-02-09)
### Bug Fixes:
* Map: Fixed a lot of design and architect issues after last milli… (#154)
* Map: Fixed a lot of design and architect issues after last million PRs
* Map: removed unnecessary hooks styles
## [v1.46.0](https://github.com/wanderer-industries/wanderer/compare/v1.45.5...v1.46.0) (2025-02-08)

View File

@@ -936,66 +936,3 @@ body > div:first-of-type {
width: 16px;
height: 16px;
}
.verticalTabsContainer {
display: flex;
width: 100%;
min-height: 300px;
}
.verticalTabsContainer .p-tabview {
width: 100%;
display: flex;
align-items: flex-start;
}
.verticalTabsContainer .p-tabview-panels {
padding: 6px 1rem !important;
flex-grow: 1;
height: 100%;
}
.verticalTabsContainer .p-tabview-nav-container {
border-right: none;
height: 100%;
}
.verticalTabsContainer .p-tabview-nav {
flex-direction: column;
width: 150px;
min-height: 100%;
border: none;
}
.verticalTabsContainer .p-tabview-nav li {
width: 100%;
border-right: 4px solid var(--surface-hover);
background-color: var(--surface-card);
transition:
background-color 200ms,
border-right-color 200ms;
}
.verticalTabsContainer .p-tabview-nav li:hover {
background-color: var(--surface-hover);
border-right: 4px solid var(--surface-100);
}
.verticalTabsContainer .p-tabview-nav li .p-tabview-nav-link {
transition: color 200ms;
justify-content: flex-end;
padding: 10px;
background-color: initial;
border: none;
color: var(--gray-400);
border-radius: initial;
font-weight: 400;
margin: 0;
}
.verticalTabsContainer .p-tabview-nav li.p-tabview-selected {
background-color: var(--surface-50);
border-right: 4px solid var(--primary-color);
}
.verticalTabsContainer .p-tabview-nav li.p-tabview-selected .p-tabview-nav-link {
font-weight: 600;
color: var(--primary-color);
}
.verticalTabsContainer .p-tabview-nav li.p-tabview-selected:hover {
border-right: 4px solid var(--primary-color);
}
.verticalTabsContainer .p-tabview-panel {
flex-grow: 1;
}

View File

@@ -2,6 +2,7 @@ import { ForwardedRef, forwardRef, MouseEvent, useCallback, useEffect, useMemo }
import ReactFlow, {
Background,
Edge,
EdgeChange,
MiniMap,
Node,
NodeChange,
@@ -78,12 +79,12 @@ const edgeTypes = {
floating: SolarSystemEdge,
};
export const MAP_ROOT_ID = 'MAP_ROOT_ID';
interface MapCompProps {
refn: ForwardedRef<MapHandlers>;
onCommand: OutCommandHandler;
onSelectionChange: OnMapSelectionChange;
onManualDelete(systems: string[]): void;
canRemoveConnection?(connectionId: string): boolean;
onConnectionInfoClick?(e: SolarSystemConnection): void;
onAddSystem?: OnMapAddSystemCallback;
onSelectionContextMenu?: NodeSelectionMouseHandler;
@@ -105,6 +106,7 @@ const MapComp = ({
onSystemContextMenu,
onConnectionInfoClick,
onSelectionContextMenu,
onManualDelete,
isShowMinimap,
showKSpaceBG,
isThickConnections,
@@ -112,8 +114,9 @@ const MapComp = ({
isSoftBackground,
theme,
onAddSystem,
canRemoveConnection,
}: MapCompProps) => {
const { getNodes } = useReactFlow();
const { getEdge, getNode, getNodes } = useReactFlow();
const [nodes, , onNodesChange] = useNodesState<Node<SolarSystemRawType>>(initialNodes);
const [edges, , onEdgesChange] = useEdgesState<Edge<SolarSystemConnection>>(initialEdges);
@@ -186,6 +189,8 @@ const MapComp = ({
const handleNodesChange = useCallback(
(changes: NodeChange[]) => {
const systemsIdsToRemove: string[] = [];
// prevents single node deselection on background / same node click
// allows deseletion of all nodes if multiple are currently selected
if (changes.length === 1 && changes[0].type == 'select' && changes[0].selected === false) {
@@ -193,12 +198,64 @@ const MapComp = ({
}
const nextChanges = changes.reduce((acc, change) => {
if (change.type !== 'remove') {
return [...acc, change];
}
const node = getNode(change.id);
if (!node) {
return [...acc, change];
}
if (node.data.locked) {
return acc;
}
systemsIdsToRemove.push(node.data.id);
return [...acc, change];
}, [] as NodeChange[]);
if (systemsIdsToRemove.length > 0) {
onManualDelete(systemsIdsToRemove);
}
onNodesChange(nextChanges);
},
[getNodes, onNodesChange],
[getNode, getNodes, onManualDelete, onNodesChange],
);
const handleEdgesChange = useCallback(
(changes: EdgeChange[]) => {
const nextChanges = changes.reduce((acc, change) => {
if (change.type !== 'remove') {
return [...acc, change];
}
if (canRemoveConnection?.(change.id)) {
return [...acc, change];
}
const edge = getEdge(change.id);
if (!edge) {
return [...acc, change];
}
const sourceNode = getNode(edge.source);
const targetNode = getNode(edge.target);
if (!sourceNode || !targetNode) {
return [...acc, change];
}
if (sourceNode.data.locked || targetNode.data.locked) {
return acc;
}
return [...acc, change];
}, [] as EdgeChange[]);
onEdgesChange(nextChanges);
},
[canRemoveConnection, getEdge, getNode, onEdgesChange],
);
useEffect(() => {
@@ -211,15 +268,12 @@ const MapComp = ({
return (
<>
<div
data-window-id={MAP_ROOT_ID}
className={clsx(classes.MapRoot, { [classes.BackgroundAlternateColor]: isSoftBackground })}
>
<div className={clsx(classes.MapRoot, { [classes.BackgroundAlternateColor]: isSoftBackground })}>
<ReactFlow
nodes={nodes}
edges={edges}
onNodesChange={handleNodesChange}
onEdgesChange={onEdgesChange}
onEdgesChange={handleEdgesChange}
onConnect={onConnect}
// TODO we need save into session all of this
// and on any action do either
@@ -258,7 +312,7 @@ const MapComp = ({
minZoom={0.2}
maxZoom={1.5}
elevateNodesOnSelect
deleteKeyCode={['']}
deleteKeyCode={['Delete']}
{...(isPanAndDrag
? {
selectionOnDrag: true,

View File

@@ -37,7 +37,7 @@ const INITIAL_DATA: MapData = {
userPermissions: {},
systemSignatures: {} as Record<string, SystemSignature[]>,
options: {} as Record<string, string | boolean>,
isSubscriptionActive: false,
is_subscription_active: false,
};
export interface MapContextProps {

View File

@@ -1,7 +1,7 @@
import { SystemKillsContent } from '../../../mapInterface/widgets/SystemKills/SystemKillsContent/SystemKillsContent';
import { useKillsCounter } from '../../hooks/useKillsCounter';
import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrapper';
import { WithChildren, WithClassName } from '@/hooks/Mapper/types/common';
import { WithChildren, WithClassName } from '@/hooks/Mapper/types/common.ts';
type TooltipSize = 'xs' | 'sm' | 'md' | 'lg';
@@ -20,18 +20,11 @@ export const KillsCounter = ({ killsCount, systemId, className, children, size =
if (!killsCount || detailedKills.length === 0 || !systemId || isLoading) return null;
const tooltipContent = (
<div style={{ width: '100%', minWidth: '300px', overflow: 'hidden' }}>
<SystemKillsContent
kills={detailedKills}
systemNameMap={systemNameMap}
onlyOneSystem={true}
autoSize={true}
limit={killsCount}
/>
</div>
<SystemKillsContent kills={detailedKills} systemNameMap={systemNameMap} compact={true} onlyOneSystem={true} />
);
return (
// @ts-ignore
<WdTooltipWrapper content={tooltipContent} className={className} size={size} interactive={true}>
{children}
</WdTooltipWrapper>

View File

@@ -4,12 +4,6 @@
z-index: 3;
}
.hoverTarget {
padding: 0.5rem;
margin: -0.5rem;
display: inline-block;
}
.localCounter {
mix-blend-mode: screen;
display: flex;

View File

@@ -24,12 +24,13 @@ export const LocalCounter = ({ localCounterCharacters, hasUserCharacters, showIc
return (
<div
style={{
width: '100%',
minWidth: '300px',
overflow: 'hidden',
width: '300px',
overflowX: 'hidden',
overflowY: 'auto',
height: '300px',
}}
>
<LocalCharactersList items={localCounterCharacters} itemTemplate={itemTemplate} itemSize={26} autoSize={true} />
<LocalCharactersList items={localCounterCharacters} itemTemplate={itemTemplate} itemSize={26} />
</div>
);
}, [localCounterCharacters, itemTemplate]);
@@ -44,16 +45,19 @@ export const LocalCounter = ({ localCounterCharacters, hasUserCharacters, showIc
[classes.Pathfinder]: theme === AvailableThemes.pathfinder,
})}
>
<WdTooltipWrapper content={pilotTooltipContent} position={TooltipPosition.right} offset={0} interactive={true}>
<div className={clsx(classes.hoverTarget)}>
<div
className={clsx(classes.localCounter, {
[classes.hasUserCharacters]: hasUserCharacters,
})}
>
{showIcon && <i className="pi pi-users" />}
<span>{localCounterCharacters.length}</span>
</div>
<WdTooltipWrapper
// @ts-ignore
content={pilotTooltipContent}
position={TooltipPosition.right}
offset={0}
>
<div
className={clsx(classes.localCounter, {
[classes.hasUserCharacters]: hasUserCharacters,
})}
>
{showIcon && <i className="pi pi-users" />}
<span>{localCounterCharacters.length}</span>
</div>
</WdTooltipWrapper>
</div>

View File

@@ -90,7 +90,11 @@ $tooltip-bg: #202020;
&.eve-system-status-home {
border: 1px solid var(--eve-solar-system-status-color-home-dark30);
background-image: linear-gradient(45deg, var(--eve-solar-system-status-color-background), transparent);
background-image: linear-gradient(
45deg,
var(--eve-solar-system-status-color-background),
transparent
);
&.selected {
border-color: var(--eve-solar-system-status-color-home);
}
@@ -98,7 +102,11 @@ $tooltip-bg: #202020;
&.eve-system-status-friendly {
border: 1px solid var(--eve-solar-system-status-color-friendly-dark20);
background-image: linear-gradient(275deg, var(--eve-solar-system-status-friendly-dark30), transparent);
background-image: linear-gradient(
275deg,
var(--eve-solar-system-status-friendly-dark30),
transparent
);
&.selected {
border-color: var(--eve-solar-system-status-color-friendly-dark5);
}
@@ -113,15 +121,27 @@ $tooltip-bg: #202020;
}
&.eve-system-status-warning {
background-image: linear-gradient(275deg, var(--eve-solar-system-status-warning), transparent);
background-image: linear-gradient(
275deg,
var(--eve-solar-system-status-warning),
transparent
);
}
&.eve-system-status-dangerous {
background-image: linear-gradient(275deg, var(--eve-solar-system-status-dangerous), transparent);
background-image: linear-gradient(
275deg,
var(--eve-solar-system-status-dangerous),
transparent
);
}
&.eve-system-status-target {
background-image: linear-gradient(275deg, var(--eve-solar-system-status-target), transparent);
background-image: linear-gradient(
275deg,
var(--eve-solar-system-status-target),
transparent
);
}
}
@@ -234,7 +254,7 @@ $tooltip-bg: #202020;
font-size: 11px;
font-weight: 500;
text-shadow: 0 0 2px rgba(231, 146, 52, 0.73);
color: var(--rf-tag-color, #38bdf8);
color: var(--rf-tag-color, #38BDF8);
}
/* Firefox kostyl */
@@ -243,6 +263,7 @@ $tooltip-bg: #202020;
font-weight: bold;
}
}
}
.BottomRow {
@@ -355,3 +376,4 @@ $tooltip-bg: #202020;
}
}
}

View File

@@ -4,7 +4,7 @@ import { Handle, NodeProps, Position } from 'reactflow';
import clsx from 'clsx';
import classes from './SolarSystemNodeDefault.module.scss';
import { PrimeIcons } from 'primereact/api';
import { useLocalCounter, useSolarSystemNode, useNodeKillsCount } from '../../hooks/useSolarSystemLogic';
import { useLocalCounter, useSolarSystemNode } from '../../hooks/useSolarSystemLogic';
import {
EFFECT_BACKGROUND_STYLES,
MARKER_BOOKMARK_BG_STYLES,
@@ -18,7 +18,6 @@ import { KillsCounter } from './SolarSystemKillsCounter';
export const SolarSystemNodeDefault = memo((props: NodeProps<MapSolarSystemType>) => {
const nodeVars = useSolarSystemNode(props);
const { localCounterCharacters } = useLocalCounter(nodeVars);
const localKillsCount = useNodeKillsCount(nodeVars.solarSystemId, nodeVars.killsCount);
return (
<>
@@ -36,9 +35,9 @@ export const SolarSystemNodeDefault = memo((props: NodeProps<MapSolarSystemType>
</div>
)}
{localKillsCount && localKillsCount > 0 && nodeVars.solarSystemId && (
{nodeVars.killsCount && nodeVars.killsCount > 0 && nodeVars.solarSystemId && (
<KillsCounter
killsCount={localKillsCount}
killsCount={nodeVars.killsCount}
systemId={nodeVars.solarSystemId}
size="lg"
killsActivityType={nodeVars.killsActivityType}

View File

@@ -4,7 +4,7 @@ import { Handle, NodeProps, Position } from 'reactflow';
import clsx from 'clsx';
import classes from './SolarSystemNodeTheme.module.scss';
import { PrimeIcons } from 'primereact/api';
import { useLocalCounter, useNodeKillsCount, useSolarSystemNode } from '../../hooks/useSolarSystemLogic';
import { useLocalCounter, useSolarSystemNode } from '../../hooks/useSolarSystemLogic';
import {
EFFECT_BACKGROUND_STYLES,
MARKER_BOOKMARK_BG_STYLES,
@@ -18,7 +18,6 @@ import { KillsCounter } from './SolarSystemKillsCounter';
export const SolarSystemNodeTheme = memo((props: NodeProps<MapSolarSystemType>) => {
const nodeVars = useSolarSystemNode(props);
const { localCounterCharacters } = useLocalCounter(nodeVars);
const localKillsCount = useNodeKillsCount(nodeVars.solarSystemId, nodeVars.killsCount);
return (
<>
@@ -36,9 +35,9 @@ export const SolarSystemNodeTheme = memo((props: NodeProps<MapSolarSystemType>)
</div>
)}
{localKillsCount && localKillsCount > 0 && nodeVars.solarSystemId && (
{nodeVars.killsCount && nodeVars.killsCount > 0 && nodeVars.solarSystemId && (
<KillsCounter
killsCount={localKillsCount}
killsCount={nodeVars.killsCount}
systemId={nodeVars.solarSystemId}
size="lg"
killsActivityType={nodeVars.killsActivityType}

View File

@@ -750,14 +750,6 @@ export const SHIP_SIZES_SIZE = {
[ShipSizeStatus.capital]: '2M',
};
export const SHIP_MASSES_SIZE: Record<number, ShipSizeStatus> = {
5_000_000: ShipSizeStatus.small,
62_000_000: ShipSizeStatus.medium,
375_000_000: ShipSizeStatus.large,
1_000_000_000: ShipSizeStatus.freight,
2_000_000_000: ShipSizeStatus.capital,
};
export const SHIP_SIZES_DESCRIPTION = {
[ShipSizeStatus.small]: 'Frigate wormhole - up to Destroyer | 5K t.',
[ShipSizeStatus.medium]: 'Cruise wormhole - up to Battlecruiser | 62K t.',

View File

@@ -10,6 +10,5 @@ export const convertSystem2Node = (sys: SolarSystemRawType): Node => {
position: sys.position,
data: sys,
draggable: !sys.locked,
deletable: !sys.locked,
};
};

View File

@@ -1,4 +1,4 @@
import { useEffect, useMemo, useState } from 'react';
import { useMemo } from 'react';
import { MapSolarSystemType } from '../map.types';
import { NodeProps } from 'reactflow';
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
@@ -10,9 +10,8 @@ import { isWormholeSpace } from '@/hooks/Mapper/components/map/helpers/isWormhol
import { getSystemClassStyles, prepareUnsplashedChunks } from '@/hooks/Mapper/components/map/helpers';
import { sortWHClasses } from '@/hooks/Mapper/helpers';
import { LabelsManager } from '@/hooks/Mapper/utils/labelsManager';
import { CharacterTypeRaw, Commands, OutCommand, SystemSignature } from '@/hooks/Mapper/types';
import { CharacterTypeRaw, OutCommand, SystemSignature } from '@/hooks/Mapper/types';
import { LABELS_INFO, LABELS_ORDER } from '@/hooks/Mapper/components/map/constants';
import { useMapEventListener } from '@/hooks/Mapper/events';
export type LabelInfo = {
id: string;
@@ -196,6 +195,7 @@ export function useSolarSystemNode(props: NodeProps<MapSolarSystemType>): SolarS
kind: s.kind,
name: s.name,
group: s.group,
sig_id: s.eve_id, // Add a unique key property
})) as UnsplashedSignatureType[],
);
}, [isShowUnsplashedSignatures, systemSigs]);
@@ -281,25 +281,3 @@ export interface SolarSystemNodeVars {
classTitle: string | null;
temporaryName?: string | null;
}
export function useNodeKillsCount(systemId: number | string, initialKillsCount: number | null): number | null {
const [killsCount, setKillsCount] = useState<number | null>(initialKillsCount);
useEffect(() => {
setKillsCount(initialKillsCount);
}, [initialKillsCount]);
useMapEventListener(event => {
if (event.name === Commands.killsUpdated && event.data?.toString() === systemId.toString()) {
//@ts-ignore
if (event.payload && typeof event.payload.kills === 'number') {
// @ts-ignore
setKillsCount(event.payload.kills);
}
return true;
}
return false;
});
return killsCount;
}

View File

@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef } from 'react';
import { Dialog } from 'primereact/dialog';
import { OutCommand } from '@/hooks/Mapper/types/mapHandlers.ts';
import { SystemSignature, TimeStatus } from '@/hooks/Mapper/types';
import { SystemSignature } from '@/hooks/Mapper/types';
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
import { CommandLinkSignatureToSystem } from '@/hooks/Mapper/types';
import { SystemSignaturesContent } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/SystemSignaturesContent';
@@ -12,8 +12,6 @@ import {
COSMIC_SIGNATURE,
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/SystemSignatureSettingsDialog';
import { SignatureGroup } from '@/hooks/Mapper/types';
import { parseSignatureCustomInfo } from '@/hooks/Mapper/helpers/parseSignatureCustomInfo';
import { getWhSize } from '@/hooks/Mapper/helpers/getWhSize';
interface SystemLinkSignatureDialogProps {
data: CommandLinkSignatureToSystem;
@@ -27,10 +25,7 @@ const signatureSettings: Setting[] = [
];
export const SystemLinkSignatureDialog = ({ data, setVisible }: SystemLinkSignatureDialogProps) => {
const {
outCommand,
data: { wormholes },
} = useMapRootState();
const { outCommand } = useMapRootState();
const ref = useRef({ outCommand });
ref.current = { outCommand };
@@ -40,44 +35,20 @@ export const SystemLinkSignatureDialog = ({ data, setVisible }: SystemLinkSignat
}, [setVisible]);
const handleSelect = useCallback(
async (signature: SystemSignature) => {
(signature: SystemSignature) => {
if (!signature) {
return;
}
const { outCommand } = ref.current;
await outCommand({
outCommand({
type: OutCommand.linkSignatureToSystem,
data: {
...data,
signature_eve_id: signature.eve_id,
},
});
if (parseSignatureCustomInfo(signature.custom_info).isEOL === true) {
await outCommand({
type: OutCommand.updateConnectionTimeStatus,
data: {
source: data.solar_system_source,
target: data.solar_system_target,
value: TimeStatus.eol,
},
});
}
const whShipSize = getWhSize(wormholes, signature.type);
if (whShipSize) {
await outCommand({
type: OutCommand.updateConnectionShipSizeType,
data: {
source: data.solar_system_source,
target: data.solar_system_target,
value: whShipSize,
},
});
}
setVisible(false);
},
[data, setVisible],

View File

@@ -5,14 +5,12 @@ import clsx from 'clsx';
export interface WidgetProps {
label: React.ReactNode | string;
windowId?: string;
children?: React.ReactNode;
}
export const Widget = ({ label, children, windowId }: WidgetProps) => {
export const Widget = ({ label, children }: WidgetProps) => {
return (
<div
data-window-id={windowId}
className={clsx(
classes.root,
'flex flex-col w-full h-full rounded',

View File

@@ -3,13 +3,11 @@ import { VirtualScroller, VirtualScrollerTemplateOptions } from 'primereact/virt
import clsx from 'clsx';
import { CharItemProps } from './types';
export type LocalCharactersListProps = {
type LocalCharactersListProps = {
items: Array<CharItemProps>;
itemSize: number;
itemTemplate: (char: CharItemProps, options: VirtualScrollerTemplateOptions) => React.ReactNode;
containerClassName?: string;
style?: React.CSSProperties;
autoSize?: boolean;
};
export const LocalCharactersList = ({
@@ -17,19 +15,7 @@ export const LocalCharactersList = ({
itemSize,
itemTemplate,
containerClassName,
style = {},
autoSize = false,
}: LocalCharactersListProps) => {
const computedHeight = autoSize ? `${Math.max(items.length, 1) * itemSize}px` : style.height || '100%';
const localStyle: React.CSSProperties = {
...style,
height: computedHeight,
width: '100%',
boxSizing: 'border-box',
overflowX: 'hidden',
};
return (
<VirtualScroller
items={items}
@@ -37,8 +23,6 @@ export const LocalCharactersList = ({
orientation="vertical"
className={clsx('w-full h-full', containerClassName)}
itemTemplate={itemTemplate}
autoSize={autoSize}
style={localStyle}
/>
);
};

View File

@@ -7,9 +7,8 @@ import { useKillsWidgetSettings } from './hooks/useKillsWidgetSettings';
import { useSystemKills } from './hooks/useSystemKills';
import { KillsSettingsDialog } from './components/SystemKillsSettingsDialog';
import { isWormholeSpace } from '@/hooks/Mapper/components/map/helpers/isWormholeSpace';
import { SolarSystemRawType } from '@/hooks/Mapper/types';
export const SystemKills: React.FC = React.memo(() => {
export const SystemKills: React.FC = () => {
const {
data: { selectedSystems, systems, isSubscriptionActive },
outCommand,
@@ -26,16 +25,6 @@ export const SystemKills: React.FC = React.memo(() => {
return map;
}, [systems]);
const systemBySolarSystemId = useMemo(() => {
const map: Record<number, SolarSystemRawType> = {};
systems.forEach(sys => {
if (sys.system_static_info?.solar_system_id != null) {
map[sys.system_static_info.solar_system_id] = sys;
}
});
return map;
}, [systems]);
const [settings] = useKillsWidgetSettings();
const visible = settings.showAll;
@@ -51,59 +40,78 @@ export const SystemKills: React.FC = React.memo(() => {
const filteredKills = useMemo(() => {
if (!settings.whOnly || !visible) return kills;
return kills.filter(kill => {
const system = systemBySolarSystemId[kill.solar_system_id];
const system = systems.find(
sys => sys.system_static_info.solar_system_id === kill.solar_system_id
);
if (!system) {
console.warn(`System with id ${kill.solar_system_id} not found.`);
return false;
}
return isWormholeSpace(system.system_static_info.system_class);
});
}, [kills, settings.whOnly, systemBySolarSystemId, visible]);
}, [kills, settings.whOnly, systems]);
return (
<div className="h-full flex flex-col min-h-0">
<div className="flex flex-col flex-1 min-h-0">
<Widget label={<KillsHeader systemId={systemId} onOpenSettings={() => setSettingsDialogVisible(true)} />}>
{!isSubscriptionActive ? (
<div className="w-full h-full flex items-center justify-center">
<span className="select-none text-center text-stone-400/80 text-sm">
Kills available with &#39;Active&#39; map subscription only (contact map administrators)
</span>
</div>
) : isNothingSelected ? (
<div className="w-full h-full flex items-center justify-center">
<span className="select-none text-center text-stone-400/80 text-sm">
No system selected (or toggle Show all systems)
</span>
</div>
) : showLoading ? (
<div className="w-full h-full flex items-center justify-center">
<span className="select-none text-center text-stone-400/80 text-sm">Loading Kills...</span>
</div>
) : error ? (
<div className="w-full h-full flex items-center justify-center">
<span className="select-none text-center text-red-400 text-sm">{error}</span>
</div>
) : !filteredKills || filteredKills.length === 0 ? (
<div className="w-full h-full flex items-center justify-center">
<span className="select-none text-center text-stone-400/80 text-sm">No kills found</span>
</div>
) : (
<div className="w-full h-full" style={{ height: '100%' }}>
<SystemKillsContent
kills={filteredKills}
systemNameMap={systemNameMap}
onlyOneSystem={!visible}
timeRange={settings.timeRange}
/>
</div>
)}
<Widget
label={
<KillsHeader
systemId={systemId}
onOpenSettings={() => setSettingsDialogVisible(true)}
/>
}
>
<div className="relative h-full">
{!isSubscriptionActive ? (
<div className="absolute inset-0 flex items-center justify-center">
<span className="select-none text-center text-stone-400/80 text-sm">
Kills available with &#39;Active&#39; map subscription only (contact map administrators)
</span>
</div>
) : isNothingSelected ? (
<div className="absolute inset-0 flex items-center justify-center">
<span className="select-none text-center text-stone-400/80 text-sm">
No system selected (or toggle Show all systems)
</span>
</div>
) : showLoading ? (
<div className="absolute inset-0 flex items-center justify-center">
<span className="select-none text-center text-stone-400/80 text-sm">
Loading Kills...
</span>
</div>
) : error ? (
<div className="absolute inset-0 flex items-center justify-center">
<span className="select-none text-center text-red-400 text-sm">
{error}
</span>
</div>
) : !filteredKills || filteredKills.length === 0 ? (
<div className="absolute inset-0 flex items-center justify-center">
<span className="select-none text-center text-stone-400/80 text-sm">
No kills found
</span>
</div>
) : (
<div className="h-full overflow-y-auto">
<SystemKillsContent
key={settings.compact ? 'compact' : 'normal'}
kills={filteredKills}
systemNameMap={systemNameMap}
compact={settings.compact}
onlyOneSystem={!visible}
/>
</div>
)}
</div>
</Widget>
</div>
{settingsDialogVisible && <KillsSettingsDialog visible setVisible={setSettingsDialogVisible} />}
<KillsSettingsDialog
visible={settingsDialogVisible}
setVisible={setSettingsDialogVisible}
/>
</div>
);
});
SystemKills.displayName = 'SystemKills';
};

View File

@@ -1,14 +1,16 @@
.wrapper {
overflow-x: hidden;
box-sizing: border-box;
.TableRowCompact {
height: 8px;
max-height: 8px;
font-size: 12px !important;
line-height: 8px;
}
.scrollerContent {
width: 100%;
box-sizing: border-box;
overflow-x: hidden;
.Table {
font-size: 12px;
border-collapse: collapse;
}
.VirtualScroller {
height: 100% !important;
.Tooltip {
white-space: pre-line;
line-height: 1.2rem;
}

View File

@@ -1,68 +1,50 @@
import React, { useMemo } from 'react';
import clsx from 'clsx';
import { DetailedKill } from '@/hooks/Mapper/types/kills';
import { VirtualScroller } from 'primereact/virtualscroller';
import { useSystemKillsItemTemplate } from '../hooks/useSystemKillsItemTemplate';
import classes from './SystemKillsContent.module.scss';
import { KillRow } from '../components/SystemKillsRow';
export const ITEM_HEIGHT = 35;
export interface SystemKillsContentProps {
interface SystemKillsContentProps {
kills: DetailedKill[];
systemNameMap: Record<string, string>;
compact?: boolean;
onlyOneSystem?: boolean;
autoSize?: boolean;
timeRange?: number;
limit?: number;
}
export const SystemKillsContent: React.FC<SystemKillsContentProps> = ({
kills,
systemNameMap,
compact = false,
onlyOneSystem = false,
autoSize = false,
timeRange = 4,
limit,
}) => {
const processedKills = useMemo(() => {
const sortedKills = kills
.filter(k => k.kill_time)
.sort((a, b) => new Date(b.kill_time!).getTime() - new Date(a.kill_time!).getTime());
if (limit !== undefined) {
return sortedKills.slice(0, limit);
} else {
const now = Date.now();
const cutoff = now - timeRange * 60 * 60 * 1000;
return sortedKills.filter(k => new Date(k.kill_time!).getTime() >= cutoff);
}
}, [kills, timeRange, limit]);
const computedHeight = autoSize ? Math.max(processedKills.length, 1) * ITEM_HEIGHT : undefined;
const scrollerHeight = autoSize ? `${computedHeight}px` : '100%';
const itemTemplate = useSystemKillsItemTemplate(systemNameMap, onlyOneSystem);
const sortedKills = useMemo(() => {
return [...kills].sort((a, b) => {
const timeA = a.kill_time ? new Date(a.kill_time).getTime() : 0;
const timeB = b.kill_time ? new Date(b.kill_time).getTime() : 0;
return timeB - timeA;
});
}, [kills]);
return (
<div className={clsx('w-full h-full', classes.wrapper)}>
<VirtualScroller
items={processedKills}
itemSize={ITEM_HEIGHT}
itemTemplate={itemTemplate}
autoSize={autoSize}
scrollWidth="100%"
style={{ height: scrollerHeight }}
className={clsx('w-full h-full custom-scrollbar select-none', {
[classes.VirtualScroller]: !autoSize,
})}
pt={{
content: {
className: classes.scrollerContent,
},
}}
/>
<div
className={clsx(
'flex flex-col w-full text-stone-200 text-xs transition-all duration-300',
compact ? 'p-1' : 'p-1'
)}
>
{sortedKills.map(kill => {
const systemIdStr = String(kill.solar_system_id);
const systemName = systemNameMap[systemIdStr] || `System ${systemIdStr}`;
return (
<KillRow
key={kill.killmail_id}
killDetails={kill}
systemName={systemName}
isCompact={compact}
onlyOneSystem={onlyOneSystem}
/>
);
})}
</div>
);
};
export default SystemKillsContent;

View File

@@ -11,8 +11,8 @@ import {
getPrimaryLogoAndTooltip,
getAttackerPrimaryImageAndTooltip,
} from '../helpers';
import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit';
import classes from './KillRowDetail.module.scss';
import { WdTooltipWrapper } from '../../../../ui-kit/WdTooltipWrapper';
import classes from './SystemKillRow.module.scss';
import { TooltipPosition } from '@/hooks/Mapper/components/ui-kit';
export interface CompactKillRowProps {
@@ -21,10 +21,15 @@ export interface CompactKillRowProps {
onlyOneSystem: boolean;
}
export const KillRowDetail: React.FC<CompactKillRowProps> = ({ killDetails, systemName, onlyOneSystem }) => {
export const CompactKillRow: React.FC<CompactKillRowProps> = ({
killDetails,
systemName,
onlyOneSystem,
}) => {
const {
killmail_id = 0,
// Victim data
// Victim
victim_char_name = 'Unknown Pilot',
victim_alliance_ticker = '',
victim_corp_ticker = '',
@@ -35,7 +40,8 @@ export const KillRowDetail: React.FC<CompactKillRowProps> = ({ killDetails, syst
victim_corp_id = 0,
victim_alliance_id = 0,
victim_ship_type_id = 0,
// Attacker data
// Attacker
final_blow_char_id = 0,
final_blow_char_name = '',
final_blow_alliance_ticker = '',
@@ -45,64 +51,72 @@ export const KillRowDetail: React.FC<CompactKillRowProps> = ({ killDetails, syst
final_blow_corp_id = 0,
final_blow_corp_name = '',
final_blow_ship_type_id = 0,
kill_time = '',
total_value = 0,
} = killDetails || {};
const attackerIsNpc = final_blow_char_id === 0;
// Define victim affiliation ticker.
const victimAffiliationTicker = victim_alliance_ticker || victim_corp_ticker || 'No Ticker';
const killValueFormatted = total_value != null && total_value > 0 ? `${formatISK(total_value)} ISK` : null;
// Tickers & strings
const victimAffiliationTicker =
victim_alliance_ticker || victim_corp_ticker || 'No Ticker';
const killValueFormatted =
total_value != null && total_value > 0 ? `${formatISK(total_value)} ISK` : null;
const attackerName = attackerIsNpc ? '' : final_blow_char_name;
const attackerTicker = attackerIsNpc
? ''
: final_blow_alliance_ticker || final_blow_corp_ticker || '';
const killTimeAgo = kill_time ? formatTimeMixed(kill_time) : '0h ago';
const attackerSubscript = getAttackerSubscript(killDetails);
const { victimCorpLogoUrl, victimAllianceLogoUrl, victimShipUrl } = buildVictimImageUrls({
// Victim images, including the ship
const {
victimCorpLogoUrl,
victimAllianceLogoUrl,
victimShipUrl,
} = buildVictimImageUrls({
victim_char_id,
victim_ship_type_id,
victim_corp_id,
victim_alliance_id,
});
// Attacker corp/alliance
const { attackerCorpLogoUrl, attackerAllianceLogoUrl } = buildAttackerImageUrls({
final_blow_char_id,
final_blow_corp_id,
final_blow_alliance_id,
});
const { url: victimPrimaryLogoUrl, tooltip: victimPrimaryTooltip } = getPrimaryLogoAndTooltip(
victimAllianceLogoUrl,
victimCorpLogoUrl,
victim_alliance_name,
victim_corp_name,
'Victim',
);
// Victim corp/alliance logo
const { url: victimPrimaryLogoUrl, tooltip: victimPrimaryTooltip } =
getPrimaryLogoAndTooltip(
victimAllianceLogoUrl,
victimCorpLogoUrl,
victim_alliance_name,
victim_corp_name,
'Victim'
);
const { url: attackerPrimaryImageUrl, tooltip: attackerPrimaryTooltip } = getAttackerPrimaryImageAndTooltip(
attackerIsNpc,
attackerAllianceLogoUrl,
attackerCorpLogoUrl,
final_blow_alliance_name,
final_blow_corp_name,
final_blow_ship_type_id,
);
// Define attackerTicker to use the alliance ticker if available, otherwise the corp ticker.
const attackerTicker = attackerIsNpc ? '' : final_blow_alliance_ticker || final_blow_corp_ticker || '';
// For the attacker image link: if the attacker is not an NPC, link to the character page; otherwise, link to the kill page.
const attackerLink = attackerIsNpc ? zkillLink('kill', killmail_id) : zkillLink('character', final_blow_char_id);
// Attacker corp/alliance or NPC ship
const { url: attackerPrimaryImageUrl, tooltip: attackerPrimaryTooltip } =
getAttackerPrimaryImageAndTooltip(
attackerIsNpc,
attackerAllianceLogoUrl,
attackerCorpLogoUrl,
final_blow_alliance_name,
final_blow_corp_name,
final_blow_ship_type_id
);
return (
<div
className={clsx(
'h-10 flex items-center border-b border-stone-800',
'text-xs whitespace-nowrap overflow-hidden leading-none',
'text-xs whitespace-nowrap overflow-hidden leading-none'
)}
>
{/* Victim Section */}
<div className="flex items-center gap-1">
{victimShipUrl && (
<div className="relative shrink-0 w-8 h-8 overflow-hidden">
@@ -114,14 +128,20 @@ export const KillRowDetail: React.FC<CompactKillRowProps> = ({ killDetails, syst
>
<img
src={victimShipUrl}
alt="Victim Ship"
className={clsx(classes.killRowImage, 'w-full h-full object-contain')}
alt="VictimShip"
className={clsx(
classes.killRowImage,
'w-full h-full object-contain'
)}
/>
</a>
</div>
)}
{victimPrimaryLogoUrl && (
<WdTooltipWrapper content={victimPrimaryTooltip} position={TooltipPosition.top}>
<WdTooltipWrapper
content={victimPrimaryTooltip}
position={TooltipPosition.top}
>
<a
href={zkillLink('kill', killmail_id)}
target="_blank"
@@ -130,14 +150,17 @@ export const KillRowDetail: React.FC<CompactKillRowProps> = ({ killDetails, syst
>
<img
src={victimPrimaryLogoUrl}
alt="Victim Primary Logo"
className={clsx(classes.killRowImage, 'w-full h-full object-contain')}
alt="VictimPrimaryLogo"
className={clsx(
classes.killRowImage,
'w-full h-full object-contain'
)}
/>
</a>
</WdTooltipWrapper>
)}
</div>
<div className="flex flex-col ml-2 flex-1 min-w-0 overflow-hidden leading-[1rem]">
<div className="flex flex-col ml-2 min-w-0 overflow-hidden leading-[1rem]">
<div className="truncate text-stone-200">
{victim_char_name}
<span className="text-stone-400"> / {victimAffiliationTicker}</span>
@@ -153,17 +176,20 @@ export const KillRowDetail: React.FC<CompactKillRowProps> = ({ killDetails, syst
</div>
</div>
<div className="flex items-center ml-auto gap-2">
<div className="flex flex-col items-end flex-1 min-w-0 overflow-hidden text-right leading-[1rem]">
{!attackerIsNpc && (final_blow_char_name || attackerTicker) && (
<div className="flex flex-col items-end min-w-0 overflow-hidden text-right leading-[1rem]">
{!attackerIsNpc && (attackerName || attackerTicker) && (
<div className="truncate text-stone-200">
{final_blow_char_name}
{!attackerIsNpc && attackerTicker && <span className="ml-1 text-stone-400">/ {attackerTicker}</span>}
{attackerName}
{attackerTicker && (
<span className="ml-1 text-stone-400">/ {attackerTicker}</span>
)}
</div>
)}
<div className="truncate text-stone-400">
{!onlyOneSystem && systemName ? (
<>
{systemName} / <span className="ml-1 text-red-400">{killTimeAgo}</span>
{systemName} /{' '}
<span className="ml-1 text-red-400">{killTimeAgo}</span>
</>
) : (
<span className="text-red-400">{killTimeAgo}</span>
@@ -171,24 +197,30 @@ export const KillRowDetail: React.FC<CompactKillRowProps> = ({ killDetails, syst
</div>
</div>
{attackerPrimaryImageUrl && (
<WdTooltipWrapper content={attackerPrimaryTooltip} position={TooltipPosition.top}>
<WdTooltipWrapper
content={attackerPrimaryTooltip}
position={TooltipPosition.top}
>
<a
href={attackerLink}
href={zkillLink('kill', killmail_id)}
target="_blank"
rel="noopener noreferrer"
className="relative block shrink-0 w-8 h-8 overflow-hidden"
>
<img
src={attackerPrimaryImageUrl}
alt={attackerIsNpc ? 'NPC Ship' : 'Attacker Primary Logo'}
className={clsx(classes.killRowImage, 'w-full h-full object-contain')}
alt={attackerIsNpc ? 'NpcShip' : 'AttackerPrimaryLogo'}
className={clsx(
classes.killRowImage,
'w-full h-full object-contain'
)}
/>
{attackerSubscript && (
<span
className={clsx(
classes.attackerCountLabel,
attackerSubscript.cssClass,
'text-[0.6rem] leading-none px-[2px]',
'text-[0.6rem] leading-none px-[2px]'
)}
>
{attackerSubscript.label}

View File

@@ -0,0 +1,268 @@
import React from 'react';
import clsx from 'clsx';
import { DetailedKill } from '@/hooks/Mapper/types/kills';
import {
formatISK,
formatTimeMixed,
zkillLink,
getAttackerSubscript,
buildVictimImageUrls,
buildAttackerImageUrls,
getPrimaryLogoAndTooltip,
getAttackerPrimaryImageAndTooltip,
} from '../helpers';
import { VictimRowSubInfo } from './VictimRowSubInfo';
import { WdTooltipWrapper } from '../../../../ui-kit/WdTooltipWrapper';
import classes from './SystemKillRow.module.scss';
import { TooltipPosition } from '@/hooks/Mapper/components/ui-kit';
export interface FullKillRowProps {
killDetails: DetailedKill;
systemName: string;
onlyOneSystem: boolean;
}
export const FullKillRow: React.FC<FullKillRowProps> = ({
killDetails,
systemName,
onlyOneSystem,
}) => {
const {
killmail_id = 0,
// Victim data
victim_char_name = '',
victim_alliance_ticker = '',
victim_corp_ticker = '',
victim_ship_name = '',
victim_char_id = 0,
victim_corp_id = 0,
victim_alliance_id = 0,
victim_ship_type_id = 0,
victim_corp_name = '',
victim_alliance_name = '',
// Attacker data
final_blow_char_id = 0,
final_blow_char_name = '',
final_blow_alliance_ticker = '',
final_blow_corp_ticker = '',
final_blow_corp_name = '',
final_blow_alliance_name = '',
final_blow_corp_id = 0,
final_blow_alliance_id = 0,
final_blow_ship_name = '',
final_blow_ship_type_id = 0,
total_value = 0,
kill_time = '',
} = killDetails || {};
const attackerIsNpc = final_blow_char_id === 0;
const victimAffiliation = victim_alliance_ticker || victim_corp_ticker || null;
const attackerAffiliation = attackerIsNpc
? ''
: final_blow_alliance_ticker || final_blow_corp_ticker || '';
const killValueFormatted =
total_value != null && total_value > 0 ? `${formatISK(total_value)} ISK` : null;
const killTimeAgo = kill_time ? formatTimeMixed(kill_time) : '0h ago';
// Build victim images
const {
victimPortraitUrl,
victimCorpLogoUrl,
victimAllianceLogoUrl,
victimShipUrl,
} = buildVictimImageUrls({
victim_char_id,
victim_ship_type_id,
victim_corp_id,
victim_alliance_id,
});
// Build attacker images
const {
attackerPortraitUrl,
attackerCorpLogoUrl,
attackerAllianceLogoUrl,
} = buildAttackerImageUrls({
final_blow_char_id,
final_blow_corp_id,
final_blow_alliance_id,
});
// Primary image for victim
const { url: victimPrimaryImageUrl, tooltip: victimPrimaryTooltip } =
getPrimaryLogoAndTooltip(
victimAllianceLogoUrl,
victimCorpLogoUrl,
victim_alliance_name,
victim_corp_name,
'Victim'
);
// Primary image for attacker
const { url: attackerPrimaryImageUrl, tooltip: attackerPrimaryTooltip } =
getAttackerPrimaryImageAndTooltip(
attackerIsNpc,
attackerAllianceLogoUrl,
attackerCorpLogoUrl,
final_blow_alliance_name,
final_blow_corp_name,
final_blow_ship_type_id
);
const attackerSubscript = getAttackerSubscript(killDetails);
return (
<div
className={clsx(
classes.killRowContainer,
'w-full text-sm py-1 px-2',
'flex flex-col sm:flex-row'
)}
>
<div className="w-full flex flex-col sm:flex-row items-start gap-2">
{/* Victim Section */}
<div className="flex items-start gap-1 min-w-0">
{victimShipUrl && (
<div className="relative shrink-0 w-12 h-12 sm:w-14 sm:h-14 overflow-hidden">
<a
href={zkillLink('kill', killmail_id)}
target="_blank"
rel="noopener noreferrer"
className="block w-full h-full"
>
<img
src={victimShipUrl}
alt="VictimShip"
className={clsx(
classes.killRowImage,
'w-full h-full object-contain'
)}
/>
</a>
</div>
)}
{victimPrimaryImageUrl && (
<WdTooltipWrapper
content={victimPrimaryTooltip}
position={TooltipPosition.top}
>
<div className="relative shrink-0 w-12 h-12 sm:w-14 sm:h-14 overflow-hidden">
<a
href={zkillLink('kill', killmail_id)}
target="_blank"
rel="noopener noreferrer"
className="block w-full h-full"
>
<img
src={victimPrimaryImageUrl}
alt="VictimPrimaryLogo"
className={clsx(
classes.killRowImage,
'w-full h-full object-contain'
)}
/>
</a>
</div>
</WdTooltipWrapper>
)}
<VictimRowSubInfo
victimCharName={victim_char_name}
victimCharacterId={victim_char_id}
victimPortraitUrl={victimPortraitUrl}
/>
<div className="flex flex-col text-stone-200 leading-4 min-w-0 overflow-hidden">
<div className="truncate font-semibold">
{victim_char_name}
{victimAffiliation && (
<span className="ml-1 text-stone-400">/ {victimAffiliation}</span>
)}
</div>
<div className="truncate text-stone-300">
{victim_ship_name}
{killValueFormatted && (
<>
<span className="ml-1 text-stone-400">/</span>
<span className="ml-1 text-green-400">{killValueFormatted}</span>
</>
)}
</div>
<div className="truncate text-stone-400">
{!onlyOneSystem && systemName && <span>{systemName}</span>}
</div>
</div>
</div>
{/* Attacker Section */}
<div className="flex items-start gap-1 min-w-0 sm:ml-auto">
<div className="flex flex-col items-end leading-4 min-w-0 overflow-hidden text-right">
{!attackerIsNpc && (
<div className="truncate font-semibold">
{final_blow_char_name}
{attackerAffiliation && (
<span className="ml-1 text-stone-400">/ {attackerAffiliation}</span>
)}
</div>
)}
{!attackerIsNpc && final_blow_ship_name && (
<div className="truncate text-stone-300">{final_blow_ship_name}</div>
)}
<div className="truncate text-red-400">{killTimeAgo}</div>
</div>
{(!attackerIsNpc && attackerPortraitUrl && final_blow_char_id > 0) && (
<div className="relative shrink-0 w-12 h-12 sm:w-14 sm:h-14 overflow-hidden">
<a
href={zkillLink('character', final_blow_char_id)}
target="_blank"
rel="noopener noreferrer"
className="block w-full h-full"
>
<img
src={attackerPortraitUrl}
alt="AttackerPortrait"
className={clsx(
classes.killRowImage,
'w-full h-full object-contain'
)}
/>
</a>
</div>
)}
{attackerPrimaryImageUrl && (
<WdTooltipWrapper
content={attackerPrimaryTooltip}
position={TooltipPosition.top}
>
<div className="relative shrink-0 w-12 h-12 sm:w-14 sm:h-14 overflow-hidden">
<a
href={zkillLink('kill', killmail_id)}
target="_blank"
rel="noopener noreferrer"
className="block w-full h-full"
>
<img
src={attackerPrimaryImageUrl}
alt={attackerIsNpc ? 'NpcShip' : 'AttackerPrimaryLogo'}
className={clsx(
classes.killRowImage,
'w-full h-full object-contain'
)}
/>
{attackerSubscript && (
<span
className={clsx(
attackerSubscript.cssClass,
classes.attackerCountLabel
)}
>
{attackerSubscript.label}
</span>
)}
</a>
</div>
</WdTooltipWrapper>
)}
</div>
</div>
</div>
);
};

View File

@@ -1,20 +0,0 @@
import { DetailedKill } from '@/hooks/Mapper/types/kills';
import { VirtualScrollerTemplateOptions } from 'primereact/virtualscroller';
import { KillRow } from './SystemKillsRow';
import clsx from 'clsx';
export function KillItemTemplate(
systemNameMap: Record<string, string>,
onlyOneSystem: boolean,
kill: DetailedKill,
options: VirtualScrollerTemplateOptions,
) {
const systemIdStr = String(kill.solar_system_id);
const systemName = systemNameMap[systemIdStr] || `System ${systemIdStr}`;
return (
<div style={{ height: `${options.props.itemSize}px` }} className={clsx({ 'bg-gray-900': options.odd })}>
<KillRow killDetails={kill} systemName={systemName} onlyOneSystem={onlyOneSystem} />
</div>
);
}

View File

@@ -1,15 +1,24 @@
import React from 'react';
import { DetailedKill } from '@/hooks/Mapper/types/kills';
import { KillRowDetail } from './KillRowDetail.tsx';
import { CompactKillRow } from './CompactKillRow';
import { FullKillRow } from './FullKillRow';
export interface KillRowProps {
killDetails: DetailedKill;
systemName: string;
isCompact?: boolean;
onlyOneSystem?: boolean;
}
const KillRowComponent: React.FC<KillRowProps> = ({ killDetails, systemName, onlyOneSystem = false }) => {
return <KillRowDetail killDetails={killDetails} systemName={systemName} onlyOneSystem={onlyOneSystem} />;
};
export const KillRow: React.FC<KillRowProps> = ({
killDetails,
systemName,
isCompact = false,
onlyOneSystem = false,
}) => {
if (isCompact) {
return <CompactKillRow killDetails={killDetails} systemName={systemName} onlyOneSystem={onlyOneSystem} />;
}
export const KillRow = React.memo(KillRowComponent);
return <FullKillRow killDetails={killDetails} systemName={systemName} onlyOneSystem={onlyOneSystem} />;
};

View File

@@ -1,14 +1,13 @@
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { Dialog } from 'primereact/dialog';
import { Button } from 'primereact/button';
import { WdImgButton } from '@/hooks/Mapper/components/ui-kit';
import { WdImgButton, SystemView, TooltipPosition } from '@/hooks/Mapper/components/ui-kit';
import { PrimeIcons } from 'primereact/api';
import { useKillsWidgetSettings } from '../hooks/useKillsWidgetSettings';
import {
AddSystemDialog,
SearchOnSubmitCallback,
} from '@/hooks/Mapper/components/mapInterface/components/AddSystemDialog';
import { SystemView, TooltipPosition } from '@/hooks/Mapper/components/ui-kit';
interface KillsSettingsDialogProps {
visible: boolean;
@@ -18,39 +17,40 @@ interface KillsSettingsDialogProps {
export const KillsSettingsDialog: React.FC<KillsSettingsDialogProps> = ({ visible, setVisible }) => {
const [globalSettings, setGlobalSettings] = useKillsWidgetSettings();
const localRef = useRef({
compact: globalSettings.compact,
showAll: globalSettings.showAll,
whOnly: globalSettings.whOnly,
excludedSystems: globalSettings.excludedSystems || [],
timeRange: globalSettings.timeRange,
});
const [, forceRender] = useState(0);
const [addSystemDialogVisible, setAddSystemDialogVisible] = useState(false);
useEffect(() => {
if (visible) {
localRef.current = {
compact: globalSettings.compact,
showAll: globalSettings.showAll,
whOnly: globalSettings.whOnly,
excludedSystems: globalSettings.excludedSystems || [],
timeRange: globalSettings.timeRange,
};
forceRender(n => n + 1);
}
}, [visible, globalSettings]);
const handleWHChange = useCallback((checked: boolean) => {
const handleCompactChange = useCallback((checked: boolean) => {
localRef.current = {
...localRef.current,
whOnly: checked,
compact: checked,
};
forceRender(n => n + 1);
}, []);
const handleTimeRangeChange = useCallback((newTimeRange: number) => {
const handleWHChange = useCallback((checked: boolean) => {
localRef.current = {
...localRef.current,
timeRange: newTimeRange,
whOnly: checked,
};
forceRender(n => n + 1);
}, []);
@@ -88,11 +88,22 @@ export const KillsSettingsDialog: React.FC<KillsSettingsDialogProps> = ({ visibl
const localData = localRef.current;
const excluded = localData.excludedSystems || [];
const timeRangeOptions = [4, 12, 24];
return (
<Dialog header="Kills Settings" visible={visible} style={{ width: '440px' }} draggable={false} onHide={handleHide}>
<div className="flex flex-col gap-3 p-2.5">
<div className="flex items-center gap-2">
<input
type="checkbox"
id="kills-compact-mode"
checked={localData.compact}
onChange={e => handleCompactChange(e.target.checked)}
/>
<label htmlFor="kills-compact-mode" className="cursor-pointer">
Use compact mode
</label>
</div>
<div className="flex items-center gap-2">
<input
type="checkbox"
@@ -100,30 +111,11 @@ export const KillsSettingsDialog: React.FC<KillsSettingsDialogProps> = ({ visibl
checked={localData.whOnly}
onChange={e => handleWHChange(e.target.checked)}
/>
<label htmlFor="kills-wormhole-only-mode" className="cursor-pointer">
<label htmlFor="kills-wh-only-mode" className="cursor-pointer">
Only show wormhole kills
</label>
</div>
<div className="flex flex-col gap-1">
<span className="text-sm">Time Range:</span>
<div className="flex flex-wrap gap-2">
{timeRangeOptions.map(option => (
<label key={option} className="cursor-pointer flex items-center gap-1">
<input
type="radio"
name="timeRange"
value={option}
checked={localData.timeRange === option}
onChange={() => handleTimeRangeChange(option)}
/>
<span className="text-sm">{option} Hours</span>
</label>
))}
</div>
</div>
{/* Excluded Systems */}
<div className="flex flex-col gap-1">
<div className="flex items-center justify-between">
<label className="text-sm text-stone-400">Excluded Systems</label>
@@ -136,7 +128,8 @@ export const KillsSettingsDialog: React.FC<KillsSettingsDialogProps> = ({ visibl
{excluded.length === 0 && <div className="text-stone-500 text-xs italic">No systems excluded.</div>}
{excluded.map(sysId => (
<div key={sysId} className="flex items-center justify-between border-b border-stone-600 py-1 px-1 text-xs">
<SystemView systemId={sysId.toString()} hideRegion />
<SystemView systemId={sysId.toString()} hideRegion compact/>
<WdImgButton
className={PrimeIcons.TRASH}
onClick={() => handleRemoveSystem(sysId)}

View File

@@ -0,0 +1,39 @@
import React from 'react';
import clsx from 'clsx';
import { zkillLink } from '../helpers';
import classes from './SystemKillRow.module.scss';
interface VictimRowSubInfoProps {
victimCharacterId: number | null;
victimPortraitUrl: string | null;
victimCharName?: string;
}
export const VictimRowSubInfo: React.FC<VictimRowSubInfoProps> = ({
victimCharacterId = 0,
victimPortraitUrl,
victimCharName,
}) => {
if (!victimPortraitUrl || !victimCharacterId || victimCharacterId <= 0) {
return null;
}
return (
<div className="flex items-start gap-1">
<div className="relative shrink-0 w-12 h-12 sm:w-14 sm:h-14 overflow-hidden">
<a
href={zkillLink('character', victimCharacterId)}
target="_blank"
rel="noopener noreferrer"
className="block w-full h-full"
>
<img
src={victimPortraitUrl}
alt={victimCharName || 'Victim Portrait'}
className={clsx(classes.killRowImage, 'w-full h-full object-contain')}
/>
</a>
</div>
</div>
);
};

View File

@@ -2,19 +2,19 @@ import { useMemo, useCallback } from 'react';
import useLocalStorageState from 'use-local-storage-state';
export interface KillsWidgetSettings {
compact: boolean;
showAll: boolean;
whOnly: boolean;
excludedSystems: number[];
version: number;
timeRange: number;
}
export const DEFAULT_KILLS_WIDGET_SETTINGS: KillsWidgetSettings = {
compact: true,
showAll: false,
whOnly: true,
excludedSystems: [],
version: 2,
timeRange: 1,
version: 0,
};
function mergeWithDefaults(settings?: Partial<KillsWidgetSettings>): KillsWidgetSettings {

View File

@@ -1,13 +0,0 @@
// useSystemKillsItemTemplate.tsx
import { useCallback } from 'react';
import { VirtualScrollerTemplateOptions } from 'primereact/virtualscroller';
import { DetailedKill } from '@/hooks/Mapper/types/kills';
import { KillItemTemplate } from '../components/KillItemTemplate';
export function useSystemKillsItemTemplate(systemNameMap: Record<string, string>, onlyOneSystem: boolean) {
return useCallback(
(kill: DetailedKill, options: VirtualScrollerTemplateOptions) =>
KillItemTemplate(systemNameMap, onlyOneSystem, kill, options),
[systemNameMap, onlyOneSystem],
);
}

View File

@@ -1,96 +0,0 @@
import React from 'react';
import { SystemView, WdCheckbox, WdImgButton, TooltipPosition } from '@/hooks/Mapper/components/ui-kit';
import { PrimeIcons } from 'primereact/api';
import { CheckboxChangeEvent } from 'primereact/checkbox';
import { InfoDrawer, LayoutEventBlocker } from '@/hooks/Mapper/components/ui-kit';
import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrapper';
export type HeaderProps = {
systemId: string;
isNotSelectedSystem: boolean;
sigCount: number;
isCompact: boolean;
lazyDeleteValue: boolean;
onLazyDeleteChange: (checked: boolean) => void;
pendingCount: number;
onUndoClick: () => void;
onSettingsClick: () => void;
};
function HeaderImpl({
systemId,
isNotSelectedSystem,
sigCount,
isCompact,
lazyDeleteValue,
onLazyDeleteChange,
pendingCount,
onUndoClick,
onSettingsClick,
}: HeaderProps) {
return (
<div className="flex justify-between items-center text-xs w-full h-full">
<div className="flex justify-between items-center gap-1">
{!isCompact && (
<div className="flex whitespace-nowrap text-ellipsis overflow-hidden text-stone-400">
{sigCount ? `[${sigCount}] ` : ''}Signatures {isNotSelectedSystem ? '' : 'in'}
</div>
)}
{!isNotSelectedSystem && <SystemView systemId={systemId} className="select-none text-center" hideRegion />}
</div>
<LayoutEventBlocker className="flex gap-2.5">
<WdTooltipWrapper content="Enable Lazy delete">
<WdCheckbox
size="xs"
labelSide="left"
label={isCompact ? '' : 'Lazy delete'}
value={lazyDeleteValue}
classNameLabel="text-stone-400 hover:text-stone-200 transition duration-300 whitespace-nowrap text-ellipsis overflow-hidden"
onChange={(event: CheckboxChangeEvent) => onLazyDeleteChange(!!event.checked)}
/>
</WdTooltipWrapper>
{pendingCount > 0 && (
<WdImgButton
className={PrimeIcons.UNDO}
style={{ color: 'red' }}
tooltip={{ content: `Undo pending changes (${pendingCount})` }}
onClick={onUndoClick}
/>
)}
<WdImgButton
className={PrimeIcons.QUESTION_CIRCLE}
tooltip={{
position: TooltipPosition.left,
content: (
<div className="flex flex-col gap-1">
<InfoDrawer title={<b className="text-slate-50">How to add/update signature?</b>}>
In game you need to select one or more signatures <br /> in the list in{' '}
<b className="text-sky-500">Probe scanner</b>. <br /> Use next hotkeys:
<br />
<b className="text-sky-500">Shift + LMB</b> or <b className="text-sky-500">Ctrl + LMB</b>
<br /> or <b className="text-sky-500">Ctrl + A</b> for select all
<br /> and then use <b className="text-sky-500">Ctrl + C</b>, after you need to go <br />
here, select Solar system and paste it with <b className="text-sky-500">Ctrl + V</b>
</InfoDrawer>
<InfoDrawer title={<b className="text-slate-50">How to select?</b>}>
For selecting any signature, click on it <br /> with hotkeys{' '}
<b className="text-sky-500">Shift + LMB</b> or <b className="text-sky-500">Ctrl + LMB</b>
</InfoDrawer>
<InfoDrawer title={<b className="text-slate-50">How to delete?</b>}>
To delete any signature, first select it <br /> and then press <b className="text-sky-500">Del</b>
</InfoDrawer>
</div>
),
}}
/>
<WdImgButton className={PrimeIcons.SLIDERS_H} onClick={onSettingsClick} />
</LayoutEventBlocker>
</div>
);
}
export const SystemSignaturesHeader = React.memo(HeaderImpl);

View File

@@ -1,5 +1,12 @@
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { Widget } from '@/hooks/Mapper/components/mapInterface/components';
import {
InfoDrawer,
LayoutEventBlocker,
SystemView,
TooltipPosition,
WdCheckbox,
WdImgButton,
} from '@/hooks/Mapper/components/ui-kit';
import { SystemSignaturesContent } from './SystemSignaturesContent';
import {
COSMIC_ANOMALY,
@@ -12,28 +19,28 @@ import {
STRUCTURE,
SystemSignatureSettingsDialog,
} from './SystemSignatureSettingsDialog';
import { SignatureGroup, SystemSignature } from '@/hooks/Mapper/types';
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
import useMaxWidth from '@/hooks/Mapper/hooks/useMaxWidth';
import { useHotkey } from '@/hooks/Mapper/hooks';
import { COMPACT_MAX_WIDTH } from './constants';
import { renderHeaderLabel } from './renders';
import { SignatureGroup } from '@/hooks/Mapper/types';
const SIGNATURE_SETTINGS_KEY = 'wanderer_system_signature_settings_v5_5';
export const SIGNATURE_WINDOW_ID = 'system_signatures_window';
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { PrimeIcons } from 'primereact/api';
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
import { CheckboxChangeEvent } from 'primereact/checkbox';
import useMaxWidth from '@/hooks/Mapper/hooks/useMaxWidth.ts';
import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrapper';
const SIGNATURE_SETTINGS_KEY = 'wanderer_system_signature_settings_v5_2';
export const SHOW_DESCRIPTION_COLUMN_SETTING = 'show_description_column_setting';
export const SHOW_UPDATED_COLUMN_SETTING = 'SHOW_UPDATED_COLUMN_SETTING';
export const SHOW_CHARACTER_COLUMN_SETTING = 'SHOW_CHARACTER_COLUMN_SETTING';
export const LAZY_DELETE_SIGNATURES_SETTING = 'LAZY_DELETE_SIGNATURES_SETTING';
export const KEEP_LAZY_DELETE_SETTING = 'KEEP_LAZY_DELETE_ENABLED_SETTING';
const SETTINGS: Setting[] = [
const settings: Setting[] = [
{ key: SHOW_UPDATED_COLUMN_SETTING, name: 'Show Updated Column', value: false, isFilter: false },
{ key: SHOW_DESCRIPTION_COLUMN_SETTING, name: 'Show Description Column', value: false, isFilter: false },
{ key: SHOW_CHARACTER_COLUMN_SETTING, name: 'Show Character Column', value: false, isFilter: false },
{ key: LAZY_DELETE_SIGNATURES_SETTING, name: 'Lazy Delete Signatures', value: false, isFilter: false },
{ key: KEEP_LAZY_DELETE_SETTING, name: 'Keep "Lazy Delete" Enabled', value: false, isFilter: false },
{ key: COSMIC_ANOMALY, name: 'Show Anomalies', value: true, isFilter: true },
{ key: COSMIC_SIGNATURE, name: 'Show Cosmic Signatures', value: true, isFilter: true },
{ key: DEPLOYABLE, name: 'Show Deployables', value: true, isFilter: true },
@@ -49,127 +56,121 @@ const SETTINGS: Setting[] = [
{ key: SignatureGroup.CombatSite, name: 'Show Combat Sites', value: true, isFilter: true },
];
function getDefaultSettings(): Setting[] {
return [...SETTINGS];
}
const defaultSettings = () => {
return [...settings];
};
export const SystemSignatures: React.FC = () => {
export const SystemSignatures = () => {
const {
data: { selectedSystems },
} = useMapRootState();
const [visible, setVisible] = useState(false);
const [currentSettings, setCurrentSettings] = useState<Setting[]>(() => {
const stored = localStorage.getItem(SIGNATURE_SETTINGS_KEY);
if (stored) {
try {
return JSON.parse(stored) as Setting[];
} catch (error) {
console.error('Error parsing stored settings', error);
}
}
return getDefaultSettings();
});
useEffect(() => {
localStorage.setItem(SIGNATURE_SETTINGS_KEY, JSON.stringify(currentSettings));
}, [currentSettings]);
const [sigCount, setSigCount] = useState<number>(0);
const [pendingSigs, setPendingSigs] = useState<SystemSignature[]>([]);
const undoPendingFnRef = useRef<() => void>(() => {});
const handleSigCountChange = useCallback((count: number) => {
setSigCount(count);
}, []);
const [settings, setSettings] = useState<Setting[]>(defaultSettings);
const [systemId] = selectedSystems;
const isNotSelectedSystem = selectedSystems.length !== 1;
const lazyDeleteValue = useMemo(
() => currentSettings.find(setting => setting.key === LAZY_DELETE_SIGNATURES_SETTING)?.value || false,
[currentSettings],
);
const lazyDeleteValue = useMemo(() => {
return settings.find(setting => setting.key === LAZY_DELETE_SIGNATURES_SETTING)!.value;
}, [settings]);
const handleSettingsChange = useCallback((newSettings: Setting[]) => {
setCurrentSettings(newSettings);
const handleSettingsChange = useCallback((settings: Setting[]) => {
setSettings(settings);
localStorage.setItem(SIGNATURE_SETTINGS_KEY, JSON.stringify(settings));
setVisible(false);
}, []);
const handleLazyDeleteChange = useCallback((value: boolean) => {
setCurrentSettings(prevSettings =>
prevSettings.map(setting => (setting.key === LAZY_DELETE_SIGNATURES_SETTING ? { ...setting, value } : setting)),
);
}, []);
const containerRef = useRef<HTMLDivElement>(null);
const isCompact = useMaxWidth(containerRef, COMPACT_MAX_WIDTH);
useHotkey(true, ['z'], event => {
if (pendingSigs.length > 0) {
event.preventDefault();
event.stopPropagation();
undoPendingFnRef.current();
setPendingSigs([]);
}
});
const handleUndoClick = useCallback(() => {
undoPendingFnRef.current();
setPendingSigs([]);
}, []);
const handleSettingsButtonClick = useCallback(() => {
setVisible(true);
}, []);
const handlePendingChange = useCallback((newPending: SystemSignature[], newUndo: () => void) => {
setPendingSigs(prev => {
if (newPending.length === prev.length && newPending.every(np => prev.some(pp => pp.eve_id === np.eve_id))) {
return prev;
}
return newPending;
setSettings(settings => {
const lazyDelete = settings.find(setting => setting.key === LAZY_DELETE_SIGNATURES_SETTING)!;
lazyDelete.value = value;
localStorage.setItem(SIGNATURE_SETTINGS_KEY, JSON.stringify(settings));
return [...settings];
});
undoPendingFnRef.current = newUndo;
}, []);
useEffect(() => {
const restoredSettings = localStorage.getItem(SIGNATURE_SETTINGS_KEY);
if (restoredSettings) {
setSettings(JSON.parse(restoredSettings));
}
}, []);
const ref = useRef<HTMLDivElement>(null);
const compact = useMaxWidth(ref, 260);
return (
<Widget
label={
<div ref={containerRef} className="w-full">
{renderHeaderLabel({
systemId,
isNotSelectedSystem,
isCompact,
sigCount,
lazyDeleteValue,
pendingCount: pendingSigs.length,
onLazyDeleteChange: handleLazyDeleteChange,
onUndoClick: handleUndoClick,
onSettingsClick: handleSettingsButtonClick,
})}
<div className="flex justify-between items-center text-xs w-full h-full" ref={ref}>
<div className="flex justify-between items-center gap-1">
{!compact && (
<div className="flex whitespace-nowrap text-ellipsis overflow-hidden text-stone-400">
Signatures {isNotSelectedSystem ? '' : 'in'}
</div>
)}
{!isNotSelectedSystem && <SystemView systemId={systemId} className="select-none text-center" hideRegion />}
</div>
<LayoutEventBlocker className="flex gap-2.5">
<WdTooltipWrapper content="Enable Lazy delete">
<WdCheckbox
size="xs"
labelSide="left"
label={compact ? '' : 'Lazy delete'}
value={lazyDeleteValue}
classNameLabel="text-stone-400 hover:text-stone-200 transition duration-300 whitespace-nowrap text-ellipsis overflow-hidden"
onChange={(event: CheckboxChangeEvent) => handleLazyDeleteChange(!!event.checked)}
/>
</WdTooltipWrapper>
<WdImgButton
className={PrimeIcons.QUESTION_CIRCLE}
tooltip={{
position: TooltipPosition.left,
// @ts-ignore
content: (
<div className="flex flex-col gap-1">
<InfoDrawer title={<b className="text-slate-50">How to add/update signature?</b>}>
In game you need select one or more signatures <br /> in list in{' '}
<b className="text-sky-500">Probe scanner</b>. <br /> Use next hotkeys:
<br />
<b className="text-sky-500">Shift + LMB</b> or <b className="text-sky-500">Ctrl + LMB</b>
<br /> or <b className="text-sky-500">Ctrl + A</b> for select all
<br />
and then use <b className="text-sky-500">Ctrl + C</b>, after you need to go <br />
here select Solar system and paste it with <b className="text-sky-500">Ctrl + V</b>
</InfoDrawer>
<InfoDrawer title={<b className="text-slate-50">How to select?</b>}>
For select any signature need click on that, <br /> with hotkeys{' '}
<b className="text-sky-500">Shift + LMB</b> or <b className="text-sky-500">Ctrl + LMB</b>
</InfoDrawer>
<InfoDrawer title={<b className="text-slate-50">How to delete?</b>}>
For delete any signature first of all you need select before
<br /> and then use <b className="text-sky-500">Del</b>
</InfoDrawer>
</div>
) as React.ReactNode,
}}
/>
<WdImgButton className={PrimeIcons.SLIDERS_H} onClick={() => setVisible(true)} />
</LayoutEventBlocker>
</div>
}
windowId={SIGNATURE_WINDOW_ID}
>
{isNotSelectedSystem ? (
<div className="w-full h-full flex justify-center items-center select-none text-center text-stone-400/80 text-sm">
System is not selected
</div>
) : (
<SystemSignaturesContent
systemId={systemId}
settings={currentSettings}
onLazyDeleteChange={handleLazyDeleteChange}
onCountChange={handleSigCountChange}
onPendingChange={handlePendingChange}
/>
<SystemSignaturesContent systemId={systemId} settings={settings} onLazyDeleteChange={handleLazyDeleteChange} />
)}
{visible && (
<SystemSignatureSettingsDialog
settings={currentSettings}
settings={settings}
onCancel={() => setVisible(false)}
onSave={handleSettingsChange}
/>
@@ -177,5 +178,3 @@ export const SystemSignatures: React.FC = () => {
</Widget>
);
};
export default SystemSignatures;

View File

@@ -0,0 +1,10 @@
.TableRowCompact {
height: 8px;
max-height: 8px;
font-size: 12px !important;
line-height: 8px;
}
.Table {
}

View File

@@ -1,28 +1,29 @@
import { useEffect, useMemo, useRef, useState, useCallback } from 'react';
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
import { parseSignatures } from '@/hooks/Mapper/helpers';
import { Commands, OutCommand } from '@/hooks/Mapper/types/mapHandlers.ts';
import { WdTooltip, WdTooltipHandlers } from '@/hooks/Mapper/components/ui-kit';
import {
getGroupIdByRawGroup,
GROUPS_LIST,
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants.ts';
import { DataTable, DataTableRowClickEvent, DataTableRowMouseEvent, SortOrder } from 'primereact/datatable';
import { Column } from 'primereact/column';
import { PrimeIcons } from 'primereact/api';
import useLocalStorageState from 'use-local-storage-state';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import useRefState from 'react-usestateref';
import { Setting } from '../SystemSignatureSettingsDialog';
import { useHotkey } from '@/hooks/Mapper/hooks';
import useMaxWidth from '@/hooks/Mapper/hooks/useMaxWidth.ts';
import { useClipboard } from '@/hooks/Mapper/hooks/useClipboard';
import { SignatureGroup, SystemSignature } from '@/hooks/Mapper/types';
import { SignatureSettings } from '@/hooks/Mapper/components/mapRootContent/components/SignatureSettings';
import { WdTooltip, WdTooltipHandlers, WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit';
import classes from './SystemSignaturesContent.module.scss';
import clsx from 'clsx';
import { SystemSignature } from '@/hooks/Mapper/types';
import { SignatureView } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/SignatureView';
import {
COMPACT_MAX_WIDTH,
GROUPS_LIST,
MEDIUM_MAX_WIDTH,
OTHER_COLUMNS_WIDTH,
getGroupIdByRawGroup,
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants';
import {
SHOW_DESCRIPTION_COLUMN_SETTING,
SHOW_UPDATED_COLUMN_SETTING,
SHOW_CHARACTER_COLUMN_SETTING,
SIGNATURE_WINDOW_ID,
} from '../SystemSignatures';
import { COSMIC_SIGNATURE } from '../SystemSignatureSettingsDialog';
getActualSigs,
getRowColorByTimeLeft,
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/helpers';
import {
renderAddedTimeLeft,
renderDescription,
@@ -30,12 +31,18 @@ import {
renderInfoColumn,
renderUpdatedTimeLeft,
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/renders';
import { ExtendedSystemSignature } from '../helpers/contentHelpers';
import { useSystemSignaturesData } from '../hooks/useSystemSignaturesData';
import { getSignatureRowClass } from '../helpers/rowStyles';
import useMaxWidth from '@/hooks/Mapper/hooks/useMaxWidth';
import { useClipboard, useHotkey } from '@/hooks/Mapper/hooks';
import useLocalStorageState from 'use-local-storage-state';
import { PrimeIcons } from 'primereact/api';
import { SignatureSettings } from '@/hooks/Mapper/components/mapRootContent/components/SignatureSettings';
import { useMapEventListener } from '@/hooks/Mapper/events';
import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrapper';
import { COSMIC_SIGNATURE } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/SystemSignatureSettingsDialog';
import {
SHOW_DESCRIPTION_COLUMN_SETTING,
SHOW_UPDATED_COLUMN_SETTING,
LAZY_DELETE_SIGNATURES_SETTING,
KEEP_LAZY_DELETE_SETTING,
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures';
type SystemSignaturesSortSettings = {
sortField: string;
sortOrder: SortOrder;
@@ -48,287 +55,391 @@ const SORT_DEFAULT_VALUES: SystemSignaturesSortSettings = {
interface SystemSignaturesContentProps {
systemId: string;
settings: { key: string; value: boolean }[];
settings: Setting[];
hideLinkedSignatures?: boolean;
selectable?: boolean;
onSelect?: (signature: SystemSignature) => void;
onLazyDeleteChange?: (value: boolean) => void;
onCountChange?: (count: number) => void;
onPendingChange?: (pending: ExtendedSystemSignature[], undo: () => void) => void;
}
const headerInlineStyle = { padding: '2px', fontSize: '12px', lineHeight: '1.333' };
export function SystemSignaturesContent({
export const SystemSignaturesContent = ({
systemId,
settings,
hideLinkedSignatures,
selectable,
onSelect,
onLazyDeleteChange,
onCountChange,
onPendingChange,
}: SystemSignaturesContentProps) {
const { signatures, selectedSignatures, setSelectedSignatures, handleDeleteSelected, handleSelectAll, handlePaste } =
useSystemSignaturesData({
systemId,
settings,
onCountChange,
onPendingChange,
onLazyDeleteChange,
});
}: SystemSignaturesContentProps) => {
const { outCommand } = useMapRootState();
const [sortSettings, setSortSettings] = useLocalStorageState<{ sortField: string; sortOrder: SortOrder }>(
'window:signatures:sort',
{ defaultValue: SORT_DEFAULT_VALUES },
);
const [signatures, setSignatures, signaturesRef] = useRefState<SystemSignature[]>([]);
const [selectedSignatures, setSelectedSignatures] = useState<SystemSignature[]>([]);
const [nameColumnWidth, setNameColumnWidth] = useState('auto');
const [selectedSignature, setSelectedSignature] = useState<SystemSignature | null>(null);
const [hoveredSig, setHoveredSig] = useState<SystemSignature | null>(null);
const [sortSettings, setSortSettings] = useLocalStorageState<SystemSignaturesSortSettings>('window:signatures:sort', {
defaultValue: SORT_DEFAULT_VALUES,
});
const tableRef = useRef<HTMLDivElement>(null);
const tooltipRef = useRef<WdTooltipHandlers>(null);
const [hoveredSignature, setHoveredSignature] = useState<SystemSignature | null>(null);
const compact = useMaxWidth(tableRef, 260);
const medium = useMaxWidth(tableRef, 380);
const refData = useRef({ selectable });
refData.current = { selectable };
const isCompact = useMaxWidth(tableRef, COMPACT_MAX_WIDTH);
const isMedium = useMaxWidth(tableRef, MEDIUM_MAX_WIDTH);
const tooltipRef = useRef<WdTooltipHandlers>(null);
const { clipboardContent, setClipboardContent } = useClipboard();
const lazyDeleteValue = useMemo(() => {
return settings.find(setting => setting.key === LAZY_DELETE_SIGNATURES_SETTING)?.value ?? false;
}, [settings]);
const keepLazyDeleteValue = useMemo(() => {
return settings.find(setting => setting.key === KEEP_LAZY_DELETE_SETTING)?.value ?? false;
}, [settings]);
const handleResize = useCallback(() => {
if (tableRef.current) {
const tableWidth = tableRef.current.offsetWidth;
const otherColumnsWidth = 276;
const availableWidth = tableWidth - otherColumnsWidth;
setNameColumnWidth(`${availableWidth}px`);
}
}, []);
const groupSettings = useMemo(() => settings.filter(s => (GROUPS_LIST as string[]).includes(s.key)), [settings]);
const showDescriptionColumn = useMemo(
() => settings.find(s => s.key === SHOW_DESCRIPTION_COLUMN_SETTING)?.value,
[settings],
);
const showUpdatedColumn = useMemo(() => settings.find(s => s.key === SHOW_UPDATED_COLUMN_SETTING)?.value, [settings]);
const filteredSignatures = useMemo(() => {
return signatures
.filter(x => {
if (hideLinkedSignatures && !!x.linked_system) {
return false;
}
const isCosmicSignature = x.kind === COSMIC_SIGNATURE;
const preparedGroup = getGroupIdByRawGroup(x.group);
if (isCosmicSignature) {
const showCosmicSignatures = settings.find(y => y.key === COSMIC_SIGNATURE)?.value;
if (showCosmicSignatures) {
return !x.group || groupSettings.find(y => y.key === preparedGroup)?.value;
} else {
return !!x.group && groupSettings.find(y => y.key === preparedGroup)?.value;
}
}
return settings.find(y => y.key === x.kind)?.value;
})
.sort((a, b) => {
return new Date(b.updated_at || 0).getTime() - new Date(a.updated_at || 0).getTime();
});
}, [signatures, settings, groupSettings, hideLinkedSignatures]);
const handleGetSignatures = useCallback(async () => {
const { signatures } = await outCommand({
type: OutCommand.getSignatures,
data: { system_id: systemId },
});
setSignatures(signatures);
}, [outCommand, systemId]);
const handleUpdateSignatures = useCallback(
async (newSignatures: SystemSignature[], updateOnly: boolean, skipUpdateUntouched?: boolean) => {
const { added, updated, removed } = getActualSigs(
signaturesRef.current,
newSignatures,
updateOnly,
skipUpdateUntouched,
);
const { signatures: updatedSignatures } = await outCommand({
type: OutCommand.updateSignatures,
data: {
system_id: systemId,
added,
updated,
removed,
},
});
setSignatures(() => updatedSignatures);
setSelectedSignatures([]);
},
[outCommand, systemId],
);
const handleDeleteSelected = useCallback(
async (e: KeyboardEvent) => {
if (selectable) {
return;
}
if (selectedSignatures.length === 0) {
return;
}
e.preventDefault();
e.stopPropagation();
const selectedSignaturesEveIds = selectedSignatures.map(x => x.eve_id);
await handleUpdateSignatures(
signatures.filter(x => !selectedSignaturesEveIds.includes(x.eve_id)),
false,
true,
);
},
[handleUpdateSignatures, selectable, signatures, selectedSignatures],
);
const handleSelectAll = useCallback(() => {
setSelectedSignatures(signatures);
}, [signatures]);
const handleSelectSignatures = useCallback(
// TODO still will be good to define types if we use typescript
// @ts-ignore
e => {
if (selectable) {
onSelect?.(e.value);
} else {
setSelectedSignatures(e.value);
}
},
[onSelect, selectable],
);
const handlePaste = async (clipboardContent: string) => {
const newSignatures = parseSignatures(
clipboardContent,
settings.map(x => x.key),
);
handleUpdateSignatures(newSignatures, !lazyDeleteValue);
if (lazyDeleteValue && !keepLazyDeleteValue) {
onLazyDeleteChange?.(false);
}
};
const handleEnterRow = useCallback(
(e: DataTableRowMouseEvent) => {
setHoveredSig(filteredSignatures[e.index]);
tooltipRef.current?.show(e.originalEvent);
},
[filteredSignatures],
);
const handleLeaveRow = useCallback((e: DataTableRowMouseEvent) => {
tooltipRef.current?.hide(e.originalEvent);
setHoveredSig(null);
}, []);
useEffect(() => {
if (selectable) return;
if (!clipboardContent?.text) return;
handlePaste(clipboardContent.text);
setClipboardContent(null);
}, [selectable, clipboardContent]);
useHotkey(true, ['a'], handleSelectAll);
useHotkey(false, ['Backspace', 'Delete'], (event: KeyboardEvent) => {
const targetWindow = (event.target as HTMLHtmlElement)?.closest(`[data-window-id="${SIGNATURE_WINDOW_ID}"]`);
if (!targetWindow) {
if (refData.current.selectable) {
return;
}
event.preventDefault();
event.stopPropagation();
handleDeleteSelected();
if (!clipboardContent?.text) {
return;
}
handlePaste(clipboardContent.text);
setClipboardContent(null);
}, [clipboardContent, selectable, lazyDeleteValue, keepLazyDeleteValue]);
useHotkey(true, ['a'], handleSelectAll);
useHotkey(false, ['Backspace', 'Delete'], handleDeleteSelected);
useEffect(() => {
if (!systemId) {
setSignatures([]);
return;
}
handleGetSignatures();
}, [systemId]);
useMapEventListener(event => {
switch (event.name) {
case Commands.signaturesUpdated:
if (event.data?.toString() !== systemId.toString()) {
return;
}
handleGetSignatures();
return true;
}
});
const [nameColumnWidth, setNameColumnWidth] = useState('auto');
const handleResize = useCallback(() => {
if (!tableRef.current) return;
const tableWidth = tableRef.current.offsetWidth;
const otherColumnsWidth = OTHER_COLUMNS_WIDTH;
setNameColumnWidth(`${tableWidth - otherColumnsWidth}px`);
}, []);
useEffect(() => {
if (!tableRef.current) return;
const observer = new ResizeObserver(handleResize);
observer.observe(tableRef.current);
handleResize();
return () => {
observer.disconnect();
};
}, [handleResize]);
if (tableRef.current) {
observer.observe(tableRef.current);
}
handleResize(); // Call on mount to set initial width
return () => {
if (tableRef.current) {
observer.unobserve(tableRef.current);
}
};
}, []);
const renderToolbar = (/*row: SystemSignature*/) => {
return (
<div className="flex justify-end items-center gap-2 mr-[4px]">
<WdTooltipWrapper content="To Edit Signature do double click">
<span className={clsx(PrimeIcons.PENCIL, 'text-[10px]')}></span>
</WdTooltipWrapper>
</div>
);
};
const [selectedSignatureForDialog, setSelectedSignatureForDialog] = useState<SystemSignature | null>(null);
const [showSignatureSettings, setShowSignatureSettings] = useState(false);
const handleRowClick = (e: DataTableRowClickEvent) => {
setSelectedSignatureForDialog(e.data as SystemSignature);
setSelectedSignature(e.data as SystemSignature);
setShowSignatureSettings(true);
};
const handleSelectSignatures = useCallback(
(e: { value: SystemSignature[] }) => {
if (selectable) {
onSelect?.(e.value[0]);
} else {
setSelectedSignatures(e.value as ExtendedSystemSignature[]);
}
},
[selectable, onSelect, setSelectedSignatures],
);
const showDescriptionColumn = settings.find(s => s.key === SHOW_DESCRIPTION_COLUMN_SETTING)?.value;
const showUpdatedColumn = settings.find(s => s.key === SHOW_UPDATED_COLUMN_SETTING)?.value;
const showCharacterColumn = settings.find(s => s.key === SHOW_CHARACTER_COLUMN_SETTING)?.value;
const enabledGroups = settings
.filter(s => GROUPS_LIST.includes(s.key as SignatureGroup) && s.value === true)
.map(s => s.key);
const filteredSignatures = useMemo<ExtendedSystemSignature[]>(() => {
return signatures.filter(sig => {
if (hideLinkedSignatures && sig.linked_system) {
return false;
}
const isCosmicSignature = sig.kind === COSMIC_SIGNATURE;
if (isCosmicSignature) {
const showCosmic = settings.find(y => y.key === COSMIC_SIGNATURE)?.value;
if (!showCosmic) return false;
if (sig.group) {
const preparedGroup = getGroupIdByRawGroup(sig.group);
return enabledGroups.includes(preparedGroup);
}
return true;
} else {
return settings.find(y => y.key === sig.kind)?.value;
}
});
}, [signatures, hideLinkedSignatures, settings, enabledGroups]);
return (
<div ref={tableRef} className="h-full">
{filteredSignatures.length === 0 ? (
<div className="w-full h-full flex justify-center items-center select-none text-stone-400/80 text-sm">
No signatures
</div>
) : (
<DataTable
value={filteredSignatures}
size="small"
selectionMode="multiple"
selection={selectedSignatures}
metaKeySelection
onSelectionChange={handleSelectSignatures}
dataKey="eve_id"
className="w-full select-none"
resizableColumns={false}
rowHover
selectAll
onRowDoubleClick={handleRowClick}
sortField={sortSettings.sortField}
sortOrder={sortSettings.sortOrder}
onSort={e => setSortSettings({ sortField: e.sortField, sortOrder: e.sortOrder })}
onRowMouseEnter={
isCompact || isMedium
? (e: DataTableRowMouseEvent) => {
setHoveredSignature(filteredSignatures[e.index]);
tooltipRef.current?.show(e.originalEvent);
<>
<div ref={tableRef} className={'h-full '}>
{filteredSignatures.length === 0 ? (
<div className="w-full h-full flex justify-center items-center select-none text-stone-400/80 text-sm">
No signatures
</div>
) : (
<>
{/* @ts-ignore */}
<DataTable
className={classes.Table}
value={filteredSignatures}
size="small"
selectionMode={selectable ? 'single' : 'multiple'}
selection={selectedSignatures}
metaKeySelection
onSelectionChange={handleSelectSignatures}
dataKey="eve_id"
tableClassName="w-full select-none"
resizableColumns={false}
onRowDoubleClick={handleRowClick}
rowHover
selectAll
sortField={sortSettings.sortField}
sortOrder={sortSettings.sortOrder}
onSort={event => setSortSettings(() => ({ sortField: event.sortField, sortOrder: event.sortOrder }))}
onRowMouseEnter={compact || medium ? handleEnterRow : undefined}
onRowMouseLeave={compact || medium ? handleLeaveRow : undefined}
rowClassName={row => {
if (selectedSignatures.some(x => x.eve_id === row.eve_id)) {
return clsx(classes.TableRowCompact, 'bg-amber-500/50 hover:bg-amber-500/70 transition duration-200');
}
: undefined
}
onRowMouseLeave={
isCompact || isMedium
? () => {
setHoveredSignature(null);
tooltipRef.current?.hide();
const dateClass = getRowColorByTimeLeft(row.inserted_at ? new Date(row.inserted_at) : undefined);
if (!dateClass) {
return clsx(classes.TableRowCompact, 'hover:bg-purple-400/20 transition duration-200');
}
: undefined
}
rowClassName={rowData => getSignatureRowClass(rowData as ExtendedSystemSignature, selectedSignatures)}
>
<Column
field="icon"
header=""
headerStyle={headerInlineStyle}
body={sig => renderIcon(sig)}
bodyClassName="p-0 px-1"
style={{ maxWidth: 26, minWidth: 26, width: 26 }}
/>
<Column
field="eve_id"
header="Id"
headerStyle={headerInlineStyle}
bodyClassName="text-ellipsis overflow-hidden whitespace-nowrap"
style={{ maxWidth: 72, minWidth: 72, width: 72 }}
sortable
/>
<Column
field="group"
header="Group"
headerStyle={headerInlineStyle}
bodyClassName="text-ellipsis overflow-hidden whitespace-nowrap"
style={{ maxWidth: 110, minWidth: 110, width: 110 }}
body={sig => sig.group ?? ''}
hidden={isCompact}
sortable
/>
<Column
field="info"
header="Info"
headerStyle={headerInlineStyle}
bodyClassName="text-ellipsis overflow-hidden whitespace-nowrap"
style={{ maxWidth: nameColumnWidth }}
hidden={isCompact || isMedium}
body={renderInfoColumn}
/>
{showDescriptionColumn && (
<Column
field="description"
header="Description"
headerStyle={headerInlineStyle}
bodyClassName="text-ellipsis overflow-hidden whitespace-nowrap"
hidden={isCompact}
body={renderDescription}
sortable
/>
)}
<Column
field="inserted_at"
header="Added"
headerStyle={headerInlineStyle}
dataType="date"
body={renderAddedTimeLeft}
style={{ minWidth: 70, maxWidth: 80 }}
bodyClassName="text-ellipsis overflow-hidden whitespace-nowrap"
sortable
/>
{showUpdatedColumn && (
<Column
field="updated_at"
header="Updated"
headerStyle={headerInlineStyle}
dataType="date"
body={renderUpdatedTimeLeft}
style={{ minWidth: 70, maxWidth: 80 }}
bodyClassName="text-ellipsis overflow-hidden whitespace-nowrap"
sortable
/>
)}
{showCharacterColumn && (
<Column
field="character_name"
header="Character"
bodyClassName="w-[70px] text-ellipsis overflow-hidden whitespace-nowrap"
sortable
></Column>
)}
return clsx(classes.TableRowCompact, dateClass);
}}
>
<Column
bodyClassName="p-0 px-1"
field="group"
body={x => renderIcon(x)}
style={{ maxWidth: 26, minWidth: 26, width: 26, height: 25 }}
></Column>
{!selectable && (
<Column
header=""
headerStyle={headerInlineStyle}
body={() => (
<div className="flex justify-end items-center gap-2 mr-[4px]">
<WdTooltipWrapper content="Double-click a row to edit signature">
<span className={PrimeIcons.PENCIL + ' text-[10px]'} />
</WdTooltipWrapper>
</div>
<Column
field="eve_id"
header="Id"
bodyClassName="text-ellipsis overflow-hidden whitespace-nowrap"
style={{ maxWidth: 72, minWidth: 72, width: 72 }}
sortable
></Column>
<Column
field="group"
header="Group"
bodyClassName="text-ellipsis overflow-hidden whitespace-nowrap"
hidden={compact}
style={{ maxWidth: 110, minWidth: 110, width: 110 }}
sortable
></Column>
<Column
field="info"
bodyClassName="text-ellipsis overflow-hidden whitespace-nowrap"
body={renderInfoColumn}
style={{ maxWidth: nameColumnWidth }}
hidden={compact || medium}
></Column>
{showDescriptionColumn && (
<Column
field="description"
header="Description"
bodyClassName="text-ellipsis overflow-hidden whitespace-nowrap"
body={renderDescription}
hidden={compact}
sortable
></Column>
)}
style={{ maxWidth: 26, minWidth: 26, width: 26 }}
bodyClassName="p-0 pl-1 pr-2"
/>
)}
</DataTable>
)}
<WdTooltip
className="bg-stone-900/95 text-slate-50"
ref={tooltipRef}
content={hoveredSignature ? <SignatureView {...hoveredSignature} /> : null}
/>
<Column
field="inserted_at"
header="Added"
dataType="date"
bodyClassName="w-[70px] text-ellipsis overflow-hidden whitespace-nowrap"
body={renderAddedTimeLeft}
sortable
></Column>
{showSignatureSettings && (
<SignatureSettings
systemId={systemId}
show
onHide={() => setShowSignatureSettings(false)}
signatureData={selectedSignatureForDialog || undefined}
{showUpdatedColumn && (
<Column
field="updated_at"
header="Updated"
dataType="date"
bodyClassName="w-[70px] text-ellipsis overflow-hidden whitespace-nowrap"
body={renderUpdatedTimeLeft}
sortable
></Column>
)}
{!selectable && (
<Column
bodyClassName="p-0 pl-1 pr-2"
field="group"
body={renderToolbar}
// headerClassName={headerClasses}
style={{ maxWidth: 26, minWidth: 26, width: 26 }}
></Column>
)}
</DataTable>
</>
)}
<WdTooltip
className="bg-stone-900/95 text-slate-50"
ref={tooltipRef}
content={hoveredSig ? <SignatureView {...hoveredSig} /> : null}
/>
)}
</div>
{showSignatureSettings && (
<SignatureSettings
systemId={systemId}
show
onHide={() => setShowSignatureSettings(false)}
signatureData={selectedSignature}
/>
)}
</div>
</>
);
}
};

View File

@@ -10,13 +10,6 @@ import {
export const TIME_ONE_MINUTE = 1000 * 60;
export const TIME_TEN_MINUTES = 1000 * 60 * 10;
export const TIME_ONE_DAY = 24 * 60 * 60 * 1000;
export const TIME_ONE_WEEK = 7 * TIME_ONE_DAY;
export const FINAL_DURATION_MS = 10000;
export const COMPACT_MAX_WIDTH = 260;
export const MEDIUM_MAX_WIDTH = 380;
export const OTHER_COLUMNS_WIDTH = 276;
export const GROUPS_LIST = [
SignatureGroup.GasSite,

View File

@@ -1,94 +0,0 @@
import { SystemSignature } from '@/hooks/Mapper/types';
import { FINAL_DURATION_MS } from '../constants';
export interface ExtendedSystemSignature extends SystemSignature {
pendingDeletion?: boolean;
pendingAddition?: boolean;
pendingUntil?: number;
}
export function prepareUpdatePayload(
systemId: string,
added: ExtendedSystemSignature[],
updated: ExtendedSystemSignature[],
removed: ExtendedSystemSignature[],
) {
return {
system_id: systemId,
added: added.map(s => ({ ...s })),
updated: updated.map(s => ({ ...s })),
removed: removed.map(s => ({ ...s })),
};
}
export function schedulePendingAdditionForSig(
sig: ExtendedSystemSignature,
finalDuration: number,
setSignatures: React.Dispatch<React.SetStateAction<ExtendedSystemSignature[]>>,
pendingAdditionMapRef: React.MutableRefObject<Record<string, { finalUntil: number; finalTimeoutId: number }>>,
setPendingUndoAdditions: React.Dispatch<React.SetStateAction<ExtendedSystemSignature[]>>,
) {
setPendingUndoAdditions(prev => [...prev, sig]);
const now = Date.now();
const finalTimeoutId = window.setTimeout(() => {
setSignatures(prev =>
prev.map(x => (x.eve_id === sig.eve_id ? { ...x, pendingAddition: false, pendingUntil: undefined } : x)),
);
const clone = { ...pendingAdditionMapRef.current };
delete clone[sig.eve_id];
pendingAdditionMapRef.current = clone;
setPendingUndoAdditions(prev => prev.filter(x => x.eve_id !== sig.eve_id));
}, finalDuration);
pendingAdditionMapRef.current = {
...pendingAdditionMapRef.current,
[sig.eve_id]: {
finalUntil: now + finalDuration,
finalTimeoutId,
},
};
setSignatures(prev =>
prev.map(x => (x.eve_id === sig.eve_id ? { ...x, pendingAddition: true, pendingUntil: now + finalDuration } : x)),
);
}
export function mergeLocalPendingAdditions(
serverSigs: ExtendedSystemSignature[],
localSigs: ExtendedSystemSignature[],
): ExtendedSystemSignature[] {
const now = Date.now();
const pendingAdditions = localSigs.filter(sig => sig.pendingAddition && sig.pendingUntil && sig.pendingUntil > now);
const mergedMap = new Map<string, ExtendedSystemSignature>();
serverSigs.forEach(sig => mergedMap.set(sig.eve_id, sig));
pendingAdditions.forEach(sig => {
if (!mergedMap.has(sig.eve_id)) {
mergedMap.set(sig.eve_id, sig);
}
});
return Array.from(mergedMap.values());
}
export function scheduleLazyDeletionTimers(
toRemove: ExtendedSystemSignature[],
setPendingMap: React.Dispatch<React.SetStateAction<Record<string, { finalUntil: number; finalTimeoutId: number }>>>,
finalizeRemoval: (sig: ExtendedSystemSignature) => Promise<void>,
finalDuration = FINAL_DURATION_MS,
) {
const now = Date.now();
toRemove.forEach(sig => {
const finalTimeoutId = window.setTimeout(async () => {
await finalizeRemoval(sig);
}, finalDuration);
setPendingMap(prev => ({
...prev,
[sig.eve_id]: {
finalUntil: now + finalDuration,
finalTimeoutId,
},
}));
});
}

View File

@@ -1,67 +1,25 @@
import { SystemSignature } from '@/hooks/Mapper/types';
import { GROUPS_LIST } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants';
import { getState } from './getState';
import { GROUPS_LIST } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants.ts';
import { getState } from './getState.ts';
/**
* Compare two lists of signatures and return which are added, updated, or removed.
*
* @param oldSignatures existing signatures (in memory or from server)
* @param newSignatures newly parsed or incoming signatures from user input
* @param updateOnly if true, do NOT remove old signatures not found in newSignatures
* @param skipUpdateUntouched if true, do NOT push unmodified signatures into the `updated` array
*/
export const getActualSigs = (
oldSignatures: SystemSignature[],
newSignatures: SystemSignature[],
updateOnly?: boolean,
updateOnly: boolean,
skipUpdateUntouched?: boolean,
): { added: SystemSignature[]; updated: SystemSignature[]; removed: SystemSignature[] } => {
const updated: SystemSignature[] = [];
const removed: SystemSignature[] = [];
const added: SystemSignature[] = [];
oldSignatures.forEach(oldSig => {
// if old sigs is not contains in newSigs we need mark it as removed
// otherwise we check
const newSig = newSignatures.find(s => s.eve_id === oldSig.eve_id);
if (newSig) {
const needUpgrade = getState(GROUPS_LIST, newSig) > getState(GROUPS_LIST, oldSig);
const mergedSig = { ...oldSig };
let changed = false;
if (needUpgrade) {
mergedSig.group = newSig.group;
mergedSig.name = newSig.name;
changed = true;
}
if (newSig.description && newSig.description !== oldSig.description) {
mergedSig.description = newSig.description;
changed = true;
}
try {
const oldInfo = JSON.parse(oldSig.custom_info || '{}');
const newInfo = JSON.parse(newSig.custom_info || '{}');
let infoChanged = false;
for (const key in newInfo) {
if (oldInfo[key] !== newInfo[key]) {
oldInfo[key] = newInfo[key];
infoChanged = true;
}
}
if (infoChanged) {
mergedSig.custom_info = JSON.stringify(oldInfo);
changed = true;
}
} catch (e) {
console.error(`getActualSigs: Error merging custom_info for ${oldSig.eve_id}`, e);
}
if (newSig.updated_at !== oldSig.updated_at) {
mergedSig.updated_at = newSig.updated_at;
changed = true;
}
if (changed) {
updated.push(mergedSig);
// we take new sig and now we need check that sig has been updated
const isNeedUpgrade = getState(GROUPS_LIST, newSig) > getState(GROUPS_LIST, oldSig);
if (isNeedUpgrade) {
updated.push({ ...oldSig, group: newSig.group, name: newSig.name });
} else if (!skipUpdateUntouched) {
updated.push({ ...oldSig });
}
@@ -72,12 +30,8 @@ export const getActualSigs = (
}
});
const oldIds = new Set(oldSignatures.map(x => x.eve_id));
newSignatures.forEach(s => {
if (!oldIds.has(s.eve_id)) {
added.push(s);
}
});
const oldSignaturesIds = oldSignatures.map(x => x.eve_id);
const added = newSignatures.filter(s => !oldSignaturesIds.includes(s.eve_id));
return { added, updated, removed };
};

View File

@@ -3,9 +3,9 @@ import {
TIME_TEN_MINUTES,
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants.ts';
export const getRowBackgroundColor = (date: Date | undefined): string => {
export const getRowColorByTimeLeft = (date: Date | undefined) => {
if (!date) {
return '';
return null;
}
const currentDate = new Date();
@@ -18,6 +18,4 @@ export const getRowBackgroundColor = (date: Date | undefined): string => {
if (diff < TIME_TEN_MINUTES) {
return 'bg-lime-700/40 transition hover:bg-lime-700/50';
}
return '';
};

View File

@@ -1,8 +1,11 @@
import { SystemSignature } from '@/hooks/Mapper/types';
// also we need detect changes, we need understand that sigs has states
// first state when kind is Cosmic Signature or Cosmic Anomaly and group is empty
// and we should detect it for ungrade sigs
export const getState = (_: string[], newSig: SystemSignature) => {
let state = -1;
if (!newSig.group) {
if (!newSig.group || newSig.group === '') {
state = 0;
} else if (!newSig.name || newSig.name === '') {
state = 1;

View File

@@ -1,5 +1,3 @@
export * from './getState';
export * from './getRowBackgroundColor';
export * from './getRowColorByTimeLeft';
export * from './getActualSigs';
export * from './contentHelpers';
export * from './rowStyles';

View File

@@ -1,34 +0,0 @@
.pendingDeletion {
background-color: #f87171;
transition: background-color 0.2s ease;
}
.pendingDeletion td {
background-color: #f87171;
transition: background-color 0.2s ease;
}
.pendingDeletion {
background-color: #f87171;
transition: background-color 0.2s ease;
}
.Table thead tr {
font-size: 12px !important;
line-height: 1.333;
}
.TableRowCompact {
font-size: 12px !important;
line-height: 1.333;
}
.Table td {
padding: 2px;
height: 25px;
border: 1px solid #383838;
box-sizing: border-box;
}

View File

@@ -1,20 +0,0 @@
import clsx from 'clsx';
import { ExtendedSystemSignature } from './contentHelpers';
import { getRowBackgroundColor } from './getRowBackgroundColor';
import classes from './rowStyles.module.scss';
export function getSignatureRowClass(
row: ExtendedSystemSignature,
selectedSignatures: ExtendedSystemSignature[],
): string {
const isSelected = selectedSignatures.some(s => s.eve_id === row.eve_id);
return clsx(
classes.TableRowCompact,
'p-selectable-row',
isSelected && 'bg-amber-500/50 hover:bg-amber-500/70 transition duration-200',
!isSelected && row.pendingDeletion && classes.pendingDeletion,
!isSelected && getRowBackgroundColor(row.inserted_at ? new Date(row.inserted_at) : undefined),
'hover:bg-purple-400/20 transition duration-200',
);
}

View File

@@ -1,26 +0,0 @@
import { ExtendedSystemSignature } from '../helpers/contentHelpers';
export interface UseSystemSignaturesDataProps {
systemId: string;
settings: { key: string; value: boolean }[];
hideLinkedSignatures?: boolean;
onCountChange?: (count: number) => void;
onPendingChange?: (pending: ExtendedSystemSignature[], undo: () => void) => void;
onLazyDeleteChange?: (value: boolean) => void;
}
export interface UseFetchingParams {
systemId: string;
signaturesRef: React.MutableRefObject<ExtendedSystemSignature[]>;
setSignatures: React.Dispatch<React.SetStateAction<ExtendedSystemSignature[]>>;
localPendingDeletions: ExtendedSystemSignature[];
}
export interface UsePendingDeletionParams {
systemId: string;
setSignatures: React.Dispatch<React.SetStateAction<ExtendedSystemSignature[]>>;
}
export interface UsePendingAdditionParams {
setSignatures: React.Dispatch<React.SetStateAction<ExtendedSystemSignature[]>>;
}

View File

@@ -1,53 +0,0 @@
import { useState, useCallback, useRef } from 'react';
import { ExtendedSystemSignature, schedulePendingAdditionForSig } from '../helpers/contentHelpers';
import { UsePendingAdditionParams } from './types';
import { FINAL_DURATION_MS } from '../constants';
export function usePendingAdditions({ setSignatures }: UsePendingAdditionParams) {
const [pendingUndoAdditions, setPendingUndoAdditions] = useState<ExtendedSystemSignature[]>([]);
const pendingAdditionMapRef = useRef<Record<string, { finalUntil: number; finalTimeoutId: number }>>({});
const processAddedSignatures = useCallback(
(added: ExtendedSystemSignature[]) => {
if (!added.length) return;
const now = Date.now();
setSignatures(prev => [
...prev,
...added.map(sig => ({
...sig,
pendingAddition: true,
pendingUntil: now + FINAL_DURATION_MS,
})),
]);
added.forEach(sig => {
schedulePendingAdditionForSig(
sig,
FINAL_DURATION_MS,
setSignatures,
pendingAdditionMapRef,
setPendingUndoAdditions,
);
});
},
[setSignatures],
);
const clearPendingAdditions = useCallback(() => {
Object.values(pendingAdditionMapRef.current).forEach(({ finalTimeoutId }) => {
clearTimeout(finalTimeoutId);
});
pendingAdditionMapRef.current = {};
setSignatures(prev =>
prev.map(x => (x.pendingAddition ? { ...x, pendingAddition: false, pendingUntil: undefined } : x)),
);
setPendingUndoAdditions([]);
}, [setSignatures]);
return {
pendingUndoAdditions,
setPendingUndoAdditions,
pendingAdditionMapRef,
processAddedSignatures,
clearPendingAdditions,
};
}

View File

@@ -1,79 +0,0 @@
import { useState, useCallback } from 'react';
import { OutCommand } from '@/hooks/Mapper/types/mapHandlers';
import { ExtendedSystemSignature, prepareUpdatePayload, scheduleLazyDeletionTimers } from '../helpers';
import { UsePendingDeletionParams } from './types';
import { FINAL_DURATION_MS } from '../constants';
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
export function usePendingDeletions({ systemId, setSignatures }: UsePendingDeletionParams) {
const { outCommand } = useMapRootState();
const [localPendingDeletions, setLocalPendingDeletions] = useState<ExtendedSystemSignature[]>([]);
const [pendingDeletionMap, setPendingDeletionMap] = useState<
Record<string, { finalUntil: number; finalTimeoutId: number }>
>({});
const processRemovedSignatures = useCallback(
async (
removed: ExtendedSystemSignature[],
added: ExtendedSystemSignature[],
updated: ExtendedSystemSignature[],
) => {
if (!removed.length) return;
const now = Date.now();
const processedRemoved = removed.map(r => ({
...r,
pendingDeletion: true,
pendingAddition: false,
pendingUntil: now + FINAL_DURATION_MS,
}));
setLocalPendingDeletions(prev => [...prev, ...processedRemoved]);
outCommand({
type: OutCommand.updateSignatures,
data: prepareUpdatePayload(systemId, added, updated, []),
});
setSignatures(prev =>
prev.map(sig => {
if (processedRemoved.find(r => r.eve_id === sig.eve_id)) {
return { ...sig, pendingDeletion: true, pendingUntil: now + FINAL_DURATION_MS };
}
return sig;
}),
);
scheduleLazyDeletionTimers(
processedRemoved,
setPendingDeletionMap,
async sig => {
await outCommand({
type: OutCommand.updateSignatures,
data: prepareUpdatePayload(systemId, [], [], [sig]),
});
setLocalPendingDeletions(prev => prev.filter(x => x.eve_id !== sig.eve_id));
setSignatures(prev => prev.filter(x => x.eve_id !== sig.eve_id));
},
FINAL_DURATION_MS,
);
},
[systemId, outCommand, setSignatures],
);
const clearPendingDeletions = useCallback(() => {
Object.values(pendingDeletionMap).forEach(({ finalTimeoutId }) => clearTimeout(finalTimeoutId));
setPendingDeletionMap({});
setSignatures(prev =>
prev.map(x => (x.pendingDeletion ? { ...x, pendingDeletion: false, pendingUntil: undefined } : x)),
);
setLocalPendingDeletions([]);
}, [pendingDeletionMap, setSignatures]);
return {
localPendingDeletions,
setLocalPendingDeletions,
pendingDeletionMap,
setPendingDeletionMap,
processRemovedSignatures,
clearPendingDeletions,
};
}

View File

@@ -1,75 +0,0 @@
import { useCallback } from 'react';
import { SystemSignature } from '@/hooks/Mapper/types';
import { OutCommand } from '@/hooks/Mapper/types/mapHandlers';
import { ExtendedSystemSignature, prepareUpdatePayload, getActualSigs, mergeLocalPendingAdditions } from '../helpers';
import { UseFetchingParams } from './types';
import { FINAL_DURATION_MS } from '../constants';
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
export function useSignatureFetching({
systemId,
signaturesRef,
setSignatures,
localPendingDeletions,
}: UseFetchingParams) {
const {
data: { characters },
outCommand,
} = useMapRootState();
const handleGetSignatures = useCallback(async () => {
if (!systemId) {
setSignatures([]);
return;
}
if (localPendingDeletions.length) {
return;
}
const resp = await outCommand({
type: OutCommand.getSignatures,
data: { system_id: systemId },
});
const serverSigs = (resp.signatures ?? []) as SystemSignature[];
const extended = serverSigs.map(s => ({
...s,
character_name: characters.find(c => c.eve_id === s.character_eve_id)?.name,
})) as ExtendedSystemSignature[];
setSignatures(prev => mergeLocalPendingAdditions(extended, prev));
}, [characters, systemId, localPendingDeletions, outCommand, setSignatures]);
const handleUpdateSignatures = useCallback(
async (newList: ExtendedSystemSignature[], updateOnly: boolean, skipUpdateUntouched?: boolean) => {
const { added, updated, removed } = getActualSigs(
signaturesRef.current,
newList,
updateOnly,
skipUpdateUntouched,
);
if (added.length > 0) {
const now = Date.now();
setSignatures(prev => [
...prev,
...added.map(a => ({
...a,
pendingAddition: true,
pendingUntil: now + FINAL_DURATION_MS,
})),
]);
}
await outCommand({
type: OutCommand.updateSignatures,
data: prepareUpdatePayload(systemId, added, updated, removed),
});
},
[systemId, outCommand, signaturesRef, setSignatures],
);
return {
handleGetSignatures,
handleUpdateSignatures,
};
}

View File

@@ -1,187 +0,0 @@
import { useCallback, useEffect, useState } from 'react';
import useRefState from 'react-usestateref';
import { useMapEventListener } from '@/hooks/Mapper/events';
import { Commands, SystemSignature } from '@/hooks/Mapper/types';
import { OutCommand } from '@/hooks/Mapper/types/mapHandlers';
import { parseSignatures } from '@/hooks/Mapper/helpers';
import {
KEEP_LAZY_DELETE_SETTING,
LAZY_DELETE_SIGNATURES_SETTING,
} from '@/hooks/Mapper/components/mapInterface/widgets';
import { ExtendedSystemSignature, getActualSigs, mergeLocalPendingAdditions } from '../helpers';
import { useSignatureFetching } from './useSignatureFetching';
import { usePendingAdditions } from './usePendingAdditions';
import { usePendingDeletions } from './usePendingDeletions';
import { UseSystemSignaturesDataProps } from './types';
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
export function useSystemSignaturesData({
systemId,
settings,
onCountChange,
onPendingChange,
onLazyDeleteChange,
}: UseSystemSignaturesDataProps) {
const { outCommand } = useMapRootState();
const [signatures, setSignatures, signaturesRef] = useRefState<ExtendedSystemSignature[]>([]);
const [selectedSignatures, setSelectedSignatures] = useState<ExtendedSystemSignature[]>([]);
const { localPendingDeletions, setLocalPendingDeletions, processRemovedSignatures, clearPendingDeletions } =
usePendingDeletions({
systemId,
setSignatures,
});
const { pendingUndoAdditions, setPendingUndoAdditions, processAddedSignatures, clearPendingAdditions } =
usePendingAdditions({
setSignatures,
});
const { handleGetSignatures, handleUpdateSignatures } = useSignatureFetching({
systemId,
signaturesRef,
setSignatures,
localPendingDeletions,
});
const handlePaste = useCallback(
async (clipboardString: string) => {
const lazyDeleteValue = settings.find(s => s.key === LAZY_DELETE_SIGNATURES_SETTING)?.value ?? false;
const incomingSignatures = parseSignatures(
clipboardString,
settings.map(s => s.key),
) as ExtendedSystemSignature[];
const current = signaturesRef.current;
const currentNonPending = lazyDeleteValue
? current.filter(sig => !sig.pendingDeletion)
: current.filter(sig => !sig.pendingDeletion && !sig.pendingAddition);
const { added, updated, removed } = getActualSigs(currentNonPending, incomingSignatures, !lazyDeleteValue, true);
if (added.length > 0) {
processAddedSignatures(added);
}
if (removed.length > 0) {
await processRemovedSignatures(removed, added, updated);
} else {
const resp = await outCommand({
type: OutCommand.updateSignatures,
data: {
system_id: systemId,
added,
updated,
removed: [],
},
});
if (resp) {
const finalSigs = (resp.signatures ?? []) as SystemSignature[];
setSignatures(prev =>
mergeLocalPendingAdditions(
finalSigs.map(x => ({ ...x })),
prev,
),
);
}
}
const keepLazy = settings.find(s => s.key === KEEP_LAZY_DELETE_SETTING)?.value ?? false;
if (lazyDeleteValue && !keepLazy) {
setTimeout(() => {
onLazyDeleteChange?.(false);
}, 0);
}
},
[
settings,
signaturesRef,
processAddedSignatures,
processRemovedSignatures,
outCommand,
systemId,
setSignatures,
onLazyDeleteChange,
],
);
const handleDeleteSelected = useCallback(async () => {
if (!selectedSignatures.length) return;
const selectedIds = selectedSignatures.map(s => s.eve_id);
const finalList = signatures.filter(s => !selectedIds.includes(s.eve_id));
await handleUpdateSignatures(finalList, false, true);
setSelectedSignatures([]);
}, [selectedSignatures, signatures, handleUpdateSignatures]);
const handleSelectAll = useCallback(() => {
setSelectedSignatures(signatures);
}, [signatures]);
const undoPending = useCallback(() => {
clearPendingDeletions();
clearPendingAdditions();
setSignatures(prev =>
prev.map(x => (x.pendingDeletion ? { ...x, pendingDeletion: false, pendingUntil: undefined } : x)),
);
if (pendingUndoAdditions.length) {
pendingUndoAdditions.forEach(async sig => {
await outCommand({
type: OutCommand.updateSignatures,
data: {
system_id: systemId,
added: [],
updated: [],
removed: [sig],
},
});
});
setSignatures(prev => prev.filter(x => !pendingUndoAdditions.some(u => u.eve_id === x.eve_id)));
setPendingUndoAdditions([]);
}
setLocalPendingDeletions([]);
}, [
clearPendingDeletions,
clearPendingAdditions,
pendingUndoAdditions,
setPendingUndoAdditions,
setLocalPendingDeletions,
setSignatures,
outCommand,
systemId,
]);
useEffect(() => {
const combined = [...localPendingDeletions, ...pendingUndoAdditions];
onPendingChange?.(combined, undoPending);
}, [localPendingDeletions, pendingUndoAdditions, onPendingChange, undoPending]);
useMapEventListener(event => {
if (event.name === Commands.signaturesUpdated && String(event.data) === String(systemId)) {
handleGetSignatures();
return true;
}
});
useEffect(() => {
if (!systemId) {
setSignatures([]);
return;
}
handleGetSignatures();
}, [systemId, handleGetSignatures, setSignatures]);
useEffect(() => {
onCountChange?.(signatures.length);
}, [signatures, onCountChange]);
return {
signatures,
selectedSignatures,
setSelectedSignatures,
handleDeleteSelected,
handleSelectAll,
handlePaste,
};
}

View File

@@ -5,4 +5,3 @@ export * from './renderAddedTimeLeft';
export * from './renderUpdatedTimeLeft';
export * from './renderLinkedSystem';
export * from './renderInfoColumn';
export * from './renderHeaderLabel';

View File

@@ -1,5 +0,0 @@
import { SystemSignaturesHeader, HeaderProps } from '../SystemSignatureHeader/SystemSignatureHeader';
export function renderHeaderLabel(props: HeaderProps) {
return <SystemSignaturesHeader {...props} />;
}

View File

@@ -24,12 +24,6 @@ export const renderInfoColumn = (row: SystemSignature) => {
</WdTooltipWrapper>
)}
{customInfo.isCrit && (
<WdTooltipWrapper offset={5} position={TooltipPosition.top} content="Signature marked as Crit">
<div className="pi pi-clock text-fuchsia-400 text-[11px] mr-[2px]"></div>
</WdTooltipWrapper>
)}
{row.type && (
<WHClassView
className="text-[11px]"

View File

@@ -1,6 +1,6 @@
import { Dialog } from 'primereact/dialog';
import { useCallback, useEffect } from 'react';
import { OutCommand, SignatureGroup, SystemSignature, TimeStatus } from '@/hooks/Mapper/types';
import { OutCommand, SignatureGroup, SystemSignature } from '@/hooks/Mapper/types';
import { Controller, FormProvider, useForm } from 'react-hook-form';
import {
SignatureGroupContent,
@@ -10,7 +10,6 @@ import { InputText } from 'primereact/inputtext';
import { SystemsSettingsProvider } from '@/hooks/Mapper/components/mapRootContent/components/SignatureSettings/Provider.tsx';
import { Button } from 'primereact/button';
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
import { getWhSize } from '@/hooks/Mapper/helpers/getWhSize';
type SystemSignaturePrepared = Omit<SystemSignature, 'linked_system'> & { linked_system: string };
@@ -18,14 +17,11 @@ export interface MapSettingsProps {
systemId: string;
show: boolean;
onHide: () => void;
signatureData: SystemSignature | undefined;
signatureData: SystemSignature | null;
}
export const SignatureSettings = ({ systemId, show, onHide, signatureData }: MapSettingsProps) => {
const {
outCommand,
data: { wormholes },
} = useMapRootState();
const { outCommand } = useMapRootState();
const handleShow = async () => {};
const signatureForm = useForm<Partial<SystemSignaturePrepared>>({});
@@ -51,31 +47,6 @@ export const SignatureSettings = ({ systemId, show, onHide, signatureData }: Map
solar_system_target: values.linked_system,
},
});
if (values.isEOL) {
await outCommand({
type: OutCommand.updateConnectionTimeStatus,
data: {
source: systemId,
target: values.linked_system,
value: TimeStatus.eol,
},
});
}
if (values.type) {
const whShipSize = getWhSize(wormholes, values.type);
if (whShipSize) {
outCommand({
type: OutCommand.updateConnectionShipSizeType,
data: {
source: systemId,
target: values.linked_system,
value: whShipSize,
},
});
}
}
}
out = {

View File

@@ -1,4 +1,4 @@
import { Map, MAP_ROOT_ID } from '@/hooks/Mapper/components/map/Map.tsx';
import { Map } from '@/hooks/Mapper/components/map/Map.tsx';
import { useCallback, useRef, useState } from 'react';
import { OutCommand, OutCommandHandler, SolarSystemConnection } from '@/hooks/Mapper/types';
import { MapRootData, useMapRootState } from '@/hooks/Mapper/mapRootProvider';
@@ -15,7 +15,7 @@ import { Connections } from '@/hooks/Mapper/components/mapRootContent/components
import { ContextMenuSystemMultiple, useContextMenuSystemMultipleHandlers } from '../contexts/ContextMenuSystemMultiple';
import { getSystemById } from '@/hooks/Mapper/helpers';
import { Commands } from '@/hooks/Mapper/types/mapHandlers.ts';
import { Node, useReactFlow, XYPosition } from 'reactflow';
import { Node, XYPosition } from 'reactflow';
import { useCommandsSystems } from '@/hooks/Mapper/mapRootProvider/hooks/api';
import { emitMapEvent, useMapEventListener } from '@/hooks/Mapper/events';
@@ -27,14 +27,13 @@ import {
AddSystemDialog,
SearchOnSubmitCallback,
} from '@/hooks/Mapper/components/mapInterface/components/AddSystemDialog';
import { useHotkey } from '../../hooks/useHotkey';
// TODO: INFO - this component needs for abstract work with Map instance
export const MapWrapper = () => {
const {
update,
outCommand,
data: { selectedConnections, selectedSystems, hubs, systems, linkSignatureToSystem },
data: { selectedConnections, selectedSystems, hubs, systems, connections, linkSignatureToSystem },
interfaceSettings: {
isShowMenu,
isShowMinimap = STORED_INTERFACE_DEFAULT_VALUES.isShowMinimap,
@@ -47,7 +46,6 @@ export const MapWrapper = () => {
} = useMapRootState();
const { deleteSystems } = useDeleteSystems();
const { mapRef, runCommand } = useCommonMapEventProcessor();
const { getNodes } = useReactFlow();
const { updateLinkSignatureToSystem } = useCommandsSystems();
const { open, ...systemContextProps } = useContextMenuSystemHandlers({ systems, hubs, outCommand });
@@ -58,8 +56,8 @@ export const MapWrapper = () => {
const [openAddSystem, setOpenAddSystem] = useState<XYPosition | null>(null);
const [selectedConnection, setSelectedConnection] = useState<SolarSystemConnection | null>(null);
const ref = useRef({ selectedConnections, selectedSystems, systemContextProps, systems, deleteSystems });
ref.current = { selectedConnections, selectedSystems, systemContextProps, systems, deleteSystems };
const ref = useRef({ selectedConnections, selectedSystems, systemContextProps, systems, connections, deleteSystems });
ref.current = { selectedConnections, selectedSystems, systemContextProps, systems, connections, deleteSystems };
useMapEventListener(event => {
runCommand(event);
@@ -116,19 +114,22 @@ export const MapWrapper = () => {
const handleConnectionDbClick = useCallback((e: SolarSystemConnection) => setSelectedConnection(e), []);
const handleDeleteSelected = useCallback(() => {
const restDel = getNodes()
.filter(x => x.selected && !x.data.locked)
.map(x => x.data.id);
const handleManualDelete = useCallback((toDelete: string[]) => {
const restDel = toDelete.filter(x => ref.current.systems.some(y => y.id === x));
if (restDel.length > 0) {
ref.current.deleteSystems(restDel);
}
}, [getNodes]);
}, []);
const onAddSystem: OnMapAddSystemCallback = useCallback(({ coordinates }) => {
setOpenAddSystem(coordinates);
}, []);
const canRemoveConnection = useCallback((connectionId: string) => {
const { connections } = ref.current;
return !connections.some(x => x.id === connectionId);
}, []);
const handleSubmitAddSystem: SearchOnSubmitCallback = useCallback(
async item => {
if (ref.current.systems.some(x => x.system_static_info.solar_system_id === item.value)) {
@@ -147,18 +148,6 @@ export const MapWrapper = () => {
[openAddSystem, outCommand],
);
useHotkey(false, ['Delete'], (event: KeyboardEvent) => {
const targetWindow = (event.target as HTMLHtmlElement)?.closest(`[data-window-id="${MAP_ROOT_ID}"]`);
if (!targetWindow) {
return;
}
event.preventDefault();
event.stopPropagation();
handleDeleteSelected();
});
return (
<>
<Map
@@ -171,11 +160,13 @@ export const MapWrapper = () => {
minimapClasses={!isShowMenu ? classes.MiniMap : undefined}
isShowMinimap={isShowMinimap}
showKSpaceBG={isShowKSpace}
onManualDelete={handleManualDelete}
isThickConnections={isThickConnections}
isShowBackgroundPattern={isShowBackgroundPattern}
isSoftBackground={isSoftBackground}
theme={theme}
onAddSystem={onAddSystem}
canRemoveConnection={canRemoveConnection}
/>
{openSettings != null && (

View File

@@ -1,13 +0,0 @@
import { SHIP_MASSES_SIZE } from '../components/map/constants';
import { ShipSizeStatus } from '../types/connection';
import { WormholeDataRaw } from '../types/wormholes';
export const getWhSize = (whDatas: WormholeDataRaw[], whType: string): ShipSizeStatus | null => {
if (whType === 'K162' || whType == null) return null;
const wormholeData = whDatas.find(wh => wh.name === whType);
if (!wormholeData?.max_mass_per_jump) return null;
return SHIP_MASSES_SIZE[wormholeData.max_mass_per_jump] ?? ShipSizeStatus.large;
};

View File

@@ -16,15 +16,13 @@ export const parseSignatures = (value: string, availableKeys: string[]): SystemS
const kind = MAPPING_TYPE_TO_ENG[sigArrInfo[1] as SignatureKind];
const signature: SystemSignature = {
outArr.push({
eve_id: sigArrInfo[0],
kind: availableKeys.includes(kind) ? kind : SignatureKind.CosmicSignature,
group: sigArrInfo[2] as SignatureGroup,
name: sigArrInfo[3],
type: '',
};
outArr.push(signature);
});
}
return outArr;

View File

@@ -2,13 +2,12 @@ import { WORMHOLES_ADDITIONAL_INFO } from '@/hooks/Mapper/components/map/constan
import { WormholeDataRaw } from '@/hooks/Mapper/types';
export const sortWHClasses = (wormholesData: Record<string, WormholeDataRaw>, statics: string[]) => {
if (!statics || !wormholesData) {
if (!statics) {
return [];
}
return statics
.map(x => wormholesData[x])
.filter(x => !!x)
.map(x => ({ name: x.name, ...WORMHOLES_ADDITIONAL_INFO[x.dest] }))
.sort((a, b) => a.wormholeClassID - b.wormholeClassID)
.map(x => x.name);

View File

@@ -1,9 +1,6 @@
import { createRoot } from 'react-dom/client';
import Mapper from './MapRoot';
const LAST_VERSION_KEY = 'wandererLastVersion';
const UI_LOADED_EVENT = 'ui_loaded';
export default {
_rootEl: null,
_errorCount: 0,
@@ -11,7 +8,7 @@ export default {
mounted() {
// create react root element
const rootEl = document.getElementById(this.el.id);
const activeVersion = localStorage.getItem(LAST_VERSION_KEY);
this._version = this.el.dataset.version;
this._rootEl = createRoot(rootEl!);
const handleError = (error: Error, componentStack: string) => {
@@ -25,7 +22,7 @@ export default {
onError: handleError,
});
this.pushEvent(UI_LOADED_EVENT, { version: activeVersion });
this.pushEvent('ui_loaded');
},
handleEventWrapper(event: string, handler: (payload: any) => void) {
@@ -35,8 +32,7 @@ export default {
},
reconnected() {
const activeVersion = localStorage.getItem(LAST_VERSION_KEY);
this.pushEvent(UI_LOADED_EVENT, { version: activeVersion });
this.pushEvent('ui_loaded');
},
async pushEventAsync(event: string, payload: any) {

View File

@@ -21,6 +21,7 @@ export interface DetailedKill {
victim_ship_type_id?: number | null;
victim_ship_name?: string;
final_blow_char_id?: number | null;
final_blow_char_name?: string;
final_blow_corp_id?: number | null;

View File

@@ -66,7 +66,6 @@ export type CommandInit = {
routes: RoutesList;
options: Record<string, string | boolean>;
reset?: boolean;
is_subscription_active?: boolean;
};
export type CommandAddSystems = SolarSystemRawType[];
export type CommandUpdateSystems = SolarSystemRawType[];

View File

@@ -33,8 +33,6 @@ export type SignatureCustomInfo = {
export type SystemSignature = {
eve_id: string;
character_eve_id?: string;
character_name?: string;
kind: SignatureKind;
name: string;
// SignatureCustomInfo

View File

@@ -1,31 +1,18 @@
import { useCallback, useRef, useState, useEffect } from 'react';
import { useCallback, useRef, useState } from 'react';
import { ContextStoreDataOpts, ProvideConstateDataReturnType, ContextStoreDataUpdate, UpdateFunc } from './types';
import { ContextStoreDataOpts, ProvideConstateDataReturnType, ContextStoreDataUpdate } from './types';
export const useContextStore = <T>(
initialValue: T,
{ notNeedRerender = false, handleBeforeUpdate, onAfterAUpdate }: ContextStoreDataOpts<T> = {},
): ProvideConstateDataReturnType<T> => {
const ref = useRef<T>(initialValue);
const queueRef = useRef<{ valOrFunc: Partial<T> | UpdateFunc<T>; force: boolean }[]>([]);
const [, setRerenderKey] = useState(0);
const refWrapper = useRef({ notNeedRerender, handleBeforeUpdate, onAfterAUpdate });
refWrapper.current = { notNeedRerender, handleBeforeUpdate, onAfterAUpdate };
const update: ContextStoreDataUpdate<T> = useCallback((valOrFunc, force = false) => {
queueRef.current.push({ valOrFunc, force });
}, []);
const processNextQueue = useCallback(() => {
const next = queueRef.current.shift();
if (!next) {
return;
}
const { valOrFunc, force } = next;
// It need to force prevent unnecessary rerendering
// update will create once
const { notNeedRerender, handleBeforeUpdate, onAfterAUpdate } = refWrapper.current;
@@ -89,19 +76,5 @@ export const useContextStore = <T>(
onAfterAUpdate?.(ref.current);
}, []);
useEffect(() => {
let requestId: number;
const process = () => {
processNextQueue();
requestId = requestAnimationFrame(process);
};
process();
return () => {
cancelAnimationFrame(requestId);
};
});
return { update, ref: ref.current };
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -53,11 +53,6 @@ public_api_disabled =
|> get_var_from_path_or_env("WANDERER_PUBLIC_API_DISABLED", "false")
|> String.to_existing_atom()
character_api_disabled =
config_dir
|> get_var_from_path_or_env("WANDERER_CHARACTER_API_DISABLED", "false")
|> String.to_existing_atom()
zkill_preload_disabled =
config_dir
|> get_var_from_path_or_env("WANDERER_ZKILL_PRELOAD_DISABLED", "false")
@@ -128,7 +123,6 @@ config :wanderer_app,
corp_id: System.get_env("WANDERER_CORP_ID", "-1") |> String.to_integer(),
corp_wallet: System.get_env("WANDERER_CORP_WALLET", ""),
public_api_disabled: public_api_disabled,
character_api_disabled: character_api_disabled,
zkill_preload_disabled: zkill_preload_disabled,
map_subscriptions_enabled: map_subscriptions_enabled,
map_connection_auto_expire_hours: map_connection_auto_expire_hours,

View File

@@ -12,6 +12,7 @@ defmodule WandererApp.Api.AccessList do
code_interface do
define(:create, action: :create)
define(:available, action: :available)
define(:new, action: :new)
define(:read, action: :read)
@@ -38,8 +39,7 @@ defmodule WandererApp.Api.AccessList do
end
create :new do
# Added :api_key to the accepted attributes
accept [:name, :description, :owner_id, :api_key]
accept [:name, :description, :owner_id]
primary?(true)
argument :owner_id, :uuid, allow_nil?: false
@@ -48,7 +48,7 @@ defmodule WandererApp.Api.AccessList do
end
update :update do
accept [:name, :description, :owner_id, :api_key]
accept [:name, :description, :owner_id]
primary?(true)
end
@@ -68,10 +68,6 @@ defmodule WandererApp.Api.AccessList do
allow_nil? true
end
attribute :api_key, :string do
allow_nil? true
end
create_timestamp(:inserted_at)
update_timestamp(:updated_at)
end

View File

@@ -11,7 +11,6 @@ defmodule WandererApp.Env do
def invites, do: get_key(:invites, false)
def map_subscriptions_enabled?, do: get_key(:map_subscriptions_enabled, false)
def public_api_disabled?, do: get_key(:public_api_disabled, false)
def character_api_disabled?, do: get_key(:character_api_disabled, false)
def zkill_preload_disabled?, do: get_key(:zkill_preload_disabled, false)
def wallet_tracking_enabled?, do: get_key(:wallet_tracking_enabled, false)
def admins, do: get_key(:admins, [])

View File

@@ -237,12 +237,6 @@ defmodule WandererApp.Map.Server do
|> map_pid!
|> GenServer.cast({&Impl.update_connection_custom_info/2, [connection_info]})
def update_signatures(map_id, signatures_update) when is_binary(map_id),
do:
map_id
|> map_pid!
|> GenServer.cast({&Impl.update_signatures/2, [signatures_update]})
@impl true
def handle_continue(:load_state, state),
do: {:noreply, state |> Impl.load_state(), {:continue, :start_map}}

View File

@@ -4,13 +4,7 @@ defmodule WandererApp.Map.Server.Impl do
"""
require Logger
alias WandererApp.Map.Server.{
AclsImpl,
CharactersImpl,
ConnectionsImpl,
SystemsImpl,
SignaturesImpl
}
alias WandererApp.Map.Server.{AclsImpl, CharactersImpl, ConnectionsImpl, SystemsImpl}
@enforce_keys [
:map_id
@@ -186,9 +180,7 @@ defmodule WandererApp.Map.Server.Impl do
defdelegate update_connection_locked(state, connection_update), to: ConnectionsImpl
defdelegate update_connection_custom_info(state, signatures_update), to: ConnectionsImpl
defdelegate update_signatures(state, signatures_update), to: SignaturesImpl
defdelegate update_connection_custom_info(state, connection_update), to: ConnectionsImpl
def import_settings(%{map_id: map_id} = state, settings, user_id) do
WandererApp.Cache.put(

View File

@@ -1,150 +0,0 @@
defmodule WandererApp.Map.Server.SignaturesImpl do
@moduledoc false
require Logger
alias WandererApp.Map.Server.{Impl, ConnectionsImpl, SystemsImpl}
def update_signatures(
%{map_id: map_id} = state,
%{
solar_system_id: solar_system_id,
character: character,
user_id: user_id,
delete_connection_with_sigs: delete_connection_with_sigs,
added_signatures: added_signatures,
updated_signatures: updated_signatures,
removed_signatures: removed_signatures
} =
_signatures_update
) do
WandererApp.Api.MapSystem.read_by_map_and_solar_system(%{
map_id: map_id,
solar_system_id: solar_system_id
})
|> case do
{:ok, system} ->
character_eve_id = character.eve_id
case not is_nil(character_eve_id) do
true ->
added_signatures =
added_signatures
|> parse_signatures(character_eve_id, system.id)
updated_signatures =
updated_signatures
|> parse_signatures(character_eve_id, system.id)
updated_signatures_eve_ids =
updated_signatures
|> Enum.map(fn s -> s.eve_id end)
removed_signatures_eve_ids =
removed_signatures
|> parse_signatures(character_eve_id, system.id)
|> Enum.map(fn s -> s.eve_id end)
WandererApp.Api.MapSystemSignature.by_system_id!(system.id)
|> Enum.filter(fn s -> s.eve_id in removed_signatures_eve_ids end)
|> Enum.each(fn s ->
if delete_connection_with_sigs && not is_nil(s.linked_system_id) do
state
|> ConnectionsImpl.delete_connection(%{
solar_system_source_id: system.solar_system_id,
solar_system_target_id: s.linked_system_id
})
end
if not is_nil(s.linked_system_id) do
state
|> SystemsImpl.update_system_linked_sig_eve_id(%{
solar_system_id: s.linked_system_id,
linked_sig_eve_id: nil
})
end
s
|> Ash.destroy!()
end)
WandererApp.Api.MapSystemSignature.by_system_id!(system.id)
|> Enum.filter(fn s -> s.eve_id in updated_signatures_eve_ids end)
|> Enum.each(fn s ->
updated = updated_signatures |> Enum.find(fn u -> u.eve_id == s.eve_id end)
if not is_nil(updated) do
s
|> WandererApp.Api.MapSystemSignature.update(
updated
|> Map.put(:updated, System.os_time())
)
end
end)
added_signatures
|> Enum.each(fn s ->
s |> WandererApp.Api.MapSystemSignature.create!()
end)
added_signatures_eve_ids =
added_signatures
|> Enum.map(fn s -> s.eve_id end)
if not is_nil(character) &&
not (added_signatures_eve_ids |> Enum.empty?()) do
WandererApp.User.ActivityTracker.track_map_event(:signatures_added, %{
character_id: character.id,
user_id: user_id,
map_id: map_id,
solar_system_id: system.solar_system_id,
signatures: added_signatures_eve_ids
})
end
if not is_nil(character) &&
not (removed_signatures_eve_ids |> Enum.empty?()) do
WandererApp.User.ActivityTracker.track_map_event(:signatures_removed, %{
character_id: character.id,
user_id: user_id,
map_id: map_id,
solar_system_id: system.solar_system_id,
signatures: removed_signatures_eve_ids
})
end
Impl.broadcast!(map_id, :signatures_updated, system.solar_system_id)
state
_ ->
state
end
_ ->
state
end
end
defp parse_signatures(signatures, character_eve_id, system_id),
do:
signatures
|> Enum.map(fn %{
"eve_id" => eve_id,
"name" => name,
"kind" => kind,
"group" => group
} = signature ->
%{
system_id: system_id,
eve_id: eve_id,
name: name,
description: Map.get(signature, "description"),
kind: kind,
group: group,
type: Map.get(signature, "type"),
custom_info: Map.get(signature, "custom_info"),
character_eve_id: character_eve_id
}
end)
end

View File

@@ -278,7 +278,7 @@ defmodule WandererApp.Map.Server.SystemsImpl do
linked_system_ids
|> Enum.each(fn linked_system_id ->
update_system_linked_sig_eve_id(state, %{
WandererApp.Map.Server.update_system_linked_sig_eve_id(map_id, %{
solar_system_id: linked_system_id,
linked_sig_eve_id: nil
})

View File

@@ -295,34 +295,4 @@ defmodule WandererApp.Maps do
character_eve_ids |> Enum.any?(fn eve_id -> eve_id in acl_roles_eve_ids end)
end
def check_user_can_delete_map(map_slug, current_user) do
map_slug
|> WandererApp.Api.Map.get_map_by_slug()
|> Ash.load([:owner, :acls, :user_permissions], actor: current_user)
|> case do
{:ok,
%{
user_permissions: user_permissions,
owner_id: owner_id
} = map} ->
user_permissions =
WandererApp.Permissions.get_map_permissions(
user_permissions,
owner_id,
current_user.characters |> Enum.map(& &1.id)
)
case user_permissions.delete_map do
true ->
{:ok, map}
_ ->
{:error, :not_authorized}
end
error ->
{:error, error}
end
end
end

View File

@@ -730,7 +730,7 @@ defmodule WandererAppWeb.CoreComponents do
)
~H"""
<div
<label
phx-feedback-for={@field.name}
class={[
"form-control",
@@ -762,7 +762,7 @@ defmodule WandererAppWeb.CoreComponents do
<div for="form_description" class="label">
<.error :for={msg <- @errors}><%= msg %></.error>
</div>
</div>
</label>
"""
end

View File

@@ -64,18 +64,6 @@ defmodule WandererAppWeb.Layouts do
"""
end
def donate_container(assigns) do
~H"""
<.link
href="https://www.patreon.com/WandererLtd"
target="_blank"
class="flex flex-col p-4 items-center absolute bottom-52 left-1 gap-2 tooltip tooltip-right text-gray-400 hover:text-white"
>
<.icon name="hero-banknotes-solid" class="h-4 w-4" />
</.link>
"""
end
def feedback_container(assigns) do
~H"""
<.link

View File

@@ -17,7 +17,6 @@
/>
</aside>
<.ping_container rtt_class={@rtt_class} />
<.donate_container />
<.feedback_container />
<.new_version_banner app_version={@app_version} />
</div>

View File

@@ -1,84 +0,0 @@
defmodule WandererAppWeb.MapCharacters do
use WandererAppWeb, :live_component
use LiveViewEvents
@impl true
def mount(socket) do
{:ok, socket}
end
@impl true
def update(
assigns,
socket
) do
{:ok,
socket
|> handle_info_or_assign(assigns)}
end
# attr(:groups, :any, required: true)
# attr(:character_settings, :any, required: true)
def render(assigns) do
~H"""
<div id={@id}>
<ul :for={group <- @groups} class="space-y-4 border-t border-b border-gray-200 py-4">
<li :for={character <- group.characters}>
<div class="flex items-center justify-between w-full space-x-2 p-1 hover:bg-gray-900">
<.character_entry character={character} character_settings={@character_settings} />
<button
phx-click="untrack"
phx-value-event-data={character.id}
class="btn btn-sm btn-icon"
>
<.icon name="hero-eye-slash" class="h-5 w-5" /> Untrack
</button>
</div>
</li>
</ul>
</div>
"""
end
attr(:character, :any, required: true)
attr(:character_settings, :any, required: true)
defp character_entry(assigns) do
~H"""
<div class="flex items-center gap-3 text-sm w-[450px]">
<span
:if={is_tracked?(@character.id, @character_settings)}
class="text-green-500 rounded-full px-2 py-1"
>
Tracked
</span>
<div class="avatar">
<div class="rounded-md w-8 h-8">
<img src={member_icon_url(@character.eve_id)} alt={@character.name} />
</div>
</div>
<span><%= @character.name %></span>
<span :if={@character.alliance_ticker}>[<%= @character.alliance_ticker %>]</span>
<span :if={@character.corporation_ticker}>[<%= @character.corporation_ticker %>]</span>
</div>
"""
end
@impl true
def handle_event("undo", %{"event-data" => event_data} = _params, socket) do
# notify_to(socket.assigns.notify_to, socket.assigns.event_name, map_slug)
{:noreply, socket}
end
defp is_tracked?(character_id, character_settings) do
Enum.any?(character_settings, fn setting ->
setting.character_id == character_id && setting.tracked
end)
end
defp get_event_name(name), do: name
defp get_event_data(_name, data), do: Jason.encode!(data)
end

View File

@@ -1,259 +0,0 @@
defmodule WandererAppWeb.MapAccessListAPIController do
@moduledoc """
API endpoints for managing Access Lists.
Endpoints:
- GET /api/map/acls?map_id=... or ?slug=... (list ACLs)
- POST /api/map/acls (create ACL)
- GET /api/acls/:id (show ACL)
- PUT /api/acls/:id (update ACL)
ACL members are managed via a separate controller.
"""
use WandererAppWeb, :controller
alias WandererApp.Api.{AccessList, Character}
alias WandererAppWeb.UtilAPIController, as: Util
import Ash.Query
require Logger
@doc """
GET /api/map/acls?map_id=... or ?slug=...
Lists the ACLs for a given map.
"""
def index(conn, params) do
case Util.fetch_map_id(params) do
{:ok, map_identifier} ->
with {:ok, map} <- get_map(map_identifier),
# Load ACLs and each ACL's :owner in a single pass:
{:ok, loaded_map} <- Ash.load(map, acls: [:owner]) do
acls = loaded_map.acls || []
json(conn, %{data: Enum.map(acls, &acl_to_list_json/1)})
else
{:error, :map_not_found} ->
conn
|> put_status(:not_found)
|> json(%{error: "Map not found"})
{:error, error} ->
conn
|> put_status(:internal_server_error)
|> json(%{error: inspect(error)})
end
{:error, msg} ->
conn
|> put_status(:bad_request)
|> json(%{error: msg})
end
end
@doc """
POST /api/map/acls
Creates a new ACL for a map.
"""
def create(conn, params) do
with {:ok, map_identifier} <- Util.fetch_map_id(params),
{:ok, map} <- get_map(map_identifier),
%{"acl" => acl_params} <- params,
owner_eve_id when not is_nil(owner_eve_id) <- Map.get(acl_params, "owner_eve_id"),
owner_eve_id_str = to_string(owner_eve_id),
{:ok, character} <- find_character_by_eve_id(owner_eve_id_str),
{:ok, new_api_key} <- {:ok, UUID.uuid4()},
new_params <-
acl_params
|> Map.delete("owner_eve_id")
|> Map.put("owner_id", character.id)
|> Map.put("api_key", new_api_key),
{:ok, new_acl} <- AccessList.new(new_params),
{:ok, _updated_map} <- associate_acl_with_map(map, new_acl) do
json(conn, %{data: acl_to_json(new_acl)})
else
nil ->
conn
|> put_status(:bad_request)
|> json(%{error: "Missing required field: owner_eve_id"})
{:error, "owner_eve_id does not match any existing character"} = error ->
conn
|> put_status(:bad_request)
|> json(%{error: inspect(error)})
# For any other error, also a bad request—adjust if you want a different code
error ->
conn
|> put_status(:bad_request)
|> json(%{error: inspect(error)})
end
end
@doc """
GET /api/acls/:id
Shows a specific ACL (with its members).
"""
def show(conn, %{"id" => id}) do
query =
AccessList
|> Ash.Query.new()
|> filter(id == ^id)
case WandererApp.Api.read(query) do
{:ok, [acl]} ->
# We load members for a single ACL
case Ash.load(acl, :members) do
{:ok, loaded_acl} ->
json(conn, %{data: acl_to_json(loaded_acl)})
{:error, error} ->
conn
|> put_status(:internal_server_error)
|> json(%{error: "Failed to load ACL members: #{inspect(error)}"})
end
{:ok, []} ->
conn
|> put_status(:not_found)
|> json(%{error: "ACL not found"})
{:error, error} ->
conn
|> put_status(:internal_server_error)
|> json(%{error: "Error reading ACL: #{inspect(error)}"})
end
end
@doc """
PUT /api/acls/:id
Updates an ACL.
"""
def update(conn, %{"id" => id, "acl" => acl_params}) do
with {:ok, acl} <- AccessList.by_id(id),
{:ok, updated_acl} <- AccessList.update(acl, acl_params),
{:ok, updated_acl} <- Ash.load(updated_acl, :members) do
json(conn, %{data: acl_to_json(updated_acl)})
else
{:error, error} ->
conn
|> put_status(:bad_request)
|> json(%{error: "Failed to update ACL: #{inspect(error)}"})
end
end
# ---------------------------------------------------------------------------
# Private / Helper Functions
# ---------------------------------------------------------------------------
defp get_map(map_identifier) do
# If your WandererApp.Api.Map.by_id/1 returns :map_not_found or
# returns {:ok, map}/{:error, ...}, you can handle that here
WandererApp.Api.Map.by_id(map_identifier)
end
defp acl_to_json(acl) do
members =
case acl.members do
%Ash.NotLoaded{} -> []
list when is_list(list) -> Enum.map(list, &member_to_json/1)
_ -> []
end
%{
id: acl.id,
name: acl.name,
description: acl.description,
owner_id: acl.owner_id,
api_key: acl.api_key,
inserted_at: acl.inserted_at,
updated_at: acl.updated_at,
members: members
}
end
defp acl_to_list_json(acl) do
# Because we loaded :owner for each ACL in index/2, we can reference it here
owner_eve_id =
case acl.owner do
%Character{eve_id: eid} -> eid
_ -> nil
end
%{
id: acl.id,
name: acl.name,
description: acl.description,
owner_eve_id: owner_eve_id,
inserted_at: acl.inserted_at,
updated_at: acl.updated_at
}
end
defp member_to_json(member) do
%{
id: member.id,
name: member.name,
role: member.role,
eve_character_id: member.eve_character_id,
inserted_at: member.inserted_at,
updated_at: member.updated_at
}
end
# Helper to find a character by external EVE id.
defp find_character_by_eve_id(eve_id) do
query =
Character
|> Ash.Query.new()
|> filter(eve_id == ^eve_id)
case WandererApp.Api.read(query) do
{:ok, [character]} ->
{:ok, character}
{:ok, []} ->
{:error, "owner_eve_id does not match any existing character"}
other ->
other
end
end
# Helper to find a character by internal id.
defp find_character_by_id(id) do
query =
Character
|> Ash.Query.new()
|> filter(id == ^id)
case WandererApp.Api.read(query) do
{:ok, [character]} -> {:ok, character}
{:ok, []} -> {:error, "Character not found"}
other -> other
end
end
# Helper to associate a new ACL with a map.
defp associate_acl_with_map(map, new_acl) do
with {:ok, api_map} <- WandererApp.Api.Map.by_id(map.id),
{:ok, loaded_map} <- Ash.load(api_map, :acls) do
new_acl_id = if is_binary(new_acl), do: new_acl, else: new_acl.id
current_acls = loaded_map.acls || []
updated_acls = current_acls ++ [new_acl_id]
case WandererApp.Api.Map.update_acls(loaded_map, %{acls: updated_acls}) do
{:ok, updated_map} ->
{:ok, updated_map}
{:error, error} ->
Logger.error("Failed to update map #{loaded_map.id} with new ACL: #{inspect(error)}")
{:error, error}
end
else
error ->
Logger.error("Error loading map ACLs: #{inspect(error)}")
{:error, error}
end
end
end

View File

@@ -1,218 +0,0 @@
defmodule WandererAppWeb.AccessListMemberAPIController do
@moduledoc """
Handles creation, role updates, and deletion of individual ACL members.
This controller supports creation of members by accepting one of the following keys:
- "eve_character_id"
- "eve_corporation_id"
- "eve_alliance_id"
For corporation and alliance members, roles "admin" and "manager" are disallowed.
"""
use WandererAppWeb, :controller
alias WandererApp.Api.AccessListMember
import Ash.Query
require Logger
@doc """
POST /api/acls/:acl_id/members
"""
def create(conn, %{"acl_id" => acl_id, "member" => member_params}) do
chosen =
cond do
Map.has_key?(member_params, "eve_corporation_id") ->
{"eve_corporation_id", "corporation"}
Map.has_key?(member_params, "eve_alliance_id") ->
{"eve_alliance_id", "alliance"}
Map.has_key?(member_params, "eve_character_id") ->
{"eve_character_id", "character"}
true ->
nil
end
if is_nil(chosen) do
conn
|> put_status(:bad_request)
|> json(%{
error:
"Missing one of eve_character_id, eve_corporation_id, or eve_alliance_id in payload"
})
else
{key, type} = chosen
raw_id = Map.get(member_params, key)
id_str = to_string(raw_id) # handle string/integer input
role = Map.get(member_params, "role", "viewer")
if type in ["corporation", "alliance"] and role in ["admin", "manager"] do
conn
|> put_status(:bad_request)
|> json(%{
error:
"#{String.capitalize(type)} members cannot have an admin or manager role"
})
else
info_fetcher =
case type do
"character" -> &WandererApp.Esi.get_character_info/1
"corporation" -> &WandererApp.Esi.get_corporation_info/1
"alliance" -> &WandererApp.Esi.get_alliance_info/1
end
with {:ok, entity_info} <- info_fetcher.(id_str) do
member_name = Map.get(entity_info, "name")
new_params =
member_params
|> Map.drop(["eve_corporation_id", "eve_alliance_id", "eve_character_id"])
|> Map.put(key, id_str)
|> Map.put("name", member_name)
|> Map.put("access_list_id", acl_id)
case AccessListMember.create(new_params) do
{:ok, new_member} ->
json(conn, %{data: member_to_json(new_member)})
{:error, error} ->
conn
|> put_status(:bad_request)
|> json(%{error: "Creation failed: #{inspect(error)}"})
end
else
{:error, error} ->
conn
|> put_status(:bad_request)
|> json(%{error: "Entity lookup failed: #{inspect(error)}"})
end
end
end
end
@doc """
PUT /api/acls/:acl_id/members/:member_id
"""
def update_role(conn, %{
"acl_id" => acl_id,
"member_id" => external_id,
"member" => member_params
}) do
# Convert external_id to string if you expect it may come in as integer
external_id_str = to_string(external_id)
membership_query =
AccessListMember
|> Ash.Query.new()
|> filter(access_list_id == ^acl_id)
|> filter(
eve_character_id == ^external_id_str or
eve_corporation_id == ^external_id_str or
eve_alliance_id == ^external_id_str
)
case WandererApp.Api.read(membership_query) do
{:ok, [membership]} ->
new_role = Map.get(member_params, "role", membership.role)
member_type =
cond do
membership.eve_corporation_id -> "corporation"
membership.eve_alliance_id -> "alliance"
membership.eve_character_id -> "character"
true -> "character"
end
if member_type in ["corporation", "alliance"] and new_role in ["admin", "manager"] do
conn
|> put_status(:bad_request)
|> json(%{
error:
"#{String.capitalize(member_type)} members cannot have an admin or manager role"
})
else
case AccessListMember.update_role(membership, member_params) do
{:ok, updated_membership} ->
json(conn, %{data: member_to_json(updated_membership)})
{:error, error} ->
conn
|> put_status(:bad_request)
|> json(%{error: inspect(error)})
end
end
{:ok, []} ->
conn
|> put_status(:not_found)
|> json(%{error: "Membership not found for given ACL and external id"})
{:error, error} ->
conn
|> put_status(:internal_server_error)
|> json(%{error: inspect(error)})
end
end
@doc """
DELETE /api/acls/:acl_id/members/:member_id
"""
def delete(conn, %{"acl_id" => acl_id, "member_id" => external_id}) do
external_id_str = to_string(external_id)
membership_query =
AccessListMember
|> Ash.Query.new()
|> filter(access_list_id == ^acl_id)
|> filter(
eve_character_id == ^external_id_str or
eve_corporation_id == ^external_id_str or
eve_alliance_id == ^external_id_str
)
case WandererApp.Api.read(membership_query) do
{:ok, [membership]} ->
case AccessListMember.destroy(membership) do
:ok ->
json(conn, %{ok: true})
{:error, error} ->
conn
|> put_status(:bad_request)
|> json(%{error: inspect(error)})
end
{:ok, []} ->
conn
|> put_status(:not_found)
|> json(%{error: "Membership not found for given ACL and external id"})
{:error, error} ->
conn
|> put_status(:internal_server_error)
|> json(%{error: inspect(error)})
end
end
# ---------------------------------------------------------------------------
# Private Helpers
# ---------------------------------------------------------------------------
@doc false
defp member_to_json(member) do
base = %{
id: member.id,
name: member.name,
role: member.role,
inserted_at: member.inserted_at,
updated_at: member.updated_at
}
cond do
member.eve_character_id -> Map.put(base, :eve_character_id, member.eve_character_id)
member.eve_corporation_id -> Map.put(base, :eve_corporation_id, member.eve_corporation_id)
member.eve_alliance_id -> Map.put(base, :eve_alliance_id, member.eve_alliance_id)
true -> base
end
end
end

View File

@@ -1,39 +0,0 @@
defmodule WandererAppWeb.CharactersAPIController do
@moduledoc """
Exposes an endpoint for listing ALL characters in the database
Endpoint:
GET /api/characters
"""
use WandererAppWeb, :controller
alias WandererApp.Api.Character
@doc """
GET /api/characters
Lists ALL characters in the database
Returns an array of objects, each with `id`, `eve_id`, `name`, etc.
"""
def index(conn, _params) do
case WandererApp.Api.read(Character) do
{:ok, characters} ->
result =
characters
|> Enum.map(&%{
id: &1.id,
eve_id: &1.eve_id,
name: &1.name,
corporation_name: &1.corporation_name,
alliance_name: &1.alliance_name
})
json(conn, %{data: result})
{:error, error} ->
conn
|> put_status(:internal_server_error)
|> json(%{error: inspect(error)})
end
end
end

View File

@@ -1,55 +0,0 @@
defmodule WandererAppWeb.Plugs.CheckAclApiKey do
@moduledoc """
A plug that checks the "Authorization: Bearer <token>" header
against the ACLs stored api_key.
"""
import Plug.Conn
alias WandererApp.Repo
alias WandererApp.Api.AccessList
def init(opts), do: opts
def call(conn, _opts) do
header = get_req_header(conn, "authorization") |> List.first()
case header do
"Bearer " <> incoming_token ->
acl_id = conn.params["id"] || conn.params["acl_id"]
if acl_id do
case Repo.get(AccessList, acl_id) do
nil ->
conn
|> send_resp(404, "ACL not found")
|> halt()
acl ->
cond do
is_nil(acl.api_key) ->
conn
|> send_resp(401, "Unauthorized (no API key set for ACL)")
|> halt()
acl.api_key == incoming_token ->
conn
true ->
conn
|> send_resp(401, "Unauthorized (invalid API key for ACL)")
|> halt()
end
end
else
conn
|> send_resp(400, "ACL ID not provided")
|> halt()
end
_ ->
conn
|> send_resp(401, "Missing or invalid 'Bearer' token")
|> halt()
end
end
end

View File

@@ -1,15 +0,0 @@
defmodule WandererAppWeb.Plugs.CheckCharacterApiDisabled do
import Plug.Conn
def init(opts), do: opts
def call(conn, _opts) do
if WandererApp.Env.character_api_disabled?() do
conn
|> send_resp(403, "Character API is disabled")
|> halt()
else
conn
end
end
end

View File

@@ -5,7 +5,6 @@ defmodule WandererAppWeb.Plugs.CheckMapApiKey do
"""
import Plug.Conn
alias WandererAppWeb.UtilAPIController, as: Util
def init(opts), do: opts
@@ -14,19 +13,27 @@ defmodule WandererAppWeb.Plugs.CheckMapApiKey do
case header do
"Bearer " <> incoming_token ->
case fetch_map(conn.query_params) do
{:ok, map} ->
if map.public_api_key == incoming_token do
conn
else
conn
|> send_resp(401, "Unauthorized (invalid token for map)")
|> halt()
case fetch_map_id(conn.query_params) do
{:ok, map_id} ->
case WandererApp.Api.Map.by_id(map_id) do
{:ok, map} ->
if map.public_api_key == incoming_token do
conn
else
conn
|> send_resp(401, "Unauthorized (invalid token for map)")
|> halt()
end
{:error, _reason} ->
conn
|> send_resp(404, "Map not found")
|> halt()
end
{:error, _reason} ->
{:error, msg} ->
conn
|> send_resp(404, "Map not found")
|> send_resp(400, msg)
|> halt()
end
@@ -37,13 +44,19 @@ defmodule WandererAppWeb.Plugs.CheckMapApiKey do
end
end
defp fetch_map(query_params) do
case Util.fetch_map_id(query_params) do
{:ok, map_id} ->
WandererApp.Api.Map.by_id(map_id)
defp fetch_map_id(%{"map_id" => mid}) when is_binary(mid) and mid != "" do
{:ok, mid}
end
error ->
error
defp fetch_map_id(%{"slug" => slug}) when is_binary(slug) and slug != "" do
case WandererApp.Api.Map.get_map_by_slug(slug) do
{:ok, map} ->
{:ok, map.id}
{:error, _reason} ->
{:error, "No map found for slug=#{slug}"}
end
end
defp fetch_map_id(_), do: {:error, "Must provide either ?map_id=UUID or ?slug=SLUG"}
end

View File

@@ -1,46 +0,0 @@
defmodule WandererAppWeb.Plugs.CheckMapSubscription do
@moduledoc """
A plug that checks the Map has active subscription
Halts with 401 if no active subscription.
"""
import Plug.Conn
def init(opts), do: opts
def call(conn, _opts) do
case fetch_map_id(conn.query_params) do
{:ok, map_id} ->
{:ok, is_subscription_active} = map_id |> WandererApp.Map.is_subscription_active?()
if is_subscription_active do
conn
else
conn
|> send_resp(401, "Unauthorized (map subscription not active)")
|> halt()
end
{:error, msg} ->
conn
|> send_resp(400, msg)
|> halt()
end
end
defp fetch_map_id(%{"map_id" => mid}) when is_binary(mid) and mid != "" do
{:ok, mid}
end
defp fetch_map_id(%{"slug" => slug}) when is_binary(slug) and slug != "" do
case WandererApp.Api.Map.get_map_by_slug(slug) do
{:ok, map} ->
{:ok, map.id}
{:error, _reason} ->
{:error, "No map found for slug=#{slug}"}
end
end
defp fetch_map_id(_), do: {:error, "Must provide either ?map_id=UUID or ?slug=SLUG"}
end

View File

@@ -314,24 +314,6 @@ defmodule WandererAppWeb.AccessListsLive do
end
end
def handle_event("generate-api-key", _params, socket) do
new_api_key = UUID.uuid4()
new_params = Map.put(socket.assigns.form.params || %{}, "api_key", new_api_key)
form = AshPhoenix.Form.validate(socket.assigns.form, new_params)
{:noreply, assign(socket, form: form)}
end
@impl true
def handle_event("noop", _, socket) do
{:noreply, socket}
end
@impl true
def handle_event(event, body, socket) do
Logger.warning(fn -> "unhandled event: #{event} #{inspect(body)}" end)
{:noreply, socket}
end
@impl true
def handle_info(
{"update_role", %{member_id: member_id, role: role}},
@@ -346,6 +328,17 @@ defmodule WandererAppWeb.AccessListsLive do
{:noreply, socket |> maybe_update_role(member, role_atom, access_list)}
end
@impl true
def handle_event("noop", _, socket) do
{:noreply, socket}
end
@impl true
def handle_event(event, body, socket) do
Logger.warning(fn -> "unhandled event: #{event} #{inspect(body)}" end)
{:noreply, socket}
end
@impl true
def handle_info({:search, text}, socket) do
active_character_id =

View File

@@ -142,50 +142,6 @@
placeholder="Select an owner"
options={Enum.map(@characters, fn character -> {character.label, character.id} end)}
/>
<!-- Divider between above inputs and the API key section -->
<hr class="my-4 border-gray-600" />
<!-- API Key Section with grid layout -->
<div class="mt-2">
<label class="block text-sm font-medium text-gray-200 mb-1">ACL API key</label>
<div class="grid grid-cols-12 gap-2">
<div class="col-span-7">
<.input
type="text"
field={f[:api_key]}
placeholder="No API Key yet"
readonly
class="w-full"
/>
</div>
<div class="col-span-3">
<.button
type="button"
phx-click="generate-api-key"
class="p-button p-component p-button-primary w-full"
style="min-width: 0;"
>
<span class="p-button-label">Generate</span>
</.button>
</div>
<div class="col-span-2">
<.button
type="button"
phx-hook="CopyToClipboard"
id="copy-acl-api-key"
data-url={f[:api_key].value}
disabled={is_nil(f[:api_key].value) or f[:api_key].value == ""}
class={"p-button p-component w-full " <> if(is_nil(f[:api_key].value) or f[:api_key].value == "", do: "p-disabled", else: "")}
>
<span class="p-button-label">Copy</span>
</.button>
</div>
</div>
</div>
<hr class="my-4 border-gray-600" />
<div class="modal-action">
<.button class="mt-2" type="submit" phx-disable-with="Saving...">
<%= (@live_action == :create && "Create") || "Save" %>

View File

@@ -128,26 +128,18 @@ defmodule WandererAppWeb.MapCoreEventHandler do
socket
end
def handle_ui_event(
"ui_loaded",
%{"version" => version},
%{assigns: %{map_slug: map_slug, app_version: app_version} = assigns} = socket
) do
is_version_valid? = to_string(version) == to_string(app_version)
def handle_ui_event("ui_loaded", _body, %{assigns: %{map_slug: map_slug} = assigns} = socket) do
assigns
|> Map.get(:map_id)
|> case do
map_id when not is_nil(map_id) ->
maybe_start_map(map_id)
if is_version_valid? do
assigns
|> Map.get(:map_id)
|> case do
map_id when not is_nil(map_id) ->
maybe_start_map(map_id)
_ ->
WandererApp.Cache.insert("map_#{map_slug}:ui_loaded", true)
end
_ ->
WandererApp.Cache.insert("map_#{map_slug}:ui_loaded", true)
end
{:noreply, socket |> assign(:is_version_valid?, is_version_valid?)}
{:noreply, socket}
end
def handle_ui_event(

View File

@@ -89,30 +89,132 @@ defmodule WandererAppWeb.MapSignaturesEventHandler do
}
} = socket
) do
first_character_eve_id =
user_characters |> List.first()
character =
current_user.characters
|> Enum.find(fn c -> c.eve_id === first_character_eve_id end)
delete_connection_with_sigs =
map_user_settings
|> WandererApp.MapUserSettingsRepo.to_form_data!()
|> WandererApp.MapUserSettingsRepo.get_boolean_setting("delete_connection_with_sigs")
map_id
|> WandererApp.Map.Server.update_signatures(%{
solar_system_id: solar_system_id |> String.to_integer(),
character: character,
user_id: current_user.id,
delete_connection_with_sigs: delete_connection_with_sigs,
added_signatures: added_signatures,
updated_signatures: updated_signatures,
removed_signatures: removed_signatures
WandererApp.Api.MapSystem.read_by_map_and_solar_system(%{
map_id: map_id,
solar_system_id: solar_system_id |> String.to_integer()
})
|> case do
{:ok, system} ->
first_character_eve_id =
user_characters |> List.first()
{:noreply, socket}
case not is_nil(first_character_eve_id) do
true ->
added_signatures =
added_signatures
|> parse_signatures(first_character_eve_id, system.id)
updated_signatures =
updated_signatures
|> parse_signatures(first_character_eve_id, system.id)
updated_signatures_eve_ids =
updated_signatures
|> Enum.map(fn s -> s.eve_id end)
removed_signatures_eve_ids =
removed_signatures
|> parse_signatures(first_character_eve_id, system.id)
|> Enum.map(fn s -> s.eve_id end)
delete_connection_with_sigs =
map_user_settings
|> WandererApp.MapUserSettingsRepo.to_form_data!()
|> WandererApp.MapUserSettingsRepo.get_boolean_setting(
"delete_connection_with_sigs"
)
WandererApp.Api.MapSystemSignature.by_system_id!(system.id)
|> Enum.filter(fn s -> s.eve_id in removed_signatures_eve_ids end)
|> Enum.each(fn s ->
if delete_connection_with_sigs && not is_nil(s.linked_system_id) do
map_id
|> WandererApp.Map.Server.delete_connection(%{
solar_system_source_id: system.solar_system_id,
solar_system_target_id: s.linked_system_id
})
end
if not is_nil(s.linked_system_id) do
map_id
|> WandererApp.Map.Server.update_system_linked_sig_eve_id(%{
solar_system_id: s.linked_system_id,
linked_sig_eve_id: nil
})
end
s
|> Ash.destroy!()
end)
WandererApp.Api.MapSystemSignature.by_system_id!(system.id)
|> Enum.filter(fn s -> s.eve_id in updated_signatures_eve_ids end)
|> Enum.each(fn s ->
updated = updated_signatures |> Enum.find(fn u -> u.eve_id == s.eve_id end)
if not is_nil(updated) do
s
|> WandererApp.Api.MapSystemSignature.update(
updated
|> Map.put(:updated, System.os_time())
)
end
end)
added_signatures
|> Enum.each(fn s ->
s |> WandererApp.Api.MapSystemSignature.create!()
end)
added_signatures_eve_ids =
added_signatures
|> Enum.map(fn s -> s.eve_id end)
first_tracked_character =
current_user.characters
|> Enum.find(fn c -> c.eve_id === first_character_eve_id end)
if not is_nil(first_tracked_character) &&
not (added_signatures_eve_ids |> Enum.empty?()) do
WandererApp.User.ActivityTracker.track_map_event(:signatures_added, %{
character_id: first_tracked_character.id,
user_id: current_user.id,
map_id: map_id,
solar_system_id: system.solar_system_id,
signatures: added_signatures_eve_ids
})
end
if not is_nil(first_tracked_character) &&
not (removed_signatures_eve_ids |> Enum.empty?()) do
WandererApp.User.ActivityTracker.track_map_event(:signatures_removed, %{
character_id: first_tracked_character.id,
user_id: current_user.id,
map_id: map_id,
solar_system_id: system.solar_system_id,
signatures: removed_signatures_eve_ids
})
end
Phoenix.PubSub.broadcast!(WandererApp.PubSub, map_id, %{
event: :signatures_updated,
payload: system.solar_system_id
})
{:reply, %{signatures: get_system_signatures(system.id)}, socket}
_ ->
{:reply, %{signatures: []},
socket
|> put_flash(
:error,
"You should enable tracking for at least one character to work with signatures."
)}
end
_ ->
{:noreply, socket}
end
end
def handle_ui_event(
@@ -275,7 +377,6 @@ defmodule WandererAppWeb.MapSignaturesEventHandler do
s
|> Map.take([
:eve_id,
:character_eve_id,
:name,
:description,
:kind,
@@ -287,4 +388,26 @@ defmodule WandererAppWeb.MapSignaturesEventHandler do
|> Map.put(:inserted_at, inserted_at |> Calendar.strftime("%Y/%m/%d %H:%M:%S"))
|> Map.put(:updated_at, updated_at |> Calendar.strftime("%Y/%m/%d %H:%M:%S"))
end)
defp parse_signatures(signatures, character_eve_id, system_id),
do:
signatures
|> Enum.map(fn %{
"eve_id" => eve_id,
"name" => name,
"kind" => kind,
"group" => group
} = signature ->
%{
system_id: system_id,
eve_id: eve_id,
name: name,
description: Map.get(signature, "description"),
kind: kind,
group: group,
type: Map.get(signature, "type"),
custom_info: Map.get(signature, "custom_info"),
character_eve_id: character_eve_id
}
end)
end

View File

@@ -10,38 +10,57 @@ defmodule WandererAppWeb.MapAuditLive do
def mount(
%{"slug" => map_slug, "period" => period, "activity" => activity} = _params,
_session,
%{assigns: %{current_user: current_user}} = socket
socket
) do
WandererApp.Maps.check_user_can_delete_map(map_slug, current_user)
current_user = socket.assigns.current_user
map_slug
|> WandererApp.Api.Map.get_map_by_slug()
|> Ash.load([:acls, :user_permissions], actor: current_user)
|> case do
{:ok,
%{
id: map_id,
name: map_name
user_permissions: user_permissions,
name: map_name,
owner_id: owner_id
} = _map} ->
{:ok, is_subscription_active} = map_id |> WandererApp.Map.is_subscription_active?()
user_permissions =
WandererApp.Permissions.get_map_permissions(
user_permissions,
owner_id,
current_user.characters |> Enum.map(& &1.id)
)
{:ok,
socket
|> assign(
map_id: map_id,
map_name: map_name,
map_slug: map_slug,
map_subscription_active: is_subscription_active,
activity: activity,
can_undo_types: [:systems_removed],
period: period || "1H",
page: 1,
per_page: 25,
end_of_stream?: false
)
|> stream(:activity, [])}
case user_permissions.delete_map do
true ->
{:ok, is_subscription_active} = map_id |> WandererApp.Map.is_subscription_active?()
{:ok,
socket
|> assign(
map_id: map_id,
map_name: map_name,
map_slug: map_slug,
map_subscription_active: is_subscription_active,
activity: activity,
can_undo_types: [:systems_removed],
period: period || "1H",
page: 1,
per_page: 25,
end_of_stream?: false
)
|> stream(:activity, [])}
_ ->
{:ok,
socket
|> put_flash(:error, "You don't have an access.")
|> push_navigate(to: ~p"/maps")}
end
_ ->
{:ok,
socket
|> put_flash(:error, "You don't have an access.")
|> push_navigate(to: ~p"/maps")}
{:ok, socket}
end
end

View File

@@ -1,151 +0,0 @@
defmodule WandererAppWeb.MapCharactersLive do
use WandererAppWeb, :live_view
require Logger
alias WandererAppWeb.MapCharacters
def mount(
%{"slug" => map_slug} = _params,
_session,
%{assigns: %{current_user: current_user}} = socket
) do
WandererApp.Maps.check_user_can_delete_map(map_slug, current_user)
|> case do
{:ok,
%{
id: map_id,
name: map_name
} = _map} ->
{:ok,
socket
|> assign(
map_id: map_id,
map_name: map_name,
map_slug: map_slug
)
|> assign(:groups, [])}
_ ->
{:ok,
socket
|> put_flash(:error, "You don't have an access.")
|> push_navigate(to: ~p"/maps")}
end
end
@impl true
def mount(_params, _session, socket) do
{:ok, socket |> assign(user_id: nil)}
end
@impl true
def handle_params(params, _url, socket) do
{:noreply, apply_action(socket, socket.assigns.live_action, params)}
end
@impl true
def handle_info(
_event,
socket
) do
{:noreply, socket}
end
def handle_event(
"untrack",
%{"event-data" => character_id},
%{
assigns: %{
map_id: map_id,
current_user: _current_user,
character_settings: character_settings
}
} = socket
) do
socket =
character_settings
|> Enum.find(&(&1.character_id == character_id))
|> case do
nil ->
socket
character_setting ->
case character_setting.tracked do
true ->
{:ok, map_character_settings} =
character_setting
|> WandererApp.MapCharacterSettingsRepo.untrack()
WandererApp.Map.Server.remove_character(map_id, map_character_settings.character_id)
socket |> put_flash(:info, "Character untracked!") |> load_characters()
_ ->
socket
end
end
{:noreply, socket}
end
@impl true
def handle_event("noop", _, socket) do
{:noreply, socket}
end
@impl true
def handle_event(event, body, socket) do
Logger.warning(fn -> "unhandled event: #{event} #{inspect(body)}" end)
{:noreply, socket}
end
defp apply_action(socket, :index, _params) do
socket
|> assign(:active_page, :map_characters)
|> assign(:page_title, "Map - Characters")
|> load_characters()
end
defp load_characters(%{assigns: %{map_id: map_id}} = socket) do
map_characters =
map_id
|> WandererApp.Map.list_characters()
|> Enum.map(&map_ui_character/1)
groups =
map_characters
|> Enum.group_by(& &1.user_id)
|> Enum.reduce([], fn {user_id, values}, acc ->
acc ++ [%{id: user_id, characters: values}]
end)
{:ok, character_settings} =
case WandererApp.MapCharacterSettingsRepo.get_all_by_map(map_id) do
{:ok, settings} -> {:ok, settings}
_ -> {:ok, []}
end
socket
|> assign(:character_settings, character_settings)
|> assign(:characters_count, map_characters |> length())
|> assign(:groups, groups)
end
defp map_ui_character(character),
do:
character
|> Map.take([
:id,
:user_id,
:eve_id,
:name,
:online,
:corporation_id,
:corporation_name,
:corporation_ticker,
:alliance_id,
:alliance_name,
:alliance_ticker
])
end

View File

@@ -1,23 +0,0 @@
<nav class="fixed top-0 z-100 px-6 pl-20 flex items-center justify-between w-full h-12 pointer-events-auto border-b border-stone-800 bg-opacity-70 bg-neutral-900">
<span className="w-full font-medium text-sm">
<.link navigate={~p"/#{@map_slug}"} class="text-neutral-100">
<%= @map_name %>
</.link>
- Characters [<%= @characters_count %>]
</span>
</nav>
<main
id="map-character-list"
class="pt-20 w-full h-full col-span-2 lg:col-span-1 p-4 pl-20 pb-20 overflow-auto"
>
<div class="flex flex-col gap-4 w-full">
<.live_component
module={MapCharacters}
id="map-characters"
notify_to={self()}
groups={@groups}
character_settings={@character_settings}
event_name="character_event"
/>
</div>
</main>

View File

@@ -166,17 +166,6 @@ defmodule WandererAppWeb.MapEventHandler do
when event_name in @map_kills_events,
do: MapKillsEventHandler.handle_server_event(event, socket)
def handle_event(
%{
assigns: %{
is_subscription_active?: false
}
} = socket,
%{event: event_name} = _event
)
when event_name in @map_kills_events,
do: socket
def handle_event(socket, {ref, result}) when is_reference(ref) do
Process.demonitor(ref, [:flush])
@@ -257,23 +246,13 @@ defmodule WandererAppWeb.MapEventHandler do
end
end
def push_map_event(
%{
assigns: %{
is_version_valid?: true
}
} = socket,
type,
body
),
do:
socket
|> Phoenix.LiveView.Utils.push_event("map_event", %{
type: type,
body: body
})
def push_map_event(socket, _type, _body), do: socket
def push_map_event(socket, type, body),
do:
socket
|> Phoenix.LiveView.Utils.push_event("map_event", %{
type: type,
body: body
})
def map_ui_character_stat(character),
do:

View File

@@ -29,15 +29,6 @@
>
<.icon name="hero-key-solid" class="w-6 h-6" />
</.link>
<.link
:if={(@user_permissions || %{}) |> Map.get(:delete_map, false)}
id={"map-characters-#{@map_slug}"}
class="h-8 w-8 hover:text-white"
navigate={~p"/#{@map_slug}/characters"}
>
<.icon name="hero-user-group-solid" class="w-6 h-6" />
</.link>
</div>
<.modal

View File

@@ -28,8 +28,7 @@ defmodule WandererAppWeb.MapsLive do
map_subscriptions_enabled?: WandererApp.Env.map_subscriptions_enabled?(),
restrict_maps_creation?: WandererApp.Env.restrict_maps_creation?(),
acls: [],
location: nil,
is_version_valid?: false
location: nil
)
|> assign_async(:maps, fn ->
_load_maps(current_user)
@@ -38,15 +37,7 @@ defmodule WandererAppWeb.MapsLive do
@impl true
def mount(_params, _session, socket) do
{:ok,
socket
|> assign(
maps: [],
characters: [],
location: nil,
map_subscriptions: [],
is_version_valid?: false
)}
{:ok, socket |> assign(maps: [], characters: [], location: nil)}
end
@impl true
@@ -97,119 +88,99 @@ defmodule WandererAppWeb.MapsLive do
end
end
defp apply_action(
%{assigns: %{current_user: current_user}} = socket,
:edit,
%{"slug" => map_slug} = _params,
url
) do
WandererApp.Maps.check_user_can_delete_map(map_slug, current_user)
|> case do
{:ok, map} ->
map = map |> map_map()
defp apply_action(socket, :edit, %{"slug" => map_slug} = _params, url) do
map =
map_slug
|> WandererApp.Api.Map.get_map_by_slug!()
|> Ash.load!([:owner, :acls])
|> map_map()
socket
|> assign(:active_page, :maps)
|> assign(:uri, URI.parse(url) |> Map.put(:path, ~p"/"))
|> assign(:page_title, "Maps - Edit")
|> assign(:scopes, ["wormholes", "stargates", "none", "all"])
|> assign(:map_slug, map_slug)
|> assign(
:characters,
[map.owner |> map_character() | socket.assigns.characters] |> Enum.uniq()
)
|> assign(
:form,
map |> AshPhoenix.Form.for_update(:update, forms: [auto?: true])
)
|> load_access_lists()
_ ->
socket
|> put_flash(:error, "You don't have an access.")
|> push_navigate(to: ~p"/maps")
end
socket
|> assign(:active_page, :maps)
|> assign(:uri, URI.parse(url) |> Map.put(:path, ~p"/"))
|> assign(:page_title, "Maps - Edit")
|> assign(:scopes, ["wormholes", "stargates", "none", "all"])
|> assign(:map_slug, map_slug)
|> assign(
:characters,
[map.owner |> map_character() | socket.assigns.characters] |> Enum.uniq()
)
|> assign(
:form,
map |> AshPhoenix.Form.for_update(:update, forms: [auto?: true])
)
|> load_access_lists()
end
defp apply_action(
%{assigns: %{current_user: current_user}} = socket,
:settings,
%{"slug" => map_slug} = _params,
_url
) do
WandererApp.Maps.check_user_can_delete_map(map_slug, current_user)
|> case do
{:ok, map} ->
{:ok, export_settings} =
map
|> WandererApp.Map.Server.get_export_settings()
defp apply_action(socket, :settings, %{"slug" => map_slug} = _params, _url) do
map =
map_slug
|> WandererApp.Api.Map.get_map_by_slug!()
|> Ash.load!([:owner, :acls])
{:ok, map_balance} = WandererApp.Map.SubscriptionManager.get_balance(map)
{:ok, export_settings} =
map
|> WandererApp.Map.Server.get_export_settings()
{:ok, map_subscriptions} =
WandererApp.Map.SubscriptionManager.get_map_subscriptions(map.id)
{:ok, map_balance} = WandererApp.Map.SubscriptionManager.get_balance(map)
subscription_form = %{
"plan" => "omega",
"period" => "1",
"characters_limit" => "100",
"hubs_limit" => "10",
"auto_renew?" => true
}
{:ok, map_subscriptions} = WandererApp.Map.SubscriptionManager.get_map_subscriptions(map.id)
{:ok, options_form_data} = WandererApp.MapRepo.options_to_form_data(map)
subscription_form = %{
"plan" => "omega",
"period" => "1",
"characters_limit" => "100",
"hubs_limit" => "10",
"auto_renew?" => true
}
{:ok, estimated_price, discount} =
WandererApp.Map.SubscriptionManager.estimate_price(subscription_form, false)
{:ok, options_form_data} = WandererApp.MapRepo.options_to_form_data(map)
socket
|> assign(:active_page, :maps)
|> assign(:page_title, "Maps - Settings")
|> assign(:map_slug, map_slug)
|> assign(:map_id, map.id)
|> assign(:public_api_key, map.public_api_key)
|> assign(:map, map)
|> assign(
export_settings: export_settings |> _get_export_map_data(),
import_form: to_form(%{}),
importing: false,
show_settings?: true,
is_topping_up?: false,
active_settings_tab: "general",
is_adding_subscription?: false,
selected_subscription: nil,
options_form: options_form_data |> to_form(),
map_subscriptions: map_subscriptions,
subscription_form: subscription_form |> to_form(),
estimated_price: estimated_price,
discount: discount,
map_balance: map_balance,
topup_form: %{} |> to_form(),
subscription_plans: ["omega", "advanced"],
subscription_periods: [
{"1 Month", "1"},
{"3 Months", "3"},
{"6 Months", "6"},
{"1 Year", "12"}
],
layout_options: [
{"Left To Right", "left_to_right"},
{"Top To Bottom", "top_to_bottom"}
]
)
|> allow_upload(:settings,
accept: ~w(.json),
max_entries: 1,
max_file_size: 10_000_000,
auto_upload: true,
progress: &handle_progress/3
)
{:ok, estimated_price, discount} =
WandererApp.Map.SubscriptionManager.estimate_price(subscription_form, false)
_ ->
socket
|> put_flash(:error, "You don't have an access.")
|> push_navigate(to: ~p"/maps")
end
socket
|> assign(:active_page, :maps)
|> assign(:page_title, "Maps - Settings")
|> assign(:map_slug, map_slug)
|> assign(:map_id, map.id)
|> assign(:public_api_key, map.public_api_key)
|> assign(:map, map)
|> assign(
export_settings: export_settings |> _get_export_map_data(),
import_form: to_form(%{}),
importing: false,
show_settings?: true,
is_topping_up?: false,
active_settings_tab: "general",
is_adding_subscription?: false,
selected_subscription: nil,
options_form: options_form_data |> to_form(),
map_subscriptions: map_subscriptions,
subscription_form: subscription_form |> to_form(),
estimated_price: estimated_price,
discount: discount,
map_balance: map_balance,
topup_form: %{} |> to_form(),
subscription_plans: ["omega", "advanced"],
subscription_periods: [
{"1 Month", "1"},
{"3 Months", "3"},
{"6 Months", "6"},
{"1 Year", "12"}
],
layout_options: [
{"Left To Right", "left_to_right"},
{"Top To Bottom", "top_to_bottom"}
]
)
|> allow_upload(:settings,
accept: ~w(.json),
max_entries: 1,
max_file_size: 10_000_000,
auto_upload: true,
progress: &handle_progress/3
)
end
defp allow_map_creation(),
@@ -325,17 +296,11 @@ defmodule WandererAppWeb.MapsLive do
|> push_patch(to: ~p"/maps/#{slug}/edit")}
end
def handle_event("open_audit", %{"data" => slug}, socket),
do:
{:noreply,
socket
|> push_navigate(to: ~p"/#{slug}/audit?period=1H&activity=all")}
def handle_event("open_characters", %{"data" => slug}, socket),
do:
{:noreply,
socket
|> push_navigate(to: ~p"/#{slug}/characters")}
def handle_event("open_audit", %{"data" => slug}, socket) do
{:noreply,
socket
|> push_navigate(to: ~p"/#{slug}/audit?period=1H&activity=all")}
end
def handle_event("open_settings", %{"data" => slug}, socket) do
{:noreply,
@@ -665,7 +630,6 @@ defmodule WandererAppWeb.MapsLive do
form =
form
|> Map.put("acls", form["acls"] || [])
|> Map.put("scope", scope)
|> Map.put(
"only_tracked_characters",
@@ -676,6 +640,14 @@ defmodule WandererAppWeb.MapsLive do
|> WandererApp.Api.Map.update(form)
|> case do
{:ok, updated_map} ->
case form["acls"] do
nil ->
{:ok, _} = WandererApp.Api.Map.update_acls(updated_map, %{acls: []})
acls when is_list(acls) ->
{:ok, _} = WandererApp.Api.Map.update_acls(updated_map, %{acls: acls})
end
{added_acls, removed_acls} = map.acls |> Enum.map(& &1.id) |> _get_acls_diff(form["acls"])
Phoenix.PubSub.broadcast(
@@ -713,7 +685,10 @@ defmodule WandererAppWeb.MapsLive do
{:noreply,
socket
|> push_navigate(to: ~p"/maps")}
|> assign_async(:maps, fn ->
_load_maps(current_user)
end)
|> push_patch(to: ~p"/maps")}
{:error, error} ->
{:noreply,

View File

@@ -7,7 +7,7 @@
class="card h-[250px] rounded-none bg-gradient-to-l from-stone-950 to-stone-900 hover:text-white transform transition duration-500"
patch={~p"/maps/new"}
>
<div class="card-body justify-center items-center">
<div class="card-body justify-center items-center ">
<.icon name="hero-plus-solid" class="w-20 h-20" />
<h3 class="card-title text-center text-md">Create Map</h3>
</div>
@@ -74,16 +74,6 @@
</span>
</h2>
<div class="flex gap-2 justify-end">
<button
:if={WandererApp.Maps.can_edit?(map, @current_user)}
id={"map-characters-#{map.slug}"}
phx-hook="MapAction"
data-event="open_characters"
data-data={map.slug}
class="h-8 w-8 hover:text-white"
>
<.icon name="hero-user-group-solid" class="w-6 h-6" />
</button>
<button
:if={WandererApp.Maps.can_edit?(map, @current_user)}
id={"map-audit-#{map.slug}"}
@@ -135,7 +125,6 @@
<% end %>
</main>
</div>
<.modal
:if={@is_connected? && @live_action in [:create, :edit]}
title={"#{(@live_action == :create && "Create") || "Edit"} Map"}
@@ -196,7 +185,7 @@
</.modal>
<.modal
:if={@live_action in [:settings] && not is_nil(assigns[:map])}
:if={@live_action in [:settings]}
title="Map Settings"
class="!min-w-[700px]"
id="map-settings-modal"
@@ -205,7 +194,7 @@
>
<div class="flex flex-col gap-3">
<div class="flex flex-col gap-2">
<div class="verticalTabsContainer">
<div class="_verticalTabsContainer_1o01l_2">
<div class="p-tabview p-component" data-pc-name="tabview" data-pc-section="root">
<div class="p-tabview-nav-container" data-pc-section="navcontainer">
<div class="p-tabview-nav-content" data-pc-section="navcontent">
@@ -317,6 +306,14 @@
</span>
</a>
</li>
<li
aria-hidden="true"
role="presentation"
class="p-tabview-ink-bar"
data-pc-section="inkbar"
style="width: 146px; left: 0px;"
>
</li>
<li
:if={not WandererApp.Env.public_api_disabled?()}
class={[
@@ -450,28 +447,29 @@
/>
</div>
<div class="flex items-center gap-2">
<.button
type="button"
phx-click="generate-map-api-key"
class="p-button p-component p-button-primary"
style="min-width: 120px;"
>
<span class="p-button-label">Generate</span>
<.button class="btn btn-primary rounded-md" phx-click="generate-map-api-key">
Generate
</.button>
<.button
type="button"
phx-hook="CopyToClipboard"
id="copy-map-api-key"
data-url={@public_api_key}
disabled={is_nil(@public_api_key)}
class={"p-button p-component " <> if(is_nil(@public_api_key), do: "p-disabled", else: "")}
class={
if is_nil(@public_api_key) do
"copy-link btn rounded-md transition-colors duration-300
bg-gray-500 hover:bg-gray-500 text-gray-300 cursor-not-allowed"
else
"copy-link btn rounded-md transition-colors duration-300
bg-blue-600 hover:bg-blue-700 text-white cursor-pointer"
end
}
>
<span class="p-button-label">Copy</span>
Copy
</.button>
</div>
</div>
</div>
<div :if={@active_settings_tab == "balance"}>
<div class="stats w-full bg-primary text-primary-content">
<div class="stat">

View File

@@ -4,7 +4,6 @@ defmodule WandererAppWeb.Router do
use Plug.ErrorHandler
import PlugDynamic.Builder
import Logger
import WandererAppWeb.UserAuth,
warn: false,
@@ -25,6 +24,7 @@ defmodule WandererAppWeb.Router do
@font_src ~w('self' https://fonts.gstatic.com data: https://web.ccpgamescdn.com https://w.appzi.io )
@script_src ~w('self' )
pipeline :admin_bauth do
plug :admin_basic_auth
end
@@ -112,21 +112,12 @@ defmodule WandererAppWeb.Router do
pipeline :api_map do
plug WandererAppWeb.Plugs.CheckMapApiKey
plug WandererAppWeb.Plugs.CheckMapSubscription
end
pipeline :api_kills do
plug WandererAppWeb.Plugs.CheckApiDisabled
end
pipeline :api_character do
plug WandererAppWeb.Plugs.CheckCharacterApiDisabled
end
pipeline :api_acl do
plug WandererAppWeb.Plugs.CheckAclApiKey
end
scope "/api/map/systems-kills", WandererAppWeb do
pipe_through [:api, :api_map, :api_kills]
@@ -135,76 +126,67 @@ defmodule WandererAppWeb.Router do
scope "/api/map", WandererAppWeb do
pipe_through [:api, :api_map]
# GET /api/map/systems?map_id=... or ?slug=...
get "/systems", MapAPIController, :list_systems
# GET /api/map/system?id=... plus either map_id=... or slug=...
get "/system", MapAPIController, :show_system
# GET /api/map/characters?map_id=... or slug=...
get "/characters", MapAPIController, :tracked_characters_with_info
# GET /api/map/structure-timers?map_id=... or slug=... and optionally ?system_id=...
get "/structure-timers", MapAPIController, :show_structure_timers
get "/acls", MapAccessListAPIController, :index
post "/acls", MapAccessListAPIController, :create
end
scope "/api/characters", WandererAppWeb do
pipe_through [:api, :api_character]
get "/", CharactersAPIController, :index
end
scope "/api/acls", WandererAppWeb do
pipe_through [:api, :api_acl]
get "/:id", MapAccessListAPIController, :show
put "/:id", MapAccessListAPIController, :update
post "/:acl_id/members", AccessListMemberAPIController, :create
put "/:acl_id/members/:member_id", AccessListMemberAPIController, :update_role
delete "/:acl_id/members/:member_id", AccessListMemberAPIController, :delete
end
scope "/api/common", WandererAppWeb do
pipe_through [:api]
# GET /api/common/system-static-info?id=...
get "/system-static-info", CommonAPIController, :show_system_static
end
#
# Browser / blog stuff
#
scope "/", WandererAppWeb do
pipe_through [:browser, :blog, :redirect_if_user_is_authenticated]
get "/welcome", BlogController, :index
end
scope "/contacts", WandererAppWeb do
pipe_through [:browser, :blog]
get "/", BlogController, :contacts
end
scope "/changelog", WandererAppWeb do
pipe_through [:browser, :blog]
get "/", BlogController, :changelog
end
scope "/news", WandererAppWeb do
pipe_through [:browser, :blog]
get "/:slug", BlogController, :show
get "/", BlogController, :list
end
scope "/license", WandererAppWeb do
pipe_through [:browser, :blog]
get "/", BlogController, :license
end
#
# Auth
#
scope "/auth", WandererAppWeb do
pipe_through :browser
get "/signout", AuthController, :signout
get "/:provider", AuthController, :request
get "/:provider/callback", AuthController, :callback
end
#
# Admin
#
scope "/admin", WandererAppWeb do
pipe_through(:browser)
pipe_through(:admin_bauth)
@@ -226,50 +208,53 @@ defmodule WandererAppWeb.Router do
)
end
#
# Additional routes / Live sessions
#
scope "/", WandererAppWeb do
pipe_through(:browser)
get "/", RedirectController, :redirect_authenticated
get "/last", MapsController, :last
get("/last", MapsController, :last)
live_session :authenticated,
on_mount: [
{WandererAppWeb.UserAuth, :ensure_authenticated},
WandererAppWeb.Nav
] do
live "/access-lists/new", AccessListsLive, :create
live "/access-lists/:id/edit", AccessListsLive, :edit
live "/access-lists/:id/add-members", AccessListsLive, :add_members
live "/access-lists/:id", AccessListsLive, :members
live "/access-lists", AccessListsLive, :index
live "/coming-soon", ComingLive, :index
live "/tracking/:slug", CharactersTrackingLive, :characters
live "/tracking", CharactersTrackingLive, :index
live "/characters", CharactersLive, :index
live "/characters/authorize", CharactersLive, :authorize
live "/maps/new", MapsLive, :create
live "/maps/:slug/edit", MapsLive, :edit
live "/maps/:slug/settings", MapsLive, :settings
live "/maps", MapsLive, :index
live "/profile", ProfileLive, :index
live "/profile/deposit", ProfileLive, :deposit
live "/profile/subscribe", ProfileLive, :subscribe
live "/:slug/audit", MapAuditLive, :index
live "/:slug/characters", MapCharactersLive, :index
live "/:slug", MapLive, :index
live("/access-lists/new", AccessListsLive, :create)
live("/access-lists/:id/edit", AccessListsLive, :edit)
live("/access-lists/:id/add-members", AccessListsLive, :add_members)
live("/access-lists/:id", AccessListsLive, :members)
live("/access-lists", AccessListsLive, :index)
live("/coming-soon", ComingLive, :index)
live("/tracking/:slug", CharactersTrackingLive, :characters)
live("/tracking", CharactersTrackingLive, :index)
live("/characters", CharactersLive, :index)
live("/characters/authorize", CharactersLive, :authorize)
live("/maps/new", MapsLive, :create)
live("/maps/:slug/edit", MapsLive, :edit)
live("/maps/:slug/settings", MapsLive, :settings)
live("/maps", MapsLive, :index)
live("/profile", ProfileLive, :index)
live("/profile/deposit", ProfileLive, :deposit)
live("/profile/subscribe", ProfileLive, :subscribe)
live("/:slug/audit", MapAuditLive, :index)
live("/:slug", MapLive, :index)
end
end
# Enable LiveDashboard and Swoosh mailbox preview in development
if Application.compile_env(:wanderer_app, :dev_routes) do
# If you want to use the LiveDashboard in production, you should put
# it behind authentication and allow only admins to access it.
# If your application does not have an admins-only section yet,
# you can use Plug.BasicAuth to set up some basic authentication
# as long as you are also using SSL (which you should anyway).
import Phoenix.LiveDashboard.Router
scope "/dev" do
pipe_through(:browser)
error_tracker_dashboard("/errors", as: :error_tracker_dev_dashboard)
live_dashboard("/dashboard", metrics: WandererAppWeb.Telemetry)
end
end

View File

@@ -2,8 +2,8 @@ defmodule WandererApp.MixProject do
use Mix.Project
@source_url "https://github.com/wanderer-industries/wanderer"
@version "1.53.1"
@version "1.46.0"
def project do
[
@@ -90,7 +90,7 @@ defmodule WandererApp.MixProject do
{:exsync, "~> 0.4", only: :dev},
{:nimble_csv, "~> 1.2.0"},
{:cachex, "~> 3.6"},
{:live_select, "~> 1.5"},
{:live_select, "~> 1.4"},
{:nebulex, "~> 2.6"},
{:decorator, "~> 1.4"},
{:slugify, "~> 1.3"},

View File

@@ -4,23 +4,23 @@
"ash_phoenix": {:hex, :ash_phoenix, "2.1.2", "7215cf3a1ebc82ca0e5317a8449e1725fa753354674a0e8cd7fc1c8ffd1181c7", [:mix], [{:ash, "~> 3.0", [hex: :ash, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.5.6 or ~> 1.6", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.20.3 or ~> 1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "b591bd731a0855f670b5bc3f48c364b1694d508071f44d57bcd508c82817c51e"},
"ash_postgres": {:hex, :ash_postgres, "2.4.1", "6fa9bbb40e9d4a73bcdd2403e036874421e8c919dc57338eb6476cc8a82fa112", [:mix], [{:ash, ">= 3.4.9 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:ash_sql, ">= 0.2.30 and < 1.0.0-0", [hex: :ash_sql, repo: "hexpm", optional: false]}, {:ecto, ">= 3.12.1 and < 4.0.0-0", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.12", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:igniter, ">= 0.3.36 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: false]}, {:inflex, "~> 2.1", [hex: :inflex, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:owl, "~> 0.11", [hex: :owl, repo: "hexpm", optional: false]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, repo: "hexpm", optional: false]}], "hexpm", "9419993fe7f200db7230c372f5aa280f8bebb175501c9e8d58703c9054006c7b"},
"ash_sql": {:hex, :ash_sql, "0.2.32", "de99255becfb9daa7991c18c870e9f276bb372acda7eda3e05c3e2ff2ca8922e", [:mix], [{:ash, ">= 3.1.7 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:ecto, "~> 3.9", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.9", [hex: :ecto_sql, repo: "hexpm", optional: false]}], "hexpm", "43773bcd33d21319c11804d76fe11f1a1b7c8faba7aaedeab6f55fde3d2405db"},
"bandit": {:hex, :bandit, "1.6.7", "42f30e37a1c89a2a12943c5dca76f731a2313e8a2e21c1a95dc8241893e922d1", [:mix], [{:hpax, "~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:thousand_island, "~> 1.0", [hex: :thousand_island, repo: "hexpm", optional: false]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "551ba8ff5e4fc908cbeb8c9f0697775fb6813a96d9de5f7fe02e34e76fd7d184"},
"bandit": {:hex, :bandit, "1.5.7", "6856b1e1df4f2b0cb3df1377eab7891bec2da6a7fd69dc78594ad3e152363a50", [:mix], [{:hpax, "~> 1.0.0", [hex: :hpax, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:thousand_island, "~> 1.0", [hex: :thousand_island, repo: "hexpm", optional: false]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "f2dd92ae87d2cbea2fa9aa1652db157b6cba6c405cb44d4f6dd87abba41371cd"},
"better_number": {:hex, :better_number, "1.0.1", "5832757e2575feda6f6e67b3ff18f1510a42efec4f5673221f89cff8132add7b", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "782efdaf7bb4a7109265878fa30497a335bf7cd5954ce37ee539a3ce7cf09ceb"},
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
"cachex": {:hex, :cachex, "3.6.0", "14a1bfbeee060dd9bec25a5b6f4e4691e3670ebda28c8ba2884b12fe30b36bf8", [:mix], [{:eternal, "~> 1.2", [hex: :eternal, repo: "hexpm", optional: false]}, {:jumper, "~> 1.0", [hex: :jumper, repo: "hexpm", optional: false]}, {:sleeplocks, "~> 1.1", [hex: :sleeplocks, repo: "hexpm", optional: false]}, {:unsafe, "~> 1.0", [hex: :unsafe, repo: "hexpm", optional: false]}], "hexpm", "ebf24e373883bc8e0c8d894a63bbe102ae13d918f790121f5cfe6e485cc8e2e2"},
"castore": {:hex, :castore, "1.0.12", "053f0e32700cbec356280c0e835df425a3be4bc1e0627b714330ad9d0f05497f", [:mix], [], "hexpm", "3dca286b2186055ba0c9449b4e95b97bf1b57b47c1f2644555879e659960c224"},
"castore": {:hex, :castore, "1.0.8", "dedcf20ea746694647f883590b82d9e96014057aff1d44d03ec90f36a5c0dc6e", [:mix], [], "hexpm", "0b2b66d2ee742cb1d9cb8c8be3b43c3a70ee8651f37b75a8b982e036752983f1"},
"cloak": {:hex, :cloak, "1.1.4", "aba387b22ea4d80d92d38ab1890cc528b06e0e7ef2a4581d71c3fdad59e997e7", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "92b20527b9aba3d939fab0dd32ce592ff86361547cfdc87d74edce6f980eb3d7"},
"comparable": {:hex, :comparable, "1.0.0", "bb669e91cedd14ae9937053e5bcbc3c52bb2f22422611f43b6e38367d94a495f", [:mix], [{:typable, "~> 0.1", [hex: :typable, repo: "hexpm", optional: false]}], "hexpm", "277c11eeb1cd726e7cd41c6c199e7e52fa16ee6830b45ad4cdc62e51f62eb60c"},
"cowboy": {:hex, :cowboy, "2.13.0", "09d770dd5f6a22cc60c071f432cd7cb87776164527f205c5a6b0f24ff6b38990", [:make, :rebar3], [{:cowlib, ">= 2.14.0 and < 3.0.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, ">= 1.8.0 and < 3.0.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "e724d3a70995025d654c1992c7b11dbfea95205c047d86ff9bf1cda92ddc5614"},
"cowboy": {:hex, :cowboy, "2.12.0", "f276d521a1ff88b2b9b4c54d0e753da6c66dd7be6c9fca3d9418b561828a3731", [:make, :rebar3], [{:cowlib, "2.13.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "8a7abe6d183372ceb21caa2709bec928ab2b72e18a3911aa1771639bef82651e"},
"cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"},
"cowlib": {:hex, :cowlib, "2.14.0", "623791c56c1cc9df54a71a9c55147a401549917f00a2e48a6ae12b812c586ced", [:make, :rebar3], [], "hexpm", "0af652d1550c8411c3b58eed7a035a7fb088c0b86aff6bc504b0bc3b7f791aa2"},
"cowlib": {:hex, :cowlib, "2.13.0", "db8f7505d8332d98ef50a3ef34b34c1afddec7506e4ee4dd4a3a266285d282ca", [:make, :rebar3], [], "hexpm", "e1e1284dc3fc030a64b1ad0d8382ae7e99da46c3246b815318a4b848873800a4"},
"credo": {:hex, :credo, "1.7.7", "771445037228f763f9b2afd612b6aa2fd8e28432a95dbbc60d8e03ce71ba4446", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8bc87496c9aaacdc3f90f01b7b0582467b69b4bd2441fe8aae3109d843cc2f2e"},
"crontab": {:hex, :crontab, "1.1.13", "3bad04f050b9f7f1c237809e42223999c150656a6b2afbbfef597d56df2144c5", [:mix], [{:ecto, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm", "d67441bec989640e3afb94e123f45a2bc42d76e02988c9613885dc3d01cf7085"},
"dart_sass": {:hex, :dart_sass, "0.5.1", "d45f20a8e324313689fb83287d4702352793ce8c9644bc254155d12656ade8b6", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}], "hexpm", "24f8a1c67e8b5267c51a33cbe6c0b5ebf12c2c83ace88b5ac04947d676b4ec81"},
"db_connection": {:hex, :db_connection, "2.7.0", "b99faa9291bb09892c7da373bb82cba59aefa9b36300f6145c5f201c7adf48ec", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dcf08f31b2701f857dfc787fbad78223d61a32204f217f15e881dd93e4bdd3ff"},
"ddrt": {:hex, :ddrt, "0.2.1", "c4e4bddcef36add5de6599ec72ec822699932413ece0ad310e4be4ab2b3ab6d3", [:mix], [{:delta_crdt, "~> 0.5.0", [hex: :delta_crdt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:merkle_map, "~> 0.2.0", [hex: :merkle_map, repo: "hexpm", optional: false]}, {:uuid, "~> 1.1", [hex: :uuid, repo: "hexpm", optional: false]}], "hexpm", "1efcd60cf4ca4a4352e752d7f41ed9d696560e5860ee07d5bf31c16950100365"},
"debounce_and_throttle": {:hex, :debounce_and_throttle, "0.9.0", "fa86c982963e00365cc9808afa496e82ca2b48f8905c6c79f8edd304800d0892", [:mix], [], "hexpm", "573a7cff4032754023d8e6874f3eff5354864c90b39b692f1fc4a44b3eb7517b"},
"decimal": {:hex, :decimal, "2.3.0", "3ad6255aa77b4a3c4f818171b12d237500e63525c2fd056699967a3e7ea20f62", [:mix], [], "hexpm", "a4d66355cb29cb47c3cf30e71329e58361cfcb37c34235ef3bf1d7bf3773aeac"},
"decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"},
"decorator": {:hex, :decorator, "1.4.0", "a57ac32c823ea7e4e67f5af56412d12b33274661bb7640ec7fc882f8d23ac419", [:mix], [], "hexpm", "0a07cedd9083da875c7418dea95b78361197cf2bf3211d743f6f7ce39656597f"},
"delta_crdt": {:hex, :delta_crdt, "0.6.5", "c7bb8c2c7e60f59e46557ab4e0224f67ba22f04c02826e273738f3dcc4767adc", [:mix], [{:merkle_map, "~> 0.2.0", [hex: :merkle_map, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c6ae23a525d30f96494186dd11bf19ed9ae21d9fe2c1f1b217d492a7cc7294ae"},
"dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"},
@@ -28,7 +28,7 @@
"doctor": {:hex, :doctor, "0.21.0", "20ef89355c67778e206225fe74913e96141c4d001cb04efdeba1a2a9704f1ab5", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "a227831daa79784eb24cdeedfa403c46a4cb7d0eab0e31232ec654314447e4e0"},
"earmark": {:hex, :earmark, "1.4.46", "8c7287bd3137e99d26ae4643e5b7ef2129a260e3dcf41f251750cb4563c8fb81", [:mix], [], "hexpm", "798d86db3d79964e759ddc0c077d5eb254968ed426399fbf5a62de2b5ff8910a"},
"earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},
"ecto": {:hex, :ecto, "3.12.5", "4a312960ce612e17337e7cefcf9be45b95a3be6b36b6f94dfb3d8c361d631866", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6eb18e80bef8bb57e17f5a7f068a1719fbda384d40fc37acb8eb8aeca493b6ea"},
"ecto": {:hex, :ecto, "3.12.3", "1a9111560731f6c3606924c81c870a68a34c819f6d4f03822f370ea31a582208", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "9efd91506ae722f95e48dc49e70d0cb632ede3b7a23896252a60a14ac6d59165"},
"ecto_sql": {:hex, :ecto_sql, "3.12.0", "73cea17edfa54bde76ee8561b30d29ea08f630959685006d9c6e7d1e59113b7d", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.12", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.7", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.19 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dc9e4d206f274f3947e96142a8fdc5f69a2a6a9abb4649ef5c882323b6d512f0"},
"erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"},
"error_tracker": {:hex, :error_tracker, "0.2.2", "7635f5ed6016df10d8e63348375acb2ca411e2f6f9703ee90cc2d4262af5faec", [:mix], [{:ecto, "~> 3.11", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:ecto_sqlite3, ">= 0.0.0", [hex: :ecto_sqlite3, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix_ecto, "~> 4.6", [hex: :phoenix_ecto, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.19 or ~> 1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm", "b975978f64d27373d3486d7de477a699e735f8c0b1c74a7370ecb80e7ae97903"},
@@ -42,7 +42,7 @@
"exsync": {:hex, :exsync, "0.4.1", "0a14fe4bfcb80a509d8a0856be3dd070fffe619b9ba90fec13c58b316c176594", [:mix], [{:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "cefb22aa805ec97ffc5b75a4e1dc54bcaf781e8b32564bf74abbe5803d1b5178"},
"file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"},
"finch": {:hex, :finch, "0.19.0", "c644641491ea854fc5c1bbaef36bfc764e3f08e7185e1f084e35e0672241b76d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.6.2 or ~> 1.7", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 1.1", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "fc5324ce209125d1e2fa0fcd2634601c52a787aff1cd33ee833664a5af4ea2b6"},
"floki": {:hex, :floki, "0.37.0", "b83e0280bbc6372f2a403b2848013650b16640cd2470aea6701f0632223d719e", [:mix], [], "hexpm", "516a0c15a69f78c47dc8e0b9b3724b29608aa6619379f91b1ffa47109b5d0dd3"},
"floki": {:hex, :floki, "0.36.2", "a7da0193538c93f937714a6704369711998a51a6164a222d710ebd54020aa7a3", [:mix], [], "hexpm", "a8766c0bc92f074e5cb36c4f9961982eda84c5d2b8e979ca67f5c268ec8ed580"},
"fresh": {:hex, :fresh, "0.4.4", "9d67a1d97112e70f4dfabd63b40e4b182ef64dfa84a2d9ee175eb4e34591e9f7", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:mint, "~> 1.5", [hex: :mint, repo: "hexpm", optional: false]}, {:mint_web_socket, "~> 1.0", [hex: :mint_web_socket, repo: "hexpm", optional: false]}], "hexpm", "ba21d3fa0aa77bf18ca397e4c851de7432bb3f9c170a1645a16e09e4bba54315"},
"gen_stage": {:hex, :gen_stage, "1.2.1", "19d8b5e9a5996d813b8245338a28246307fd8b9c99d1237de199d21efc4c76a1", [:mix], [], "hexpm", "83e8be657fa05b992ffa6ac1e3af6d57aa50aace8f691fcf696ff02f8335b001"},
"gettext": {:hex, :gettext, "0.24.0", "6f4d90ac5f3111673cbefc4ebee96fe5f37a114861ab8c7b7d5b30a1108ce6d8", [:mix], [{:expo, "~> 0.5.1", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "bdf75cdfcbe9e4622dd18e034b227d77dd17f0f133853a1c73b97b3d6c770e8b"},
@@ -50,7 +50,7 @@
"git_ops": {:hex, :git_ops, "2.6.1", "cc7799a68c26cf814d6d1a5121415b4f5bf813de200908f930b27a2f1fe9dad5", [:mix], [{:git_cli, "~> 0.2", [hex: :git_cli, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "ce62d07e41fe993ec22c35d5edb11cf333a21ddaead6f5d9868fcb607d42039e"},
"glob_ex": {:hex, :glob_ex, "0.1.8", "f7ef872877ca2ae7a792ab1f9ff73d9c16bf46ecb028603a8a3c5283016adc07", [:mix], [], "hexpm", "9e39d01729419a60a937c9260a43981440c43aa4cadd1fa6672fecd58241c464"},
"heroicons": {:hex, :heroicons, "0.5.5", "c2bcb05a90f010df246a5a2a2b54cac15483b5de137b2ef0bead77fcdf06e21a", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:phoenix_live_view, ">= 0.18.2", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "2f4bf929440fecd5191ba9f40e5009b0f75dc993d765c0e4d068fcb7026d6da1"},
"hpax": {:hex, :hpax, "1.0.2", "762df951b0c399ff67cc57c3995ec3cf46d696e41f0bba17da0518d94acd4aac", [:mix], [], "hexpm", "2f09b4c1074e0abd846747329eaa26d535be0eb3d189fa69d812bfb8bfefd32f"},
"hpax": {:hex, :hpax, "1.0.0", "28dcf54509fe2152a3d040e4e3df5b265dcb6cb532029ecbacf4ce52caea3fd2", [:mix], [], "hexpm", "7f1314731d711e2ca5fdc7fd361296593fc2542570b3105595bb0bc6d0fad601"},
"igniter": {:hex, :igniter, "0.3.38", "c45e285098eb8be65bcde7206e113b34be40155026e7926d390c00e39fbc38d9", [:mix], [{:glob_ex, "~> 0.1.7", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:rewrite, "~> 0.9", [hex: :rewrite, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.4", [hex: :sourceror, repo: "hexpm", optional: false]}, {:spitfire, ">= 0.1.3 and < 1.0.0-0", [hex: :spitfire, repo: "hexpm", optional: false]}], "hexpm", "19aa9b109cd9fc858999da0a30ad9e8e883ddff7abfa7817e3b69a711c65cd13"},
"inflex": {:hex, :inflex, "2.1.0", "a365cf0821a9dacb65067abd95008ca1b0bb7dcdd85ae59965deef2aa062924c", [:mix], [], "hexpm", "14c17d05db4ee9b6d319b0bff1bdf22aa389a25398d1952c7a0b5f3d93162dd8"},
"iterex": {:hex, :iterex, "0.1.2", "58f9b9b9a22a55cbfc7b5234a9c9c63eaac26d276b3db80936c0e1c60355a5a6", [:mix], [], "hexpm", "2e103b8bcc81757a9af121f6dc0df312c9a17220f302b1193ef720460d03029d"},
@@ -58,7 +58,7 @@
"jose": {:hex, :jose, "1.11.10", "a903f5227417bd2a08c8a00a0cbcc458118be84480955e8d251297a425723f83", [:mix, :rebar3], [], "hexpm", "0d6cd36ff8ba174db29148fc112b5842186b68a90ce9fc2b3ec3afe76593e614"},
"jumper": {:hex, :jumper, "1.0.2", "68cdcd84472a00ac596b4e6459a41b3062d4427cbd4f1e8c8793c5b54f1406a7", [:mix], [], "hexpm", "9b7782409021e01ab3c08270e26f36eb62976a38c1aa64b2eaf6348422f165e1"},
"libgraph": {:hex, :libgraph, "0.16.0", "3936f3eca6ef826e08880230f806bfea13193e49bf153f93edcf0239d4fd1d07", [:mix], [], "hexpm", "41ca92240e8a4138c30a7e06466acc709b0cbb795c643e9e17174a178982d6bf"},
"live_select": {:hex, :live_select, "1.5.4", "a9bea42204bcf4ca5162c31c2dab4b398dbf3c674177734f33576fc6d7b87afd", [:mix], [{:ecto, "~> 3.8", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix, ">= 1.6.0", [hex: :phoenix, repo: "hexpm", optional: true]}, {:phoenix_html, "~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_html_helpers, "~> 1.0", [hex: :phoenix_html_helpers, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.19 or ~> 1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "4fa26776341a119aa8997cc7293a09288e6f10604d1e1e10f6704688d19be648"},
"live_select": {:hex, :live_select, "1.4.2", "193056948a52144177bb53266b116117c5ae129939a67f15d7927750d35dd1a9", [:mix], [{:ecto, "~> 3.8", [hex: :ecto, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix, ">= 1.6.0", [hex: :phoenix, repo: "hexpm", optional: true]}, {:phoenix_html, "~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_html_helpers, "~> 1.0", [hex: :phoenix_html_helpers, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.19", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "fc59e20d8fcb78f3971e898019ad82a4fe2bb516414ccfd63c8463231030ed1f"},
"live_view_events": {:hex, :live_view_events, "0.1.2", "cd8df6d330c1e5e376664e9bd924ea2272c6060d234019be3cb7579c1c562590", [:mix], [{:phoenix_live_view, "~> 0.19", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "d54cb2515698a548a7ec9cc8d36798fc4799a157e9344f10642c3f848a6a1174"},
"makeup": {:hex, :makeup, "1.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"},
"makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"},
@@ -81,27 +81,26 @@
"owl": {:hex, :owl, "0.11.0", "2cd46185d330aa2400f1c8c3cddf8d2ff6320baeff23321d1810e58127082cae", [:mix], [{:ucwidth, "~> 0.2", [hex: :ucwidth, repo: "hexpm", optional: true]}], "hexpm", "73f5783f0e963cc04a061be717a0dbb3e49ae0c4bfd55fb4b78ece8d33a65efe"},
"parent": {:hex, :parent, "0.12.1", "495c4386f06de0df492e0a7a7199c10323a55e9e933b27222060dd86dccd6d62", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2ab589ef1f37bfcedbfb5ecfbab93354972fb7391201b8907a866dadd20b39d1"},
"pathex": {:hex, :pathex, "2.5.3", "0f2674c7cb52ae9220766cae2653b4013578349ae5ec07cb0c31b92684b3f19a", [:mix], [], "hexpm", "767aefc27d0303f583ba2064f0a49546067ab5de3c42b89f014a0ba32ea04830"},
"phoenix": {:hex, :phoenix, "1.7.20", "6bababaf27d59f5628f9b608de902a021be2cecefb8231e1dbdc0a2e2e480e9b", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.7", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "6be2ab98302e8784a31829e0d50d8bdfa81a23cd912c395bafd8b8bfb5a086c2"},
"phoenix": {:hex, :phoenix, "1.7.14", "a7d0b3f1bc95987044ddada111e77bd7f75646a08518942c72a8440278ae7825", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.7", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "c7859bc56cc5dfef19ecfc240775dae358cbaa530231118a9e014df392ace61a"},
"phoenix_ddos": {:hex, :phoenix_ddos, "1.1.19", "4a15054480627e437d02b4ab9d6316a3755db1275ff2699a8b9a5aeed751be50", [:mix], [{:cachex, ">= 3.0.0", [hex: :cachex, repo: "hexpm", optional: false]}, {:phoenix, ">= 1.5.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, ">= 0.0.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "9c6c39893644fd8bd7363e890e8d2c5981238224678db1d3e62f7fc94cac3ee6"},
"phoenix_ecto": {:hex, :phoenix_ecto, "4.6.2", "3b83b24ab5a2eb071a20372f740d7118767c272db386831b2e77638c4dcc606d", [:mix], [{:ecto, "~> 3.5", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.1", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.16 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm", "3f94d025f59de86be00f5f8c5dd7b5965a3298458d21ab1c328488be3b5fcd59"},
"phoenix_html": {:hex, :phoenix_html, "4.2.1", "35279e2a39140068fc03f8874408d58eef734e488fc142153f055c5454fd1c08", [:mix], [], "hexpm", "cff108100ae2715dd959ae8f2a8cef8e20b593f8dfd031c9cba92702cf23e053"},
"phoenix_html": {:hex, :phoenix_html, "4.1.1", "4c064fd3873d12ebb1388425a8f2a19348cef56e7289e1998e2d2fa758aa982e", [:mix], [], "hexpm", "f2f2df5a72bc9a2f510b21497fd7d2b86d932ec0598f0210fed4114adc546c6f"},
"phoenix_html_helpers": {:hex, :phoenix_html_helpers, "1.0.1", "7eed85c52eff80a179391036931791ee5d2f713d76a81d0d2c6ebafe1e11e5ec", [:mix], [{:phoenix_html, "~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "cffd2385d1fa4f78b04432df69ab8da63dc5cf63e07b713a4dcf36a3740e3090"},
"phoenix_live_dashboard": {:hex, :phoenix_live_dashboard, "0.8.4", "4508e481f791ce62ec6a096e13b061387158cbeefacca68c6c1928e1305e23ed", [:mix], [{:ecto, "~> 3.6.2 or ~> 3.7", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_mysql_extras, "~> 0.5", [hex: :ecto_mysql_extras, repo: "hexpm", optional: true]}, {:ecto_psql_extras, "~> 0.7", [hex: :ecto_psql_extras, repo: "hexpm", optional: true]}, {:ecto_sqlite3_extras, "~> 1.1.7 or ~> 1.2.0", [hex: :ecto_sqlite3_extras, repo: "hexpm", optional: true]}, {:mime, "~> 1.6 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.19 or ~> 1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6 or ~> 1.0", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "2984aae96994fbc5c61795a73b8fb58153b41ff934019cfb522343d2d3817d59"},
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.5.3", "f2161c207fda0e4fb55165f650f7f8db23f02b29e3bff00ff7ef161d6ac1f09d", [:mix], [{:file_system, "~> 0.3 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "b4ec9cd73cb01ff1bd1cac92e045d13e7030330b74164297d1aee3907b54803c"},
"phoenix_live_view": {:hex, :phoenix_live_view, "0.20.17", "f396bbdaf4ba227b82251eb75ac0afa6b3da5e509bc0d030206374237dfc9450", [:mix], [{:floki, "~> 0.36", [hex: :floki, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.6.15 or ~> 1.7.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.3 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.15", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a61d741ffb78c85fdbca0de084da6a48f8ceb5261a79165b5a0b59e5f65ce98b"},
"phoenix_multi_select": {:hex, :phoenix_multi_select, "0.1.2", "ffea2dfeebf518aaa9553871e786ea60d274a01774c033b80bad96d60beee86f", [:make, :mix], [{:phoenix, "~> 1.7", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 4.1", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.20", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "f26b21565b499ef7a7e52b37efbf795d8f2315ab59e8d3badc865297344634db"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "2.1.3", "3168d78ba41835aecad272d5e8cd51aa87a7ac9eb836eabc42f6e57538e3731d", [:mix], [], "hexpm", "bba06bc1dcfd8cb086759f0edc94a8ba2bc8896d5331a1e2c2902bf8e36ee502"},
"phoenix_template": {:hex, :phoenix_template, "1.0.4", "e2092c132f3b5e5b2d49c96695342eb36d0ed514c5b252a77048d5969330d639", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "2c0c81f0e5c6753faf5cca2f229c9709919aba34fab866d3bc05060c9c444206"},
"plug": {:hex, :plug, "1.16.1", "40c74619c12f82736d2214557dedec2e9762029b2438d6d175c5074c933edc9d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a13ff6b9006b03d7e33874945b2755253841b238c34071ed85b0e86057f8cddc"},
"plug_content_security_policy": {:hex, :plug_content_security_policy, "0.2.1", "0a19c76307ad000b3757739c14b34b83ecccf7d0a3472e64e14797a20b62939b", [:mix], [{:plug, "~> 1.3", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "ceea10050671c0387c64526e2cb337ee08e12705c737eaed80439266df5b2e29"},
"plug_cowboy": {:hex, :plug_cowboy, "2.7.3", "1304d36752e8bdde213cea59ef424ca932910a91a07ef9f3874be709c4ddb94b", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "77c95524b2aa5364b247fa17089029e73b951ebc1adeef429361eab0bb55819d"},
"plug_cowboy": {:hex, :plug_cowboy, "2.7.2", "fdadb973799ae691bf9ecad99125b16625b1c6039999da5fe544d99218e662e4", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "245d8a11ee2306094840c000e8816f0cbed69a23fc0ac2bcf8d7835ae019bb2f"},
"plug_crypto": {:hex, :plug_crypto, "2.1.0", "f44309c2b06d249c27c8d3f65cfe08158ade08418cf540fd4f72d4d6863abb7b", [:mix], [], "hexpm", "131216a4b030b8f8ce0f26038bc4421ae60e4bb95c5cf5395e1421437824c4fa"},
"plug_dynamic": {:hex, :plug_dynamic, "1.0.0", "aecc1a6c19bb4a4d3ceb35ae85999e9ec77cf50eeead754607bc657d47478b32", [:mix], [{:plug, "~> 1.6", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "403590330db12255755e0ce6397aaf05b000f255cfe5ea8edf70dc9d4413b99c"},
"postgrex": {:hex, :postgrex, "0.19.1", "73b498508b69aded53907fe48a1fee811be34cc720e69ef4ccd568c8715495ea", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "8bac7885a18f381e091ec6caf41bda7bb8c77912bb0e9285212829afe5d8a8f8"},
"prom_ex": {:hex, :prom_ex, "1.9.0", "63e6dda6c05cdeec1f26c48443dcc38ffd2118b3665ae8d2bd0e5b79f2aea03e", [:mix], [{:absinthe, ">= 1.6.0", [hex: :absinthe, repo: "hexpm", optional: true]}, {:broadway, ">= 1.0.2", [hex: :broadway, repo: "hexpm", optional: true]}, {:ecto, ">= 3.5.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:finch, "~> 0.15", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:oban, ">= 2.4.0", [hex: :oban, repo: "hexpm", optional: true]}, {:octo_fetch, "~> 0.3", [hex: :octo_fetch, repo: "hexpm", optional: false]}, {:phoenix, ">= 1.5.0", [hex: :phoenix, repo: "hexpm", optional: true]}, {:phoenix_live_view, ">= 0.14.0", [hex: :phoenix_live_view, repo: "hexpm", optional: true]}, {:plug, ">= 1.12.1", [hex: :plug, repo: "hexpm", optional: true]}, {:plug_cowboy, "~> 2.5", [hex: :plug_cowboy, repo: "hexpm", optional: false]}, {:telemetry, ">= 1.0.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}, {:telemetry_metrics_prometheus_core, "~> 1.0", [hex: :telemetry_metrics_prometheus_core, repo: "hexpm", optional: false]}, {:telemetry_poller, "~> 1.0", [hex: :telemetry_poller, repo: "hexpm", optional: false]}], "hexpm", "01f3d4f69ec93068219e686cc65e58a29c42bea5429a8ff4e2121f19db178ee6"},
"qex": {:hex, :qex, "0.5.1", "0d82c0f008551d24fffb99d97f8299afcb8ea9cf99582b770bd004ed5af63fd6", [:mix], [], "hexpm", "935a39fdaf2445834b95951456559e9dc2063d0a055742c558a99987b38d6bab"},
"quantum": {:hex, :quantum, "3.5.3", "ee38838a07761663468145f489ad93e16a79440bebd7c0f90dc1ec9850776d99", [:mix], [{:crontab, "~> 1.1", [hex: :crontab, repo: "hexpm", optional: false]}, {:gen_stage, "~> 0.14 or ~> 1.0", [hex: :gen_stage, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_registry, "~> 0.2", [hex: :telemetry_registry, repo: "hexpm", optional: false]}], "hexpm", "500fd3fa77dcd723ed9f766d4a175b684919ff7b6b8cfd9d7d0564d58eba8734"},
"ranch": {:hex, :ranch, "2.2.0", "25528f82bc8d7c6152c57666ca99ec716510fe0925cb188172f41ce93117b1b0", [:make, :rebar3], [], "hexpm", "fa0b99a1780c80218a4197a59ea8d3bdae32fbff7e88527d7d8a4787eff4f8e7"},
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
"reactor": {:hex, :reactor, "0.10.0", "1206113c21ba69b889e072b2c189c05a7aced523b9c3cb8dbe2dab7062cb699a", [:mix], [{:igniter, "~> 0.2", [hex: :igniter, repo: "hexpm", optional: false]}, {:iterex, "~> 0.1", [hex: :iterex, repo: "hexpm", optional: false]}, {:libgraph, "~> 0.16", [hex: :libgraph, repo: "hexpm", optional: false]}, {:spark, "~> 2.0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.2", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "4003c33e4c8b10b38897badea395e404d74d59a31beb30469a220f2b1ffe6457"},
"req": {:hex, :req, "0.4.14", "103de133a076a31044e5458e0f850d5681eef23dfabf3ea34af63212e3b902e2", [:mix], [{:aws_signature, "~> 0.3.2", [hex: :aws_signature, repo: "hexpm", optional: true]}, {:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.17", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 1.6 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:nimble_ownership, "~> 0.2.0 or ~> 0.3.0", [hex: :nimble_ownership, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "2ddd3d33f9ab714ced8d3c15fd03db40c14dbf129003c4a3eb80fac2cc0b1b08"},
"retry": {:hex, :retry, "0.18.0", "dc58ebe22c95aa00bc2459f9e0c5400e6005541cf8539925af0aa027dc860543", [:mix], [], "hexpm", "9483959cc7bf69c9e576d9dfb2b678b71c045d3e6f39ab7c9aa1489df4492d73"},
@@ -124,14 +123,14 @@
"telemetry_poller": {:hex, :telemetry_poller, "1.1.0", "58fa7c216257291caaf8d05678c8d01bd45f4bdbc1286838a28c4bb62ef32999", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "9eb9d9cbfd81cbd7cdd24682f8711b6e2b691289a0de6826e58452f28c103c8f"},
"telemetry_registry": {:hex, :telemetry_registry, "0.3.2", "701576890320be6428189bff963e865e8f23e0ff3615eade8f78662be0fc003c", [:mix, :rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "e7ed191eb1d115a3034af8e1e35e4e63d5348851d556646d46ca3d1b4e16bab9"},
"tesla": {:hex, :tesla, "1.11.0", "81b2b10213dddb27105ec6102d9eb0cc93d7097a918a0b1594f2dfd1a4601190", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: true]}, {:finch, "~> 0.13", [hex: :finch, repo: "hexpm", optional: true]}, {:fuse, "~> 2.4", [hex: :fuse, repo: "hexpm", optional: true]}, {:gun, ">= 1.0.0", [hex: :gun, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: true]}, {:ibrowse, "4.4.2", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:msgpax, "~> 2.3", [hex: :msgpax, repo: "hexpm", optional: true]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "b83ab5d4c2d202e1ea2b7e17a49f788d49a699513d7c4f08f2aef2c281be69db"},
"thousand_island": {:hex, :thousand_island, "1.3.11", "b68f3e91f74d564ae20b70d981bbf7097dde084343c14ae8a33e5b5fbb3d6f37", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "555c18c62027f45d9c80df389c3d01d86ba11014652c00be26e33b1b64e98d29"},
"thousand_island": {:hex, :thousand_island, "1.3.5", "6022b6338f1635b3d32406ff98d68b843ba73b3aa95cfc27154223244f3a6ca5", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2be6954916fdfe4756af3239fb6b6d75d0b8063b5df03ba76fd8a4c87849e180"},
"typable": {:hex, :typable, "0.3.0", "0431e121d124cd26f312123e313d2689b9a5322b15add65d424c07779eaa3ca1", [:mix], [], "hexpm", "880a0797752da1a4c508ac48f94711e04c86156f498065a83d160eef945858f8"},
"ueberauth": {:hex, :ueberauth, "0.10.8", "ba78fbcbb27d811a6cd06ad851793aaf7d27c3b30c9e95349c2c362b344cd8f0", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "f2d3172e52821375bccb8460e5fa5cb91cfd60b19b636b6e57e9759b6f8c10c1"},
"unsafe": {:hex, :unsafe, "1.0.2", "23c6be12f6c1605364801f4b47007c0c159497d0446ad378b5cf05f1855c0581", [:mix], [], "hexpm", "b485231683c3ab01a9cd44cb4a79f152c6f3bb87358439c6f68791b85c2df675"},
"uuid": {:hex, :uuid, "1.1.8", "e22fc04499de0de3ed1116b770c7737779f226ceefa0badb3592e64d5cfb4eb9", [:mix], [], "hexpm", "c790593b4c3b601f5dc2378baae7efaf5b3d73c4c6456ba85759905be792f2ac"},
"version_tasks": {:hex, :version_tasks, "0.12.0", "df384f454369f5f922a541cdc21da2db643c7424c03994986dab2b1702a5b724", [:mix], [{:git_cli, "~> 0.2", [hex: :git_cli, repo: "hexpm", optional: false]}], "hexpm", "c85e0ec9ad498795609ad849b6dbc668876cecb993fce1f4073016a5b87ee430"},
"websock": {:hex, :websock, "0.5.3", "2f69a6ebe810328555b6fe5c831a851f485e303a7c8ce6c5f675abeb20ebdadc", [:mix], [], "hexpm", "6105453d7fac22c712ad66fab1d45abdf049868f253cf719b625151460b8b453"},
"websock_adapter": {:hex, :websock_adapter, "0.5.8", "3b97dc94e407e2d1fc666b2fb9acf6be81a1798a2602294aac000260a7c4a47d", [:mix], [{:bandit, ">= 0.6.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "315b9a1865552212b5f35140ad194e67ce31af45bcee443d4ecb96b5fd3f3782"},
"websock_adapter": {:hex, :websock_adapter, "0.5.7", "65fa74042530064ef0570b75b43f5c49bb8b235d6515671b3d250022cb8a1f9e", [:mix], [{:bandit, ">= 0.6.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "d0f478ee64deddfec64b800673fd6e0c8888b079d9f3444dd96d2a98383bdbd1"},
"x509": {:hex, :x509, "0.8.9", "03c47e507171507d3d3028d802f48dd575206af2ef00f764a900789dfbe17476", [:mix], [], "hexpm", "ea3fb16a870a199cb2c45908a2c3e89cc934f0434173dc0c828136f878f11661"},
"yamerl": {:hex, :yamerl, "0.10.0", "4ff81fee2f1f6a46f1700c0d880b24d193ddb74bd14ef42cb0bcf46e81ef2f8e", [:rebar3], [], "hexpm", "346adb2963f1051dc837a2364e4acf6eb7d80097c0f53cbdc3046ec8ec4b4e6e"},
"yaml_elixir": {:hex, :yaml_elixir, "2.9.0", "9a256da867b37b8d2c1ffd5d9de373a4fda77a32a45b452f1708508ba7bbcb53", [:mix], [{:yamerl, "~> 0.10", [hex: :yamerl, repo: "hexpm", optional: false]}], "hexpm", "0cb0e7d4c56f5e99a6253ed1a670ed0e39c13fc45a6da054033928607ac08dfc"},

View File

@@ -1,425 +0,0 @@
%{
title: "User Guide: Characters & ACL API Endpoints",
author: "Wanderer Team",
cover_image_uri: "/images/news/02-20-acl-api/generate-acl-key.png",
tags: ~w(acl characters guide interface),
description: "Learn how to retrieve and manage Access Lists and Characters through the Wanderer public APIs. This guide covers available endpoints, request examples, and sample responses."
}
---
## Introduction
Wanderers expanded public API now lets you retrieve **all characters** in the system and manage “Access Lists” (ACLs) for controlling visibility or permissions. These endpoints allow you to:
- Fetch a list of **all** EVE characters known to the system.
- List ACLs for a given map.
- Create new ACLs for maps (with automatic API key generation).
- Update existing ACLs.
- Add, remove, and change the roles of ACL members.
This guide provides step-by-step instructions, request/response examples, and details on how to authenticate each call.
---
## Authentication
Unless otherwise noted, these endpoints require a valid **Bearer** token. Pass it in the `Authorization` header:
```bash
Authorization: Bearer <REDACTED_TOKEN>
```
If the token is missing or invalid, youll receive a `401 Unauthorized` error.
_(No API key is required for some “common” endpoints, but ACL- and character-related endpoints require a valid token.)_
There are two types of tokens in use:
1. **Map API Token:** Available in the map settings. This token is used for map-specific endpoints (e.g. listing ACLs for a map and creating ACLs).
![Generate Map API Key](/images/news/01-05-map-public-api/generate-key.png "Generate Map API Key")
2. **ACL API Token:** Available in the create/edit ACL screen. This token is used for ACL member management endpoints.
![Generate ACL API Key](/images/news/02-20-acl-api/generate-key.png "Generate ACL API Key")
---
## Endpoints Overview
### 1. List **All** Characters
```bash
GET /api/characters
```
- **Description:** Returns a list of **all** characters known to Wanderer.
- **Toggle:** Controlled by the environment variable `WANDERER_CHARACTER_API_DISABLED` (default is `false`).
- **Example Request:**
```bash
curl -H "Authorization: Bearer <REDACTED_TOKEN>" \
"https://wanderer.example.com/api/characters"
```
- **Example Response (redacted):**
```json
{
"data": [
{
"id": "b374d9e6-47a7-4e20-85ad-d608809827b5",
"name": "Some Character",
"eve_id": "2122825111",
"corporation_name": "School of Applied Knowledge",
"alliance_name": null
},
{
"id": "6963bee6-eaa1-40e2-8200-4bc2fcbd7350",
"name": "Other Character",
"eve_id": "2122019111",
"corporation_name": "Some Corporation",
"alliance_name": null
}
...
]
}
```
Use the `eve_id` when referencing a character in ACL operations.
---
### 2. List ACLs for a Given Map
```bash
GET /api/map/acls?map_id=<UUID>
GET /api/map/acls?slug=<map-slug>
```
- **Description:** Lists all ACLs associated with a map, specified by either `map_id` (UUID) or `slug` (map slug).
- **Authentication:** Requires the Map API Token (available in map settings).
- **Example Request (using slug):**
```bash
curl -H "Authorization: Bearer <REDACTED_TOKEN>" \
"https://wanderer.example.com/api/map/acls?slug=mapname"
```
- **Example Response (redacted):**
```json
{
"data": [
{
"id": "19712899-ec3a-47b1-b73b-2bae221c5513",
"name": "aclName",
"description": null,
"owner_eve_id": "11111111111",
"inserted_at": "2025-02-13T03:32:25.144403Z",
"updated_at": "2025-02-13T03:32:25.144403Z"
}
]
}
```
---
### 3. Show a Specific ACL (Including Members)
```bash
GET /api/acls/:id
```
- **Description:** Fetches a single ACL by ID, with its members preloaded.
- **Authentication:** Requires the ACL API Token.
- **Example Request:**
```bash
curl -H "Authorization: Bearer <REDACTED_TOKEN>" \
"https://wanderer.example.com/api/acls/19712899-ec3a-47b1-b73b-2bae221c5513"
```
- **Example Response (redacted):**
```json
{
"data": {
"id": "19712899-ec3a-47b1-b73b-2bae221c5513",
"name": "aclName",
"description": null,
"owner_id": "d43a9083-2705-40c9-a314-f7f412346661",
"members": [
{
"id": "8d63ab1e-b44f-4e81-8227-8fb8d928dad8",
"name": "Other Character",
"role": "admin",
"inserted_at": "2025-02-13T03:33:32.332598Z",
"updated_at": "2025-02-13T03:33:36.644520Z"
},
...
]
}
}
```
---
### 4. Create a New ACL Associated with a Map
```bash
POST /api/map/acls
```
- **Description:** Creates a new ACL for a map and generates a new ACL API key. The map record tracks its ACLs.
- **Required Query Parameter:** Either `map_id` (UUID) or `slug` (map slug).
- **Request Body Example:**
```json
{
"acl": {
"name": "New ACL",
"description": "Optional description",
"owner_eve_id": "EXTERNAL_EVE_ID"
}
}
```
- `owner_eve_id` must be the external EVE id (the `eve_id` from `/api/characters`).
- **Example Request (using map slug):**
```bash
curl -X POST \
-H "Authorization: Bearer <MAP_API_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"acl": {
"name": "New ACL",
"description": "Optional description",
"owner_eve_id": "EXTERNAL_EVE_ID"
}
}' \
"https://wanderer.example.com/api/map/acls?slug=mapname"
```
- **Example Request (using map UUID):**
```bash
curl -X POST \
-H "Authorization: Bearer <MAP_API_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"acl": {
"name": "New ACL",
"description": "Optional description",
"owner_eve_id": "EXTERNAL_EVE_ID"
}
}' \
"https://wanderer.example.com/api/map/acls?map_id=YOUR_MAP_UUID"
```
- **Example Response (redacted):**
```json
{
"data": {
"id": "NEW_ACL_UUID",
"name": "New ACL",
"description": "Optional description",
"owner_id": "OWNER_ID",
"api_key": "GENERATED_ACL_API_KEY",
"inserted_at": "2025-02-14T17:00:00Z",
"updated_at": "2025-02-14T17:00:00Z",
"members": []
}
}
```
---
### 5. Update an ACL
```bash
PUT /api/acls/:id
```
- **Description:** Updates an existing ACL (e.g. name, description, api_key).
The update endpoint fetches the ACL record first and then applies the update.
- **Authentication:** Requires the ACL API Token.
- **Example Request:**
```bash
curl -X PUT \
-H "Authorization: Bearer <ACL_API_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"acl": {
"name": "Updated ACL Name",
"description": "This is the updated description",
"api_key": "EXISTING_ACL_API_KEY"
}
}' \
"https://wanderer.example.com/api/acls/ACL_UUID"
```
- **Example Response (redacted):**
```json
{
"data": {
"id": "ACL_UUID",
"name": "Updated ACL Name",
"description": "This is the updated description",
"owner_id": "OWNER_ID",
"api_key": "EXISTING_ACL_API_KEY",
"inserted_at": "2025-02-14T16:49:13.423556Z",
"updated_at": "2025-02-14T17:22:51.343784Z",
"members": []
}
}
```
---
### 6. Add a Member to an ACL
```bash
POST /api/acls/:acl_id/members
```
- **Description:** Adds a new member (character, corporation, or alliance) to the specified ACL.
- **Authentication:** Requires the ACL API Token.
- **Request Body Example:**
For **character** membership, use `eve_character_id`. For **corporation**, use `eve_corporation_id`. For **alliance**, use `eve_alliance_id`.
```json
{
"member": {
"name": "New Member",
"eve_character_id": "EXTERNAL_EVE_ID",
"role": "viewer"
}
}
```
- **Example Request:**
```bash
curl -X POST \
-H "Authorization: Bearer <ACL_API_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"member": {
"name": "New Member",
"eve_character_id": "EXTERNAL_EVE_ID",
"role": "viewer"
}
}' \
"https://wanderer.example.com/api/acls/ACL_UUID/members"
```
- **Example Response (redacted):**
```json
{
"data": {
"id": "MEMBERSHIP_UUID",
"name": "New Member",
"role": "viewer",
"inserted_at": "...",
"updated_at": "..."
}
}
```
---
### 7. Change a Members Role
```bash
PUT /api/acls/:acl_id/members/:member_id
```
- **Description:** Updates an ACL members role (e.g. from `viewer` to `admin`).
The `:member_id` is the external EVE id (or corp/alliance id) used when creating the membership.
- **Authentication:** Requires the ACL API Token.
- **Request Body Example:**
```json
{
"member": {
"role": "admin"
}
}
```
- **Example Request:**
```bash
curl -X PUT \
-H "Authorization: Bearer <ACL_API_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"member": {
"role": "admin"
}
}' \
"https://wanderer.example.com/api/acls/ACL_UUID/members/EXTERNAL_EVE_ID"
```
- **Example Response (redacted):**
```json
{
"data": {
"id": "MEMBERSHIP_UUID",
"name": "New Member",
"role": "admin",
...
}
}
```
---
### 8. Remove a Member from an ACL
```bash
DELETE /api/acls/:acl_id/members/:member_id
```
- **Description:** Removes the member with the specified external EVE id (or corp/alliance id) from the ACL.
- **Authentication:** Requires the ACL API Token.
- **Example Request:**
```bash
curl -X DELETE \
-H "Authorization: Bearer <ACL_API_TOKEN>" \
"https://wanderer.example.com/api/acls/ACL_UUID/members/EXTERNAL_EVE_ID"
```
- **Example Response:**
```json
{ "ok": true }
```
---
## Conclusion
This guide outlines how to:
1. **List** all characters (`GET /api/characters`) so you can pick a valid character to add to your ACL.
2. **List** ACLs for a specified map (`GET /api/map/acls?map_id=<UUID>` or `?slug=<map-slug>`).
3. **Show** ACL details, including its members (`GET /api/acls/:id`).
4. **Create** a new ACL for a map (`POST /api/map/acls`), which generates a new ACL API key.
5. **Update** an existing ACL (`PUT /api/acls/:id`).
6. **Add** members (characters, corporations, alliances) to an ACL (`POST /api/acls/:acl_id/members`).
7. **Change** a members role (`PUT /api/acls/:acl_id/members/:member_id`).
8. **Remove** a member from an ACL (`DELETE /api/acls/:acl_id/members/:member_id`).
By following these request patterns, you can manage your ACL resources in a fully programmatic fashion. If you have any questions, feel free to reach out to the Wanderer Team.
Fly safe,
**WANDERER TEAM**

View File

@@ -1,21 +0,0 @@
defmodule WandererApp.Repo.Migrations.AddAclApiKey do
@moduledoc """
Updates resources based on their most recent snapshots.
This file was autogenerated with `mix ash_postgres.generate_migrations`
"""
use Ecto.Migration
def up do
alter table(:access_lists_v1) do
add :api_key, :text
end
end
def down do
alter table(:access_lists_v1) do
remove :api_key
end
end
end

View File

@@ -1,108 +0,0 @@
{
"attributes": [
{
"allow_nil?": false,
"default": "fragment(\"gen_random_uuid()\")",
"generated?": false,
"primary_key?": true,
"references": null,
"size": null,
"source": "id",
"type": "uuid"
},
{
"allow_nil?": false,
"default": "nil",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "name",
"type": "text"
},
{
"allow_nil?": true,
"default": "nil",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "description",
"type": "text"
},
{
"allow_nil?": true,
"default": "nil",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "api_key",
"type": "text"
},
{
"allow_nil?": false,
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "inserted_at",
"type": "utc_datetime_usec"
},
{
"allow_nil?": false,
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "updated_at",
"type": "utc_datetime_usec"
},
{
"allow_nil?": true,
"default": "nil",
"generated?": false,
"primary_key?": false,
"references": {
"deferrable": false,
"destination_attribute": "id",
"destination_attribute_default": null,
"destination_attribute_generated": null,
"index?": false,
"match_type": null,
"match_with": null,
"multitenancy": {
"attribute": null,
"global": null,
"strategy": null
},
"name": "access_lists_v1_owner_id_fkey",
"on_delete": null,
"on_update": null,
"primary_key?": true,
"schema": "public",
"table": "character_v1"
},
"size": null,
"source": "owner_id",
"type": "uuid"
}
],
"base_filter": null,
"check_constraints": [],
"custom_indexes": [],
"custom_statements": [],
"has_create_action": true,
"hash": "5118AF0DEBEEED63DC30565ECFFEDF682876FAD476AF2796E973C6883E4054E0",
"identities": [],
"multitenancy": {
"attribute": null,
"global": null,
"strategy": null
},
"repo": "Elixir.WandererApp.Repo",
"schema": null,
"table": "access_lists_v1"
}

View File

@@ -1,198 +0,0 @@
#!/usr/bin/env bash
#
# Example script to test your Map & ACL endpoints using curl.
# Requires `jq` to parse JSON responses.
# If any command fails, this script will exit immediately
set -e
#############################################
# Environment Variables (must be set before)
#############################################
: "${BASE_URL:?Need to set BASE_URL, e.g. http://localhost:4444}"
: "${MAP_TOKEN:?Need to set MAP_TOKEN (Bearer token for map requests)}"
: "${MAP_SLUG:?Need to set MAP_SLUG (slug for the map to test)}"
: "${EVE_CHARACTER_ID:?Need to set EVE_CHARACTER_ID (e.g. from /api/characters)}"
echo "Using BASE_URL = $BASE_URL"
echo "Using MAP_TOKEN = $MAP_TOKEN"
echo "Using MAP_SLUG = $MAP_SLUG"
echo "Using EVE_CHARACTER_ID = $EVE_CHARACTER_ID"
echo "-------------------------------------"
#############################################
# 1) Get list of characters (just to confirm they exist)
#############################################
echo
echo "=== 1) Get All Characters (for reference) ==="
curl -s "$BASE_URL/api/characters" | jq
#############################################
# 2) Get ACLs for the given map slug
#############################################
echo
echo "=== 2) List ACLs for Map Slug '$MAP_SLUG' ==="
ACL_LIST_JSON=$(curl -s -H "Authorization: Bearer $MAP_TOKEN" \
"$BASE_URL/api/map/acls?slug=$MAP_SLUG")
echo "$ACL_LIST_JSON" | jq
# Attempt to parse out the first ACL ID and token from the JSON data array:
FIRST_ACL_ID=$(echo "$ACL_LIST_JSON" | jq -r '.data[0].id // empty')
FIRST_ACL_TOKEN=$(echo "$ACL_LIST_JSON" | jq -r '.data[0].api_key // empty')
#############################################
# 3) Decide whether to use an existing ACL or create a new one
#############################################
if [ -z "$FIRST_ACL_ID" ] || [ "$FIRST_ACL_ID" = "null" ]; then
echo "No existing ACL found for map slug: $MAP_SLUG."
USE_EXISTING_ACL=false
else
# We found at least one ACL. But does it have a token?
if [ -z "$FIRST_ACL_TOKEN" ] || [ "$FIRST_ACL_TOKEN" = "null" ]; then
echo "Found an ACL with ID $FIRST_ACL_ID but no api_key in the response."
echo "We cannot do membership actions on it without a token."
USE_EXISTING_ACL=false
else
echo "Parsed ACL_ID from existing ACL: $FIRST_ACL_ID"
echo "Parsed ACL_TOKEN from existing ACL: $FIRST_ACL_TOKEN"
USE_EXISTING_ACL=true
fi
fi
#############################################
# 4) If we cannot use an existing ACL, create a new one
#############################################
if [ "$USE_EXISTING_ACL" = false ]; then
echo
echo "=== Creating a new ACL for membership testing ==="
NEW_ACL_RESPONSE=$(curl -s -X POST \
-H "Authorization: Bearer $MAP_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"acl": {
"name": "Auto-Created ACL",
"description": "Created because none with a token was found",
"owner_eve_id": "'"$EVE_CHARACTER_ID"'"
}
}' \
"$BASE_URL/api/map/acls?slug=$MAP_SLUG")
echo "New ACL creation response:"
echo "$NEW_ACL_RESPONSE" | jq
ACL_ID=$(echo "$NEW_ACL_RESPONSE" | jq -r '.data.id // empty')
ACL_TOKEN=$(echo "$NEW_ACL_RESPONSE" | jq -r '.data.api_key // empty')
if [ -z "$ACL_ID" ] || [ "$ACL_ID" = "null" ] || \
[ -z "$ACL_TOKEN" ] || [ "$ACL_TOKEN" = "null" ]; then
echo "Failed to create an ACL with a valid token. Exiting..."
exit 1
fi
echo "Newly created ACL_ID: $ACL_ID"
echo "Newly created ACL_TOKEN: $ACL_TOKEN"
else
# Use the existing ACL's details
ACL_ID="$FIRST_ACL_ID"
ACL_TOKEN="$FIRST_ACL_TOKEN"
fi
#############################################
# 5) Show the details of that ACL
#############################################
echo
echo "=== 5) Show ACL Details ==="
ACL_DETAILS=$(curl -s \
-H "Authorization: Bearer $ACL_TOKEN" \
"$BASE_URL/api/acls/$ACL_ID")
echo "$ACL_DETAILS" | jq || {
echo "ACL details response is not valid JSON. Raw response:"
echo "$ACL_DETAILS"
exit 1
}
#############################################
# 6) Create a new ACL member (viewer)
#############################################
echo
echo "=== 6) Create a New ACL Member (viewer) ==="
CREATE_MEMBER_RESP=$(curl -s -X POST \
-H "Authorization: Bearer $ACL_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"member": {
"eve_character_id": "'"$EVE_CHARACTER_ID"'",
"role": "viewer"
}
}' \
"$BASE_URL/api/acls/$ACL_ID/members")
echo "$CREATE_MEMBER_RESP" | jq || {
echo "Create member response is not valid JSON. Raw response:"
echo "$CREATE_MEMBER_RESP"
exit 1
}
#############################################
# 7) Update the member's role (e.g., admin)
#############################################
echo
echo "=== 7) Update Member Role to 'admin' ==="
UPDATE_MEMBER_RESP=$(curl -s -X PUT \
-H "Authorization: Bearer $ACL_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"member": {
"role": "admin"
}
}' \
"$BASE_URL/api/acls/$ACL_ID/members/$EVE_CHARACTER_ID")
echo "$UPDATE_MEMBER_RESP" | jq || {
echo "Update member response is not valid JSON. Raw response:"
echo "$UPDATE_MEMBER_RESP"
exit 1
}
#############################################
# 8) Delete the member
#############################################
echo
echo "=== 8) Delete the Member ==="
DELETE_MEMBER_RESP=$(curl -s -X DELETE \
-H "Authorization: Bearer $ACL_TOKEN" \
"$BASE_URL/api/acls/$ACL_ID/members/$EVE_CHARACTER_ID")
echo "$DELETE_MEMBER_RESP" | jq || {
echo "Delete member response is not valid JSON. Raw response:"
echo "$DELETE_MEMBER_RESP"
exit 1
}
#############################################
# 9) (Optional) Update the ACL itself
#############################################
echo
echo "=== 9) Update the ACLs name/description ==="
UPDATED_ACL=$(curl -s -X PUT \
-H "Authorization: Bearer $ACL_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"acl": {
"name": "Updated ACL Name (script)",
"description": "An updated description from test script"
}
}' \
"$BASE_URL/api/acls/$ACL_ID")
echo "$UPDATED_ACL" | jq || {
echo "Update ACL response is not valid JSON. Raw response:"
echo "$UPDATED_ACL"
exit 1
}
echo
echo "=== Done! ==="