mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-03 22:35:41 +00:00
Compare commits
63 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1e9b4c2e8 | ||
|
|
42c30e0741 | ||
|
|
3b45e77e65 | ||
|
|
dcb2b6b912 | ||
|
|
638a4e2535 | ||
|
|
489fde16d1 | ||
|
|
35e1c363e5 | ||
|
|
6b97d36bf1 | ||
|
|
82f6a7f701 | ||
|
|
2d92dfbafa | ||
|
|
f81f41f555 | ||
|
|
54c7b44d69 | ||
|
|
9da6605ccb | ||
|
|
a90bf9762a | ||
|
|
c87cfb3c43 | ||
|
|
85cb9ccfa8 | ||
|
|
da2639786d | ||
|
|
3cf77da293 | ||
|
|
3dd7633194 | ||
|
|
ae7f4edf4a | ||
|
|
52eab28f27 | ||
|
|
6098d32bce | ||
|
|
1839834771 | ||
|
|
7cdfb87853 | ||
|
|
3d54783a3e | ||
|
|
f965461820 | ||
|
|
6d67f87d4b | ||
|
|
60697a50c2 | ||
|
|
778d23da06 | ||
|
|
0ee9a15d5d | ||
|
|
24bb902bb9 | ||
|
|
32fe6395a1 | ||
|
|
5f506bf4b2 | ||
|
|
0127ebfe46 | ||
|
|
8c5366fd9b | ||
|
|
dbcad892a9 | ||
|
|
6da3096db1 | ||
|
|
cd8efcd6e3 | ||
|
|
b52471ae5e | ||
|
|
438fecb61f | ||
|
|
70b589a359 | ||
|
|
cf7069b3b2 | ||
|
|
b2198e469e | ||
|
|
8ab337e8e7 | ||
|
|
51878ab503 | ||
|
|
401dfad298 | ||
|
|
18cff7d312 | ||
|
|
7896de00d6 | ||
|
|
3b079505c3 | ||
|
|
5b972b03e5 | ||
|
|
79b284c46d | ||
|
|
b29e57b3a4 | ||
|
|
c6f4baeee3 | ||
|
|
6d341be072 | ||
|
|
2437ec9c84 | ||
|
|
7e692b5805 | ||
|
|
01b7370ecd | ||
|
|
20ad8b07d7 | ||
|
|
cab1880fb0 | ||
|
|
78eefcd6a7 | ||
|
|
eec78d38a8 | ||
|
|
73f8b1f06b | ||
|
|
f96cb01860 |
@@ -1,7 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "wanderer-dev",
|
"name": "wanderer-dev",
|
||||||
"dockerComposeFile": ["./docker-compose.yml"],
|
"dockerComposeFile": ["./docker-compose.yml"],
|
||||||
"extensions": ["jakebecker.elixir-ls"],
|
"extensions": [
|
||||||
|
"jakebecker.elixir-ls",
|
||||||
|
"JakeBecker.elixir-ls",
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
"esbenp.prettier-vscode"
|
||||||
|
],
|
||||||
"service": "wanderer",
|
"service": "wanderer",
|
||||||
"workspaceFolder": "/app",
|
"workspaceFolder": "/app",
|
||||||
"shutdownAction": "stopCompose",
|
"shutdownAction": "stopCompose",
|
||||||
|
|||||||
@@ -7,4 +7,5 @@ export EVE_CLIENT_WITH_WALLET_SECRET="<EVE_CLIENT_WITH_WALLET_SECRET>"
|
|||||||
export GIT_SHA="1111"
|
export GIT_SHA="1111"
|
||||||
export WANDERER_INVITES="false"
|
export WANDERER_INVITES="false"
|
||||||
export WANDERER_PUBLIC_API_DISABLED="false"
|
export WANDERER_PUBLIC_API_DISABLED="false"
|
||||||
|
export WANDERER_CHARACTER_API_DISABLED="false"
|
||||||
export WANDERER_ZKILL_PRELOAD_DISABLED="false"
|
export WANDERER_ZKILL_PRELOAD_DISABLED="false"
|
||||||
|
|||||||
23
.github/workflows/build.yml
vendored
23
.github/workflows/build.yml
vendored
@@ -1,8 +1,6 @@
|
|||||||
name: Build
|
name: Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
|
||||||
types: [opened, synchronize, reopened, labeled, unlabeled]
|
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
@@ -41,8 +39,28 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|
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:
|
build:
|
||||||
name: 🛠 Build
|
name: 🛠 Build
|
||||||
|
needs: manual-approval
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
if: ${{ (github.ref == 'refs/heads/main') && github.event_name == 'push' }}
|
if: ${{ (github.ref == 'refs/heads/main') && github.event_name == 'push' }}
|
||||||
permissions:
|
permissions:
|
||||||
@@ -140,7 +158,6 @@ jobs:
|
|||||||
platform:
|
platform:
|
||||||
- linux/amd64
|
- linux/amd64
|
||||||
- linux/arm64
|
- linux/arm64
|
||||||
- linux/arm64/v8
|
|
||||||
steps:
|
steps:
|
||||||
- name: Prepare
|
- name: Prepare
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
228
CHANGELOG.md
228
CHANGELOG.md
@@ -2,6 +2,234 @@
|
|||||||
|
|
||||||
<!-- changelog -->
|
<!-- changelog -->
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Features:
|
||||||
|
|
||||||
|
* Added WANDERER_RESTRICT_MAPS_CREATION env support
|
||||||
|
|
||||||
|
## [v1.45.5](https://github.com/wanderer-industries/wanderer/compare/v1.45.4...v1.45.5) (2025-02-07)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes:
|
||||||
|
|
||||||
|
* restore styling for local characters list (#152)
|
||||||
|
|
||||||
## [v1.45.4](https://github.com/wanderer-industries/wanderer/compare/v1.45.3...v1.45.4) (2025-02-07)
|
## [v1.45.4](https://github.com/wanderer-industries/wanderer/compare/v1.45.3...v1.45.4) (2025-02-07)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -936,3 +936,66 @@ body > div:first-of-type {
|
|||||||
width: 16px;
|
width: 16px;
|
||||||
height: 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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
.active {
|
|
||||||
background-color: rgba(98, 98, 98, 0.33);
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
.active {
|
|
||||||
background-color: rgba(98, 98, 98, 0.33);
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
.active {
|
|
||||||
background-color: rgba(98, 98, 98, 0.33);
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
.active {
|
|
||||||
background-color: rgba(98, 98, 98, 0.33);
|
|
||||||
}
|
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
export * from './useSystemInfo';
|
export * from './useSystemInfo';
|
||||||
export * from './useGetOwnOnlineCharacters';
|
export * from './useGetOwnOnlineCharacters';
|
||||||
|
export * from './useElementWidth';
|
||||||
|
|||||||
43
assets/js/hooks/Mapper/components/hooks/useElementWidth.ts
Normal file
43
assets/js/hooks/Mapper/components/hooks/useElementWidth.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import { useState, useLayoutEffect, RefObject } from 'react';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* useElementWidth
|
||||||
|
*
|
||||||
|
* A custom hook that accepts a ref to an HTML element and returns its current width.
|
||||||
|
* It uses a ResizeObserver and window resize listener to update the width when necessary.
|
||||||
|
*
|
||||||
|
* @param ref - A RefObject pointing to an HTML element.
|
||||||
|
* @returns The current width of the element.
|
||||||
|
*/
|
||||||
|
export function useElementWidth<T extends HTMLElement>(ref: RefObject<T>): number {
|
||||||
|
const [width, setWidth] = useState<number>(0);
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
const updateWidth = () => {
|
||||||
|
if (ref.current) {
|
||||||
|
const newWidth = ref.current.getBoundingClientRect().width;
|
||||||
|
if (newWidth > 0) {
|
||||||
|
setWidth(newWidth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
updateWidth(); // Initial measurement
|
||||||
|
|
||||||
|
const observer = new ResizeObserver(() => {
|
||||||
|
const id = setTimeout(updateWidth, 100);
|
||||||
|
return () => clearTimeout(id);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ref.current) {
|
||||||
|
observer.observe(ref.current);
|
||||||
|
}
|
||||||
|
window.addEventListener("resize", updateWidth);
|
||||||
|
return () => {
|
||||||
|
observer.disconnect();
|
||||||
|
window.removeEventListener("resize", updateWidth);
|
||||||
|
};
|
||||||
|
}, [ref]);
|
||||||
|
|
||||||
|
return width;
|
||||||
|
}
|
||||||
@@ -84,7 +84,6 @@ interface MapCompProps {
|
|||||||
onCommand: OutCommandHandler;
|
onCommand: OutCommandHandler;
|
||||||
onSelectionChange: OnMapSelectionChange;
|
onSelectionChange: OnMapSelectionChange;
|
||||||
onManualDelete(systems: string[]): void;
|
onManualDelete(systems: string[]): void;
|
||||||
canRemoveConnection?(connectionId: string): boolean;
|
|
||||||
onConnectionInfoClick?(e: SolarSystemConnection): void;
|
onConnectionInfoClick?(e: SolarSystemConnection): void;
|
||||||
onAddSystem?: OnMapAddSystemCallback;
|
onAddSystem?: OnMapAddSystemCallback;
|
||||||
onSelectionContextMenu?: NodeSelectionMouseHandler;
|
onSelectionContextMenu?: NodeSelectionMouseHandler;
|
||||||
@@ -114,9 +113,8 @@ const MapComp = ({
|
|||||||
isSoftBackground,
|
isSoftBackground,
|
||||||
theme,
|
theme,
|
||||||
onAddSystem,
|
onAddSystem,
|
||||||
canRemoveConnection,
|
|
||||||
}: MapCompProps) => {
|
}: MapCompProps) => {
|
||||||
const { getEdge, getNode, getNodes } = useReactFlow();
|
const { getNode, getNodes } = useReactFlow();
|
||||||
const [nodes, , onNodesChange] = useNodesState<Node<SolarSystemRawType>>(initialNodes);
|
const [nodes, , onNodesChange] = useNodesState<Node<SolarSystemRawType>>(initialNodes);
|
||||||
const [edges, , onEdgesChange] = useEdgesState<Edge<SolarSystemConnection>>(initialEdges);
|
const [edges, , onEdgesChange] = useEdgesState<Edge<SolarSystemConnection>>(initialEdges);
|
||||||
|
|
||||||
@@ -189,7 +187,7 @@ const MapComp = ({
|
|||||||
|
|
||||||
const handleNodesChange = useCallback(
|
const handleNodesChange = useCallback(
|
||||||
(changes: NodeChange[]) => {
|
(changes: NodeChange[]) => {
|
||||||
const systemsIdsToRemove: string[] = [];
|
// const systemsIdsToRemove: string[] = [];
|
||||||
|
|
||||||
// prevents single node deselection on background / same node click
|
// prevents single node deselection on background / same node click
|
||||||
// allows deseletion of all nodes if multiple are currently selected
|
// allows deseletion of all nodes if multiple are currently selected
|
||||||
@@ -198,66 +196,33 @@ const MapComp = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const nextChanges = changes.reduce((acc, change) => {
|
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];
|
return [...acc, change];
|
||||||
|
// if (change.type !== 'remove') {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 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[]);
|
}, [] as NodeChange[]);
|
||||||
|
|
||||||
if (systemsIdsToRemove.length > 0) {
|
// if (systemsIdsToRemove.length > 0) {
|
||||||
onManualDelete(systemsIdsToRemove);
|
// onManualDelete(systemsIdsToRemove);
|
||||||
}
|
// }
|
||||||
|
|
||||||
onNodesChange(nextChanges);
|
onNodesChange(nextChanges);
|
||||||
},
|
},
|
||||||
[getNode, getNodes, onManualDelete, 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(() => {
|
useEffect(() => {
|
||||||
update(x => ({
|
update(x => ({
|
||||||
...x,
|
...x,
|
||||||
@@ -273,7 +238,7 @@ const MapComp = ({
|
|||||||
nodes={nodes}
|
nodes={nodes}
|
||||||
edges={edges}
|
edges={edges}
|
||||||
onNodesChange={handleNodesChange}
|
onNodesChange={handleNodesChange}
|
||||||
onEdgesChange={handleEdgesChange}
|
onEdgesChange={onEdgesChange}
|
||||||
onConnect={onConnect}
|
onConnect={onConnect}
|
||||||
// TODO we need save into session all of this
|
// TODO we need save into session all of this
|
||||||
// and on any action do either
|
// and on any action do either
|
||||||
@@ -312,7 +277,7 @@ const MapComp = ({
|
|||||||
minZoom={0.2}
|
minZoom={0.2}
|
||||||
maxZoom={1.5}
|
maxZoom={1.5}
|
||||||
elevateNodesOnSelect
|
elevateNodesOnSelect
|
||||||
deleteKeyCode={['Delete']}
|
deleteKeyCode={['']}
|
||||||
{...(isPanAndDrag
|
{...(isPanAndDrag
|
||||||
? {
|
? {
|
||||||
selectionOnDrag: true,
|
selectionOnDrag: true,
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const INITIAL_DATA: MapData = {
|
|||||||
userPermissions: {},
|
userPermissions: {},
|
||||||
systemSignatures: {} as Record<string, SystemSignature[]>,
|
systemSignatures: {} as Record<string, SystemSignature[]>,
|
||||||
options: {} as Record<string, string | boolean>,
|
options: {} as Record<string, string | boolean>,
|
||||||
is_subscription_active: false,
|
isSubscriptionActive: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface MapContextProps {
|
export interface MapContextProps {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { SystemKillsContent } from '../../../mapInterface/widgets/SystemKills/SystemKillsContent/SystemKillsContent';
|
import { SystemKillsContent } from '../../../mapInterface/widgets/SystemKills/SystemKillsContent/SystemKillsContent';
|
||||||
import { useKillsCounter } from '../../hooks/useKillsCounter';
|
import { useKillsCounter } from '../../hooks/useKillsCounter';
|
||||||
import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrapper';
|
import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrapper';
|
||||||
import { WithChildren, WithClassName } from '@/hooks/Mapper/types/common.ts';
|
import { WithChildren, WithClassName } from '@/hooks/Mapper/types/common';
|
||||||
|
|
||||||
type TooltipSize = 'xs' | 'sm' | 'md' | 'lg';
|
type TooltipSize = 'xs' | 'sm' | 'md' | 'lg';
|
||||||
|
|
||||||
@@ -20,11 +20,18 @@ export const KillsCounter = ({ killsCount, systemId, className, children, size =
|
|||||||
if (!killsCount || detailedKills.length === 0 || !systemId || isLoading) return null;
|
if (!killsCount || detailedKills.length === 0 || !systemId || isLoading) return null;
|
||||||
|
|
||||||
const tooltipContent = (
|
const tooltipContent = (
|
||||||
<SystemKillsContent kills={detailedKills} systemNameMap={systemNameMap} compact={true} onlyOneSystem={true} />
|
<div style={{ width: '100%', minWidth: '300px', overflow: 'hidden' }}>
|
||||||
|
<SystemKillsContent
|
||||||
|
kills={detailedKills}
|
||||||
|
systemNameMap={systemNameMap}
|
||||||
|
onlyOneSystem={true}
|
||||||
|
autoSize={true}
|
||||||
|
limit={killsCount}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
// @ts-ignore
|
|
||||||
<WdTooltipWrapper content={tooltipContent} className={className} size={size} interactive={true}>
|
<WdTooltipWrapper content={tooltipContent} className={className} size={size} interactive={true}>
|
||||||
{children}
|
{children}
|
||||||
</WdTooltipWrapper>
|
</WdTooltipWrapper>
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
.TooltipActive {
|
||||||
|
pointer-events: auto !important;
|
||||||
|
position: relative;
|
||||||
|
z-index: 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hoverTarget {
|
||||||
|
padding: 0.5rem;
|
||||||
|
margin: -0.5rem;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.localCounter {
|
||||||
|
mix-blend-mode: screen;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1px;
|
||||||
|
position: relative;
|
||||||
|
top: 1px;
|
||||||
|
color: var(--rf-node-local-counter);
|
||||||
|
|
||||||
|
&.hasUserCharacters {
|
||||||
|
color: var(--rf-has-user-characters);
|
||||||
|
}
|
||||||
|
|
||||||
|
& > i {
|
||||||
|
font-size: 9px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
& > span {
|
||||||
|
font-size: 9px;
|
||||||
|
line-height: 9px;
|
||||||
|
font-weight: var(--rf-local-counter-font-weight, 500);
|
||||||
|
|
||||||
|
@-moz-document url-prefix() {
|
||||||
|
position: relative;
|
||||||
|
top: -1px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.Pathfinder {
|
||||||
|
.localCounter {
|
||||||
|
@-moz-document url-prefix() {
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
& > span {
|
||||||
|
position: relative;
|
||||||
|
top: -1px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,37 +2,34 @@ import { useMemo } from 'react';
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrapper';
|
import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrapper';
|
||||||
import { TooltipPosition } from '@/hooks/Mapper/components/ui-kit/WdTooltip';
|
import { TooltipPosition } from '@/hooks/Mapper/components/ui-kit/WdTooltip';
|
||||||
import { LocalCharactersList, CharItemProps } from '../../../mapInterface/widgets/LocalCharacters/components';
|
import { CharItemProps, LocalCharactersList } from '../../../mapInterface/widgets/LocalCharacters/components';
|
||||||
import { useLocalCharactersItemTemplate } from '../../../mapInterface/widgets/LocalCharacters/hooks/useLocalCharacters';
|
import { useLocalCharactersItemTemplate } from '../../../mapInterface/widgets/LocalCharacters/hooks/useLocalCharacters';
|
||||||
import { useLocalCharacterWidgetSettings } from '../../../mapInterface/widgets/LocalCharacters/hooks/useLocalWidgetSettings';
|
import { useLocalCharacterWidgetSettings } from '../../../mapInterface/widgets/LocalCharacters/hooks/useLocalWidgetSettings';
|
||||||
|
import classes from './SolarSystemLocalCounter.module.scss';
|
||||||
|
import { AvailableThemes } from '@/hooks/Mapper/mapRootProvider';
|
||||||
|
import { useTheme } from '@/hooks/Mapper/hooks/useTheme.ts';
|
||||||
|
|
||||||
interface LocalCounterProps {
|
interface LocalCounterProps {
|
||||||
localCounterCharacters: Array<CharItemProps>;
|
localCounterCharacters: Array<CharItemProps>;
|
||||||
classes: { [key: string]: string };
|
|
||||||
hasUserCharacters: boolean;
|
hasUserCharacters: boolean;
|
||||||
showIcon?: boolean;
|
showIcon?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function LocalCounter({
|
export const LocalCounter = ({ localCounterCharacters, hasUserCharacters, showIcon = true }: LocalCounterProps) => {
|
||||||
localCounterCharacters,
|
|
||||||
hasUserCharacters,
|
|
||||||
classes,
|
|
||||||
showIcon = true,
|
|
||||||
}: LocalCounterProps) {
|
|
||||||
const [settings] = useLocalCharacterWidgetSettings();
|
const [settings] = useLocalCharacterWidgetSettings();
|
||||||
const itemTemplate = useLocalCharactersItemTemplate(settings.showShipName);
|
const itemTemplate = useLocalCharactersItemTemplate(settings.showShipName);
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
const pilotTooltipContent = useMemo(() => {
|
const pilotTooltipContent = useMemo(() => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
width: '300px',
|
width: '100%',
|
||||||
overflowX: 'hidden',
|
minWidth: '300px',
|
||||||
overflowY: 'auto',
|
overflow: 'hidden',
|
||||||
height: '300px',
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<LocalCharactersList items={localCounterCharacters} itemTemplate={itemTemplate} itemSize={26} />
|
<LocalCharactersList items={localCounterCharacters} itemTemplate={itemTemplate} itemSize={26} autoSize={true} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}, [localCounterCharacters, itemTemplate]);
|
}, [localCounterCharacters, itemTemplate]);
|
||||||
@@ -42,23 +39,23 @@ export function LocalCounter({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.LocalCounterLayer} style={{ zIndex: 9999 }}>
|
<div
|
||||||
<WdTooltipWrapper
|
className={clsx(classes.TooltipActive, {
|
||||||
// @ts-ignore
|
[classes.Pathfinder]: theme === AvailableThemes.pathfinder,
|
||||||
content={pilotTooltipContent}
|
})}
|
||||||
position={TooltipPosition.right}
|
>
|
||||||
offset={180}
|
<WdTooltipWrapper content={pilotTooltipContent} position={TooltipPosition.right} offset={0} interactive={true}>
|
||||||
interactive={true}
|
<div className={clsx(classes.hoverTarget)}>
|
||||||
>
|
<div
|
||||||
<div
|
className={clsx(classes.localCounter, {
|
||||||
className={clsx(classes.localCounter, {
|
[classes.hasUserCharacters]: hasUserCharacters,
|
||||||
[classes.hasUserCharacters]: hasUserCharacters,
|
})}
|
||||||
})}
|
>
|
||||||
>
|
{showIcon && <i className="pi pi-users" />}
|
||||||
{showIcon && <i className="pi pi-users" style={{ fontSize: '0.50rem' }} />}
|
<span>{localCounterCharacters.length}</span>
|
||||||
<span>{localCounterCharacters.length}</span>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</WdTooltipWrapper>
|
</WdTooltipWrapper>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ $tooltip-bg: #202020;
|
|||||||
border: 1px solid darken($pastel-blue, 10%);
|
border: 1px solid darken($pastel-blue, 10%);
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 3;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
&.Mataria,
|
&.Mataria,
|
||||||
@@ -90,11 +90,7 @@ $tooltip-bg: #202020;
|
|||||||
|
|
||||||
&.eve-system-status-home {
|
&.eve-system-status-home {
|
||||||
border: 1px solid var(--eve-solar-system-status-color-home-dark30);
|
border: 1px solid var(--eve-solar-system-status-color-home-dark30);
|
||||||
background-image: linear-gradient(
|
background-image: linear-gradient(45deg, var(--eve-solar-system-status-color-background), transparent);
|
||||||
275deg,
|
|
||||||
var(--eve-solar-system-status-home),
|
|
||||||
transparent
|
|
||||||
);
|
|
||||||
&.selected {
|
&.selected {
|
||||||
border-color: var(--eve-solar-system-status-color-home);
|
border-color: var(--eve-solar-system-status-color-home);
|
||||||
}
|
}
|
||||||
@@ -102,11 +98,7 @@ $tooltip-bg: #202020;
|
|||||||
|
|
||||||
&.eve-system-status-friendly {
|
&.eve-system-status-friendly {
|
||||||
border: 1px solid var(--eve-solar-system-status-color-friendly-dark20);
|
border: 1px solid var(--eve-solar-system-status-color-friendly-dark20);
|
||||||
background-image: linear-gradient(
|
background-image: linear-gradient(275deg, var(--eve-solar-system-status-friendly-dark30), transparent);
|
||||||
275deg,
|
|
||||||
var(--eve-solar-system-status-friendly-dark30),
|
|
||||||
transparent
|
|
||||||
);
|
|
||||||
&.selected {
|
&.selected {
|
||||||
border-color: var(--eve-solar-system-status-color-friendly-dark5);
|
border-color: var(--eve-solar-system-status-color-friendly-dark5);
|
||||||
}
|
}
|
||||||
@@ -121,27 +113,15 @@ $tooltip-bg: #202020;
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.eve-system-status-warning {
|
&.eve-system-status-warning {
|
||||||
background-image: linear-gradient(
|
background-image: linear-gradient(275deg, var(--eve-solar-system-status-warning), transparent);
|
||||||
275deg,
|
|
||||||
var(--eve-solar-system-status-warning),
|
|
||||||
transparent
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.eve-system-status-dangerous {
|
&.eve-system-status-dangerous {
|
||||||
background-image: linear-gradient(
|
background-image: linear-gradient(275deg, var(--eve-solar-system-status-dangerous), transparent);
|
||||||
275deg,
|
|
||||||
var(--eve-solar-system-status-dangerous),
|
|
||||||
transparent
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.eve-system-status-target {
|
&.eve-system-status-target {
|
||||||
background-image: linear-gradient(
|
background-image: linear-gradient(275deg, var(--eve-solar-system-status-target), transparent);
|
||||||
275deg,
|
|
||||||
var(--eve-solar-system-status-target),
|
|
||||||
transparent
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,7 +234,7 @@ $tooltip-bg: #202020;
|
|||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
text-shadow: 0 0 2px rgba(231, 146, 52, 0.73);
|
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 */
|
/* Firefox kostyl */
|
||||||
@@ -263,7 +243,6 @@ $tooltip-bg: #202020;
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.BottomRow {
|
.BottomRow {
|
||||||
@@ -273,7 +252,7 @@ $tooltip-bg: #202020;
|
|||||||
height: 19px;
|
height: 19px;
|
||||||
|
|
||||||
.hasLocalCounter {
|
.hasLocalCounter {
|
||||||
margin-right: 1.25rem;
|
margin-right: 2px;
|
||||||
&.countAbove9 {
|
&.countAbove9 {
|
||||||
margin-right: 1.5rem;
|
margin-right: 1.5rem;
|
||||||
}
|
}
|
||||||
@@ -319,7 +298,8 @@ $tooltip-bg: #202020;
|
|||||||
|
|
||||||
.Handlers {
|
.Handlers {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 2;
|
z-index: 4;
|
||||||
|
pointer-events: none;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -332,6 +312,7 @@ $tooltip-bg: #202020;
|
|||||||
border: 1px solid $pastel-blue;
|
border: 1px solid $pastel-blue;
|
||||||
width: 5px;
|
width: 5px;
|
||||||
height: 5px;
|
height: 5px;
|
||||||
|
pointer-events: auto;
|
||||||
|
|
||||||
&.selected {
|
&.selected {
|
||||||
border-color: $pastel-pink;
|
border-color: $pastel-pink;
|
||||||
@@ -374,39 +355,3 @@ $tooltip-bg: #202020;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.LocalCounterLayer {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
pointer-events: none;
|
|
||||||
z-index: 9999;
|
|
||||||
padding: 8;
|
|
||||||
|
|
||||||
.localCounter {
|
|
||||||
position: absolute;
|
|
||||||
pointer-events: auto;
|
|
||||||
top: 10.5px;
|
|
||||||
right: 8px;
|
|
||||||
mix-blend-mode: screen;
|
|
||||||
gap: 2px;
|
|
||||||
color: var(--rf-node-local-counter, #5cb85c);
|
|
||||||
|
|
||||||
&.hasUserCharacters {
|
|
||||||
color: var(--rf-has-user-characters, #fbbf24);
|
|
||||||
}
|
|
||||||
|
|
||||||
& > i {
|
|
||||||
position: relative;
|
|
||||||
top: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
& > span {
|
|
||||||
font-size: 9px;
|
|
||||||
line-height: 9px;
|
|
||||||
font-weight: var(--rf-local-counter-font-weight, 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Handle, NodeProps, Position } from 'reactflow';
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import classes from './SolarSystemNodeDefault.module.scss';
|
import classes from './SolarSystemNodeDefault.module.scss';
|
||||||
import { PrimeIcons } from 'primereact/api';
|
import { PrimeIcons } from 'primereact/api';
|
||||||
import { useLocalCounter, useSolarSystemNode } from '../../hooks/useSolarSystemLogic';
|
import { useLocalCounter, useSolarSystemNode, useNodeKillsCount } from '../../hooks/useSolarSystemLogic';
|
||||||
import {
|
import {
|
||||||
EFFECT_BACKGROUND_STYLES,
|
EFFECT_BACKGROUND_STYLES,
|
||||||
MARKER_BOOKMARK_BG_STYLES,
|
MARKER_BOOKMARK_BG_STYLES,
|
||||||
@@ -18,6 +18,7 @@ import { KillsCounter } from './SolarSystemKillsCounter';
|
|||||||
export const SolarSystemNodeDefault = memo((props: NodeProps<MapSolarSystemType>) => {
|
export const SolarSystemNodeDefault = memo((props: NodeProps<MapSolarSystemType>) => {
|
||||||
const nodeVars = useSolarSystemNode(props);
|
const nodeVars = useSolarSystemNode(props);
|
||||||
const { localCounterCharacters } = useLocalCounter(nodeVars);
|
const { localCounterCharacters } = useLocalCounter(nodeVars);
|
||||||
|
const localKillsCount = useNodeKillsCount(nodeVars.solarSystemId, nodeVars.killsCount);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -35,9 +36,9 @@ export const SolarSystemNodeDefault = memo((props: NodeProps<MapSolarSystemType>
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{nodeVars.killsCount && nodeVars.killsCount > 0 && nodeVars.solarSystemId && (
|
{localKillsCount && localKillsCount > 0 && nodeVars.solarSystemId && (
|
||||||
<KillsCounter
|
<KillsCounter
|
||||||
killsCount={nodeVars.killsCount}
|
killsCount={localKillsCount}
|
||||||
systemId={nodeVars.solarSystemId}
|
systemId={nodeVars.solarSystemId}
|
||||||
size="lg"
|
size="lg"
|
||||||
killsActivityType={nodeVars.killsActivityType}
|
killsActivityType={nodeVars.killsActivityType}
|
||||||
@@ -65,6 +66,7 @@ export const SolarSystemNodeDefault = memo((props: NodeProps<MapSolarSystemType>
|
|||||||
nodeVars.status !== undefined ? classes[STATUS_CLASSES[nodeVars.status]] : '',
|
nodeVars.status !== undefined ? classes[STATUS_CLASSES[nodeVars.status]] : '',
|
||||||
{ [classes.selected]: nodeVars.selected },
|
{ [classes.selected]: nodeVars.selected },
|
||||||
)}
|
)}
|
||||||
|
onMouseDownCapture={e => nodeVars.dbClick(e)}
|
||||||
>
|
>
|
||||||
{nodeVars.visible && (
|
{nodeVars.visible && (
|
||||||
<>
|
<>
|
||||||
@@ -120,18 +122,18 @@ export const SolarSystemNodeDefault = memo((props: NodeProps<MapSolarSystemType>
|
|||||||
|
|
||||||
{nodeVars.isWormhole && !nodeVars.customName && <div />}
|
{nodeVars.isWormhole && !nodeVars.customName && <div />}
|
||||||
|
|
||||||
<div className="flex items-center justify-end">
|
<div className="flex items-center gap-1 justify-end">
|
||||||
<div
|
<div className={clsx('flex items-center gap-1')}>
|
||||||
className={clsx('flex items-center gap-1', {
|
|
||||||
[classes.hasLocalCounter]: nodeVars.charactersInSystem.length > 0,
|
|
||||||
[classes.countAbove9]: nodeVars.charactersInSystem.length > 9,
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
{nodeVars.locked && <i className={clsx(PrimeIcons.LOCK, classes.lockIcon)} />}
|
{nodeVars.locked && <i className={clsx(PrimeIcons.LOCK, classes.lockIcon)} />}
|
||||||
{nodeVars.hubs.includes(nodeVars.solarSystemId) && (
|
{nodeVars.hubs.includes(nodeVars.solarSystemId) && (
|
||||||
<i className={clsx(PrimeIcons.MAP_MARKER, classes.mapMarker)} />
|
<i className={clsx(PrimeIcons.MAP_MARKER, classes.mapMarker)} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<LocalCounter
|
||||||
|
hasUserCharacters={nodeVars.hasUserCharacters}
|
||||||
|
localCounterCharacters={localCounterCharacters}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
@@ -158,7 +160,7 @@ export const SolarSystemNodeDefault = memo((props: NodeProps<MapSolarSystemType>
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div onMouseDownCapture={e => nodeVars.dbClick(e)} className={classes.Handlers}>
|
<div className={classes.Handlers}>
|
||||||
<Handle
|
<Handle
|
||||||
type="source"
|
type="source"
|
||||||
className={clsx(classes.Handle, classes.HandleTop, {
|
className={clsx(classes.Handle, classes.HandleTop, {
|
||||||
@@ -200,11 +202,6 @@ export const SolarSystemNodeDefault = memo((props: NodeProps<MapSolarSystemType>
|
|||||||
id="d"
|
id="d"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<LocalCounter
|
|
||||||
hasUserCharacters={nodeVars.hasUserCharacters}
|
|
||||||
localCounterCharacters={localCounterCharacters}
|
|
||||||
classes={classes}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,3 +4,17 @@
|
|||||||
Only override what's different from the base
|
Only override what's different from the base
|
||||||
Currently none required
|
Currently none required
|
||||||
---------------------------------------------- */
|
---------------------------------------------- */
|
||||||
|
|
||||||
|
.RootCustomNode {
|
||||||
|
&.eve-system-status-home {
|
||||||
|
border: 1px solid var(--eve-solar-system-status-color-home-dark30);
|
||||||
|
background-image: linear-gradient(
|
||||||
|
275deg,
|
||||||
|
var(--eve-solar-system-status-home),
|
||||||
|
transparent
|
||||||
|
);
|
||||||
|
&.selected {
|
||||||
|
border-color: var(--eve-solar-system-status-color-home);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Handle, NodeProps, Position } from 'reactflow';
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import classes from './SolarSystemNodeTheme.module.scss';
|
import classes from './SolarSystemNodeTheme.module.scss';
|
||||||
import { PrimeIcons } from 'primereact/api';
|
import { PrimeIcons } from 'primereact/api';
|
||||||
import { useLocalCounter, useSolarSystemNode } from '../../hooks/useSolarSystemLogic';
|
import { useLocalCounter, useNodeKillsCount, useSolarSystemNode } from '../../hooks/useSolarSystemLogic';
|
||||||
import {
|
import {
|
||||||
EFFECT_BACKGROUND_STYLES,
|
EFFECT_BACKGROUND_STYLES,
|
||||||
MARKER_BOOKMARK_BG_STYLES,
|
MARKER_BOOKMARK_BG_STYLES,
|
||||||
@@ -18,6 +18,7 @@ import { KillsCounter } from './SolarSystemKillsCounter';
|
|||||||
export const SolarSystemNodeTheme = memo((props: NodeProps<MapSolarSystemType>) => {
|
export const SolarSystemNodeTheme = memo((props: NodeProps<MapSolarSystemType>) => {
|
||||||
const nodeVars = useSolarSystemNode(props);
|
const nodeVars = useSolarSystemNode(props);
|
||||||
const { localCounterCharacters } = useLocalCounter(nodeVars);
|
const { localCounterCharacters } = useLocalCounter(nodeVars);
|
||||||
|
const localKillsCount = useNodeKillsCount(nodeVars.solarSystemId, nodeVars.killsCount);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -25,7 +26,7 @@ export const SolarSystemNodeTheme = memo((props: NodeProps<MapSolarSystemType>)
|
|||||||
<div className={classes.Bookmarks}>
|
<div className={classes.Bookmarks}>
|
||||||
{nodeVars.labelCustom !== '' && (
|
{nodeVars.labelCustom !== '' && (
|
||||||
<div className={clsx(classes.Bookmark, MARKER_BOOKMARK_BG_STYLES.custom)}>
|
<div className={clsx(classes.Bookmark, MARKER_BOOKMARK_BG_STYLES.custom)}>
|
||||||
<span className="[text-shadow:_0_1px_0_rgb(0_0_0_/_40%)] ">{nodeVars.labelCustom}</span>
|
<span className="[text-shadow:_0_1px_0_rgb(0_0_0_/_40%)]">{nodeVars.labelCustom}</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -35,9 +36,9 @@ export const SolarSystemNodeTheme = memo((props: NodeProps<MapSolarSystemType>)
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{nodeVars.killsCount && nodeVars.killsCount > 0 && nodeVars.solarSystemId && (
|
{localKillsCount && localKillsCount > 0 && nodeVars.solarSystemId && (
|
||||||
<KillsCounter
|
<KillsCounter
|
||||||
killsCount={nodeVars.killsCount}
|
killsCount={localKillsCount}
|
||||||
systemId={nodeVars.solarSystemId}
|
systemId={nodeVars.solarSystemId}
|
||||||
size="lg"
|
size="lg"
|
||||||
killsActivityType={nodeVars.killsActivityType}
|
killsActivityType={nodeVars.killsActivityType}
|
||||||
@@ -65,6 +66,7 @@ export const SolarSystemNodeTheme = memo((props: NodeProps<MapSolarSystemType>)
|
|||||||
nodeVars.status !== undefined ? classes[STATUS_CLASSES[nodeVars.status]] : '',
|
nodeVars.status !== undefined ? classes[STATUS_CLASSES[nodeVars.status]] : '',
|
||||||
{ [classes.selected]: nodeVars.selected },
|
{ [classes.selected]: nodeVars.selected },
|
||||||
)}
|
)}
|
||||||
|
onMouseDownCapture={e => nodeVars.dbClick(e)}
|
||||||
>
|
>
|
||||||
{nodeVars.visible && (
|
{nodeVars.visible && (
|
||||||
<>
|
<>
|
||||||
@@ -130,18 +132,18 @@ export const SolarSystemNodeTheme = memo((props: NodeProps<MapSolarSystemType>)
|
|||||||
|
|
||||||
{nodeVars.isWormhole && !nodeVars.customName && <div />}
|
{nodeVars.isWormhole && !nodeVars.customName && <div />}
|
||||||
|
|
||||||
<div className="flex items-center justify-end">
|
<div className="flex items-center gap-1 justify-end">
|
||||||
<div
|
<div className={clsx('flex items-center gap-1')}>
|
||||||
className={clsx('flex items-center gap-1', {
|
|
||||||
[classes.hasLocalCounter]: nodeVars.charactersInSystem.length > 0,
|
|
||||||
[classes.countAbove9]: nodeVars.charactersInSystem.length > 9,
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
{nodeVars.locked && <i className={clsx(PrimeIcons.LOCK, classes.lockIcon)} />}
|
{nodeVars.locked && <i className={clsx(PrimeIcons.LOCK, classes.lockIcon)} />}
|
||||||
{nodeVars.hubs.includes(nodeVars.solarSystemId) && (
|
{nodeVars.hubs.includes(nodeVars.solarSystemId) && (
|
||||||
<i className={clsx(PrimeIcons.MAP_MARKER, classes.mapMarker)} />
|
<i className={clsx(PrimeIcons.MAP_MARKER, classes.mapMarker)} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<LocalCounter
|
||||||
|
hasUserCharacters={nodeVars.hasUserCharacters}
|
||||||
|
localCounterCharacters={localCounterCharacters}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
@@ -168,7 +170,7 @@ export const SolarSystemNodeTheme = memo((props: NodeProps<MapSolarSystemType>)
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div onMouseDownCapture={e => nodeVars.dbClick(e)} className={classes.Handlers}>
|
<div className={classes.Handlers}>
|
||||||
<Handle
|
<Handle
|
||||||
type="source"
|
type="source"
|
||||||
className={clsx(classes.Handle, classes.HandleTop, {
|
className={clsx(classes.Handle, classes.HandleTop, {
|
||||||
@@ -210,11 +212,6 @@ export const SolarSystemNodeTheme = memo((props: NodeProps<MapSolarSystemType>)
|
|||||||
id="d"
|
id="d"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<LocalCounter
|
|
||||||
hasUserCharacters={nodeVars.hasUserCharacters}
|
|
||||||
localCounterCharacters={localCounterCharacters}
|
|
||||||
classes={classes}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,5 +10,6 @@ export const convertSystem2Node = (sys: SolarSystemRawType): Node => {
|
|||||||
position: sys.position,
|
position: sys.position,
|
||||||
data: sys,
|
data: sys,
|
||||||
draggable: !sys.locked,
|
draggable: !sys.locked,
|
||||||
|
deletable: !sys.locked,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useMemo } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
import { MapSolarSystemType } from '../map.types';
|
import { MapSolarSystemType } from '../map.types';
|
||||||
import { NodeProps } from 'reactflow';
|
import { NodeProps } from 'reactflow';
|
||||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||||
@@ -10,8 +10,9 @@ import { isWormholeSpace } from '@/hooks/Mapper/components/map/helpers/isWormhol
|
|||||||
import { getSystemClassStyles, prepareUnsplashedChunks } from '@/hooks/Mapper/components/map/helpers';
|
import { getSystemClassStyles, prepareUnsplashedChunks } from '@/hooks/Mapper/components/map/helpers';
|
||||||
import { sortWHClasses } from '@/hooks/Mapper/helpers';
|
import { sortWHClasses } from '@/hooks/Mapper/helpers';
|
||||||
import { LabelsManager } from '@/hooks/Mapper/utils/labelsManager';
|
import { LabelsManager } from '@/hooks/Mapper/utils/labelsManager';
|
||||||
import { CharacterTypeRaw, OutCommand, SystemSignature } from '@/hooks/Mapper/types';
|
import { CharacterTypeRaw, Commands, OutCommand, SystemSignature } from '@/hooks/Mapper/types';
|
||||||
import { LABELS_INFO, LABELS_ORDER } from '@/hooks/Mapper/components/map/constants';
|
import { LABELS_INFO, LABELS_ORDER } from '@/hooks/Mapper/components/map/constants';
|
||||||
|
import { useMapEventListener } from '@/hooks/Mapper/events';
|
||||||
|
|
||||||
export type LabelInfo = {
|
export type LabelInfo = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -195,7 +196,6 @@ export function useSolarSystemNode(props: NodeProps<MapSolarSystemType>): SolarS
|
|||||||
kind: s.kind,
|
kind: s.kind,
|
||||||
name: s.name,
|
name: s.name,
|
||||||
group: s.group,
|
group: s.group,
|
||||||
sig_id: s.eve_id, // Add a unique key property
|
|
||||||
})) as UnsplashedSignatureType[],
|
})) as UnsplashedSignatureType[],
|
||||||
);
|
);
|
||||||
}, [isShowUnsplashedSignatures, systemSigs]);
|
}, [isShowUnsplashedSignatures, systemSigs]);
|
||||||
@@ -281,3 +281,25 @@ export interface SolarSystemNodeVars {
|
|||||||
classTitle: string | null;
|
classTitle: string | null;
|
||||||
temporaryName?: 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;
|
||||||
|
}
|
||||||
@@ -31,6 +31,6 @@
|
|||||||
--window-corner: #72716f;
|
--window-corner: #72716f;
|
||||||
|
|
||||||
--rf-local-counter-font-weight: 500;
|
--rf-local-counter-font-weight: 500;
|
||||||
--rf-node-local-counter: #5cb85c;
|
--rf-node-local-counter: inherit;
|
||||||
--rf-has-user-characters: #fbbf24;
|
--rf-has-user-characters: #ffc75d;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
|
|
||||||
$friendlyBase: #3bbd39;
|
$friendlyBase: #3bbd39;
|
||||||
$friendlyAlpha: #3bbd3952;
|
$friendlyAlpha: #3bbd3952;
|
||||||
$friendlyDark20: darken($friendlyBase, 20%);
|
$friendlyDark20: darken($friendlyBase, 20%);
|
||||||
$friendlyDark30: darken($friendlyBase, 30%);
|
$friendlyDark30: darken($friendlyBase, 30%);
|
||||||
$friendlyDark5: darken($friendlyBase, 5%);
|
$friendlyDark5: darken($friendlyBase, 5%);
|
||||||
|
|
||||||
$lookingForBase: #43c2fd;
|
$lookingForBase: #43c2fd;
|
||||||
$lookingForAlpha: rgba(67, 176, 253, 0.48);
|
$lookingForAlpha: rgba(67, 176, 253, 0.48);
|
||||||
$lookingForDark15: darken($lookingForBase, 15%);
|
$lookingForDark15: darken($lookingForBase, 15%);
|
||||||
|
|
||||||
$homeBase: rgb(197, 253, 67);
|
$homeBase: rgb(179, 253, 67);
|
||||||
$homeAlpha: rgba(197, 253, 67, 0.32);
|
$homeAlpha: rgba(186, 248, 48, 0.32);
|
||||||
|
$homeBackground: #a0fa5636;
|
||||||
$homeDark30: darken($homeBase, 30%);
|
$homeDark30: darken($homeBase, 30%);
|
||||||
|
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--pastel-blue: #5a7d9a;
|
--pastel-blue: #5a7d9a;
|
||||||
--pastel-pink: #d291bc;
|
--pastel-pink: #d291bc;
|
||||||
@@ -98,6 +98,7 @@ $homeDark30: darken($homeBase, 30%);
|
|||||||
--eve-solar-system-status-color-unknown: transparent;
|
--eve-solar-system-status-color-unknown: transparent;
|
||||||
--eve-solar-system-status-home: #{$homeAlpha};
|
--eve-solar-system-status-home: #{$homeAlpha};
|
||||||
--eve-solar-system-status-color-home: #{$homeBase};
|
--eve-solar-system-status-color-home: #{$homeBase};
|
||||||
|
--eve-solar-system-status-color-background: #{$homeBackground};
|
||||||
--eve-solar-system-status-color-home-dark30: #{$homeDark30};
|
--eve-solar-system-status-color-home-dark30: #{$homeDark30};
|
||||||
--eve-solar-system-status-friendly: #{$friendlyAlpha};
|
--eve-solar-system-status-friendly: #{$friendlyAlpha};
|
||||||
--eve-solar-system-status-color-friendly: #{$friendlyBase};
|
--eve-solar-system-status-color-friendly: #{$friendlyBase};
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
@import './eve-common';
|
@import './eve-common';
|
||||||
@import url('https://fonts.googleapis.com/css2?family=Oxygen:wght@300;400;700&display=swap');
|
@import url('https://fonts.googleapis.com/css2?family=Oxygen:wght@300;400;700&display=swap');
|
||||||
|
|
||||||
|
$homeBase: rgb(197, 253, 67);
|
||||||
|
$homeAlpha: rgba(197, 253, 67, 0.32);
|
||||||
|
$homeDark30: darken($homeBase, 30%);
|
||||||
|
|
||||||
.pathfinder-theme {
|
.pathfinder-theme {
|
||||||
/* -- Override values from the default theme -- */
|
/* -- Override values from the default theme -- */
|
||||||
--rf-bg-color: #000000;
|
--rf-bg-color: #000000;
|
||||||
@@ -41,4 +45,10 @@
|
|||||||
--eve-wh-type-color-c6: #d9534f;
|
--eve-wh-type-color-c6: #d9534f;
|
||||||
--eve-wh-type-color-c13: #7986cb;
|
--eve-wh-type-color-c13: #7986cb;
|
||||||
--eve-wh-type-color-drifter: #44aa82;
|
--eve-wh-type-color-drifter: #44aa82;
|
||||||
|
|
||||||
|
--rf-node-local-counter: #5cb85c;
|
||||||
|
--rf-has-user-characters: #ffc75d;
|
||||||
|
|
||||||
|
--eve-solar-system-status-home: #{$homeAlpha};
|
||||||
|
--eve-solar-system-status-color-home: #{$homeBase};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ import clsx from 'clsx';
|
|||||||
|
|
||||||
export interface WidgetProps {
|
export interface WidgetProps {
|
||||||
label: React.ReactNode | string;
|
label: React.ReactNode | string;
|
||||||
|
windowId?: string;
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Widget = ({ label, children }: WidgetProps) => {
|
export const Widget = ({ label, children, windowId }: WidgetProps) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
data-window-id={windowId}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
classes.root,
|
classes.root,
|
||||||
'flex flex-col w-full h-full rounded',
|
'flex flex-col w-full h-full rounded',
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
.VirtualScroller {
|
||||||
|
height: 100% !important;
|
||||||
|
}
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
import { useMemo, useRef } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { Widget } from '@/hooks/Mapper/components/mapInterface/components';
|
import { Widget } from '@/hooks/Mapper/components/mapInterface/components';
|
||||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||||
import clsx from 'clsx';
|
import { sortCharacters } from '@/hooks/Mapper/components/mapInterface/helpers/sortCharacters';
|
||||||
import { LayoutEventBlocker, WdCheckbox } from '@/hooks/Mapper/components/ui-kit';
|
|
||||||
import { sortCharacters } from '@/hooks/Mapper/components/mapInterface/helpers/sortCharacters.ts';
|
|
||||||
import { useMapCheckPermissions, useMapGetOption } from '@/hooks/Mapper/mapRootProvider/hooks/api';
|
import { useMapCheckPermissions, useMapGetOption } from '@/hooks/Mapper/mapRootProvider/hooks/api';
|
||||||
import { UserPermission } from '@/hooks/Mapper/types/permissions.ts';
|
import { UserPermission } from '@/hooks/Mapper/types/permissions';
|
||||||
import useMaxWidth from '@/hooks/Mapper/hooks/useMaxWidth.ts';
|
|
||||||
import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrapper';
|
|
||||||
import { LocalCharactersList } from './components/LocalCharactersList';
|
import { LocalCharactersList } from './components/LocalCharactersList';
|
||||||
import { useLocalCharactersItemTemplate } from './hooks/useLocalCharacters';
|
import { useLocalCharactersItemTemplate } from './hooks/useLocalCharacters';
|
||||||
import { useLocalCharacterWidgetSettings } from './hooks/useLocalWidgetSettings';
|
import { useLocalCharacterWidgetSettings } from './hooks/useLocalWidgetSettings';
|
||||||
|
import { LocalCharactersHeader } from './components/LocalCharactersHeader';
|
||||||
|
import classes from './LocalCharacters.module.scss';
|
||||||
|
import clsx from 'clsx';
|
||||||
|
|
||||||
export const LocalCharacters = () => {
|
export const LocalCharacters = () => {
|
||||||
const {
|
const {
|
||||||
@@ -18,11 +17,9 @@ export const LocalCharacters = () => {
|
|||||||
} = useMapRootState();
|
} = useMapRootState();
|
||||||
|
|
||||||
const [settings, setSettings] = useLocalCharacterWidgetSettings();
|
const [settings, setSettings] = useLocalCharacterWidgetSettings();
|
||||||
|
|
||||||
const [systemId] = selectedSystems;
|
const [systemId] = selectedSystems;
|
||||||
const restrictOfflineShowing = useMapGetOption('restrict_offline_showing');
|
const restrictOfflineShowing = useMapGetOption('restrict_offline_showing');
|
||||||
const isAdminOrManager = useMapCheckPermissions([UserPermission.MANAGE_MAP]);
|
const isAdminOrManager = useMapCheckPermissions([UserPermission.MANAGE_MAP]);
|
||||||
|
|
||||||
const showOffline = useMemo(
|
const showOffline = useMemo(
|
||||||
() => !restrictOfflineShowing || isAdminOrManager,
|
() => !restrictOfflineShowing || isAdminOrManager,
|
||||||
[isAdminOrManager, restrictOfflineShowing],
|
[isAdminOrManager, restrictOfflineShowing],
|
||||||
@@ -42,7 +39,6 @@ export const LocalCharacters = () => {
|
|||||||
if (!showOffline || !settings.showOffline) {
|
if (!showOffline || !settings.showOffline) {
|
||||||
return filtered.filter(c => c.online);
|
return filtered.filter(c => c.online);
|
||||||
}
|
}
|
||||||
|
|
||||||
return filtered;
|
return filtered;
|
||||||
}, [
|
}, [
|
||||||
characters,
|
characters,
|
||||||
@@ -58,64 +54,18 @@ export const LocalCharacters = () => {
|
|||||||
const isNotSelectedSystem = selectedSystems.length !== 1;
|
const isNotSelectedSystem = selectedSystems.length !== 1;
|
||||||
const showList = sorted.length > 0 && selectedSystems.length === 1;
|
const showList = sorted.length > 0 && selectedSystems.length === 1;
|
||||||
|
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
|
||||||
const compact = useMaxWidth(ref, 145);
|
|
||||||
|
|
||||||
const itemTemplate = useLocalCharactersItemTemplate(settings.showShipName);
|
const itemTemplate = useLocalCharactersItemTemplate(settings.showShipName);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Widget
|
<Widget
|
||||||
label={
|
label={
|
||||||
<div className="flex w-full items-center" ref={ref}>
|
<LocalCharactersHeader
|
||||||
<div className="flex-shrink-0 select-none mr-2">
|
sortedCount={sorted.length}
|
||||||
Local{showList ? ` [${sorted.length}]` : ''}
|
showList={showList}
|
||||||
</div>
|
showOffline={showOffline}
|
||||||
<div className="flex-grow overflow-hidden">
|
settings={settings}
|
||||||
<LayoutEventBlocker className="flex items-center gap-2 justify-end">
|
setSettings={setSettings}
|
||||||
{showOffline && (
|
/>
|
||||||
<WdTooltipWrapper content="Show offline characters in system">
|
|
||||||
<div className={clsx("min-w-0", { "max-w-[100px]": compact })}>
|
|
||||||
<WdCheckbox
|
|
||||||
size="xs"
|
|
||||||
labelSide="left"
|
|
||||||
label="Show offline"
|
|
||||||
value={settings.showOffline}
|
|
||||||
classNameLabel={clsx("whitespace-nowrap", { "truncate": compact })}
|
|
||||||
onChange={() =>
|
|
||||||
setSettings(prev => ({ ...prev, showOffline: !prev.showOffline }))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</WdTooltipWrapper>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{settings.compact && (
|
|
||||||
<WdTooltipWrapper content="Show ship name in compact rows">
|
|
||||||
<div className={clsx("min-w-0", { "max-w-[100px]": compact })}>
|
|
||||||
<WdCheckbox
|
|
||||||
size="xs"
|
|
||||||
labelSide="left"
|
|
||||||
label="Show ship name"
|
|
||||||
value={settings.showShipName}
|
|
||||||
classNameLabel={clsx("whitespace-nowrap", { "truncate": compact })}
|
|
||||||
onChange={() =>
|
|
||||||
setSettings(prev => ({ ...prev, showShipName: !prev.showShipName }))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</WdTooltipWrapper>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<span
|
|
||||||
className={clsx("w-4 h-4 cursor-pointer", {
|
|
||||||
"hero-bars-2": settings.compact,
|
|
||||||
"hero-bars-3": !settings.compact,
|
|
||||||
})}
|
|
||||||
onClick={() => setSettings(prev => ({ ...prev, compact: !prev.compact }))}
|
|
||||||
/>
|
|
||||||
</LayoutEventBlocker>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{isNotSelectedSystem && (
|
{isNotSelectedSystem && (
|
||||||
@@ -123,19 +73,20 @@ export const LocalCharacters = () => {
|
|||||||
System is not selected
|
System is not selected
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isNobodyHere && !isNotSelectedSystem && (
|
{isNobodyHere && !isNotSelectedSystem && (
|
||||||
<div className="w-full h-full flex justify-center items-center select-none text-stone-400/80 text-sm">
|
<div className="w-full h-full flex justify-center items-center select-none text-stone-400/80 text-sm">
|
||||||
Nobody here
|
Nobody here
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{showList && (
|
{showList && (
|
||||||
<LocalCharactersList
|
<LocalCharactersList
|
||||||
items={sorted}
|
items={sorted}
|
||||||
itemSize={settings.compact ? 26 : 41}
|
itemSize={settings.compact ? 26 : 41}
|
||||||
itemTemplate={itemTemplate}
|
itemTemplate={itemTemplate}
|
||||||
containerClassName="w-full h-full overflow-x-hidden overflow-y-auto"
|
containerClassName={clsx(
|
||||||
|
'w-full h-full overflow-x-hidden overflow-y-auto custom-scrollbar select-none',
|
||||||
|
classes.VirtualScroller,
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
// .VirtualScroller {
|
|
||||||
// height: 100% !important;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import React, { useRef } from 'react';
|
||||||
|
import clsx from 'clsx';
|
||||||
|
import useMaxWidth from '@/hooks/Mapper/hooks/useMaxWidth';
|
||||||
|
import { LayoutEventBlocker, TooltipPosition, WdCheckbox, WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit';
|
||||||
|
|
||||||
|
interface LocalCharactersHeaderProps {
|
||||||
|
sortedCount: number;
|
||||||
|
showList: boolean;
|
||||||
|
showOffline: boolean;
|
||||||
|
settings: {
|
||||||
|
compact: boolean;
|
||||||
|
showOffline: boolean;
|
||||||
|
showShipName: boolean;
|
||||||
|
};
|
||||||
|
setSettings: (fn: (prev: any) => any) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const LocalCharactersHeader: React.FC<LocalCharactersHeaderProps> = ({
|
||||||
|
sortedCount,
|
||||||
|
showList,
|
||||||
|
showOffline,
|
||||||
|
settings,
|
||||||
|
setSettings,
|
||||||
|
}) => {
|
||||||
|
const headerRef = useRef<HTMLDivElement>(null);
|
||||||
|
const compactOffline = useMaxWidth(headerRef, 145);
|
||||||
|
const compactShipName = useMaxWidth(headerRef, 195);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex w-full items-center text-xs justify-between" ref={headerRef}>
|
||||||
|
<div className="flex-shrink-0 select-none mr-2">Local{showList ? ` [${sortedCount}]` : ''}</div>
|
||||||
|
<LayoutEventBlocker className="flex items-center gap-2 justify-end">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
{showOffline && (
|
||||||
|
<WdTooltipWrapper content="Show offline characters in system" position={TooltipPosition.top}>
|
||||||
|
<WdCheckbox
|
||||||
|
size="xs"
|
||||||
|
labelSide="left"
|
||||||
|
label={compactOffline ? '' : 'Offline'}
|
||||||
|
value={settings.showOffline}
|
||||||
|
onChange={() => setSettings((prev: any) => ({ ...prev, showOffline: !prev.showOffline }))}
|
||||||
|
classNameLabel={clsx('whitespace-nowrap text-stone-400 hover:text-stone-200 transition duration-300', {
|
||||||
|
truncate: compactOffline,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
</WdTooltipWrapper>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{settings.compact && (
|
||||||
|
<WdTooltipWrapper content="Show ship name in compact rows" position={TooltipPosition.top}>
|
||||||
|
<WdCheckbox
|
||||||
|
size="xs"
|
||||||
|
labelSide="left"
|
||||||
|
label={compactShipName ? '' : 'Ship name'}
|
||||||
|
value={settings.showShipName}
|
||||||
|
onChange={() => setSettings((prev: any) => ({ ...prev, showShipName: !prev.showShipName }))}
|
||||||
|
classNameLabel={clsx('whitespace-nowrap text-stone-400 hover:text-stone-200 transition duration-300', {
|
||||||
|
truncate: compactShipName,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
</WdTooltipWrapper>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<WdTooltipWrapper content="Enable compact mode" position={TooltipPosition.top}>
|
||||||
|
<span
|
||||||
|
className={clsx('w-4 h-4 min-w-[1rem] cursor-pointer', {
|
||||||
|
'hero-bars-2': settings.compact,
|
||||||
|
'hero-bars-3': !settings.compact,
|
||||||
|
})}
|
||||||
|
onClick={() => setSettings((prev: any) => ({ ...prev, compact: !prev.compact }))}
|
||||||
|
/>
|
||||||
|
</WdTooltipWrapper>
|
||||||
|
</LayoutEventBlocker>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,13 +1,6 @@
|
|||||||
.VirtualScroller {
|
|
||||||
height: 100% !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CharacterRow {
|
.CharacterRow {
|
||||||
//border-left-width: 1px;
|
|
||||||
|
|
||||||
&.CardBorderLeftIsOwn {
|
&.CardBorderLeftIsOwn {
|
||||||
border-left-color: rgb(251 146 60 / 1)
|
border-left-color: rgb(251 146 60 / 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import classes from './LocalCharactersItemTemplate.module.scss';
|
||||||
|
import clsx from 'clsx';
|
||||||
|
import { CharacterCard } from '@/hooks/Mapper/components/ui-kit';
|
||||||
|
import { CharItemProps } from '@/hooks/Mapper/components/mapInterface/widgets/LocalCharacters/components';
|
||||||
|
import { VirtualScrollerTemplateOptions } from 'primereact/virtualscroller';
|
||||||
|
|
||||||
|
export type LocalCharactersItemTemplateProps = { showShipName: boolean } & CharItemProps &
|
||||||
|
VirtualScrollerTemplateOptions;
|
||||||
|
|
||||||
|
export const LocalCharactersItemTemplate = ({ showShipName, ...options }: LocalCharactersItemTemplateProps) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={clsx(
|
||||||
|
classes.CharacterRow,
|
||||||
|
'box-border flex items-center w-full whitespace-nowrap overflow-hidden text-ellipsis min-w-[0px]',
|
||||||
|
{
|
||||||
|
'surface-hover': options.odd,
|
||||||
|
'border-b border-gray-600 border-opacity-20': !options.last,
|
||||||
|
'bg-green-500 hover:bg-green-700 transition duration-300 bg-opacity-10 hover:bg-opacity-10': options.online,
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
style={{ height: `${options.props.itemSize}px` }}
|
||||||
|
>
|
||||||
|
<CharacterCard showShipName={showShipName} {...options} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './LocalCharactersItemTemplate.tsx';
|
||||||
@@ -3,25 +3,42 @@ import { VirtualScroller, VirtualScrollerTemplateOptions } from 'primereact/virt
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { CharItemProps } from './types';
|
import { CharItemProps } from './types';
|
||||||
|
|
||||||
type LocalCharactersListProps = {
|
export type LocalCharactersListProps = {
|
||||||
items: Array<CharItemProps>;
|
items: Array<CharItemProps>;
|
||||||
|
|
||||||
itemSize: number;
|
itemSize: number;
|
||||||
|
|
||||||
itemTemplate: (char: CharItemProps, options: VirtualScrollerTemplateOptions) => React.ReactNode;
|
itemTemplate: (char: CharItemProps, options: VirtualScrollerTemplateOptions) => React.ReactNode;
|
||||||
|
|
||||||
containerClassName?: string;
|
containerClassName?: string;
|
||||||
|
style?: React.CSSProperties;
|
||||||
|
autoSize?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function LocalCharactersList({ items, itemSize, itemTemplate, containerClassName }: LocalCharactersListProps) {
|
export const LocalCharactersList = ({
|
||||||
|
items,
|
||||||
|
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 (
|
return (
|
||||||
<VirtualScroller
|
<VirtualScroller
|
||||||
items={items}
|
items={items}
|
||||||
itemSize={itemSize}
|
itemSize={itemSize}
|
||||||
orientation="vertical"
|
orientation="vertical"
|
||||||
className={clsx('w-full h-full', containerClassName)}
|
className={clsx('w-full h-full', containerClassName)}
|
||||||
autoSize={false}
|
|
||||||
itemTemplate={itemTemplate}
|
itemTemplate={itemTemplate}
|
||||||
|
autoSize={autoSize}
|
||||||
|
style={localStyle}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
|
export * from './LocalCharactersItemTemplate';
|
||||||
export * from './LocalCharactersList';
|
export * from './LocalCharactersList';
|
||||||
export * from './types';
|
export * from './types';
|
||||||
|
|||||||
@@ -1,33 +1,12 @@
|
|||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { VirtualScrollerTemplateOptions } from 'primereact/virtualscroller';
|
import { VirtualScrollerTemplateOptions } from 'primereact/virtualscroller';
|
||||||
import clsx from 'clsx';
|
import { CharItemProps, LocalCharactersItemTemplate } from '../components';
|
||||||
import classes from './useLocalCharacters.module.scss';
|
|
||||||
import { CharacterCard } from '@/hooks/Mapper/components/ui-kit';
|
|
||||||
import { CharItemProps } from '../components';
|
|
||||||
|
|
||||||
export function useLocalCharactersItemTemplate(showShipName: boolean) {
|
export function useLocalCharactersItemTemplate(showShipName: boolean) {
|
||||||
return useCallback(
|
return useCallback(
|
||||||
(char: CharItemProps, options: VirtualScrollerTemplateOptions) => {
|
(char: CharItemProps, options: VirtualScrollerTemplateOptions) => (
|
||||||
return (
|
<LocalCharactersItemTemplate {...char} {...options} showShipName={showShipName} />
|
||||||
<div
|
),
|
||||||
className={clsx(classes.CharacterRow, 'box-border flex items-center', {
|
|
||||||
'surface-hover': options.odd,
|
|
||||||
'border-b border-gray-600 border-opacity-20': !options.last,
|
|
||||||
'bg-green-500 hover:bg-green-700 transition duration-300 bg-opacity-10 hover:bg-opacity-10': char.online,
|
|
||||||
})}
|
|
||||||
style={{
|
|
||||||
height: `${options.props.itemSize}px`,
|
|
||||||
whiteSpace: 'nowrap',
|
|
||||||
overflow: 'hidden',
|
|
||||||
textOverflow: 'ellipsis',
|
|
||||||
minWidth: 0,
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<CharacterCard showShipName={showShipName} {...char} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
[showShipName],
|
[showShipName],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import classes from './RoutesList.module.scss';
|
import classes from './RoutesList.module.scss';
|
||||||
import { Route, SystemStaticInfoShort } from '@/hooks/Mapper/types/routes.ts';
|
import { Route, SystemStaticInfoShort } from '@/hooks/Mapper/types/routes.ts';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { SystemViewStandalone, WdTooltip, WdTooltipHandlers } from '@/hooks/Mapper/components/ui-kit';
|
import { SystemViewStandalone, TooltipPosition, WdTooltip, WdTooltipHandlers } from '@/hooks/Mapper/components/ui-kit';
|
||||||
import { getBackgroundClass, getShapeClass } from '@/hooks/Mapper/components/map/helpers';
|
import { getBackgroundClass, getShapeClass } from '@/hooks/Mapper/components/map/helpers';
|
||||||
import { MouseEvent, useCallback, useRef, useState } from 'react';
|
import { MouseEvent, useCallback, useRef, useState } from 'react';
|
||||||
import { Commands } from '@/hooks/Mapper/types';
|
import { Commands } from '@/hooks/Mapper/types';
|
||||||
@@ -46,9 +46,11 @@ export const RouteSystem = ({
|
|||||||
<>
|
<>
|
||||||
<WdTooltip
|
<WdTooltip
|
||||||
ref={tooltipRef}
|
ref={tooltipRef}
|
||||||
|
position={TooltipPosition.top}
|
||||||
// targetSelector={`.tooltip-route-sys_${destination}_${solar_system_id}`}
|
// targetSelector={`.tooltip-route-sys_${destination}_${solar_system_id}`}
|
||||||
content={() => (
|
content={() => (
|
||||||
<SystemViewStandalone
|
<SystemViewStandalone
|
||||||
|
className="mx-[4px]"
|
||||||
security={security}
|
security={security}
|
||||||
system_class={system_class}
|
system_class={system_class}
|
||||||
class_title={class_title}
|
class_title={class_title}
|
||||||
@@ -63,8 +65,8 @@ export const RouteSystem = ({
|
|||||||
tooltipRef.current?.show(e);
|
tooltipRef.current?.show(e);
|
||||||
onMouseEnter?.(solar_system_id);
|
onMouseEnter?.(solar_system_id);
|
||||||
}}
|
}}
|
||||||
onMouseLeave={e => {
|
onMouseLeave={() => {
|
||||||
tooltipRef.current?.hide(e);
|
tooltipRef.current?.hide();
|
||||||
onMouseLeave?.();
|
onMouseLeave?.();
|
||||||
}}
|
}}
|
||||||
onContextMenu={handleContext}
|
onContextMenu={handleContext}
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ export const RoutesWidgetComp = () => {
|
|||||||
}, [data, update]);
|
}, [data, update]);
|
||||||
|
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
const compact = useMaxWidth(ref, 155);
|
const compact = useMaxWidth(ref, 170);
|
||||||
const [openAddSystem, setOpenAddSystem] = useState<boolean>(false);
|
const [openAddSystem, setOpenAddSystem] = useState<boolean>(false);
|
||||||
|
|
||||||
const onAddSystem = useCallback(() => setOpenAddSystem(true), []);
|
const onAddSystem = useCallback(() => setOpenAddSystem(true), []);
|
||||||
@@ -217,14 +217,14 @@ export const RoutesWidgetComp = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<WdTooltipWrapper content="Show shortest route">
|
<WdTooltipWrapper content="Show shortest route" position={TooltipPosition.top}>
|
||||||
<WdCheckbox
|
<WdCheckbox
|
||||||
size="xs"
|
size="xs"
|
||||||
labelSide="left"
|
labelSide="left"
|
||||||
label={compact ? '' : 'Show shortest'}
|
label={compact ? '' : 'Show shortest'}
|
||||||
value={!isSecure}
|
value={!isSecure}
|
||||||
onChange={handleSecureChange}
|
onChange={handleSecureChange}
|
||||||
classNameLabel={clsx('text-red-400')}
|
classNameLabel="text-red-400 whitespace-nowrap"
|
||||||
/>
|
/>
|
||||||
</WdTooltipWrapper>
|
</WdTooltipWrapper>
|
||||||
<WdImgButton
|
<WdImgButton
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ import { useKillsWidgetSettings } from './hooks/useKillsWidgetSettings';
|
|||||||
import { useSystemKills } from './hooks/useSystemKills';
|
import { useSystemKills } from './hooks/useSystemKills';
|
||||||
import { KillsSettingsDialog } from './components/SystemKillsSettingsDialog';
|
import { KillsSettingsDialog } from './components/SystemKillsSettingsDialog';
|
||||||
import { isWormholeSpace } from '@/hooks/Mapper/components/map/helpers/isWormholeSpace';
|
import { isWormholeSpace } from '@/hooks/Mapper/components/map/helpers/isWormholeSpace';
|
||||||
|
import { SolarSystemRawType } from '@/hooks/Mapper/types';
|
||||||
|
|
||||||
export const SystemKills: React.FC = () => {
|
export const SystemKills: React.FC = React.memo(() => {
|
||||||
const {
|
const {
|
||||||
data: { selectedSystems, systems, isSubscriptionActive },
|
data: { selectedSystems, systems, isSubscriptionActive },
|
||||||
outCommand,
|
outCommand,
|
||||||
} = useMapRootState();
|
} = useMapRootState();
|
||||||
|
|
||||||
const [systemId] = selectedSystems || [];
|
const [systemId] = selectedSystems || [];
|
||||||
|
|
||||||
const [settingsDialogVisible, setSettingsDialogVisible] = useState(false);
|
const [settingsDialogVisible, setSettingsDialogVisible] = useState(false);
|
||||||
|
|
||||||
const systemNameMap = useMemo(() => {
|
const systemNameMap = useMemo(() => {
|
||||||
@@ -26,6 +26,16 @@ export const SystemKills: React.FC = () => {
|
|||||||
return map;
|
return map;
|
||||||
}, [systems]);
|
}, [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 [settings] = useKillsWidgetSettings();
|
||||||
const visible = settings.showAll;
|
const visible = settings.showAll;
|
||||||
|
|
||||||
@@ -41,74 +51,59 @@ export const SystemKills: React.FC = () => {
|
|||||||
const filteredKills = useMemo(() => {
|
const filteredKills = useMemo(() => {
|
||||||
if (!settings.whOnly || !visible) return kills;
|
if (!settings.whOnly || !visible) return kills;
|
||||||
return kills.filter(kill => {
|
return kills.filter(kill => {
|
||||||
const system = systems.find(sys => sys.system_static_info.solar_system_id === kill.solar_system_id);
|
const system = systemBySolarSystemId[kill.solar_system_id];
|
||||||
if (!system) {
|
if (!system) {
|
||||||
console.warn(`System with id ${kill.solar_system_id} not found.`);
|
console.warn(`System with id ${kill.solar_system_id} not found.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return isWormholeSpace(system.system_static_info.system_class);
|
return isWormholeSpace(system.system_static_info.system_class);
|
||||||
});
|
});
|
||||||
}, [kills, settings.whOnly, systems]);
|
}, [kills, settings.whOnly, systemBySolarSystemId, visible]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full flex flex-col min-h-0">
|
<div className="h-full flex flex-col min-h-0">
|
||||||
<div className="flex flex-col flex-1 min-h-0">
|
<div className="flex flex-col flex-1 min-h-0">
|
||||||
<Widget
|
<Widget label={<KillsHeader systemId={systemId} onOpenSettings={() => setSettingsDialogVisible(true)} />}>
|
||||||
label={
|
{!isSubscriptionActive ? (
|
||||||
<KillsHeader systemId={systemId} onOpenSettings={() => setSettingsDialogVisible(true)} />
|
<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 'Active' map subscription only (contact map administrators)
|
||||||
{!isSubscriptionActive && (
|
</span>
|
||||||
<div className="w-full h-full flex justify-center items-center select-none text-center text-stone-400/80 text-sm">
|
</div>
|
||||||
Kills available with 'Active' map subscription only (contact map administrators)
|
) : 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>
|
</div>
|
||||||
)}
|
|
||||||
{isSubscriptionActive && (
|
|
||||||
<>
|
|
||||||
{isNothingSelected && (
|
|
||||||
<div className="w-full h-full flex justify-center items-center select-none text-center text-stone-400/80 text-sm">
|
|
||||||
No system selected (or toggle “Show all systems”)
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!isNothingSelected && showLoading && (
|
|
||||||
<div className="w-full h-full flex justify-center items-center select-none text-center text-stone-400/80 text-sm">
|
|
||||||
Loading Kills...
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!isNothingSelected && !showLoading && error && (
|
|
||||||
<div className="w-full h-full flex justify-center items-center select-none text-center text-red-400 text-sm">
|
|
||||||
{error}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!isNothingSelected &&
|
|
||||||
!showLoading &&
|
|
||||||
!error &&
|
|
||||||
(!filteredKills || filteredKills.length === 0) && (
|
|
||||||
<div className="w-full h-full flex justify-center items-center select-none text-center text-stone-400/80 text-sm">
|
|
||||||
No kills found
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!isNothingSelected && !showLoading && !error && (
|
|
||||||
<div className="flex-1 flex flex-col overflow-y-auto">
|
|
||||||
<SystemKillsContent
|
|
||||||
key={settings.compact ? 'compact' : 'normal'}
|
|
||||||
kills={filteredKills}
|
|
||||||
systemNameMap={systemNameMap}
|
|
||||||
compact={settings.compact}
|
|
||||||
onlyOneSystem={!visible}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</Widget>
|
</Widget>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<KillsSettingsDialog visible={settingsDialogVisible} setVisible={setSettingsDialogVisible} />
|
{settingsDialogVisible && <KillsSettingsDialog visible setVisible={setSettingsDialogVisible} />}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
|
SystemKills.displayName = 'SystemKills';
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
.TableRowCompact {
|
.wrapper {
|
||||||
height: 8px;
|
overflow-x: hidden;
|
||||||
max-height: 8px;
|
box-sizing: border-box;
|
||||||
font-size: 12px !important;
|
|
||||||
line-height: 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.Table {
|
.scrollerContent {
|
||||||
font-size: 12px;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
box-sizing: border-box;
|
||||||
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.Tooltip {
|
.VirtualScroller {
|
||||||
white-space: pre-line;
|
height: 100% !important;
|
||||||
line-height: 1.2rem;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,50 +1,68 @@
|
|||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { DetailedKill } from '@/hooks/Mapper/types/kills';
|
import { DetailedKill } from '@/hooks/Mapper/types/kills';
|
||||||
import { KillRow } from '../components/SystemKillsRow';
|
import { VirtualScroller } from 'primereact/virtualscroller';
|
||||||
|
import { useSystemKillsItemTemplate } from '../hooks/useSystemKillsItemTemplate';
|
||||||
|
import classes from './SystemKillsContent.module.scss';
|
||||||
|
|
||||||
interface SystemKillsContentProps {
|
export const ITEM_HEIGHT = 35;
|
||||||
|
|
||||||
|
export interface SystemKillsContentProps {
|
||||||
kills: DetailedKill[];
|
kills: DetailedKill[];
|
||||||
systemNameMap: Record<string, string>;
|
systemNameMap: Record<string, string>;
|
||||||
compact?: boolean;
|
|
||||||
onlyOneSystem?: boolean;
|
onlyOneSystem?: boolean;
|
||||||
|
autoSize?: boolean;
|
||||||
|
timeRange?: number;
|
||||||
|
limit?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SystemKillsContent: React.FC<SystemKillsContentProps> = ({
|
export const SystemKillsContent: React.FC<SystemKillsContentProps> = ({
|
||||||
kills,
|
kills,
|
||||||
systemNameMap,
|
systemNameMap,
|
||||||
compact = false,
|
|
||||||
onlyOneSystem = false,
|
onlyOneSystem = false,
|
||||||
|
autoSize = false,
|
||||||
|
timeRange = 4,
|
||||||
|
limit,
|
||||||
}) => {
|
}) => {
|
||||||
const sortedKills = useMemo(() => {
|
const processedKills = useMemo(() => {
|
||||||
return [...kills].sort((a, b) => {
|
const sortedKills = kills
|
||||||
const timeA = a.kill_time ? new Date(a.kill_time).getTime() : 0;
|
.filter(k => k.kill_time)
|
||||||
const timeB = b.kill_time ? new Date(b.kill_time).getTime() : 0;
|
.sort((a, b) => new Date(b.kill_time!).getTime() - new Date(a.kill_time!).getTime());
|
||||||
return timeB - timeA;
|
|
||||||
});
|
if (limit !== undefined) {
|
||||||
}, [kills]);
|
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);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div className={clsx('w-full h-full', classes.wrapper)}>
|
||||||
className={clsx(
|
<VirtualScroller
|
||||||
'flex flex-col w-full text-stone-200 text-xs transition-all duration-300',
|
items={processedKills}
|
||||||
compact ? 'p-1' : 'p-1'
|
itemSize={ITEM_HEIGHT}
|
||||||
)}
|
itemTemplate={itemTemplate}
|
||||||
>
|
autoSize={autoSize}
|
||||||
{sortedKills.map(kill => {
|
scrollWidth="100%"
|
||||||
const systemIdStr = String(kill.solar_system_id);
|
style={{ height: scrollerHeight }}
|
||||||
const systemName = systemNameMap[systemIdStr] || `System ${systemIdStr}`;
|
className={clsx('w-full h-full custom-scrollbar select-none', {
|
||||||
|
[classes.VirtualScroller]: !autoSize,
|
||||||
return (
|
})}
|
||||||
<KillRow
|
pt={{
|
||||||
key={kill.killmail_id}
|
content: {
|
||||||
killDetails={kill}
|
className: classes.scrollerContent,
|
||||||
systemName={systemName}
|
},
|
||||||
isCompact={compact}
|
}}
|
||||||
onlyOneSystem={onlyOneSystem}
|
/>
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default SystemKillsContent;
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import clsx from 'clsx';
|
|
||||||
import { zkillLink } from '../helpers';
|
|
||||||
import classes from './SystemKillRow.module.scss';
|
|
||||||
|
|
||||||
interface AttackerRowSubInfoProps {
|
|
||||||
finalBlowCharId: number | null | undefined;
|
|
||||||
finalBlowCharName?: string;
|
|
||||||
attackerPortraitUrl: string | null;
|
|
||||||
|
|
||||||
finalBlowCorpId: number | null | undefined;
|
|
||||||
finalBlowCorpName?: string;
|
|
||||||
attackerCorpLogoUrl: string | null;
|
|
||||||
|
|
||||||
finalBlowAllianceId: number | null | undefined;
|
|
||||||
finalBlowAllianceName?: string;
|
|
||||||
attackerAllianceLogoUrl: string | null;
|
|
||||||
|
|
||||||
containerHeight?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const AttackerRowSubInfo: React.FC<AttackerRowSubInfoProps> = ({
|
|
||||||
finalBlowCharId = 0,
|
|
||||||
finalBlowCharName,
|
|
||||||
attackerPortraitUrl,
|
|
||||||
containerHeight = 8,
|
|
||||||
}) => {
|
|
||||||
if (!attackerPortraitUrl || finalBlowCharId === null || finalBlowCharId <= 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const containerClass = `h-${containerHeight}`;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={clsx('flex items-start gap-1', containerClass)}>
|
|
||||||
<div className="relative shrink-0 w-auto h-full overflow-hidden">
|
|
||||||
<a
|
|
||||||
href={zkillLink('character', finalBlowCharId)}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="block h-full"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
src={attackerPortraitUrl}
|
|
||||||
alt={finalBlowCharName || 'AttackerPortrait'}
|
|
||||||
className={clsx(classes.killRowImage, 'h-full w-auto object-contain')}
|
|
||||||
/>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,263 +0,0 @@
|
|||||||
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
|
|
||||||
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
|
|
||||||
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';
|
|
||||||
|
|
||||||
// Victim images, now also pulling victimShipUrl
|
|
||||||
const {
|
|
||||||
victimPortraitUrl,
|
|
||||||
victimCorpLogoUrl,
|
|
||||||
victimAllianceLogoUrl,
|
|
||||||
victimShipUrl,
|
|
||||||
} = buildVictimImageUrls({
|
|
||||||
victim_char_id,
|
|
||||||
victim_ship_type_id,
|
|
||||||
victim_corp_id,
|
|
||||||
victim_alliance_id,
|
|
||||||
});
|
|
||||||
// Attacker images
|
|
||||||
const {
|
|
||||||
attackerPortraitUrl,
|
|
||||||
attackerCorpLogoUrl,
|
|
||||||
attackerAllianceLogoUrl,
|
|
||||||
} = buildAttackerImageUrls({
|
|
||||||
final_blow_char_id,
|
|
||||||
final_blow_corp_id,
|
|
||||||
final_blow_alliance_id,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Primary corp/alliance logo for victim
|
|
||||||
const { url: victimPrimaryImageUrl, tooltip: victimPrimaryTooltip } =
|
|
||||||
getPrimaryLogoAndTooltip(
|
|
||||||
victimAllianceLogoUrl,
|
|
||||||
victimCorpLogoUrl,
|
|
||||||
victim_alliance_name,
|
|
||||||
victim_corp_name,
|
|
||||||
'Victim'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Primary image for attacker => NPC => ship, else corp/alliance
|
|
||||||
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,
|
|
||||||
'h-18 w-full justify-between items-start text-sm py-[4px]'
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{/* ---------------- Victim Side ---------------- */}
|
|
||||||
<div className="flex items-start gap-1 min-w-0 h-full">
|
|
||||||
{victimShipUrl && (
|
|
||||||
<div className="relative shrink-0 w-14 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-14 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">
|
|
||||||
<span className="font-semibold">{victim_char_name}</span>
|
|
||||||
{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>
|
|
||||||
|
|
||||||
<div className="flex items-start gap-1 min-w-0 h-full">
|
|
||||||
<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 && final_blow_char_id > 0 && (
|
|
||||||
<div className="relative shrink-0 w-14 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-14 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>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -11,8 +11,8 @@ import {
|
|||||||
getPrimaryLogoAndTooltip,
|
getPrimaryLogoAndTooltip,
|
||||||
getAttackerPrimaryImageAndTooltip,
|
getAttackerPrimaryImageAndTooltip,
|
||||||
} from '../helpers';
|
} from '../helpers';
|
||||||
import { WdTooltipWrapper } from '../../../../ui-kit/WdTooltipWrapper';
|
import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit';
|
||||||
import classes from './SystemKillRow.module.scss';
|
import classes from './KillRowDetail.module.scss';
|
||||||
import { TooltipPosition } from '@/hooks/Mapper/components/ui-kit';
|
import { TooltipPosition } from '@/hooks/Mapper/components/ui-kit';
|
||||||
|
|
||||||
export interface CompactKillRowProps {
|
export interface CompactKillRowProps {
|
||||||
@@ -21,15 +21,10 @@ export interface CompactKillRowProps {
|
|||||||
onlyOneSystem: boolean;
|
onlyOneSystem: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CompactKillRow: React.FC<CompactKillRowProps> = ({
|
export const KillRowDetail: React.FC<CompactKillRowProps> = ({ killDetails, systemName, onlyOneSystem }) => {
|
||||||
killDetails,
|
|
||||||
systemName,
|
|
||||||
onlyOneSystem,
|
|
||||||
}) => {
|
|
||||||
const {
|
const {
|
||||||
killmail_id = 0,
|
killmail_id = 0,
|
||||||
|
// Victim data
|
||||||
// Victim
|
|
||||||
victim_char_name = 'Unknown Pilot',
|
victim_char_name = 'Unknown Pilot',
|
||||||
victim_alliance_ticker = '',
|
victim_alliance_ticker = '',
|
||||||
victim_corp_ticker = '',
|
victim_corp_ticker = '',
|
||||||
@@ -40,8 +35,7 @@ export const CompactKillRow: React.FC<CompactKillRowProps> = ({
|
|||||||
victim_corp_id = 0,
|
victim_corp_id = 0,
|
||||||
victim_alliance_id = 0,
|
victim_alliance_id = 0,
|
||||||
victim_ship_type_id = 0,
|
victim_ship_type_id = 0,
|
||||||
|
// Attacker data
|
||||||
// Attacker
|
|
||||||
final_blow_char_id = 0,
|
final_blow_char_id = 0,
|
||||||
final_blow_char_name = '',
|
final_blow_char_name = '',
|
||||||
final_blow_alliance_ticker = '',
|
final_blow_alliance_ticker = '',
|
||||||
@@ -51,72 +45,64 @@ export const CompactKillRow: React.FC<CompactKillRowProps> = ({
|
|||||||
final_blow_corp_id = 0,
|
final_blow_corp_id = 0,
|
||||||
final_blow_corp_name = '',
|
final_blow_corp_name = '',
|
||||||
final_blow_ship_type_id = 0,
|
final_blow_ship_type_id = 0,
|
||||||
|
|
||||||
kill_time = '',
|
kill_time = '',
|
||||||
total_value = 0,
|
total_value = 0,
|
||||||
} = killDetails || {};
|
} = killDetails || {};
|
||||||
|
|
||||||
const attackerIsNpc = final_blow_char_id === 0;
|
const attackerIsNpc = final_blow_char_id === 0;
|
||||||
|
|
||||||
// Tickers & strings
|
// Define victim affiliation ticker.
|
||||||
const victimAffiliationTicker =
|
const victimAffiliationTicker = victim_alliance_ticker || victim_corp_ticker || 'No Ticker';
|
||||||
victim_alliance_ticker || victim_corp_ticker || 'No Ticker';
|
|
||||||
const killValueFormatted =
|
const killValueFormatted = total_value != null && total_value > 0 ? `${formatISK(total_value)} ISK` : null;
|
||||||
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 killTimeAgo = kill_time ? formatTimeMixed(kill_time) : '0h ago';
|
||||||
|
|
||||||
const attackerSubscript = getAttackerSubscript(killDetails);
|
const attackerSubscript = getAttackerSubscript(killDetails);
|
||||||
|
|
||||||
// Victim images, including the ship
|
const { victimCorpLogoUrl, victimAllianceLogoUrl, victimShipUrl } = buildVictimImageUrls({
|
||||||
const {
|
|
||||||
victimCorpLogoUrl,
|
|
||||||
victimAllianceLogoUrl,
|
|
||||||
victimShipUrl,
|
|
||||||
} = buildVictimImageUrls({
|
|
||||||
victim_char_id,
|
victim_char_id,
|
||||||
victim_ship_type_id,
|
victim_ship_type_id,
|
||||||
victim_corp_id,
|
victim_corp_id,
|
||||||
victim_alliance_id,
|
victim_alliance_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Attacker corp/alliance
|
|
||||||
const { attackerCorpLogoUrl, attackerAllianceLogoUrl } = buildAttackerImageUrls({
|
const { attackerCorpLogoUrl, attackerAllianceLogoUrl } = buildAttackerImageUrls({
|
||||||
final_blow_char_id,
|
final_blow_char_id,
|
||||||
final_blow_corp_id,
|
final_blow_corp_id,
|
||||||
final_blow_alliance_id,
|
final_blow_alliance_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Victim corp/alliance logo
|
const { url: victimPrimaryLogoUrl, tooltip: victimPrimaryTooltip } = getPrimaryLogoAndTooltip(
|
||||||
const { url: victimPrimaryLogoUrl, tooltip: victimPrimaryTooltip } =
|
victimAllianceLogoUrl,
|
||||||
getPrimaryLogoAndTooltip(
|
victimCorpLogoUrl,
|
||||||
victimAllianceLogoUrl,
|
victim_alliance_name,
|
||||||
victimCorpLogoUrl,
|
victim_corp_name,
|
||||||
victim_alliance_name,
|
'Victim',
|
||||||
victim_corp_name,
|
);
|
||||||
'Victim'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Attacker corp/alliance or NPC ship
|
const { url: attackerPrimaryImageUrl, tooltip: attackerPrimaryTooltip } = getAttackerPrimaryImageAndTooltip(
|
||||||
const { url: attackerPrimaryImageUrl, tooltip: attackerPrimaryTooltip } =
|
attackerIsNpc,
|
||||||
getAttackerPrimaryImageAndTooltip(
|
attackerAllianceLogoUrl,
|
||||||
attackerIsNpc,
|
attackerCorpLogoUrl,
|
||||||
attackerAllianceLogoUrl,
|
final_blow_alliance_name,
|
||||||
attackerCorpLogoUrl,
|
final_blow_corp_name,
|
||||||
final_blow_alliance_name,
|
final_blow_ship_type_id,
|
||||||
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);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'h-10 flex items-center border-b border-stone-800',
|
'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">
|
<div className="flex items-center gap-1">
|
||||||
{victimShipUrl && (
|
{victimShipUrl && (
|
||||||
<div className="relative shrink-0 w-8 h-8 overflow-hidden">
|
<div className="relative shrink-0 w-8 h-8 overflow-hidden">
|
||||||
@@ -128,20 +114,14 @@ export const CompactKillRow: React.FC<CompactKillRowProps> = ({
|
|||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
src={victimShipUrl}
|
src={victimShipUrl}
|
||||||
alt="VictimShip"
|
alt="Victim Ship"
|
||||||
className={clsx(
|
className={clsx(classes.killRowImage, 'w-full h-full object-contain')}
|
||||||
classes.killRowImage,
|
|
||||||
'w-full h-full object-contain'
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{victimPrimaryLogoUrl && (
|
{victimPrimaryLogoUrl && (
|
||||||
<WdTooltipWrapper
|
<WdTooltipWrapper content={victimPrimaryTooltip} position={TooltipPosition.top}>
|
||||||
content={victimPrimaryTooltip}
|
|
||||||
position={TooltipPosition.top}
|
|
||||||
>
|
|
||||||
<a
|
<a
|
||||||
href={zkillLink('kill', killmail_id)}
|
href={zkillLink('kill', killmail_id)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
@@ -150,17 +130,14 @@ export const CompactKillRow: React.FC<CompactKillRowProps> = ({
|
|||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
src={victimPrimaryLogoUrl}
|
src={victimPrimaryLogoUrl}
|
||||||
alt="VictimPrimaryLogo"
|
alt="Victim Primary Logo"
|
||||||
className={clsx(
|
className={clsx(classes.killRowImage, 'w-full h-full object-contain')}
|
||||||
classes.killRowImage,
|
|
||||||
'w-full h-full object-contain'
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
</WdTooltipWrapper>
|
</WdTooltipWrapper>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col ml-2 min-w-0 overflow-hidden leading-[1rem]">
|
<div className="flex flex-col ml-2 flex-1 min-w-0 overflow-hidden leading-[1rem]">
|
||||||
<div className="truncate text-stone-200">
|
<div className="truncate text-stone-200">
|
||||||
{victim_char_name}
|
{victim_char_name}
|
||||||
<span className="text-stone-400"> / {victimAffiliationTicker}</span>
|
<span className="text-stone-400"> / {victimAffiliationTicker}</span>
|
||||||
@@ -176,20 +153,17 @@ export const CompactKillRow: React.FC<CompactKillRowProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center ml-auto gap-2">
|
<div className="flex items-center ml-auto gap-2">
|
||||||
<div className="flex flex-col items-end min-w-0 overflow-hidden text-right leading-[1rem]">
|
<div className="flex flex-col items-end flex-1 min-w-0 overflow-hidden text-right leading-[1rem]">
|
||||||
{!attackerIsNpc && (attackerName || attackerTicker) && (
|
{!attackerIsNpc && (final_blow_char_name || attackerTicker) && (
|
||||||
<div className="truncate text-stone-200">
|
<div className="truncate text-stone-200">
|
||||||
{attackerName}
|
{final_blow_char_name}
|
||||||
{attackerTicker && (
|
{!attackerIsNpc && attackerTicker && <span className="ml-1 text-stone-400">/ {attackerTicker}</span>}
|
||||||
<span className="ml-1 text-stone-400">/ {attackerTicker}</span>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="truncate text-stone-400">
|
<div className="truncate text-stone-400">
|
||||||
{!onlyOneSystem && systemName ? (
|
{!onlyOneSystem && systemName ? (
|
||||||
<>
|
<>
|
||||||
{systemName} /{' '}
|
{systemName} / <span className="ml-1 text-red-400">{killTimeAgo}</span>
|
||||||
<span className="ml-1 text-red-400">{killTimeAgo}</span>
|
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<span className="text-red-400">{killTimeAgo}</span>
|
<span className="text-red-400">{killTimeAgo}</span>
|
||||||
@@ -197,30 +171,24 @@ export const CompactKillRow: React.FC<CompactKillRowProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{attackerPrimaryImageUrl && (
|
{attackerPrimaryImageUrl && (
|
||||||
<WdTooltipWrapper
|
<WdTooltipWrapper content={attackerPrimaryTooltip} position={TooltipPosition.top}>
|
||||||
content={attackerPrimaryTooltip}
|
|
||||||
position={TooltipPosition.top}
|
|
||||||
>
|
|
||||||
<a
|
<a
|
||||||
href={zkillLink('kill', killmail_id)}
|
href={attackerLink}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="relative block shrink-0 w-8 h-8 overflow-hidden"
|
className="relative block shrink-0 w-8 h-8 overflow-hidden"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
src={attackerPrimaryImageUrl}
|
src={attackerPrimaryImageUrl}
|
||||||
alt={attackerIsNpc ? 'NpcShip' : 'AttackerPrimaryLogo'}
|
alt={attackerIsNpc ? 'NPC Ship' : 'Attacker Primary Logo'}
|
||||||
className={clsx(
|
className={clsx(classes.killRowImage, 'w-full h-full object-contain')}
|
||||||
classes.killRowImage,
|
|
||||||
'w-full h-full object-contain'
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
{attackerSubscript && (
|
{attackerSubscript && (
|
||||||
<span
|
<span
|
||||||
className={clsx(
|
className={clsx(
|
||||||
classes.attackerCountLabel,
|
classes.attackerCountLabel,
|
||||||
attackerSubscript.cssClass,
|
attackerSubscript.cssClass,
|
||||||
'text-[0.6rem] leading-none px-[2px]'
|
'text-[0.6rem] leading-none px-[2px]',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{attackerSubscript.label}
|
{attackerSubscript.label}
|
||||||
@@ -1,20 +1,22 @@
|
|||||||
import React from 'react';
|
import React, { useRef } from 'react';
|
||||||
import {
|
import {
|
||||||
LayoutEventBlocker,
|
LayoutEventBlocker,
|
||||||
|
SystemView,
|
||||||
|
TooltipPosition,
|
||||||
WdCheckbox,
|
WdCheckbox,
|
||||||
WdImgButton,
|
WdImgButton,
|
||||||
TooltipPosition,
|
WdTooltipWrapper,
|
||||||
SystemView,
|
|
||||||
} from '@/hooks/Mapper/components/ui-kit';
|
} from '@/hooks/Mapper/components/ui-kit';
|
||||||
import { useKillsWidgetSettings } from '../hooks/useKillsWidgetSettings';
|
import { useKillsWidgetSettings } from '../hooks/useKillsWidgetSettings';
|
||||||
import { PrimeIcons } from 'primereact/api';
|
import { PrimeIcons } from 'primereact/api';
|
||||||
|
import useMaxWidth from '@/hooks/Mapper/hooks/useMaxWidth.ts';
|
||||||
|
|
||||||
interface KillsWidgetHeaderProps {
|
interface KillsHeaderProps {
|
||||||
systemId?: string;
|
systemId?: string;
|
||||||
onOpenSettings: () => void;
|
onOpenSettings: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const KillsHeader: React.FC<KillsWidgetHeaderProps> = ({ systemId, onOpenSettings }) => {
|
export const KillsHeader: React.FC<KillsHeaderProps> = ({ systemId, onOpenSettings }) => {
|
||||||
const [settings, setSettings] = useKillsWidgetSettings();
|
const [settings, setSettings] = useKillsWidgetSettings();
|
||||||
const { showAll } = settings;
|
const { showAll } = settings;
|
||||||
|
|
||||||
@@ -22,8 +24,11 @@ export const KillsHeader: React.FC<KillsWidgetHeaderProps> = ({ systemId, onOpen
|
|||||||
setSettings(prev => ({ ...prev, showAll: !prev.showAll }));
|
setSettings(prev => ({ ...prev, showAll: !prev.showAll }));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const headerRef = useRef<HTMLDivElement>(null);
|
||||||
|
const compact = useMaxWidth(headerRef, 150);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-between items-center text-xs w-full">
|
<div className="flex w-full items-center justify-between text-xs" ref={headerRef}>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<div className="text-stone-400">
|
<div className="text-stone-400">
|
||||||
Kills
|
Kills
|
||||||
@@ -32,24 +37,28 @@ export const KillsHeader: React.FC<KillsWidgetHeaderProps> = ({ systemId, onOpen
|
|||||||
{systemId && !showAll && <SystemView systemId={systemId} className="select-none text-center" hideRegion />}
|
{systemId && !showAll && <SystemView systemId={systemId} className="select-none text-center" hideRegion />}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LayoutEventBlocker className="flex gap-2 items-center">
|
<LayoutEventBlocker className="flex items-center gap-2 justify-end">
|
||||||
<WdCheckbox
|
<div className="flex items-center gap-2">
|
||||||
size="xs"
|
<WdTooltipWrapper content="Show all systems" position={TooltipPosition.top}>
|
||||||
labelSide="left"
|
<WdCheckbox
|
||||||
label="Show all systems"
|
size="xs"
|
||||||
value={showAll}
|
labelSide="left"
|
||||||
classNameLabel="text-stone-400 hover:text-stone-200 transition duration-300"
|
label={compact ? 'All' : 'Show all systems'}
|
||||||
onChange={onToggleShowAllVisible}
|
value={showAll}
|
||||||
/>
|
onChange={onToggleShowAllVisible}
|
||||||
|
classNameLabel="whitespace-nowrap text-stone-400 hover:text-stone-200 transition duration-300"
|
||||||
|
/>
|
||||||
|
</WdTooltipWrapper>
|
||||||
|
|
||||||
<WdImgButton
|
<WdImgButton
|
||||||
className={PrimeIcons.SLIDERS_H}
|
className={PrimeIcons.SLIDERS_H}
|
||||||
onClick={onOpenSettings}
|
onClick={onOpenSettings}
|
||||||
tooltip={{
|
tooltip={{
|
||||||
content: 'Open Kills Settings',
|
content: 'Open Kills Settings',
|
||||||
position: TooltipPosition.left,
|
position: TooltipPosition.top,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
</LayoutEventBlocker>
|
</LayoutEventBlocker>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,24 +1,15 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { DetailedKill } from '@/hooks/Mapper/types/kills';
|
import { DetailedKill } from '@/hooks/Mapper/types/kills';
|
||||||
import { CompactKillRow } from './CompactKillRow';
|
import { KillRowDetail } from './KillRowDetail.tsx';
|
||||||
import { FullKillRow } from './FullKillRow';
|
|
||||||
|
|
||||||
export interface KillRowProps {
|
export interface KillRowProps {
|
||||||
killDetails: DetailedKill;
|
killDetails: DetailedKill;
|
||||||
systemName: string;
|
systemName: string;
|
||||||
isCompact?: boolean;
|
|
||||||
onlyOneSystem?: boolean;
|
onlyOneSystem?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const KillRow: React.FC<KillRowProps> = ({
|
const KillRowComponent: React.FC<KillRowProps> = ({ killDetails, systemName, onlyOneSystem = false }) => {
|
||||||
killDetails,
|
return <KillRowDetail killDetails={killDetails} systemName={systemName} onlyOneSystem={onlyOneSystem} />;
|
||||||
systemName,
|
|
||||||
isCompact = false,
|
|
||||||
onlyOneSystem = false,
|
|
||||||
}) => {
|
|
||||||
if (isCompact) {
|
|
||||||
return <CompactKillRow killDetails={killDetails} systemName={systemName} onlyOneSystem={onlyOneSystem} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <FullKillRow killDetails={killDetails} systemName={systemName} onlyOneSystem={onlyOneSystem} />;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const KillRow = React.memo(KillRowComponent);
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { Dialog } from 'primereact/dialog';
|
import { Dialog } from 'primereact/dialog';
|
||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
import { WdImgButton, SystemView, TooltipPosition } from '@/hooks/Mapper/components/ui-kit';
|
import { WdImgButton } from '@/hooks/Mapper/components/ui-kit';
|
||||||
import { PrimeIcons } from 'primereact/api';
|
import { PrimeIcons } from 'primereact/api';
|
||||||
import { useKillsWidgetSettings } from '../hooks/useKillsWidgetSettings';
|
import { useKillsWidgetSettings } from '../hooks/useKillsWidgetSettings';
|
||||||
import {
|
import {
|
||||||
AddSystemDialog,
|
AddSystemDialog,
|
||||||
SearchOnSubmitCallback,
|
SearchOnSubmitCallback,
|
||||||
} from '@/hooks/Mapper/components/mapInterface/components/AddSystemDialog';
|
} from '@/hooks/Mapper/components/mapInterface/components/AddSystemDialog';
|
||||||
|
import { SystemView, TooltipPosition } from '@/hooks/Mapper/components/ui-kit';
|
||||||
|
|
||||||
interface KillsSettingsDialogProps {
|
interface KillsSettingsDialogProps {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
@@ -17,36 +18,27 @@ interface KillsSettingsDialogProps {
|
|||||||
export const KillsSettingsDialog: React.FC<KillsSettingsDialogProps> = ({ visible, setVisible }) => {
|
export const KillsSettingsDialog: React.FC<KillsSettingsDialogProps> = ({ visible, setVisible }) => {
|
||||||
const [globalSettings, setGlobalSettings] = useKillsWidgetSettings();
|
const [globalSettings, setGlobalSettings] = useKillsWidgetSettings();
|
||||||
const localRef = useRef({
|
const localRef = useRef({
|
||||||
compact: globalSettings.compact,
|
|
||||||
showAll: globalSettings.showAll,
|
showAll: globalSettings.showAll,
|
||||||
whOnly: globalSettings.whOnly,
|
whOnly: globalSettings.whOnly,
|
||||||
excludedSystems: globalSettings.excludedSystems || [],
|
excludedSystems: globalSettings.excludedSystems || [],
|
||||||
|
timeRange: globalSettings.timeRange,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [, forceRender] = useState(0);
|
const [, forceRender] = useState(0);
|
||||||
|
|
||||||
const [addSystemDialogVisible, setAddSystemDialogVisible] = useState(false);
|
const [addSystemDialogVisible, setAddSystemDialogVisible] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
localRef.current = {
|
localRef.current = {
|
||||||
compact: globalSettings.compact,
|
|
||||||
showAll: globalSettings.showAll,
|
showAll: globalSettings.showAll,
|
||||||
whOnly: globalSettings.whOnly,
|
whOnly: globalSettings.whOnly,
|
||||||
excludedSystems: globalSettings.excludedSystems || [],
|
excludedSystems: globalSettings.excludedSystems || [],
|
||||||
|
timeRange: globalSettings.timeRange,
|
||||||
};
|
};
|
||||||
forceRender(n => n + 1);
|
forceRender(n => n + 1);
|
||||||
}
|
}
|
||||||
}, [visible, globalSettings]);
|
}, [visible, globalSettings]);
|
||||||
|
|
||||||
const handleCompactChange = useCallback((checked: boolean) => {
|
|
||||||
localRef.current = {
|
|
||||||
...localRef.current,
|
|
||||||
compact: checked,
|
|
||||||
};
|
|
||||||
forceRender(n => n + 1);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleWHChange = useCallback((checked: boolean) => {
|
const handleWHChange = useCallback((checked: boolean) => {
|
||||||
localRef.current = {
|
localRef.current = {
|
||||||
...localRef.current,
|
...localRef.current,
|
||||||
@@ -55,6 +47,14 @@ export const KillsSettingsDialog: React.FC<KillsSettingsDialogProps> = ({ visibl
|
|||||||
forceRender(n => n + 1);
|
forceRender(n => n + 1);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const handleTimeRangeChange = useCallback((newTimeRange: number) => {
|
||||||
|
localRef.current = {
|
||||||
|
...localRef.current,
|
||||||
|
timeRange: newTimeRange,
|
||||||
|
};
|
||||||
|
forceRender(n => n + 1);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleRemoveSystem = useCallback((sysId: number) => {
|
const handleRemoveSystem = useCallback((sysId: number) => {
|
||||||
localRef.current = {
|
localRef.current = {
|
||||||
...localRef.current,
|
...localRef.current,
|
||||||
@@ -88,22 +88,11 @@ export const KillsSettingsDialog: React.FC<KillsSettingsDialogProps> = ({ visibl
|
|||||||
|
|
||||||
const localData = localRef.current;
|
const localData = localRef.current;
|
||||||
const excluded = localData.excludedSystems || [];
|
const excluded = localData.excludedSystems || [];
|
||||||
|
const timeRangeOptions = [4, 12, 24];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog header="Kills Settings" visible={visible} style={{ width: '440px' }} draggable={false} onHide={handleHide}>
|
<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 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">
|
<div className="flex items-center gap-2">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
@@ -111,11 +100,30 @@ export const KillsSettingsDialog: React.FC<KillsSettingsDialogProps> = ({ visibl
|
|||||||
checked={localData.whOnly}
|
checked={localData.whOnly}
|
||||||
onChange={e => handleWHChange(e.target.checked)}
|
onChange={e => handleWHChange(e.target.checked)}
|
||||||
/>
|
/>
|
||||||
<label htmlFor="kills-wh-only-mode" className="cursor-pointer">
|
<label htmlFor="kills-wormhole-only-mode" className="cursor-pointer">
|
||||||
Only show wormhole kills
|
Only show wormhole kills
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</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 flex-col gap-1">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<label className="text-sm text-stone-400">Excluded Systems</label>
|
<label className="text-sm text-stone-400">Excluded Systems</label>
|
||||||
@@ -128,8 +136,7 @@ export const KillsSettingsDialog: React.FC<KillsSettingsDialogProps> = ({ visibl
|
|||||||
{excluded.length === 0 && <div className="text-stone-500 text-xs italic">No systems excluded.</div>}
|
{excluded.length === 0 && <div className="text-stone-500 text-xs italic">No systems excluded.</div>}
|
||||||
{excluded.map(sysId => (
|
{excluded.map(sysId => (
|
||||||
<div key={sysId} className="flex items-center justify-between border-b border-stone-600 py-1 px-1 text-xs">
|
<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 compact/>
|
<SystemView systemId={sysId.toString()} hideRegion />
|
||||||
|
|
||||||
<WdImgButton
|
<WdImgButton
|
||||||
className={PrimeIcons.TRASH}
|
className={PrimeIcons.TRASH}
|
||||||
onClick={() => handleRemoveSystem(sysId)}
|
onClick={() => handleRemoveSystem(sysId)}
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
// VictimSubRowInfo.tsx
|
|
||||||
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 === null || victimCharacterId <= 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex items-start gap-1 h-14">
|
|
||||||
<div className="relative shrink-0 w-14 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>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -2,19 +2,19 @@ import { useMemo, useCallback } from 'react';
|
|||||||
import useLocalStorageState from 'use-local-storage-state';
|
import useLocalStorageState from 'use-local-storage-state';
|
||||||
|
|
||||||
export interface KillsWidgetSettings {
|
export interface KillsWidgetSettings {
|
||||||
compact: boolean;
|
|
||||||
showAll: boolean;
|
showAll: boolean;
|
||||||
whOnly: boolean;
|
whOnly: boolean;
|
||||||
excludedSystems: number[];
|
excludedSystems: number[];
|
||||||
version: number;
|
version: number;
|
||||||
|
timeRange: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_KILLS_WIDGET_SETTINGS: KillsWidgetSettings = {
|
export const DEFAULT_KILLS_WIDGET_SETTINGS: KillsWidgetSettings = {
|
||||||
compact: true,
|
|
||||||
showAll: false,
|
showAll: false,
|
||||||
whOnly: true,
|
whOnly: true,
|
||||||
excludedSystems: [],
|
excludedSystems: [],
|
||||||
version: 0,
|
version: 2,
|
||||||
|
timeRange: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
function mergeWithDefaults(settings?: Partial<KillsWidgetSettings>): KillsWidgetSettings {
|
function mergeWithDefaults(settings?: Partial<KillsWidgetSettings>): KillsWidgetSettings {
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// 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],
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
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);
|
||||||
@@ -1,12 +1,5 @@
|
|||||||
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { Widget } from '@/hooks/Mapper/components/mapInterface/components';
|
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 { SystemSignaturesContent } from './SystemSignaturesContent';
|
||||||
import {
|
import {
|
||||||
COSMIC_ANOMALY,
|
COSMIC_ANOMALY,
|
||||||
@@ -19,28 +12,28 @@ import {
|
|||||||
STRUCTURE,
|
STRUCTURE,
|
||||||
SystemSignatureSettingsDialog,
|
SystemSignatureSettingsDialog,
|
||||||
} from './SystemSignatureSettingsDialog';
|
} from './SystemSignatureSettingsDialog';
|
||||||
import { SignatureGroup } from '@/hooks/Mapper/types';
|
import { SignatureGroup, SystemSignature } from '@/hooks/Mapper/types';
|
||||||
|
|
||||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
||||||
|
|
||||||
import { PrimeIcons } from 'primereact/api';
|
|
||||||
|
|
||||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||||
import { CheckboxChangeEvent } from 'primereact/checkbox';
|
import useMaxWidth from '@/hooks/Mapper/hooks/useMaxWidth';
|
||||||
import useMaxWidth from '@/hooks/Mapper/hooks/useMaxWidth.ts';
|
import { useHotkey } from '@/hooks/Mapper/hooks';
|
||||||
import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrapper';
|
import { COMPACT_MAX_WIDTH } from './constants';
|
||||||
|
import { renderHeaderLabel } from './renders';
|
||||||
|
|
||||||
const SIGNATURE_SETTINGS_KEY = 'wanderer_system_signature_settings_v5_2';
|
const SIGNATURE_SETTINGS_KEY = 'wanderer_system_signature_settings_v5_5';
|
||||||
|
export const SIGNATURE_WINDOW_ID = 'system_signatures_window';
|
||||||
export const SHOW_DESCRIPTION_COLUMN_SETTING = 'show_description_column_setting';
|
export const SHOW_DESCRIPTION_COLUMN_SETTING = 'show_description_column_setting';
|
||||||
export const SHOW_UPDATED_COLUMN_SETTING = 'SHOW_UPDATED_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 LAZY_DELETE_SIGNATURES_SETTING = 'LAZY_DELETE_SIGNATURES_SETTING';
|
||||||
export const KEEP_LAZY_DELETE_SETTING = 'KEEP_LAZY_DELETE_ENABLED_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_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_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: 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: 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_ANOMALY, name: 'Show Anomalies', value: true, isFilter: true },
|
||||||
{ key: COSMIC_SIGNATURE, name: 'Show Cosmic Signatures', value: true, isFilter: true },
|
{ key: COSMIC_SIGNATURE, name: 'Show Cosmic Signatures', value: true, isFilter: true },
|
||||||
{ key: DEPLOYABLE, name: 'Show Deployables', value: true, isFilter: true },
|
{ key: DEPLOYABLE, name: 'Show Deployables', value: true, isFilter: true },
|
||||||
@@ -56,121 +49,127 @@ const settings: Setting[] = [
|
|||||||
{ key: SignatureGroup.CombatSite, name: 'Show Combat Sites', value: true, isFilter: true },
|
{ key: SignatureGroup.CombatSite, name: 'Show Combat Sites', value: true, isFilter: true },
|
||||||
];
|
];
|
||||||
|
|
||||||
const defaultSettings = () => {
|
function getDefaultSettings(): Setting[] {
|
||||||
return [...settings];
|
return [...SETTINGS];
|
||||||
};
|
}
|
||||||
|
|
||||||
export const SystemSignatures = () => {
|
export const SystemSignatures: React.FC = () => {
|
||||||
const {
|
const {
|
||||||
data: { selectedSystems },
|
data: { selectedSystems },
|
||||||
} = useMapRootState();
|
} = useMapRootState();
|
||||||
|
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [settings, setSettings] = useState<Setting[]>(defaultSettings);
|
|
||||||
|
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 [systemId] = selectedSystems;
|
const [systemId] = selectedSystems;
|
||||||
|
|
||||||
const isNotSelectedSystem = selectedSystems.length !== 1;
|
const isNotSelectedSystem = selectedSystems.length !== 1;
|
||||||
|
|
||||||
const lazyDeleteValue = useMemo(() => {
|
const lazyDeleteValue = useMemo(
|
||||||
return settings.find(setting => setting.key === LAZY_DELETE_SIGNATURES_SETTING)!.value;
|
() => currentSettings.find(setting => setting.key === LAZY_DELETE_SIGNATURES_SETTING)?.value || false,
|
||||||
}, [settings]);
|
[currentSettings],
|
||||||
|
);
|
||||||
|
|
||||||
const handleSettingsChange = useCallback((settings: Setting[]) => {
|
const handleSettingsChange = useCallback((newSettings: Setting[]) => {
|
||||||
setSettings(settings);
|
setCurrentSettings(newSettings);
|
||||||
localStorage.setItem(SIGNATURE_SETTINGS_KEY, JSON.stringify(settings));
|
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleLazyDeleteChange = useCallback((value: boolean) => {
|
const handleLazyDeleteChange = useCallback((value: boolean) => {
|
||||||
setSettings(settings => {
|
setCurrentSettings(prevSettings =>
|
||||||
const lazyDelete = settings.find(setting => setting.key === LAZY_DELETE_SIGNATURES_SETTING)!;
|
prevSettings.map(setting => (setting.key === LAZY_DELETE_SIGNATURES_SETTING ? { ...setting, value } : setting)),
|
||||||
lazyDelete.value = value;
|
);
|
||||||
localStorage.setItem(SIGNATURE_SETTINGS_KEY, JSON.stringify(settings));
|
|
||||||
return [...settings];
|
|
||||||
});
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const restoredSettings = localStorage.getItem(SIGNATURE_SETTINGS_KEY);
|
const isCompact = useMaxWidth(containerRef, COMPACT_MAX_WIDTH);
|
||||||
|
|
||||||
if (restoredSettings) {
|
useHotkey(true, ['z'], event => {
|
||||||
setSettings(JSON.parse(restoredSettings));
|
if (pendingSigs.length > 0) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
undoPendingFnRef.current();
|
||||||
|
setPendingSigs([]);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleUndoClick = useCallback(() => {
|
||||||
|
undoPendingFnRef.current();
|
||||||
|
setPendingSigs([]);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const handleSettingsButtonClick = useCallback(() => {
|
||||||
const compact = useMaxWidth(ref, 260);
|
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;
|
||||||
|
});
|
||||||
|
undoPendingFnRef.current = newUndo;
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Widget
|
<Widget
|
||||||
label={
|
label={
|
||||||
<div className="flex justify-between items-center text-xs w-full h-full" ref={ref}>
|
<div ref={containerRef} className="w-full">
|
||||||
<div className="flex justify-between items-center gap-1">
|
{renderHeaderLabel({
|
||||||
{!compact && (
|
systemId,
|
||||||
<div className="flex whitespace-nowrap text-ellipsis overflow-hidden text-stone-400">
|
isNotSelectedSystem,
|
||||||
Signatures {isNotSelectedSystem ? '' : 'in'}
|
isCompact,
|
||||||
</div>
|
sigCount,
|
||||||
)}
|
lazyDeleteValue,
|
||||||
{!isNotSelectedSystem && <SystemView systemId={systemId} className="select-none text-center" hideRegion />}
|
pendingCount: pendingSigs.length,
|
||||||
</div>
|
onLazyDeleteChange: handleLazyDeleteChange,
|
||||||
|
onUndoClick: handleUndoClick,
|
||||||
<LayoutEventBlocker className="flex gap-2.5">
|
onSettingsClick: handleSettingsButtonClick,
|
||||||
<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>
|
</div>
|
||||||
}
|
}
|
||||||
|
windowId={SIGNATURE_WINDOW_ID}
|
||||||
>
|
>
|
||||||
{isNotSelectedSystem ? (
|
{isNotSelectedSystem ? (
|
||||||
<div className="w-full h-full flex justify-center items-center select-none text-center text-stone-400/80 text-sm">
|
<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
|
System is not selected
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<SystemSignaturesContent systemId={systemId} settings={settings} onLazyDeleteChange={handleLazyDeleteChange} />
|
<SystemSignaturesContent
|
||||||
|
systemId={systemId}
|
||||||
|
settings={currentSettings}
|
||||||
|
onLazyDeleteChange={handleLazyDeleteChange}
|
||||||
|
onCountChange={handleSigCountChange}
|
||||||
|
onPendingChange={handlePendingChange}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
{visible && (
|
{visible && (
|
||||||
<SystemSignatureSettingsDialog
|
<SystemSignatureSettingsDialog
|
||||||
settings={settings}
|
settings={currentSettings}
|
||||||
onCancel={() => setVisible(false)}
|
onCancel={() => setVisible(false)}
|
||||||
onSave={handleSettingsChange}
|
onSave={handleSettingsChange}
|
||||||
/>
|
/>
|
||||||
@@ -178,3 +177,5 @@ export const SystemSignatures = () => {
|
|||||||
</Widget>
|
</Widget>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default SystemSignatures;
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
.TableRowCompact {
|
|
||||||
height: 8px;
|
|
||||||
max-height: 8px;
|
|
||||||
font-size: 12px !important;
|
|
||||||
line-height: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.Table {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,29 +1,28 @@
|
|||||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
import { useEffect, useMemo, useRef, useState, useCallback } from 'react';
|
||||||
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 { DataTable, DataTableRowClickEvent, DataTableRowMouseEvent, SortOrder } from 'primereact/datatable';
|
||||||
import { Column } from 'primereact/column';
|
import { Column } from 'primereact/column';
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import { PrimeIcons } from 'primereact/api';
|
||||||
import useRefState from 'react-usestateref';
|
import useLocalStorageState from 'use-local-storage-state';
|
||||||
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 classes from './SystemSignaturesContent.module.scss';
|
import { SignatureGroup, SystemSignature } from '@/hooks/Mapper/types';
|
||||||
import clsx from 'clsx';
|
import { SignatureSettings } from '@/hooks/Mapper/components/mapRootContent/components/SignatureSettings';
|
||||||
import { SystemSignature } from '@/hooks/Mapper/types';
|
import { WdTooltip, WdTooltipHandlers, WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit';
|
||||||
import { SignatureView } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/SignatureView';
|
import { SignatureView } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/SignatureView';
|
||||||
import {
|
import {
|
||||||
getActualSigs,
|
COMPACT_MAX_WIDTH,
|
||||||
getRowColorByTimeLeft,
|
GROUPS_LIST,
|
||||||
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/helpers';
|
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';
|
||||||
import {
|
import {
|
||||||
renderAddedTimeLeft,
|
renderAddedTimeLeft,
|
||||||
renderDescription,
|
renderDescription,
|
||||||
@@ -31,18 +30,12 @@ import {
|
|||||||
renderInfoColumn,
|
renderInfoColumn,
|
||||||
renderUpdatedTimeLeft,
|
renderUpdatedTimeLeft,
|
||||||
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/renders';
|
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/renders';
|
||||||
import useLocalStorageState from 'use-local-storage-state';
|
import { ExtendedSystemSignature } from '../helpers/contentHelpers';
|
||||||
import { PrimeIcons } from 'primereact/api';
|
import { useSystemSignaturesData } from '../hooks/useSystemSignaturesData';
|
||||||
import { SignatureSettings } from '@/hooks/Mapper/components/mapRootContent/components/SignatureSettings';
|
import { getSignatureRowClass } from '../helpers/rowStyles';
|
||||||
import { useMapEventListener } from '@/hooks/Mapper/events';
|
import useMaxWidth from '@/hooks/Mapper/hooks/useMaxWidth';
|
||||||
import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrapper';
|
import { useClipboard, useHotkey } from '@/hooks/Mapper/hooks';
|
||||||
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 = {
|
type SystemSignaturesSortSettings = {
|
||||||
sortField: string;
|
sortField: string;
|
||||||
sortOrder: SortOrder;
|
sortOrder: SortOrder;
|
||||||
@@ -55,391 +48,287 @@ const SORT_DEFAULT_VALUES: SystemSignaturesSortSettings = {
|
|||||||
|
|
||||||
interface SystemSignaturesContentProps {
|
interface SystemSignaturesContentProps {
|
||||||
systemId: string;
|
systemId: string;
|
||||||
settings: Setting[];
|
settings: { key: string; value: boolean }[];
|
||||||
hideLinkedSignatures?: boolean;
|
hideLinkedSignatures?: boolean;
|
||||||
selectable?: boolean;
|
selectable?: boolean;
|
||||||
onSelect?: (signature: SystemSignature) => void;
|
onSelect?: (signature: SystemSignature) => void;
|
||||||
onLazyDeleteChange?: (value: boolean) => void;
|
onLazyDeleteChange?: (value: boolean) => void;
|
||||||
|
onCountChange?: (count: number) => void;
|
||||||
|
onPendingChange?: (pending: ExtendedSystemSignature[], undo: () => void) => void;
|
||||||
}
|
}
|
||||||
export const SystemSignaturesContent = ({
|
|
||||||
|
const headerInlineStyle = { padding: '2px', fontSize: '12px', lineHeight: '1.333' };
|
||||||
|
|
||||||
|
export function SystemSignaturesContent({
|
||||||
systemId,
|
systemId,
|
||||||
settings,
|
settings,
|
||||||
hideLinkedSignatures,
|
hideLinkedSignatures,
|
||||||
selectable,
|
selectable,
|
||||||
onSelect,
|
onSelect,
|
||||||
onLazyDeleteChange,
|
onLazyDeleteChange,
|
||||||
}: SystemSignaturesContentProps) => {
|
onCountChange,
|
||||||
const { outCommand } = useMapRootState();
|
onPendingChange,
|
||||||
|
}: SystemSignaturesContentProps) {
|
||||||
const [signatures, setSignatures, signaturesRef] = useRefState<SystemSignature[]>([]);
|
const { signatures, selectedSignatures, setSelectedSignatures, handleDeleteSelected, handleSelectAll, handlePaste } =
|
||||||
const [selectedSignatures, setSelectedSignatures] = useState<SystemSignature[]>([]);
|
useSystemSignaturesData({
|
||||||
const [nameColumnWidth, setNameColumnWidth] = useState('auto');
|
systemId,
|
||||||
const [selectedSignature, setSelectedSignature] = useState<SystemSignature | null>(null);
|
settings,
|
||||||
|
onCountChange,
|
||||||
const [hoveredSig, setHoveredSig] = useState<SystemSignature | null>(null);
|
onPendingChange,
|
||||||
|
onLazyDeleteChange,
|
||||||
const [sortSettings, setSortSettings] = useLocalStorageState<SystemSignaturesSortSettings>('window:signatures:sort', {
|
|
||||||
defaultValue: SORT_DEFAULT_VALUES,
|
|
||||||
});
|
|
||||||
|
|
||||||
const tableRef = useRef<HTMLDivElement>(null);
|
|
||||||
const compact = useMaxWidth(tableRef, 260);
|
|
||||||
const medium = useMaxWidth(tableRef, 380);
|
|
||||||
const refData = useRef({ selectable });
|
|
||||||
refData.current = { selectable };
|
|
||||||
|
|
||||||
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);
|
const [sortSettings, setSortSettings] = useLocalStorageState<{ sortField: string; sortOrder: SortOrder }>(
|
||||||
}, [outCommand, systemId]);
|
'window:signatures:sort',
|
||||||
|
{ defaultValue: SORT_DEFAULT_VALUES },
|
||||||
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(
|
const tableRef = useRef<HTMLDivElement>(null);
|
||||||
async (e: KeyboardEvent) => {
|
const tooltipRef = useRef<WdTooltipHandlers>(null);
|
||||||
if (selectable) {
|
const [hoveredSignature, setHoveredSignature] = useState<SystemSignature | null>(null);
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (selectedSignatures.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
e.preventDefault();
|
const isCompact = useMaxWidth(tableRef, COMPACT_MAX_WIDTH);
|
||||||
e.stopPropagation();
|
const isMedium = useMaxWidth(tableRef, MEDIUM_MAX_WIDTH);
|
||||||
|
|
||||||
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);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
|
const { clipboardContent, setClipboardContent } = useClipboard();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (refData.current.selectable) {
|
if (selectable) return;
|
||||||
return;
|
if (!clipboardContent?.text) return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!clipboardContent?.text) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePaste(clipboardContent.text);
|
handlePaste(clipboardContent.text);
|
||||||
|
|
||||||
setClipboardContent(null);
|
setClipboardContent(null);
|
||||||
}, [clipboardContent, selectable, lazyDeleteValue, keepLazyDeleteValue]);
|
}, [selectable, clipboardContent]);
|
||||||
|
|
||||||
useHotkey(true, ['a'], handleSelectAll);
|
useHotkey(true, ['a'], handleSelectAll);
|
||||||
useHotkey(false, ['Backspace', 'Delete'], handleDeleteSelected);
|
useHotkey(false, ['Backspace', 'Delete'], (event: KeyboardEvent) => {
|
||||||
|
const targetWindow = (event.target as HTMLHtmlElement)?.closest(`[data-window-id="${SIGNATURE_WINDOW_ID}"]`);
|
||||||
|
|
||||||
useEffect(() => {
|
if (!targetWindow) {
|
||||||
if (!systemId) {
|
|
||||||
setSignatures([]);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleGetSignatures();
|
event.preventDefault();
|
||||||
}, [systemId]);
|
event.stopPropagation();
|
||||||
|
handleDeleteSelected();
|
||||||
useMapEventListener(event => {
|
|
||||||
switch (event.name) {
|
|
||||||
case Commands.signaturesUpdated:
|
|
||||||
if (event.data?.toString() !== systemId.toString()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
handleGetSignatures();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
const [nameColumnWidth, setNameColumnWidth] = useState('auto');
|
||||||
const observer = new ResizeObserver(handleResize);
|
const handleResize = useCallback(() => {
|
||||||
if (tableRef.current) {
|
if (!tableRef.current) return;
|
||||||
observer.observe(tableRef.current);
|
const tableWidth = tableRef.current.offsetWidth;
|
||||||
}
|
const otherColumnsWidth = OTHER_COLUMNS_WIDTH;
|
||||||
|
setNameColumnWidth(`${tableWidth - otherColumnsWidth}px`);
|
||||||
handleResize(); // Call on mount to set initial width
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
if (tableRef.current) {
|
|
||||||
observer.unobserve(tableRef.current);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}, []);
|
}, []);
|
||||||
|
useEffect(() => {
|
||||||
|
if (!tableRef.current) return;
|
||||||
|
const observer = new ResizeObserver(handleResize);
|
||||||
|
observer.observe(tableRef.current);
|
||||||
|
handleResize();
|
||||||
|
return () => {
|
||||||
|
observer.disconnect();
|
||||||
|
};
|
||||||
|
}, [handleResize]);
|
||||||
|
|
||||||
const renderToolbar = (/*row: SystemSignature*/) => {
|
const [selectedSignatureForDialog, setSelectedSignatureForDialog] = useState<SystemSignature | null>(null);
|
||||||
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 [showSignatureSettings, setShowSignatureSettings] = useState(false);
|
const [showSignatureSettings, setShowSignatureSettings] = useState(false);
|
||||||
|
|
||||||
const handleRowClick = (e: DataTableRowClickEvent) => {
|
const handleRowClick = (e: DataTableRowClickEvent) => {
|
||||||
setSelectedSignature(e.data as SystemSignature);
|
setSelectedSignatureForDialog(e.data as SystemSignature);
|
||||||
setShowSignatureSettings(true);
|
setShowSignatureSettings(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
const handleSelectSignatures = useCallback(
|
||||||
<>
|
(e: { value: SystemSignature[] }) => {
|
||||||
<div ref={tableRef} className={'h-full '}>
|
if (selectable) {
|
||||||
{filteredSignatures.length === 0 ? (
|
onSelect?.(e.value[0]);
|
||||||
<div className="w-full h-full flex justify-center items-center select-none text-stone-400/80 text-sm">
|
} else {
|
||||||
No signatures
|
setSelectedSignatures(e.value as ExtendedSystemSignature[]);
|
||||||
</div>
|
}
|
||||||
) : (
|
},
|
||||||
<>
|
[selectable, onSelect, setSelectedSignatures],
|
||||||
{/* @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');
|
|
||||||
}
|
|
||||||
|
|
||||||
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');
|
|
||||||
}
|
|
||||||
|
|
||||||
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>
|
|
||||||
|
|
||||||
<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>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Column
|
|
||||||
field="inserted_at"
|
|
||||||
header="Added"
|
|
||||||
dataType="date"
|
|
||||||
bodyClassName="w-[70px] text-ellipsis overflow-hidden whitespace-nowrap"
|
|
||||||
body={renderAddedTimeLeft}
|
|
||||||
sortable
|
|
||||||
></Column>
|
|
||||||
|
|
||||||
{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}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{showSignatureSettings && (
|
|
||||||
<SignatureSettings
|
|
||||||
systemId={systemId}
|
|
||||||
show
|
|
||||||
onHide={() => setShowSignatureSettings(false)}
|
|
||||||
signatureData={selectedSignature}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
onRowMouseLeave={
|
||||||
|
isCompact || isMedium
|
||||||
|
? () => {
|
||||||
|
setHoveredSignature(null);
|
||||||
|
tooltipRef.current?.hide();
|
||||||
|
}
|
||||||
|
: 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>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!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>
|
||||||
|
)}
|
||||||
|
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}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{showSignatureSettings && (
|
||||||
|
<SignatureSettings
|
||||||
|
systemId={systemId}
|
||||||
|
show
|
||||||
|
onHide={() => setShowSignatureSettings(false)}
|
||||||
|
signatureData={selectedSignatureForDialog || undefined}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,6 +10,13 @@ import {
|
|||||||
|
|
||||||
export const TIME_ONE_MINUTE = 1000 * 60;
|
export const TIME_ONE_MINUTE = 1000 * 60;
|
||||||
export const TIME_TEN_MINUTES = 1000 * 60 * 10;
|
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 = [
|
export const GROUPS_LIST = [
|
||||||
SignatureGroup.GasSite,
|
SignatureGroup.GasSite,
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
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,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,25 +1,67 @@
|
|||||||
import { SystemSignature } from '@/hooks/Mapper/types';
|
import { SystemSignature } from '@/hooks/Mapper/types';
|
||||||
import { GROUPS_LIST } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants.ts';
|
import { GROUPS_LIST } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants';
|
||||||
import { getState } from './getState.ts';
|
import { getState } from './getState';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 = (
|
export const getActualSigs = (
|
||||||
oldSignatures: SystemSignature[],
|
oldSignatures: SystemSignature[],
|
||||||
newSignatures: SystemSignature[],
|
newSignatures: SystemSignature[],
|
||||||
updateOnly: boolean,
|
updateOnly?: boolean,
|
||||||
skipUpdateUntouched?: boolean,
|
skipUpdateUntouched?: boolean,
|
||||||
): { added: SystemSignature[]; updated: SystemSignature[]; removed: SystemSignature[] } => {
|
): { added: SystemSignature[]; updated: SystemSignature[]; removed: SystemSignature[] } => {
|
||||||
const updated: SystemSignature[] = [];
|
const updated: SystemSignature[] = [];
|
||||||
const removed: SystemSignature[] = [];
|
const removed: SystemSignature[] = [];
|
||||||
|
const added: SystemSignature[] = [];
|
||||||
|
|
||||||
oldSignatures.forEach(oldSig => {
|
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);
|
const newSig = newSignatures.find(s => s.eve_id === oldSig.eve_id);
|
||||||
if (newSig) {
|
if (newSig) {
|
||||||
// we take new sig and now we need check that sig has been updated
|
const needUpgrade = getState(GROUPS_LIST, newSig) > getState(GROUPS_LIST, oldSig);
|
||||||
const isNeedUpgrade = getState(GROUPS_LIST, newSig) > getState(GROUPS_LIST, oldSig);
|
const mergedSig = { ...oldSig };
|
||||||
if (isNeedUpgrade) {
|
let changed = false;
|
||||||
updated.push({ ...oldSig, group: newSig.group, name: newSig.name });
|
|
||||||
|
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);
|
||||||
} else if (!skipUpdateUntouched) {
|
} else if (!skipUpdateUntouched) {
|
||||||
updated.push({ ...oldSig });
|
updated.push({ ...oldSig });
|
||||||
}
|
}
|
||||||
@@ -30,8 +72,12 @@ export const getActualSigs = (
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const oldSignaturesIds = oldSignatures.map(x => x.eve_id);
|
const oldIds = new Set(oldSignatures.map(x => x.eve_id));
|
||||||
const added = newSignatures.filter(s => !oldSignaturesIds.includes(s.eve_id));
|
newSignatures.forEach(s => {
|
||||||
|
if (!oldIds.has(s.eve_id)) {
|
||||||
|
added.push(s);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return { added, updated, removed };
|
return { added, updated, removed };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import {
|
|||||||
TIME_TEN_MINUTES,
|
TIME_TEN_MINUTES,
|
||||||
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants.ts';
|
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants.ts';
|
||||||
|
|
||||||
export const getRowColorByTimeLeft = (date: Date | undefined) => {
|
export const getRowBackgroundColor = (date: Date | undefined): string => {
|
||||||
if (!date) {
|
if (!date) {
|
||||||
return null;
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentDate = new Date();
|
const currentDate = new Date();
|
||||||
@@ -18,4 +18,6 @@ export const getRowColorByTimeLeft = (date: Date | undefined) => {
|
|||||||
if (diff < TIME_TEN_MINUTES) {
|
if (diff < TIME_TEN_MINUTES) {
|
||||||
return 'bg-lime-700/40 transition hover:bg-lime-700/50';
|
return 'bg-lime-700/40 transition hover:bg-lime-700/50';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
};
|
};
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
import { SystemSignature } from '@/hooks/Mapper/types';
|
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) => {
|
export const getState = (_: string[], newSig: SystemSignature) => {
|
||||||
let state = -1;
|
let state = -1;
|
||||||
if (!newSig.group || newSig.group === '') {
|
if (!newSig.group) {
|
||||||
state = 0;
|
state = 0;
|
||||||
} else if (!newSig.name || newSig.name === '') {
|
} else if (!newSig.name || newSig.name === '') {
|
||||||
state = 1;
|
state = 1;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
export * from './getState';
|
export * from './getState';
|
||||||
export * from './getRowColorByTimeLeft';
|
export * from './getRowBackgroundColor';
|
||||||
export * from './getActualSigs';
|
export * from './getActualSigs';
|
||||||
|
export * from './contentHelpers';
|
||||||
|
export * from './rowStyles';
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
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',
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
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[]>>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
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,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
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,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
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,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,187 @@
|
|||||||
|
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,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -5,3 +5,4 @@ export * from './renderAddedTimeLeft';
|
|||||||
export * from './renderUpdatedTimeLeft';
|
export * from './renderUpdatedTimeLeft';
|
||||||
export * from './renderLinkedSystem';
|
export * from './renderLinkedSystem';
|
||||||
export * from './renderInfoColumn';
|
export * from './renderInfoColumn';
|
||||||
|
export * from './renderHeaderLabel';
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import { SystemSignaturesHeader, HeaderProps } from '../SystemSignatureHeader/SystemSignatureHeader';
|
||||||
|
|
||||||
|
export function renderHeaderLabel(props: HeaderProps) {
|
||||||
|
return <SystemSignaturesHeader {...props} />;
|
||||||
|
}
|
||||||
@@ -24,6 +24,12 @@ export const renderInfoColumn = (row: SystemSignature) => {
|
|||||||
</WdTooltipWrapper>
|
</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 && (
|
{row.type && (
|
||||||
<WHClassView
|
<WHClassView
|
||||||
className="text-[11px]"
|
className="text-[11px]"
|
||||||
|
|||||||
@@ -3,7 +3,12 @@ import { Dialog } from 'primereact/dialog';
|
|||||||
import { useCallback, useMemo, useState } from 'react';
|
import { useCallback, useMemo, useState } from 'react';
|
||||||
import { TabPanel, TabView } from 'primereact/tabview';
|
import { TabPanel, TabView } from 'primereact/tabview';
|
||||||
import { PrettySwitchbox } from './components';
|
import { PrettySwitchbox } from './components';
|
||||||
import { InterfaceStoredSettingsProps, useMapRootState, InterfaceStoredSettings } from '@/hooks/Mapper/mapRootProvider';
|
import {
|
||||||
|
InterfaceStoredSettingsProps,
|
||||||
|
useMapRootState,
|
||||||
|
InterfaceStoredSettings,
|
||||||
|
AvailableThemes
|
||||||
|
} from '@/hooks/Mapper/mapRootProvider';
|
||||||
import { OutCommand } from '@/hooks/Mapper/types';
|
import { OutCommand } from '@/hooks/Mapper/types';
|
||||||
import { Dropdown } from 'primereact/dropdown';
|
import { Dropdown } from 'primereact/dropdown';
|
||||||
import { WidgetsSettings } from '@/hooks/Mapper/components/mapRootContent/components/MapSettings/components/WidgetsSettings/WidgetsSettings.tsx';
|
import { WidgetsSettings } from '@/hooks/Mapper/components/mapRootContent/components/MapSettings/components/WidgetsSettings/WidgetsSettings.tsx';
|
||||||
@@ -112,8 +117,8 @@ const UI_CHECKBOXES_PROPS: SettingsListItem[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const THEME_OPTIONS = [
|
const THEME_OPTIONS = [
|
||||||
{ label: 'Default', value: 'default' },
|
{ label: 'Default', value: AvailableThemes.default },
|
||||||
{ label: 'Pathfinder', value: 'pathfinder' },
|
{ label: 'Pathfinder', value: AvailableThemes.pathfinder },
|
||||||
];
|
];
|
||||||
|
|
||||||
const THEME_SETTING: SettingsListItem = {
|
const THEME_SETTING: SettingsListItem = {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export interface MapSettingsProps {
|
|||||||
systemId: string;
|
systemId: string;
|
||||||
show: boolean;
|
show: boolean;
|
||||||
onHide: () => void;
|
onHide: () => void;
|
||||||
signatureData: SystemSignature | null;
|
signatureData: SystemSignature | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SignatureSettings = ({ systemId, show, onHide, signatureData }: MapSettingsProps) => {
|
export const SignatureSettings = ({ systemId, show, onHide, signatureData }: MapSettingsProps) => {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export const MapWrapper = () => {
|
|||||||
const {
|
const {
|
||||||
update,
|
update,
|
||||||
outCommand,
|
outCommand,
|
||||||
data: { selectedConnections, selectedSystems, hubs, systems, connections, linkSignatureToSystem },
|
data: { selectedConnections, selectedSystems, hubs, systems, linkSignatureToSystem },
|
||||||
interfaceSettings: {
|
interfaceSettings: {
|
||||||
isShowMenu,
|
isShowMenu,
|
||||||
isShowMinimap = STORED_INTERFACE_DEFAULT_VALUES.isShowMinimap,
|
isShowMinimap = STORED_INTERFACE_DEFAULT_VALUES.isShowMinimap,
|
||||||
@@ -56,8 +56,8 @@ export const MapWrapper = () => {
|
|||||||
const [openAddSystem, setOpenAddSystem] = useState<XYPosition | null>(null);
|
const [openAddSystem, setOpenAddSystem] = useState<XYPosition | null>(null);
|
||||||
const [selectedConnection, setSelectedConnection] = useState<SolarSystemConnection | null>(null);
|
const [selectedConnection, setSelectedConnection] = useState<SolarSystemConnection | null>(null);
|
||||||
|
|
||||||
const ref = useRef({ selectedConnections, selectedSystems, systemContextProps, systems, connections, deleteSystems });
|
const ref = useRef({ selectedConnections, selectedSystems, systemContextProps, systems, deleteSystems });
|
||||||
ref.current = { selectedConnections, selectedSystems, systemContextProps, systems, connections, deleteSystems };
|
ref.current = { selectedConnections, selectedSystems, systemContextProps, systems, deleteSystems };
|
||||||
|
|
||||||
useMapEventListener(event => {
|
useMapEventListener(event => {
|
||||||
runCommand(event);
|
runCommand(event);
|
||||||
@@ -125,11 +125,6 @@ export const MapWrapper = () => {
|
|||||||
setOpenAddSystem(coordinates);
|
setOpenAddSystem(coordinates);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const canRemoveConnection = useCallback((connectionId: string) => {
|
|
||||||
const { connections } = ref.current;
|
|
||||||
return !connections.some(x => x.id === connectionId);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleSubmitAddSystem: SearchOnSubmitCallback = useCallback(
|
const handleSubmitAddSystem: SearchOnSubmitCallback = useCallback(
|
||||||
async item => {
|
async item => {
|
||||||
if (ref.current.systems.some(x => x.system_static_info.solar_system_id === item.value)) {
|
if (ref.current.systems.some(x => x.system_static_info.solar_system_id === item.value)) {
|
||||||
@@ -166,7 +161,6 @@ export const MapWrapper = () => {
|
|||||||
isSoftBackground={isSoftBackground}
|
isSoftBackground={isSoftBackground}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
onAddSystem={onAddSystem}
|
onAddSystem={onAddSystem}
|
||||||
canRemoveConnection={canRemoveConnection}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{openSettings != null && (
|
{openSettings != null && (
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ import classes from './WdCheckbox.module.scss';
|
|||||||
import { Checkbox, CheckboxChangeEvent } from 'primereact/checkbox';
|
import { Checkbox, CheckboxChangeEvent } from 'primereact/checkbox';
|
||||||
import { WithClassName } from '@/hooks/Mapper/types/common';
|
import { WithClassName } from '@/hooks/Mapper/types/common';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
|
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
|
|
||||||
export interface WdCheckboxProps {
|
export interface WdCheckboxProps {
|
||||||
label: string;
|
label: React.ReactNode | string;
|
||||||
classNameLabel?: string;
|
classNameLabel?: string;
|
||||||
value: boolean;
|
value: boolean;
|
||||||
labelSide?: 'left' | 'right';
|
labelSide?: 'left' | 'right';
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import clsx from 'clsx';
|
||||||
|
import { WdCheckbox, WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display modes for the responsive checkbox.
|
||||||
|
*
|
||||||
|
* - "full": show the full label (e.g. "Show offline" or "Show ship name")
|
||||||
|
* - "abbr": show the abbreviated label (e.g. "Offline" or "Ship name")
|
||||||
|
* - "checkbox": show only the checkbox (no text)
|
||||||
|
* - "hide": do not render the checkbox at all
|
||||||
|
*/
|
||||||
|
export type WdDisplayMode = 'full' | 'abbr' | 'checkbox' | 'hide';
|
||||||
|
|
||||||
|
export interface WdResponsiveCheckboxProps {
|
||||||
|
tooltipContent: string;
|
||||||
|
size: 'xs' | 'normal' | 'm';
|
||||||
|
labelFull: string;
|
||||||
|
labelAbbreviated: string;
|
||||||
|
value: boolean;
|
||||||
|
onChange: () => void;
|
||||||
|
classNameLabel?: string;
|
||||||
|
containerClassName?: string;
|
||||||
|
labelSide?: 'left' | 'right';
|
||||||
|
displayMode: WdDisplayMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const WdResponsiveCheckbox: React.FC<WdResponsiveCheckboxProps> = ({
|
||||||
|
tooltipContent,
|
||||||
|
size,
|
||||||
|
labelFull,
|
||||||
|
labelAbbreviated,
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
classNameLabel,
|
||||||
|
containerClassName,
|
||||||
|
labelSide = 'left',
|
||||||
|
displayMode,
|
||||||
|
}) => {
|
||||||
|
if (displayMode === 'hide') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const label =
|
||||||
|
displayMode === 'full'
|
||||||
|
? labelFull
|
||||||
|
: displayMode === 'abbr'
|
||||||
|
? labelAbbreviated
|
||||||
|
: displayMode === 'checkbox'
|
||||||
|
? ''
|
||||||
|
: labelFull;
|
||||||
|
|
||||||
|
const checkbox = (
|
||||||
|
<div className={clsx('min-w-0', containerClassName)}>
|
||||||
|
<WdCheckbox
|
||||||
|
size={size}
|
||||||
|
labelSide={labelSide}
|
||||||
|
label={label}
|
||||||
|
value={value}
|
||||||
|
classNameLabel={classNameLabel}
|
||||||
|
onChange={onChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return tooltipContent ? <WdTooltipWrapper content={tooltipContent}>{checkbox}</WdTooltipWrapper> : checkbox;
|
||||||
|
};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './WdResponsiveCheckbox';
|
||||||
@@ -1,13 +1,4 @@
|
|||||||
import React, {
|
import React, { ForwardedRef, forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
||||||
ForwardedRef,
|
|
||||||
forwardRef,
|
|
||||||
useCallback,
|
|
||||||
useEffect,
|
|
||||||
useImperativeHandle,
|
|
||||||
useLayoutEffect,
|
|
||||||
useRef,
|
|
||||||
useState,
|
|
||||||
} from 'react';
|
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import debounce from 'lodash.debounce';
|
import debounce from 'lodash.debounce';
|
||||||
@@ -58,11 +49,11 @@ export const WdTooltip = forwardRef(function WdTooltip(
|
|||||||
className,
|
className,
|
||||||
...restProps
|
...restProps
|
||||||
}: TooltipProps,
|
}: TooltipProps,
|
||||||
ref: ForwardedRef<WdTooltipHandlers>
|
ref: ForwardedRef<WdTooltipHandlers>,
|
||||||
) {
|
) {
|
||||||
// Always initialize position so we never have a null value.
|
// Always initialize position so we never have a null value.
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [pos, setPos] = useState<OffsetPosition>({ left: 0, top: 0 });
|
const [pos, setPos] = useState<OffsetPosition | null>(null);
|
||||||
const tooltipRef = useRef<HTMLDivElement>(null);
|
const tooltipRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const [isMouseInsideTooltip, setIsMouseInsideTooltip] = useState(false);
|
const [isMouseInsideTooltip, setIsMouseInsideTooltip] = useState(false);
|
||||||
@@ -80,8 +71,13 @@ export const WdTooltip = forwardRef(function WdTooltip(
|
|||||||
let newLeft = x;
|
let newLeft = x;
|
||||||
let newTop = y;
|
let newTop = y;
|
||||||
|
|
||||||
if (newLeft < 0) newLeft = 10;
|
if (newLeft < 0) {
|
||||||
if (newTop < 0) newTop = 10;
|
newLeft = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newTop < 0) {
|
||||||
|
newTop = 10;
|
||||||
|
}
|
||||||
|
|
||||||
const rightEdge = newLeft + tooltipWidth + 10;
|
const rightEdge = newLeft + tooltipWidth + 10;
|
||||||
if (rightEdge > window.innerWidth) {
|
if (rightEdge > window.innerWidth) {
|
||||||
@@ -99,11 +95,13 @@ export const WdTooltip = forwardRef(function WdTooltip(
|
|||||||
const scheduleHide = useCallback(() => {
|
const scheduleHide = useCallback(() => {
|
||||||
if (!interactive) {
|
if (!interactive) {
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
setPos(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!hideTimeoutRef.current) {
|
if (!hideTimeoutRef.current) {
|
||||||
hideTimeoutRef.current = setTimeout(() => {
|
hideTimeoutRef.current = setTimeout(() => {
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
setPos(null);
|
||||||
}, LEAVE_DELAY);
|
}, LEAVE_DELAY);
|
||||||
}
|
}
|
||||||
}, [interactive]);
|
}, [interactive]);
|
||||||
@@ -130,12 +128,12 @@ export const WdTooltip = forwardRef(function WdTooltip(
|
|||||||
clearTimeout(hideTimeoutRef.current);
|
clearTimeout(hideTimeoutRef.current);
|
||||||
}
|
}
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
setPos(null);
|
||||||
},
|
},
|
||||||
getIsMouseInside: () => isMouseInsideTooltip,
|
getIsMouseInside: () => isMouseInsideTooltip,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Recalculate position once the tooltip element has been rendered.
|
useEffect(() => {
|
||||||
useLayoutEffect(() => {
|
|
||||||
if (!tooltipRef.current || !triggerInfo) return;
|
if (!tooltipRef.current || !triggerInfo) return;
|
||||||
|
|
||||||
const tooltipEl = tooltipRef.current;
|
const tooltipEl = tooltipRef.current;
|
||||||
@@ -147,30 +145,36 @@ export const WdTooltip = forwardRef(function WdTooltip(
|
|||||||
const tooltipBounds = tooltipEl.getBoundingClientRect();
|
const tooltipBounds = tooltipEl.getBoundingClientRect();
|
||||||
x = rect.left - tooltipBounds.width - offset;
|
x = rect.left - tooltipBounds.width - offset;
|
||||||
y = rect.top + rect.height / 2 - tooltipBounds.height / 2;
|
y = rect.top + rect.height / 2 - tooltipBounds.height / 2;
|
||||||
|
|
||||||
if (x <= 0) {
|
if (x <= 0) {
|
||||||
x = rect.left + rect.width + offset;
|
x = rect.left + rect.width + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPos(calcTooltipPosition({ x, y }));
|
setPos(calcTooltipPosition({ x, y }));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tPosition === TooltipPosition.right) {
|
if (tPosition === TooltipPosition.right) {
|
||||||
x = rect.left + rect.width + offset;
|
x = rect.left + rect.width + offset;
|
||||||
y = rect.top + rect.height / 2 - tooltipEl.offsetHeight / 2;
|
y = rect.top + rect.height / 2 - tooltipEl.offsetHeight / 2;
|
||||||
setPos(calcTooltipPosition({ x, y }));
|
setPos(calcTooltipPosition({ x, y }));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tPosition === TooltipPosition.top) {
|
if (tPosition === TooltipPosition.top) {
|
||||||
x = rect.left + rect.width / 2 - tooltipEl.offsetWidth / 2;
|
x = rect.left + rect.width / 2 - tooltipEl.offsetWidth / 2;
|
||||||
y = rect.top - tooltipEl.offsetHeight - offset;
|
y = rect.top - tooltipEl.offsetHeight - offset;
|
||||||
setPos(calcTooltipPosition({ x, y }));
|
setPos(calcTooltipPosition({ x, y }));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tPosition === TooltipPosition.bottom) {
|
if (tPosition === TooltipPosition.bottom) {
|
||||||
x = rect.left + rect.width / 2 - tooltipEl.offsetWidth / 2;
|
x = rect.left + rect.width / 2 - tooltipEl.offsetWidth / 2;
|
||||||
y = rect.bottom + offset;
|
y = rect.bottom + offset;
|
||||||
setPos(calcTooltipPosition({ x, y }));
|
setPos(calcTooltipPosition({ x, y }));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default case: use stored coordinates.
|
// Default case: use stored coordinates.
|
||||||
setPos(calcTooltipPosition({ x, y }));
|
setPos(calcTooltipPosition({ x, y }));
|
||||||
}, [calcTooltipPosition, triggerInfo, tPosition, offset]);
|
}, [calcTooltipPosition, triggerInfo, tPosition, offset]);
|
||||||
@@ -184,6 +188,7 @@ export const WdTooltip = forwardRef(function WdTooltip(
|
|||||||
scheduleHide();
|
scheduleHide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const triggerEl = targetEl.closest(targetSelector);
|
const triggerEl = targetEl.closest(targetSelector);
|
||||||
const insideTooltip = interactive && tooltipRef.current?.contains(targetEl);
|
const insideTooltip = interactive && tooltipRef.current?.contains(targetEl);
|
||||||
|
|
||||||
@@ -196,6 +201,7 @@ export const WdTooltip = forwardRef(function WdTooltip(
|
|||||||
clearTimeout(hideTimeoutRef.current);
|
clearTimeout(hideTimeoutRef.current);
|
||||||
hideTimeoutRef.current = null;
|
hideTimeoutRef.current = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
|
|
||||||
if (triggerEl && tooltipRef.current) {
|
if (triggerEl && tooltipRef.current) {
|
||||||
@@ -206,30 +212,26 @@ export const WdTooltip = forwardRef(function WdTooltip(
|
|||||||
let y = evt.clientY;
|
let y = evt.clientY;
|
||||||
|
|
||||||
switch (tPosition) {
|
switch (tPosition) {
|
||||||
case TooltipPosition.left: {
|
case TooltipPosition.left:
|
||||||
x = rect.left - tooltipEl.offsetWidth - offset;
|
x = rect.left - tooltipEl.offsetWidth - offset;
|
||||||
y = rect.top + rect.height / 2 - tooltipEl.offsetHeight / 2;
|
y = rect.top + rect.height / 2 - tooltipEl.offsetHeight / 2;
|
||||||
|
|
||||||
if (x <= 0) {
|
if (x <= 0) {
|
||||||
x = rect.left + rect.width + offset;
|
x = rect.left + rect.width + offset;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
case TooltipPosition.right:
|
||||||
case TooltipPosition.right: {
|
|
||||||
x = rect.left + rect.width + offset;
|
x = rect.left + rect.width + offset;
|
||||||
y = rect.top + rect.height / 2 - tooltipEl.offsetHeight / 2;
|
y = rect.top + rect.height / 2 - tooltipEl.offsetHeight / 2;
|
||||||
break;
|
break;
|
||||||
}
|
case TooltipPosition.top:
|
||||||
case TooltipPosition.top: {
|
|
||||||
x = rect.left + rect.width / 2 - tooltipEl.offsetWidth / 2;
|
x = rect.left + rect.width / 2 - tooltipEl.offsetWidth / 2;
|
||||||
y = rect.top - tooltipEl.offsetHeight - offset;
|
y = rect.top - tooltipEl.offsetHeight - offset;
|
||||||
break;
|
break;
|
||||||
}
|
case TooltipPosition.bottom:
|
||||||
case TooltipPosition.bottom: {
|
|
||||||
x = rect.left + rect.width / 2 - tooltipEl.offsetWidth / 2;
|
x = rect.left + rect.width / 2 - tooltipEl.offsetWidth / 2;
|
||||||
y = rect.bottom + offset;
|
y = rect.bottom + offset;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setPos(calcTooltipPosition({ x, y }));
|
setPos(calcTooltipPosition({ x, y }));
|
||||||
@@ -237,13 +239,10 @@ export const WdTooltip = forwardRef(function WdTooltip(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const debounced = debounce(handleMouseMove, 15);
|
const debounced = debounce(handleMouseMove, 15);
|
||||||
const listener = (evt: Event) => {
|
|
||||||
debounced(evt as MouseEvent);
|
|
||||||
};
|
|
||||||
|
|
||||||
document.addEventListener('mousemove', listener);
|
document.addEventListener('mousemove', debounced);
|
||||||
return () => {
|
return () => {
|
||||||
document.removeEventListener('mousemove', listener);
|
document.removeEventListener('mousemove', debounced);
|
||||||
debounced.cancel();
|
debounced.cancel();
|
||||||
};
|
};
|
||||||
}, [targetSelector, interactive, tPosition, offset, calcTooltipPosition, scheduleHide]);
|
}, [targetSelector, interactive, tPosition, offset, calcTooltipPosition, scheduleHide]);
|
||||||
@@ -265,11 +264,12 @@ export const WdTooltip = forwardRef(function WdTooltip(
|
|||||||
classes.tooltip,
|
classes.tooltip,
|
||||||
interactive ? 'pointer-events-auto' : 'pointer-events-none',
|
interactive ? 'pointer-events-auto' : 'pointer-events-none',
|
||||||
'absolute p-1 border rounded-sm border-green-300 border-opacity-10 bg-stone-900 bg-opacity-90',
|
'absolute p-1 border rounded-sm border-green-300 border-opacity-10 bg-stone-900 bg-opacity-90',
|
||||||
className
|
className,
|
||||||
|
pos === null ? 'invisible' : '',
|
||||||
)}
|
)}
|
||||||
style={{
|
style={{
|
||||||
top: pos.top,
|
top: pos?.top ?? 0,
|
||||||
left: pos.left,
|
left: pos?.left ?? 0,
|
||||||
zIndex: 10000,
|
zIndex: 10000,
|
||||||
}}
|
}}
|
||||||
onMouseEnter={() => {
|
onMouseEnter={() => {
|
||||||
@@ -289,7 +289,7 @@ export const WdTooltip = forwardRef(function WdTooltip(
|
|||||||
>
|
>
|
||||||
{typeof content === 'function' ? content() : content}
|
{typeof content === 'function' ? content() : content}
|
||||||
</div>,
|
</div>,
|
||||||
document.body
|
document.body,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { forwardRef, HTMLProps, ReactNode } from 'react';
|
import { forwardRef, HTMLProps, ReactNode, useMemo } from 'react';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { WdTooltip, WdTooltipHandlers, TooltipProps } from '@/hooks/Mapper/components/ui-kit';
|
import { WdTooltip, WdTooltipHandlers, TooltipProps } from '@/hooks/Mapper/components/ui-kit';
|
||||||
import classes from './WdTooltipWrapper.module.scss';
|
import classes from './WdTooltipWrapper.module.scss';
|
||||||
@@ -13,11 +13,8 @@ export type WdTooltipWrapperProps = {
|
|||||||
Omit<TooltipProps, 'content'>;
|
Omit<TooltipProps, 'content'>;
|
||||||
|
|
||||||
export const WdTooltipWrapper = forwardRef<WdTooltipHandlers, WdTooltipWrapperProps>(
|
export const WdTooltipWrapper = forwardRef<WdTooltipHandlers, WdTooltipWrapperProps>(
|
||||||
(
|
({ className, children, content, offset, position, targetSelector, interactive, size, ...props }, forwardedRef) => {
|
||||||
{ className, children, content, offset, position, targetSelector, interactive = false, size, ...props },
|
const suffix = useMemo(() => Math.random().toString(36).slice(2, 7), []);
|
||||||
forwardedRef,
|
|
||||||
) => {
|
|
||||||
const suffix = Math.random().toString(36).slice(2, 7);
|
|
||||||
const autoClass = `wdTooltipAutoTrigger-${suffix}`;
|
const autoClass = `wdTooltipAutoTrigger-${suffix}`;
|
||||||
const finalTargetSelector = targetSelector || `.${autoClass}`;
|
const finalTargetSelector = targetSelector || `.${autoClass}`;
|
||||||
|
|
||||||
|
|||||||
@@ -11,3 +11,5 @@ export * from './WdImgButton';
|
|||||||
export * from './WdTooltip';
|
export * from './WdTooltip';
|
||||||
export * from './WdCheckbox';
|
export * from './WdCheckbox';
|
||||||
export * from './TimeAgo';
|
export * from './TimeAgo';
|
||||||
|
export * from './WdTooltipWrapper';
|
||||||
|
export * from './WdResponsiveCheckBox';
|
||||||
|
|||||||
@@ -16,13 +16,15 @@ export const parseSignatures = (value: string, availableKeys: string[]): SystemS
|
|||||||
|
|
||||||
const kind = MAPPING_TYPE_TO_ENG[sigArrInfo[1] as SignatureKind];
|
const kind = MAPPING_TYPE_TO_ENG[sigArrInfo[1] as SignatureKind];
|
||||||
|
|
||||||
outArr.push({
|
const signature: SystemSignature = {
|
||||||
eve_id: sigArrInfo[0],
|
eve_id: sigArrInfo[0],
|
||||||
kind: availableKeys.includes(kind) ? kind : SignatureKind.CosmicSignature,
|
kind: availableKeys.includes(kind) ? kind : SignatureKind.CosmicSignature,
|
||||||
group: sigArrInfo[2] as SignatureGroup,
|
group: sigArrInfo[2] as SignatureGroup,
|
||||||
name: sigArrInfo[3],
|
name: sigArrInfo[3],
|
||||||
type: '',
|
type: '',
|
||||||
});
|
};
|
||||||
|
|
||||||
|
outArr.push(signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
return outArr;
|
return outArr;
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ import { WORMHOLES_ADDITIONAL_INFO } from '@/hooks/Mapper/components/map/constan
|
|||||||
import { WormholeDataRaw } from '@/hooks/Mapper/types';
|
import { WormholeDataRaw } from '@/hooks/Mapper/types';
|
||||||
|
|
||||||
export const sortWHClasses = (wormholesData: Record<string, WormholeDataRaw>, statics: string[]) => {
|
export const sortWHClasses = (wormholesData: Record<string, WormholeDataRaw>, statics: string[]) => {
|
||||||
if (!statics) {
|
if (!statics || !wormholesData) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return statics
|
return statics
|
||||||
.map(x => wormholesData[x])
|
.map(x => wormholesData[x])
|
||||||
|
.filter(x => !!x)
|
||||||
.map(x => ({ name: x.name, ...WORMHOLES_ADDITIONAL_INFO[x.dest] }))
|
.map(x => ({ name: x.name, ...WORMHOLES_ADDITIONAL_INFO[x.dest] }))
|
||||||
.sort((a, b) => a.wormholeClassID - b.wormholeClassID)
|
.sort((a, b) => a.wormholeClassID - b.wormholeClassID)
|
||||||
.map(x => x.name);
|
.map(x => x.name);
|
||||||
|
|||||||
7
assets/js/hooks/Mapper/hooks/useTheme.ts
Normal file
7
assets/js/hooks/Mapper/hooks/useTheme.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { AvailableThemes, useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||||
|
|
||||||
|
export const useTheme = (): AvailableThemes => {
|
||||||
|
const { interfaceSettings } = useMapRootState();
|
||||||
|
|
||||||
|
return interfaceSettings.theme;
|
||||||
|
};
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
import { createRoot } from 'react-dom/client';
|
import { createRoot } from 'react-dom/client';
|
||||||
import Mapper from './MapRoot';
|
import Mapper from './MapRoot';
|
||||||
|
|
||||||
|
const LAST_VERSION_KEY = 'wandererLastVersion';
|
||||||
|
const UI_LOADED_EVENT = 'ui_loaded';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
_rootEl: null,
|
_rootEl: null,
|
||||||
_errorCount: 0,
|
_errorCount: 0,
|
||||||
@@ -8,7 +11,7 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
// create react root element
|
// create react root element
|
||||||
const rootEl = document.getElementById(this.el.id);
|
const rootEl = document.getElementById(this.el.id);
|
||||||
this._version = this.el.dataset.version;
|
const activeVersion = localStorage.getItem(LAST_VERSION_KEY);
|
||||||
this._rootEl = createRoot(rootEl!);
|
this._rootEl = createRoot(rootEl!);
|
||||||
|
|
||||||
const handleError = (error: Error, componentStack: string) => {
|
const handleError = (error: Error, componentStack: string) => {
|
||||||
@@ -22,7 +25,7 @@ export default {
|
|||||||
onError: handleError,
|
onError: handleError,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.pushEvent('ui_loaded');
|
this.pushEvent(UI_LOADED_EVENT, { version: activeVersion });
|
||||||
},
|
},
|
||||||
|
|
||||||
handleEventWrapper(event: string, handler: (payload: any) => void) {
|
handleEventWrapper(event: string, handler: (payload: any) => void) {
|
||||||
@@ -32,7 +35,8 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
reconnected() {
|
reconnected() {
|
||||||
this.pushEvent('ui_loaded');
|
const activeVersion = localStorage.getItem(LAST_VERSION_KEY);
|
||||||
|
this.pushEvent(UI_LOADED_EVENT, { version: activeVersion });
|
||||||
},
|
},
|
||||||
|
|
||||||
async pushEventAsync(event: string, payload: any) {
|
async pushEventAsync(event: string, payload: any) {
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ const INITIAL_DATA: MapRootData = {
|
|||||||
linkSignatureToSystem: null,
|
linkSignatureToSystem: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export enum AvailableThemes {
|
||||||
|
default = 'default',
|
||||||
|
pathfinder = 'pathfinder',
|
||||||
|
}
|
||||||
|
|
||||||
export enum InterfaceStoredSettingsProps {
|
export enum InterfaceStoredSettingsProps {
|
||||||
isShowMenu = 'isShowMenu',
|
isShowMenu = 'isShowMenu',
|
||||||
isShowMinimap = 'isShowMinimap',
|
isShowMinimap = 'isShowMinimap',
|
||||||
@@ -65,7 +70,7 @@ export type InterfaceStoredSettings = {
|
|||||||
isShowUnsplashedSignatures: boolean;
|
isShowUnsplashedSignatures: boolean;
|
||||||
isShowBackgroundPattern: boolean;
|
isShowBackgroundPattern: boolean;
|
||||||
isSoftBackground: boolean;
|
isSoftBackground: boolean;
|
||||||
theme: string;
|
theme: AvailableThemes;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const STORED_INTERFACE_DEFAULT_VALUES: InterfaceStoredSettings = {
|
export const STORED_INTERFACE_DEFAULT_VALUES: InterfaceStoredSettings = {
|
||||||
@@ -76,7 +81,7 @@ export const STORED_INTERFACE_DEFAULT_VALUES: InterfaceStoredSettings = {
|
|||||||
isShowUnsplashedSignatures: false,
|
isShowUnsplashedSignatures: false,
|
||||||
isShowBackgroundPattern: true,
|
isShowBackgroundPattern: true,
|
||||||
isSoftBackground: false,
|
isSoftBackground: false,
|
||||||
theme: 'default',
|
theme: AvailableThemes.default,
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface MapRootContextProps {
|
export interface MapRootContextProps {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ export interface DetailedKill {
|
|||||||
victim_ship_type_id?: number | null;
|
victim_ship_type_id?: number | null;
|
||||||
victim_ship_name?: string;
|
victim_ship_name?: string;
|
||||||
|
|
||||||
|
|
||||||
final_blow_char_id?: number | null;
|
final_blow_char_id?: number | null;
|
||||||
final_blow_char_name?: string;
|
final_blow_char_name?: string;
|
||||||
final_blow_corp_id?: number | null;
|
final_blow_corp_id?: number | null;
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ export type CommandInit = {
|
|||||||
routes: RoutesList;
|
routes: RoutesList;
|
||||||
options: Record<string, string | boolean>;
|
options: Record<string, string | boolean>;
|
||||||
reset?: boolean;
|
reset?: boolean;
|
||||||
|
is_subscription_active?: boolean;
|
||||||
};
|
};
|
||||||
export type CommandAddSystems = SolarSystemRawType[];
|
export type CommandAddSystems = SolarSystemRawType[];
|
||||||
export type CommandUpdateSystems = SolarSystemRawType[];
|
export type CommandUpdateSystems = SolarSystemRawType[];
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ export type SignatureCustomInfo = {
|
|||||||
|
|
||||||
export type SystemSignature = {
|
export type SystemSignature = {
|
||||||
eve_id: string;
|
eve_id: string;
|
||||||
|
character_eve_id?: string;
|
||||||
|
character_name?: string;
|
||||||
kind: SignatureKind;
|
kind: SignatureKind;
|
||||||
name: string;
|
name: string;
|
||||||
// SignatureCustomInfo
|
// SignatureCustomInfo
|
||||||
|
|||||||
@@ -1,18 +1,31 @@
|
|||||||
import { useCallback, useRef, useState } from 'react';
|
import { useCallback, useRef, useState, useEffect } from 'react';
|
||||||
|
|
||||||
import { ContextStoreDataOpts, ProvideConstateDataReturnType, ContextStoreDataUpdate } from './types';
|
import { ContextStoreDataOpts, ProvideConstateDataReturnType, ContextStoreDataUpdate, UpdateFunc } from './types';
|
||||||
|
|
||||||
export const useContextStore = <T>(
|
export const useContextStore = <T>(
|
||||||
initialValue: T,
|
initialValue: T,
|
||||||
{ notNeedRerender = false, handleBeforeUpdate, onAfterAUpdate }: ContextStoreDataOpts<T> = {},
|
{ notNeedRerender = false, handleBeforeUpdate, onAfterAUpdate }: ContextStoreDataOpts<T> = {},
|
||||||
): ProvideConstateDataReturnType<T> => {
|
): ProvideConstateDataReturnType<T> => {
|
||||||
const ref = useRef<T>(initialValue);
|
const ref = useRef<T>(initialValue);
|
||||||
|
const queueRef = useRef<{ valOrFunc: Partial<T> | UpdateFunc<T>; force: boolean }[]>([]);
|
||||||
const [, setRerenderKey] = useState(0);
|
const [, setRerenderKey] = useState(0);
|
||||||
|
|
||||||
const refWrapper = useRef({ notNeedRerender, handleBeforeUpdate, onAfterAUpdate });
|
const refWrapper = useRef({ notNeedRerender, handleBeforeUpdate, onAfterAUpdate });
|
||||||
refWrapper.current = { notNeedRerender, handleBeforeUpdate, onAfterAUpdate };
|
refWrapper.current = { notNeedRerender, handleBeforeUpdate, onAfterAUpdate };
|
||||||
|
|
||||||
const update: ContextStoreDataUpdate<T> = useCallback((valOrFunc, force = false) => {
|
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
|
// It need to force prevent unnecessary rerendering
|
||||||
// update will create once
|
// update will create once
|
||||||
const { notNeedRerender, handleBeforeUpdate, onAfterAUpdate } = refWrapper.current;
|
const { notNeedRerender, handleBeforeUpdate, onAfterAUpdate } = refWrapper.current;
|
||||||
@@ -76,5 +89,19 @@ export const useContextStore = <T>(
|
|||||||
onAfterAUpdate?.(ref.current);
|
onAfterAUpdate?.(ref.current);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let requestId: number;
|
||||||
|
const process = () => {
|
||||||
|
processNextQueue();
|
||||||
|
requestId = requestAnimationFrame(process);
|
||||||
|
};
|
||||||
|
|
||||||
|
process();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
cancelAnimationFrame(requestId);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
return { update, ref: ref.current };
|
return { update, ref: ref.current };
|
||||||
};
|
};
|
||||||
|
|||||||
BIN
assets/static/images/news/02-20-acl-api/generate-acl-key.png
Executable file
BIN
assets/static/images/news/02-20-acl-api/generate-acl-key.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -53,6 +53,11 @@ public_api_disabled =
|
|||||||
|> get_var_from_path_or_env("WANDERER_PUBLIC_API_DISABLED", "false")
|
|> get_var_from_path_or_env("WANDERER_PUBLIC_API_DISABLED", "false")
|
||||||
|> String.to_existing_atom()
|
|> 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 =
|
zkill_preload_disabled =
|
||||||
config_dir
|
config_dir
|
||||||
|> get_var_from_path_or_env("WANDERER_ZKILL_PRELOAD_DISABLED", "false")
|
|> get_var_from_path_or_env("WANDERER_ZKILL_PRELOAD_DISABLED", "false")
|
||||||
@@ -107,6 +112,11 @@ admins =
|
|||||||
admins -> admins |> String.split(",")
|
admins -> admins |> String.split(",")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
restrict_maps_creation =
|
||||||
|
config_dir
|
||||||
|
|> get_var_from_path_or_env("WANDERER_RESTRICT_MAPS_CREATION", "false")
|
||||||
|
|> String.to_existing_atom()
|
||||||
|
|
||||||
config :wanderer_app,
|
config :wanderer_app,
|
||||||
web_app_url: web_app_url,
|
web_app_url: web_app_url,
|
||||||
git_sha: System.get_env("GIT_SHA", "111"),
|
git_sha: System.get_env("GIT_SHA", "111"),
|
||||||
@@ -118,12 +128,14 @@ config :wanderer_app,
|
|||||||
corp_id: System.get_env("WANDERER_CORP_ID", "-1") |> String.to_integer(),
|
corp_id: System.get_env("WANDERER_CORP_ID", "-1") |> String.to_integer(),
|
||||||
corp_wallet: System.get_env("WANDERER_CORP_WALLET", ""),
|
corp_wallet: System.get_env("WANDERER_CORP_WALLET", ""),
|
||||||
public_api_disabled: public_api_disabled,
|
public_api_disabled: public_api_disabled,
|
||||||
|
character_api_disabled: character_api_disabled,
|
||||||
zkill_preload_disabled: zkill_preload_disabled,
|
zkill_preload_disabled: zkill_preload_disabled,
|
||||||
map_subscriptions_enabled: map_subscriptions_enabled,
|
map_subscriptions_enabled: map_subscriptions_enabled,
|
||||||
map_connection_auto_expire_hours: map_connection_auto_expire_hours,
|
map_connection_auto_expire_hours: map_connection_auto_expire_hours,
|
||||||
map_connection_auto_eol_hours: map_connection_auto_eol_hours,
|
map_connection_auto_eol_hours: map_connection_auto_eol_hours,
|
||||||
map_connection_eol_expire_timeout_mins: map_connection_eol_expire_timeout_mins,
|
map_connection_eol_expire_timeout_mins: map_connection_eol_expire_timeout_mins,
|
||||||
wallet_tracking_enabled: wallet_tracking_enabled,
|
wallet_tracking_enabled: wallet_tracking_enabled,
|
||||||
|
restrict_maps_creation: restrict_maps_creation,
|
||||||
subscription_settings: %{
|
subscription_settings: %{
|
||||||
plans: [
|
plans: [
|
||||||
%{
|
%{
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ defmodule WandererApp.Api.AccessList do
|
|||||||
|
|
||||||
code_interface do
|
code_interface do
|
||||||
define(:create, action: :create)
|
define(:create, action: :create)
|
||||||
|
|
||||||
define(:available, action: :available)
|
define(:available, action: :available)
|
||||||
define(:new, action: :new)
|
define(:new, action: :new)
|
||||||
define(:read, action: :read)
|
define(:read, action: :read)
|
||||||
@@ -39,7 +38,8 @@ defmodule WandererApp.Api.AccessList do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create :new do
|
create :new do
|
||||||
accept [:name, :description, :owner_id]
|
# Added :api_key to the accepted attributes
|
||||||
|
accept [:name, :description, :owner_id, :api_key]
|
||||||
primary?(true)
|
primary?(true)
|
||||||
|
|
||||||
argument :owner_id, :uuid, allow_nil?: false
|
argument :owner_id, :uuid, allow_nil?: false
|
||||||
@@ -48,7 +48,7 @@ defmodule WandererApp.Api.AccessList do
|
|||||||
end
|
end
|
||||||
|
|
||||||
update :update do
|
update :update do
|
||||||
accept [:name, :description, :owner_id]
|
accept [:name, :description, :owner_id, :api_key]
|
||||||
primary?(true)
|
primary?(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -68,6 +68,10 @@ defmodule WandererApp.Api.AccessList do
|
|||||||
allow_nil? true
|
allow_nil? true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
attribute :api_key, :string do
|
||||||
|
allow_nil? true
|
||||||
|
end
|
||||||
|
|
||||||
create_timestamp(:inserted_at)
|
create_timestamp(:inserted_at)
|
||||||
update_timestamp(:updated_at)
|
update_timestamp(:updated_at)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ defmodule WandererApp.Character.TransactionsTracker.Impl do
|
|||||||
Phoenix.PubSub.broadcast(
|
Phoenix.PubSub.broadcast(
|
||||||
WandererApp.PubSub,
|
WandererApp.PubSub,
|
||||||
"corporation",
|
"corporation",
|
||||||
{:transactions, character.corporation_id, transactions}
|
{:transactions, character.corporation_id, transactions |> Enum.sort_by(& &1.date, :desc)}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ defmodule WandererApp.Env do
|
|||||||
def invites, do: get_key(:invites, false)
|
def invites, do: get_key(:invites, false)
|
||||||
def map_subscriptions_enabled?, do: get_key(:map_subscriptions_enabled, false)
|
def map_subscriptions_enabled?, do: get_key(:map_subscriptions_enabled, false)
|
||||||
def public_api_disabled?, do: get_key(:public_api_disabled, 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 zkill_preload_disabled?, do: get_key(:zkill_preload_disabled, false)
|
||||||
def wallet_tracking_enabled?, do: get_key(:wallet_tracking_enabled, false)
|
def wallet_tracking_enabled?, do: get_key(:wallet_tracking_enabled, false)
|
||||||
def admins, do: get_key(:admins, [])
|
def admins, do: get_key(:admins, [])
|
||||||
@@ -20,6 +21,12 @@ defmodule WandererApp.Env do
|
|||||||
def corp_eve_id, do: get_key(:corp_id, -1)
|
def corp_eve_id, do: get_key(:corp_id, -1)
|
||||||
def subscription_settings, do: get_key(:subscription_settings)
|
def subscription_settings, do: get_key(:subscription_settings)
|
||||||
|
|
||||||
|
@decorate cacheable(
|
||||||
|
cache: WandererApp.Cache,
|
||||||
|
key: "restrict_maps_creation"
|
||||||
|
)
|
||||||
|
def restrict_maps_creation?, do: get_key(:restrict_maps_creation, false)
|
||||||
|
|
||||||
@decorate cacheable(
|
@decorate cacheable(
|
||||||
cache: WandererApp.Cache,
|
cache: WandererApp.Cache,
|
||||||
key: "map-connection-auto-expire-hours"
|
key: "map-connection-auto-expire-hours"
|
||||||
|
|||||||
@@ -237,6 +237,12 @@ defmodule WandererApp.Map.Server do
|
|||||||
|> map_pid!
|
|> map_pid!
|
||||||
|> GenServer.cast({&Impl.update_connection_custom_info/2, [connection_info]})
|
|> 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
|
@impl true
|
||||||
def handle_continue(:load_state, state),
|
def handle_continue(:load_state, state),
|
||||||
do: {:noreply, state |> Impl.load_state(), {:continue, :start_map}}
|
do: {:noreply, state |> Impl.load_state(), {:continue, :start_map}}
|
||||||
|
|||||||
@@ -4,7 +4,13 @@ defmodule WandererApp.Map.Server.Impl do
|
|||||||
"""
|
"""
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
alias WandererApp.Map.Server.{AclsImpl, CharactersImpl, ConnectionsImpl, SystemsImpl}
|
alias WandererApp.Map.Server.{
|
||||||
|
AclsImpl,
|
||||||
|
CharactersImpl,
|
||||||
|
ConnectionsImpl,
|
||||||
|
SystemsImpl,
|
||||||
|
SignaturesImpl
|
||||||
|
}
|
||||||
|
|
||||||
@enforce_keys [
|
@enforce_keys [
|
||||||
:map_id
|
:map_id
|
||||||
@@ -180,7 +186,9 @@ defmodule WandererApp.Map.Server.Impl do
|
|||||||
|
|
||||||
defdelegate update_connection_locked(state, connection_update), to: ConnectionsImpl
|
defdelegate update_connection_locked(state, connection_update), to: ConnectionsImpl
|
||||||
|
|
||||||
defdelegate update_connection_custom_info(state, connection_update), to: ConnectionsImpl
|
defdelegate update_connection_custom_info(state, signatures_update), to: ConnectionsImpl
|
||||||
|
|
||||||
|
defdelegate update_signatures(state, signatures_update), to: SignaturesImpl
|
||||||
|
|
||||||
def import_settings(%{map_id: map_id} = state, settings, user_id) do
|
def import_settings(%{map_id: map_id} = state, settings, user_id) do
|
||||||
WandererApp.Cache.put(
|
WandererApp.Cache.put(
|
||||||
|
|||||||
150
lib/wanderer_app/map/server/map_server_signatures_impl.ex
Normal file
150
lib/wanderer_app/map/server/map_server_signatures_impl.ex
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
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
|
||||||
@@ -278,7 +278,7 @@ defmodule WandererApp.Map.Server.SystemsImpl do
|
|||||||
|
|
||||||
linked_system_ids
|
linked_system_ids
|
||||||
|> Enum.each(fn linked_system_id ->
|
|> Enum.each(fn linked_system_id ->
|
||||||
WandererApp.Map.Server.update_system_linked_sig_eve_id(map_id, %{
|
update_system_linked_sig_eve_id(state, %{
|
||||||
solar_system_id: linked_system_id,
|
solar_system_id: linked_system_id,
|
||||||
linked_sig_eve_id: nil
|
linked_sig_eve_id: nil
|
||||||
})
|
})
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user