mirror of
https://github.com/wanderer-industries/wanderer
synced 2026-02-13 09:26:03 +00:00
Compare commits
269 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5af43dca1 | ||
|
|
549fa1d2cf | ||
|
|
34a4d5dc9f | ||
|
|
15142f188b | ||
|
|
daf4a81568 | ||
|
|
8c5340e911 | ||
|
|
6b0f636964 | ||
|
|
09ebd29eb4 | ||
|
|
35bd5645bf | ||
|
|
a6948ee1da | ||
|
|
98b3f5855c | ||
|
|
11ad48b40a | ||
|
|
ecd018abfe | ||
|
|
f430f74e98 | ||
|
|
9e146d1117 | ||
|
|
0a707fb423 | ||
|
|
8cda76cc43 | ||
|
|
2005e6f3dd | ||
|
|
ab066a342f | ||
|
|
82b4a5f35a | ||
|
|
ca3a25b836 | ||
|
|
8e46c01a8a | ||
|
|
9d9fa3c6b5 | ||
|
|
0e24501225 | ||
|
|
25a3d8951e | ||
|
|
f4ddc8dc8b | ||
|
|
ac9b46e24d | ||
|
|
40d0a0777a | ||
|
|
608792d99a | ||
|
|
dc9e0c821e | ||
|
|
79d4fd0e43 | ||
|
|
5d03c1ecc7 | ||
|
|
2eef05495e | ||
|
|
f724455a1e | ||
|
|
33bbb3425c | ||
|
|
a919bd9038 | ||
|
|
8ae34cd94a | ||
|
|
2f38da52e8 | ||
|
|
89d7df0ba2 | ||
|
|
ba0c10d2e4 | ||
|
|
996c88d839 | ||
|
|
80e998cf79 | ||
|
|
d2bcb89fa1 | ||
|
|
922f296f17 | ||
|
|
71dc20c933 | ||
|
|
80f7d34d3d | ||
|
|
113fe1c695 | ||
|
|
5550844912 | ||
|
|
0228e68a1d | ||
|
|
3424667af1 | ||
|
|
6c7b28a6c1 | ||
|
|
3988079cd3 | ||
|
|
f5d407fee0 | ||
|
|
a857422c46 | ||
|
|
ec6717d0ef | ||
|
|
56dacdcbbd | ||
|
|
c8e17b1691 | ||
|
|
19c7fe59ee | ||
|
|
682100c231 | ||
|
|
f9ac79cdcc | ||
|
|
f09f220645 | ||
|
|
e585cdfd20 | ||
|
|
3a3180f7b3 | ||
|
|
53abc580e5 | ||
|
|
8710d172a0 | ||
|
|
301a380a4b | ||
|
|
8c911f89e0 | ||
|
|
d7e09fc94e | ||
|
|
3b7e191898 | ||
|
|
f351fbaf20 | ||
|
|
016e793ba7 | ||
|
|
db483fd253 | ||
|
|
911ba231cd | ||
|
|
b3053f325d | ||
|
|
4ab47334fc | ||
|
|
e163f02526 | ||
|
|
9e22dba8f1 | ||
|
|
9631406def | ||
|
|
f6ae448c3b | ||
|
|
46345ef596 | ||
|
|
1625f16c8f | ||
|
|
b4ef9ae983 | ||
|
|
3b9c2dd996 | ||
|
|
8a0f9a58d0 | ||
|
|
5fe8caac0d | ||
|
|
f18f567727 | ||
|
|
91acc49980 | ||
|
|
ae3873a225 | ||
|
|
b351c6cc26 | ||
|
|
698244d945 | ||
|
|
2c7dd9dc5b | ||
|
|
36934cce0b | ||
|
|
b7da7e4ecb | ||
|
|
6471ea5590 | ||
|
|
b46bcac642 | ||
|
|
52d90361e9 | ||
|
|
1c902d3319 | ||
|
|
8f671a359b | ||
|
|
840c416684 | ||
|
|
56e29ad30a | ||
|
|
cd8f8b5801 | ||
|
|
70e013fa3d | ||
|
|
d6bfaf8008 | ||
|
|
95944199a0 | ||
|
|
3bd5db8cf3 | ||
|
|
a245330ada | ||
|
|
1226b6abf3 | ||
|
|
7a1f5c0966 | ||
|
|
e5afa1d5bc | ||
|
|
1473fe8646 | ||
|
|
7039ced11e | ||
|
|
42b5bb337f | ||
|
|
1dbb24f6ec | ||
|
|
c242f510e0 | ||
|
|
c59d51636e | ||
|
|
c5a8aa1b4d | ||
|
|
cba050a9e7 | ||
|
|
59fcbef3b1 | ||
|
|
2f1eb6eeaa | ||
|
|
71ae326cf7 | ||
|
|
07829caf0f | ||
|
|
a5850b5a8d | ||
|
|
9f6849209b | ||
|
|
7bd295cbad | ||
|
|
078e5fc19e | ||
|
|
3877e121c3 | ||
|
|
dcb2a0cdb2 | ||
|
|
f5294eee84 | ||
|
|
a5c87b6fa4 | ||
|
|
eae275f515 | ||
|
|
68ae6706dd | ||
|
|
a34b30af15 | ||
|
|
38b49266ed | ||
|
|
049884bb4c | ||
|
|
3c75b2b59f | ||
|
|
4ad5d191a3 | ||
|
|
2499c24cc1 | ||
|
|
6f0043205c | ||
|
|
597741fa60 | ||
|
|
d313ae8cd2 | ||
|
|
06d5d8072e | ||
|
|
f2d112df5c | ||
|
|
716604fa84 | ||
|
|
cae958a1e6 | ||
|
|
283b36c882 | ||
|
|
051e71f1a6 | ||
|
|
20a50e8db0 | ||
|
|
79d7f7ce7d | ||
|
|
6c4b65c446 | ||
|
|
2b07af5e12 | ||
|
|
d0901eecb4 | ||
|
|
ee85d29c54 | ||
|
|
a237d6513d | ||
|
|
02979588c1 | ||
|
|
3abe40855f | ||
|
|
d0d9418a89 | ||
|
|
3ce742eb01 | ||
|
|
ae566fb907 | ||
|
|
fa32c62f63 | ||
|
|
6880be11c5 | ||
|
|
5289893264 | ||
|
|
f15370a3df | ||
|
|
cfac867c0a | ||
|
|
f50ea40b15 | ||
|
|
04b2d57081 | ||
|
|
b235ea52e0 | ||
|
|
2cb2dc526c | ||
|
|
f3c38ba62a | ||
|
|
29473f2d3b | ||
|
|
48654250e8 | ||
|
|
7aa24245b6 | ||
|
|
6070d74684 | ||
|
|
c3de3c4e35 | ||
|
|
5c513f3e50 | ||
|
|
5a980c6b89 | ||
|
|
85c075c5a6 | ||
|
|
f068afd16e | ||
|
|
ac71b0af64 | ||
|
|
5c515d6acd | ||
|
|
4585c3a94b | ||
|
|
cf2c27c961 | ||
|
|
f8e403025c | ||
|
|
46a1898be9 | ||
|
|
25fa7c07bc | ||
|
|
e7219e0eec | ||
|
|
45130fcffa | ||
|
|
5f75d4440d | ||
|
|
34210f63e3 | ||
|
|
5f60fd4922 | ||
|
|
47ef7dda55 | ||
|
|
0f3550a687 | ||
|
|
8f242f3535 | ||
|
|
1ce39e5394 | ||
|
|
cca7b912aa | ||
|
|
d939e32500 | ||
|
|
97ebe66db5 | ||
|
|
f437fc4541 | ||
|
|
6c65538450 | ||
|
|
d566a74df4 | ||
|
|
03e030a7d3 | ||
|
|
e738e1da9c | ||
|
|
972b3a6cbe | ||
|
|
96b4a3077e | ||
|
|
6b308e8a1e | ||
|
|
d0874cbc6f | ||
|
|
f106a51bf5 | ||
|
|
dc47dc5f81 | ||
|
|
dc81cffeea | ||
|
|
5766fcf4d8 | ||
|
|
c57a3b2cea | ||
|
|
0c1fa8e79b | ||
|
|
36cc91915c | ||
|
|
bb644fde31 | ||
|
|
269b54d382 | ||
|
|
a9115cc653 | ||
|
|
eeea7aee8b | ||
|
|
700089e381 | ||
|
|
932935557c | ||
|
|
2890a76cf2 | ||
|
|
4ac9b2e2b7 | ||
|
|
f92436f3f0 | ||
|
|
22d97cc99d | ||
|
|
305838573c | ||
|
|
cc7ad81d2f | ||
|
|
a694e57512 | ||
|
|
20be7fc67d | ||
|
|
54bfee414b | ||
|
|
42e0f8f660 | ||
|
|
b881c84a52 | ||
|
|
9e9dc39200 | ||
|
|
abd7e4e15c | ||
|
|
9666a8e78a | ||
|
|
271a3d90f8 | ||
|
|
01e291daf4 | ||
|
|
d39fa0363a | ||
|
|
a872561b18 | ||
|
|
857608f8ef | ||
|
|
7a74ae566b | ||
|
|
f2c8724763 | ||
|
|
9a8dc4dbe5 | ||
|
|
083e300ff5 | ||
|
|
ae4ebc0e36 | ||
|
|
c175f19142 | ||
|
|
0ebc703774 | ||
|
|
4615e20838 | ||
|
|
f4d28f282a | ||
|
|
1fe8ef17bd | ||
|
|
6088afb38c | ||
|
|
5764c41d23 | ||
|
|
09444596ff | ||
|
|
ee15d90f9c | ||
|
|
f5b014dae9 | ||
|
|
5e0965ead4 | ||
|
|
712379f4bb | ||
|
|
4c39c6fb39 | ||
|
|
a14e829f09 | ||
|
|
4002285882 | ||
|
|
d732d15ef6 | ||
|
|
7613ca78da | ||
|
|
c8631708b9 | ||
|
|
63ca473113 | ||
|
|
a7d6b06332 | ||
|
|
8f6da817db | ||
|
|
378f22a1ef | ||
|
|
14730097b2 | ||
|
|
e8bff3098a | ||
|
|
be7bbe6872 | ||
|
|
7df8284124 | ||
|
|
21ca630abd |
@@ -16,3 +16,8 @@ export WANDERER_SSE_ENABLED="true"
|
||||
export WANDERER_WEBHOOKS_ENABLED="true"
|
||||
export WANDERER_SSE_MAX_CONNECTIONS="1000"
|
||||
export WANDERER_WEBHOOK_TIMEOUT_MS="15000"
|
||||
|
||||
# Promo codes for map subscriptions (optional)
|
||||
# Format: CODE:DISCOUNT_PERCENT,CODE2:DISCOUNT_PERCENT2
|
||||
# Codes are case-insensitive, discounts stack with period discounts
|
||||
# export WANDERER_PROMO_CODES="PROMO2025:10,NEWUSER:20"
|
||||
|
||||
110
.github/workflows/test.yml
vendored
110
.github/workflows/test.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
test:
|
||||
name: Test Suite
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15
|
||||
@@ -35,17 +35,17 @@ jobs:
|
||||
--health-retries 5
|
||||
ports:
|
||||
- 5432:5432
|
||||
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
|
||||
- name: Setup Elixir/OTP
|
||||
uses: erlef/setup-beam@v1
|
||||
with:
|
||||
elixir-version: ${{ env.ELIXIR_VERSION }}
|
||||
otp-version: ${{ env.OTP_VERSION }}
|
||||
|
||||
|
||||
- name: Cache Elixir dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
@@ -54,12 +54,12 @@ jobs:
|
||||
_build
|
||||
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
|
||||
restore-keys: ${{ runner.os }}-mix-
|
||||
|
||||
|
||||
- name: Install Elixir dependencies
|
||||
run: |
|
||||
mix deps.get
|
||||
mix deps.compile
|
||||
|
||||
|
||||
- name: Check code formatting
|
||||
id: format
|
||||
run: |
|
||||
@@ -71,42 +71,42 @@ jobs:
|
||||
echo "count=1" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
continue-on-error: true
|
||||
|
||||
|
||||
- name: Compile code and capture warnings
|
||||
id: compile
|
||||
run: |
|
||||
# Capture compilation output
|
||||
output=$(mix compile 2>&1 || true)
|
||||
echo "$output" > compile_output.txt
|
||||
|
||||
|
||||
# Count warnings
|
||||
warning_count=$(echo "$output" | grep -c "warning:" || echo "0")
|
||||
|
||||
|
||||
# Check if compilation succeeded
|
||||
if mix compile > /dev/null 2>&1; then
|
||||
echo "status=✅ Success" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "status=❌ Failed" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
|
||||
echo "warnings=$warning_count" >> $GITHUB_OUTPUT
|
||||
echo "output<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$output" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
continue-on-error: true
|
||||
|
||||
|
||||
- name: Setup database
|
||||
run: |
|
||||
mix ecto.create
|
||||
mix ecto.migrate
|
||||
|
||||
|
||||
- name: Run tests with coverage
|
||||
id: tests
|
||||
run: |
|
||||
# Run tests with coverage
|
||||
output=$(mix test --cover 2>&1 || true)
|
||||
echo "$output" > test_output.txt
|
||||
|
||||
|
||||
# Parse test results
|
||||
if echo "$output" | grep -q "0 failures"; then
|
||||
echo "status=✅ All Passed" >> $GITHUB_OUTPUT
|
||||
@@ -115,16 +115,16 @@ jobs:
|
||||
echo "status=❌ Some Failed" >> $GITHUB_OUTPUT
|
||||
test_status="failed"
|
||||
fi
|
||||
|
||||
|
||||
# Extract test counts
|
||||
test_line=$(echo "$output" | grep -E "[0-9]+ tests?, [0-9]+ failures?" | head -1 || echo "0 tests, 0 failures")
|
||||
total_tests=$(echo "$test_line" | grep -o '[0-9]\+ tests\?' | grep -o '[0-9]\+' | head -1 || echo "0")
|
||||
failures=$(echo "$test_line" | grep -o '[0-9]\+ failures\?' | grep -o '[0-9]\+' | head -1 || echo "0")
|
||||
|
||||
|
||||
echo "total=$total_tests" >> $GITHUB_OUTPUT
|
||||
echo "failures=$failures" >> $GITHUB_OUTPUT
|
||||
echo "passed=$((total_tests - failures))" >> $GITHUB_OUTPUT
|
||||
|
||||
|
||||
# Calculate success rate
|
||||
if [ "$total_tests" -gt 0 ]; then
|
||||
success_rate=$(echo "scale=1; ($total_tests - $failures) * 100 / $total_tests" | bc)
|
||||
@@ -132,26 +132,26 @@ jobs:
|
||||
success_rate="0"
|
||||
fi
|
||||
echo "success_rate=$success_rate" >> $GITHUB_OUTPUT
|
||||
|
||||
|
||||
exit_code=$?
|
||||
echo "exit_code=$exit_code" >> $GITHUB_OUTPUT
|
||||
continue-on-error: true
|
||||
|
||||
|
||||
- name: Generate coverage report
|
||||
id: coverage
|
||||
run: |
|
||||
# Generate coverage report with GitHub format
|
||||
output=$(mix coveralls.github 2>&1 || true)
|
||||
echo "$output" > coverage_output.txt
|
||||
|
||||
|
||||
# Extract coverage percentage
|
||||
coverage=$(echo "$output" | grep -o '[0-9]\+\.[0-9]\+%' | head -1 | sed 's/%//' || echo "0")
|
||||
if [ -z "$coverage" ]; then
|
||||
coverage="0"
|
||||
fi
|
||||
|
||||
|
||||
echo "percentage=$coverage" >> $GITHUB_OUTPUT
|
||||
|
||||
|
||||
# Determine status
|
||||
if (( $(echo "$coverage >= 80" | bc -l) )); then
|
||||
echo "status=✅ Excellent" >> $GITHUB_OUTPUT
|
||||
@@ -161,14 +161,14 @@ jobs:
|
||||
echo "status=❌ Needs Improvement" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
continue-on-error: true
|
||||
|
||||
|
||||
- name: Run Credo analysis
|
||||
id: credo
|
||||
run: |
|
||||
# Run Credo and capture output
|
||||
output=$(mix credo --strict --format=json 2>&1 || true)
|
||||
echo "$output" > credo_output.txt
|
||||
|
||||
|
||||
# Try to parse JSON output
|
||||
if echo "$output" | jq . > /dev/null 2>&1; then
|
||||
issues=$(echo "$output" | jq '.issues | length' 2>/dev/null || echo "0")
|
||||
@@ -183,12 +183,12 @@ jobs:
|
||||
normal_issues="0"
|
||||
low_issues="0"
|
||||
fi
|
||||
|
||||
|
||||
echo "total_issues=$issues" >> $GITHUB_OUTPUT
|
||||
echo "high_issues=$high_issues" >> $GITHUB_OUTPUT
|
||||
echo "normal_issues=$normal_issues" >> $GITHUB_OUTPUT
|
||||
echo "low_issues=$low_issues" >> $GITHUB_OUTPUT
|
||||
|
||||
|
||||
# Determine status
|
||||
if [ "$issues" -eq 0 ]; then
|
||||
echo "status=✅ Clean" >> $GITHUB_OUTPUT
|
||||
@@ -198,24 +198,24 @@ jobs:
|
||||
echo "status=❌ Needs Attention" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
continue-on-error: true
|
||||
|
||||
|
||||
- name: Run Dialyzer analysis
|
||||
id: dialyzer
|
||||
run: |
|
||||
# Ensure PLT is built
|
||||
mix dialyzer --plt
|
||||
|
||||
|
||||
# Run Dialyzer and capture output
|
||||
output=$(mix dialyzer --format=github 2>&1 || true)
|
||||
echo "$output" > dialyzer_output.txt
|
||||
|
||||
|
||||
# Count warnings and errors
|
||||
warnings=$(echo "$output" | grep -c "warning:" || echo "0")
|
||||
errors=$(echo "$output" | grep -c "error:" || echo "0")
|
||||
|
||||
|
||||
echo "warnings=$warnings" >> $GITHUB_OUTPUT
|
||||
echo "errors=$errors" >> $GITHUB_OUTPUT
|
||||
|
||||
|
||||
# Determine status
|
||||
if [ "$errors" -eq 0 ] && [ "$warnings" -eq 0 ]; then
|
||||
echo "status=✅ Clean" >> $GITHUB_OUTPUT
|
||||
@@ -225,7 +225,7 @@ jobs:
|
||||
echo "status=❌ Has Errors" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
continue-on-error: true
|
||||
|
||||
|
||||
- name: Create test results summary
|
||||
id: summary
|
||||
run: |
|
||||
@@ -236,11 +236,11 @@ jobs:
|
||||
coverage_score=${{ steps.coverage.outputs.percentage }}
|
||||
credo_score=$(echo "scale=0; (100 - ${{ steps.credo.outputs.total_issues }} * 2)" | bc | sed 's/^-.*$/0/')
|
||||
dialyzer_score=$(echo "scale=0; (100 - ${{ steps.dialyzer.outputs.warnings }} * 2 - ${{ steps.dialyzer.outputs.errors }} * 10)" | bc | sed 's/^-.*$/0/')
|
||||
|
||||
|
||||
overall_score=$(echo "scale=1; ($format_score + $compile_score + $test_score + $coverage_score + $credo_score + $dialyzer_score) / 6" | bc)
|
||||
|
||||
|
||||
echo "overall_score=$overall_score" >> $GITHUB_OUTPUT
|
||||
|
||||
|
||||
# Determine overall status
|
||||
if (( $(echo "$overall_score >= 90" | bc -l) )); then
|
||||
echo "overall_status=🌟 Excellent" >> $GITHUB_OUTPUT
|
||||
@@ -252,7 +252,7 @@ jobs:
|
||||
echo "overall_status=❌ Poor" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
continue-on-error: true
|
||||
|
||||
|
||||
- name: Find existing PR comment
|
||||
if: github.event_name == 'pull_request'
|
||||
id: find_comment
|
||||
@@ -261,7 +261,7 @@ jobs:
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
comment-author: 'github-actions[bot]'
|
||||
body-includes: '## 🧪 Test Results Summary'
|
||||
|
||||
|
||||
- name: Create or update PR comment
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: peter-evans/create-or-update-comment@v4
|
||||
@@ -271,11 +271,11 @@ jobs:
|
||||
edit-mode: replace
|
||||
body: |
|
||||
## 🧪 Test Results Summary
|
||||
|
||||
|
||||
**Overall Quality Score: ${{ steps.summary.outputs.overall_score }}%** ${{ steps.summary.outputs.overall_status }}
|
||||
|
||||
|
||||
### 📊 Metrics Dashboard
|
||||
|
||||
|
||||
| Category | Status | Count | Details |
|
||||
|----------|---------|-------|---------|
|
||||
| 📝 **Code Formatting** | ${{ steps.format.outputs.status }} | ${{ steps.format.outputs.count }} issues | `mix format --check-formatted` |
|
||||
@@ -284,50 +284,50 @@ jobs:
|
||||
| 📊 **Coverage** | ${{ steps.coverage.outputs.status }} | ${{ steps.coverage.outputs.percentage }}% | `mix coveralls` |
|
||||
| 🎯 **Credo** | ${{ steps.credo.outputs.status }} | ${{ steps.credo.outputs.total_issues }} issues | High: ${{ steps.credo.outputs.high_issues }}, Normal: ${{ steps.credo.outputs.normal_issues }}, Low: ${{ steps.credo.outputs.low_issues }} |
|
||||
| 🔍 **Dialyzer** | ${{ steps.dialyzer.outputs.status }} | ${{ steps.dialyzer.outputs.errors }} errors, ${{ steps.dialyzer.outputs.warnings }} warnings | `mix dialyzer` |
|
||||
|
||||
|
||||
### 🎯 Quality Gates
|
||||
|
||||
|
||||
Based on the project's quality thresholds:
|
||||
- **Compilation Warnings**: ${{ steps.compile.outputs.warnings }}/148 (limit: 148)
|
||||
- **Credo Issues**: ${{ steps.credo.outputs.total_issues }}/87 (limit: 87)
|
||||
- **Credo Issues**: ${{ steps.credo.outputs.total_issues }}/87 (limit: 87)
|
||||
- **Dialyzer Warnings**: ${{ steps.dialyzer.outputs.warnings }}/161 (limit: 161)
|
||||
- **Test Coverage**: ${{ steps.coverage.outputs.percentage }}%/50% (minimum: 50%)
|
||||
- **Test Failures**: ${{ steps.tests.outputs.failures }}/0 (limit: 0)
|
||||
|
||||
|
||||
<details>
|
||||
<summary>📈 Progress Toward Goals</summary>
|
||||
|
||||
|
||||
Target goals for the project:
|
||||
- ✨ **Zero compilation warnings** (currently: ${{ steps.compile.outputs.warnings }})
|
||||
- ✨ **≤10 Credo issues** (currently: ${{ steps.credo.outputs.total_issues }})
|
||||
- ✨ **Zero Dialyzer warnings** (currently: ${{ steps.dialyzer.outputs.warnings }})
|
||||
- ✨ **≥85% test coverage** (currently: ${{ steps.coverage.outputs.percentage }}%)
|
||||
- ✅ **Zero test failures** (currently: ${{ steps.tests.outputs.failures }})
|
||||
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
<details>
|
||||
<summary>🔧 Quick Actions</summary>
|
||||
|
||||
|
||||
To improve code quality:
|
||||
```bash
|
||||
# Fix formatting issues
|
||||
mix format
|
||||
|
||||
|
||||
# View detailed Credo analysis
|
||||
mix credo --strict
|
||||
|
||||
|
||||
# Check Dialyzer warnings
|
||||
mix dialyzer
|
||||
|
||||
|
||||
# Generate detailed coverage report
|
||||
mix coveralls.html
|
||||
```
|
||||
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
🤖 *Auto-generated by GitHub Actions* • Updated: ${{ github.event.head_commit.timestamp }}
|
||||
|
||||
> **Note**: This comment will be updated automatically when new commits are pushed to this PR.
|
||||
|
||||
> **Note**: This comment will be updated automatically when new commits are pushed to this PR.
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -17,6 +17,9 @@ repomix*
|
||||
/priv/static/images/
|
||||
/priv/static/*.js
|
||||
/priv/static/*.css
|
||||
/priv/static/*-*.png
|
||||
/priv/static/*-*.webp
|
||||
/priv/static/*-*.webmanifest
|
||||
|
||||
# Dialyzer PLT files
|
||||
/priv/plts/
|
||||
|
||||
469
CHANGELOG.md
469
CHANGELOG.md
@@ -2,6 +2,475 @@
|
||||
|
||||
<!-- changelog -->
|
||||
|
||||
## [v1.95.0](https://github.com/wanderer-industries/wanderer/compare/v1.94.0...v1.95.0) (2026-02-11)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* subscriptions: Added top map donators support
|
||||
|
||||
* Added lost files
|
||||
|
||||
* Added paywall for RoutesBy widget
|
||||
|
||||
* removed unnecessary env variable for routes
|
||||
|
||||
* Add systems with Security Status cleaning. Add trade hubs. Add ability to store data for this widget
|
||||
|
||||
* Add Routes By widget. Allow to find nearest blue loot and red loot stations. Added ability to set waypoint to station.
|
||||
|
||||
* auto add system on sig addition
|
||||
|
||||
* map: Reviewed changes
|
||||
|
||||
* map: Logic for multiple owner updates
|
||||
|
||||
* map: wip New Dialog for Structure Owners
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* signatures: Fixed back linked sigs data sync and leading to system override issues
|
||||
|
||||
* signatures: Moved C1/C2/C3 and C4/C5 to the bottom of the available list
|
||||
|
||||
* use cache for sse
|
||||
|
||||
* adding system when linked signature is provided
|
||||
|
||||
* saving updates to unknown sigs
|
||||
|
||||
* wh position and sig type change
|
||||
|
||||
* api updates and linked sig addition
|
||||
|
||||
* api fixes and format
|
||||
|
||||
* Wrong file added to commits
|
||||
|
||||
## [v1.94.0](https://github.com/wanderer-industries/wanderer/compare/v1.93.0...v1.94.0) (2026-02-08)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* administration: Added registered characters admin view with cort/ally info, sort and filter options
|
||||
|
||||
## [v1.93.0](https://github.com/wanderer-industries/wanderer/compare/v1.92.0...v1.93.0) (2026-02-08)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* subscriptions: Added an ability to withdraw from map to user balance
|
||||
|
||||
## [v1.92.0](https://github.com/wanderer-industries/wanderer/compare/v1.91.11...v1.92.0) (2026-01-14)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* Added ability to select a range of wh classes for k162.
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: Show c1/c2/c3 or c4/c5 or link signature modal
|
||||
|
||||
## [v1.91.11](https://github.com/wanderer-industries/wanderer/compare/v1.91.10...v1.91.11) (2026-01-13)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* allow sig api when map relay is off
|
||||
|
||||
## [v1.91.10](https://github.com/wanderer-industries/wanderer/compare/v1.91.9...v1.91.10) (2026-01-07)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* remove actor context requirement from sig api
|
||||
|
||||
## [v1.91.9](https://github.com/wanderer-industries/wanderer/compare/v1.91.8...v1.91.9) (2026-01-06)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed rally point cancel logic
|
||||
|
||||
## [v1.91.8](https://github.com/wanderer-industries/wanderer/compare/v1.91.7...v1.91.8) (2026-01-06)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed rally point cancel logic
|
||||
|
||||
## [v1.91.7](https://github.com/wanderer-industries/wanderer/compare/v1.91.6...v1.91.7) (2026-01-05)
|
||||
|
||||
|
||||
|
||||
|
||||
## [v1.91.6](https://github.com/wanderer-industries/wanderer/compare/v1.91.5...v1.91.6) (2026-01-04)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed new connections got deleted after linked signature cleanup
|
||||
|
||||
## [v1.91.5](https://github.com/wanderer-industries/wanderer/compare/v1.91.4...v1.91.5) (2025-12-30)
|
||||
|
||||
|
||||
|
||||
|
||||
## [v1.91.4](https://github.com/wanderer-industries/wanderer/compare/v1.91.3...v1.91.4) (2025-12-30)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed connections create between k-space systems (considered as wh connection)
|
||||
|
||||
## [v1.91.3](https://github.com/wanderer-industries/wanderer/compare/v1.91.2...v1.91.3) (2025-12-28)
|
||||
|
||||
|
||||
|
||||
|
||||
## [v1.91.2](https://github.com/wanderer-industries/wanderer/compare/v1.91.1...v1.91.2) (2025-12-27)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed map scopes updates & logic
|
||||
|
||||
## [v1.91.1](https://github.com/wanderer-industries/wanderer/compare/v1.91.0...v1.91.1) (2025-12-25)
|
||||
|
||||
|
||||
|
||||
|
||||
## [v1.91.0](https://github.com/wanderer-industries/wanderer/compare/v1.90.13...v1.91.0) (2025-12-24)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* admin: added maps administration view with basic info, search, restore/delete, acls view and edit options
|
||||
|
||||
## [v1.90.13](https://github.com/wanderer-industries/wanderer/compare/v1.90.12...v1.90.13) (2025-12-19)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed welcome page
|
||||
|
||||
## [v1.90.12](https://github.com/wanderer-industries/wanderer/compare/v1.90.11...v1.90.12) (2025-12-19)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed permissions update after character corp updates
|
||||
|
||||
## [v1.90.11](https://github.com/wanderer-industries/wanderer/compare/v1.90.10...v1.90.11) (2025-12-18)
|
||||
|
||||
|
||||
|
||||
|
||||
## [v1.90.10](https://github.com/wanderer-industries/wanderer/compare/v1.90.9...v1.90.10) (2025-12-18)
|
||||
|
||||
|
||||
|
||||
|
||||
## [v1.90.9](https://github.com/wanderer-industries/wanderer/compare/v1.90.8...v1.90.9) (2025-12-15)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: reduce chracters untrack grace period to 15 mins (after change/close/disconnect from map)
|
||||
|
||||
## [v1.90.8](https://github.com/wanderer-industries/wanderer/compare/v1.90.7...v1.90.8) (2025-12-15)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: skip systems or connections cleanup for not started maps
|
||||
|
||||
## [v1.90.7](https://github.com/wanderer-industries/wanderer/compare/v1.90.6...v1.90.7) (2025-12-15)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed scopes
|
||||
|
||||
## [v1.90.6](https://github.com/wanderer-industries/wanderer/compare/v1.90.5...v1.90.6) (2025-12-12)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed map scopes
|
||||
|
||||
## [v1.90.5](https://github.com/wanderer-industries/wanderer/compare/v1.90.4...v1.90.5) (2025-12-12)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed map scopes
|
||||
|
||||
## [v1.90.4](https://github.com/wanderer-industries/wanderer/compare/v1.90.3...v1.90.4) (2025-12-12)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed map scopes & signatures clean up behaviour
|
||||
|
||||
## [v1.90.3](https://github.com/wanderer-industries/wanderer/compare/v1.90.2...v1.90.3) (2025-12-11)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: added pagination for long ACL lists
|
||||
|
||||
## [v1.90.2](https://github.com/wanderer-industries/wanderer/compare/v1.90.1...v1.90.2) (2025-12-10)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: added system position updates to SSE
|
||||
|
||||
## [v1.90.1](https://github.com/wanderer-industries/wanderer/compare/v1.90.0...v1.90.1) (2025-12-08)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed connections and signatures remove issues, added comprehensive audit log for auto removed connections and signatures
|
||||
|
||||
## [v1.90.0](https://github.com/wanderer-industries/wanderer/compare/v1.89.6...v1.90.0) (2025-12-06)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* core: Added several map scopes support (Wh, Hi, Low, Null, Pochven)
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed clean up for linked signatures
|
||||
|
||||
* core: fixed issue with default select mode
|
||||
|
||||
* apiV1 default fields updates
|
||||
|
||||
## [v1.89.6](https://github.com/wanderer-industries/wanderer/compare/v1.89.5...v1.89.6) (2025-12-02)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* kills: fixed zkb links (added "allow-popups-to-escape-sandbox" to CSP)
|
||||
|
||||
## [v1.89.5](https://github.com/wanderer-industries/wanderer/compare/v1.89.4...v1.89.5) (2025-12-02)
|
||||
|
||||
|
||||
|
||||
|
||||
## [v1.89.4](https://github.com/wanderer-industries/wanderer/compare/v1.89.3...v1.89.4) (2025-12-02)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed acl character update issues
|
||||
|
||||
## [v1.89.3](https://github.com/wanderer-industries/wanderer/compare/v1.89.2...v1.89.3) (2025-11-30)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed tracking issues
|
||||
|
||||
## [v1.89.2](https://github.com/wanderer-industries/wanderer/compare/v1.89.1...v1.89.2) (2025-11-30)
|
||||
|
||||
|
||||
|
||||
|
||||
## [v1.89.1](https://github.com/wanderer-industries/wanderer/compare/v1.89.0...v1.89.1) (2025-11-30)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed tracking issues
|
||||
|
||||
## [v1.89.0](https://github.com/wanderer-industries/wanderer/compare/v1.88.13...v1.89.0) (2025-11-30)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* removed unnecessary command
|
||||
|
||||
* rework wormholes reference
|
||||
|
||||
## [v1.88.13](https://github.com/wanderer-industries/wanderer/compare/v1.88.12...v1.88.13) (2025-11-29)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed tracking issues
|
||||
|
||||
## [v1.88.12](https://github.com/wanderer-industries/wanderer/compare/v1.88.11...v1.88.12) (2025-11-29)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed c4 -> ns connections auto size issues
|
||||
|
||||
## [v1.88.11](https://github.com/wanderer-industries/wanderer/compare/v1.88.10...v1.88.11) (2025-11-29)
|
||||
|
||||
|
||||
|
||||
|
||||
## [v1.88.10](https://github.com/wanderer-industries/wanderer/compare/v1.88.9...v1.88.10) (2025-11-29)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed pings cleanup
|
||||
|
||||
## [v1.88.9](https://github.com/wanderer-industries/wanderer/compare/v1.88.8...v1.88.9) (2025-11-29)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed linked signatures cleanup
|
||||
|
||||
## [v1.88.8](https://github.com/wanderer-industries/wanderer/compare/v1.88.7...v1.88.8) (2025-11-28)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed pings issue
|
||||
|
||||
## [v1.88.7](https://github.com/wanderer-industries/wanderer/compare/v1.88.6...v1.88.7) (2025-11-28)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed tracking issues
|
||||
|
||||
## [v1.88.6](https://github.com/wanderer-industries/wanderer/compare/v1.88.5...v1.88.6) (2025-11-28)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed tracking issues
|
||||
|
||||
## [v1.88.5](https://github.com/wanderer-industries/wanderer/compare/v1.88.4...v1.88.5) (2025-11-28)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed env errors
|
||||
|
||||
## [v1.88.4](https://github.com/wanderer-industries/wanderer/compare/v1.88.3...v1.88.4) (2025-11-27)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* defensive check for undefined excluded systems
|
||||
|
||||
## [v1.88.3](https://github.com/wanderer-industries/wanderer/compare/v1.88.2...v1.88.3) (2025-11-26)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* core: fixed env issues
|
||||
|
||||
## [v1.88.1](https://github.com/wanderer-industries/wanderer/compare/v1.88.0...v1.88.1) (2025-11-26)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* sse enable checkbox, and kills ticker
|
||||
|
||||
* apiv1 token auth and structure fixes
|
||||
|
||||
* removed ipv6 distribution env settings
|
||||
|
||||
* tests: updated tests
|
||||
|
||||
* tests: updated tests
|
||||
|
||||
* clean up id generation
|
||||
|
||||
* resolve issue with async event processing
|
||||
|
||||
## [v1.88.0](https://github.com/wanderer-industries/wanderer/compare/v1.87.0...v1.88.0) (2025-11-25)
|
||||
|
||||
|
||||
|
||||
52
Makefile
52
Makefile
@@ -32,8 +32,58 @@ format f:
|
||||
test t:
|
||||
MIX_ENV=test mix test
|
||||
|
||||
# Run tests in 4 parallel partitions (useful for CI or faster local runs)
|
||||
test-parallel tp:
|
||||
@echo "Running tests in 4 parallel partitions..."
|
||||
@mkdir -p /tmp/wanderer_test_results
|
||||
@rm -f /tmp/wanderer_test_results/partition_*.txt /tmp/wanderer_test_results/exit_*.txt
|
||||
@for i in 1 2 3 4; do \
|
||||
(MIX_TEST_PARTITION=$$i MIX_ENV=test mix test --partitions 4 2>&1; echo $$? > /tmp/wanderer_test_results/exit_$$i.txt) | \
|
||||
tee /tmp/wanderer_test_results/partition_$$i.txt | sed "s/^/[P$$i] /" & \
|
||||
done; \
|
||||
wait
|
||||
@echo ""
|
||||
@echo "========================================"
|
||||
@echo " TEST RESULTS SUMMARY"
|
||||
@echo "========================================"
|
||||
@total_tests=0; total_failures=0; total_excluded=0; all_passed=true; \
|
||||
for i in 1 2 3 4; do \
|
||||
exit_code=$$(cat /tmp/wanderer_test_results/exit_$$i.txt 2>/dev/null || echo "1"); \
|
||||
if [ "$$exit_code" != "0" ]; then all_passed=false; fi; \
|
||||
summary=$$(grep -E "^[0-9]+ (tests?|doctest)" /tmp/wanderer_test_results/partition_$$i.txt | tail -1 || echo "No results"); \
|
||||
tests=$$(echo "$$summary" | grep -oE "^[0-9]+" || echo "0"); \
|
||||
failures=$$(echo "$$summary" | grep -oE "[0-9]+ failures?" | grep -oE "^[0-9]+" || echo "0"); \
|
||||
excluded=$$(echo "$$summary" | grep -oE "[0-9]+ excluded" | grep -oE "^[0-9]+" || echo "0"); \
|
||||
total_tests=$$((total_tests + tests)); \
|
||||
total_failures=$$((total_failures + failures)); \
|
||||
total_excluded=$$((total_excluded + excluded)); \
|
||||
if [ "$$exit_code" = "0" ]; then \
|
||||
echo "Partition $$i: ✓ $$summary"; \
|
||||
else \
|
||||
echo "Partition $$i: ✗ $$summary (exit code: $$exit_code)"; \
|
||||
fi; \
|
||||
done; \
|
||||
echo "========================================"; \
|
||||
echo "TOTAL: $$total_tests tests, $$total_failures failures, $$total_excluded excluded"; \
|
||||
echo "========================================"; \
|
||||
if [ "$$all_passed" = "true" ]; then \
|
||||
echo "✓ All partitions passed!"; \
|
||||
else \
|
||||
echo "✗ Some partitions failed. Details below:"; \
|
||||
echo ""; \
|
||||
for i in 1 2 3 4; do \
|
||||
exit_code=$$(cat /tmp/wanderer_test_results/exit_$$i.txt 2>/dev/null || echo "1"); \
|
||||
if [ "$$exit_code" != "0" ]; then \
|
||||
echo "======== PARTITION $$i FAILURES ========"; \
|
||||
grep -A 50 "Failures:" /tmp/wanderer_test_results/partition_$$i.txt 2>/dev/null || cat /tmp/wanderer_test_results/partition_$$i.txt; \
|
||||
echo ""; \
|
||||
fi; \
|
||||
done; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
coverage cover co:
|
||||
mix test --cover
|
||||
MIX_ENV=test mix test --cover
|
||||
|
||||
unit-tests ut:
|
||||
@echo "Running unit tests..."
|
||||
|
||||
@@ -1001,3 +1001,27 @@ body > div:first-of-type {
|
||||
.verticalTabsContainer .p-tabview-panel {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
/* Blog post CTA links - only in main post content */
|
||||
.post-content a {
|
||||
display: inline-block;
|
||||
background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
|
||||
color: white !important;
|
||||
padding: 0.5rem 1.25rem;
|
||||
border-radius: 0.5rem;
|
||||
text-decoration: none !important;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 4px 15px rgba(236, 72, 153, 0.3);
|
||||
}
|
||||
|
||||
.post-content a:hover {
|
||||
background: linear-gradient(135deg, #db2777 0%, #7c3aed 100%);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 20px rgba(236, 72, 153, 0.4);
|
||||
}
|
||||
|
||||
.post-content a:active {
|
||||
transform: translateY(0);
|
||||
box-shadow: 0 2px 10px rgba(236, 72, 153, 0.3);
|
||||
}
|
||||
|
||||
@@ -8,3 +8,15 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ContextMenu {
|
||||
width: max-content;
|
||||
min-width: unset;
|
||||
|
||||
:global {
|
||||
.p-submenu-list {
|
||||
width: max-content;
|
||||
min-width: unset !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
import React, { RefObject, useMemo } from 'react';
|
||||
import React, { RefObject, useCallback, useMemo } from 'react';
|
||||
import { ContextMenu } from 'primereact/contextmenu';
|
||||
import { PrimeIcons } from 'primereact/api';
|
||||
import { MenuItem } from 'primereact/menuitem';
|
||||
import { SolarSystemRawType, SolarSystemStaticInfoRaw } from '@/hooks/Mapper/types';
|
||||
import { CharacterTypeRaw, SolarSystemRawType, SolarSystemStaticInfoRaw } from '@/hooks/Mapper/types';
|
||||
import classes from './ContextMenuSystemInfo.module.scss';
|
||||
import { getSystemById } from '@/hooks/Mapper/helpers';
|
||||
import { useWaypointMenu } from '@/hooks/Mapper/components/contexts/hooks';
|
||||
import { WaypointSetContextHandler } from '@/hooks/Mapper/components/contexts/types.ts';
|
||||
import { FastSystemActions } from '@/hooks/Mapper/components/contexts/components';
|
||||
import { useJumpPlannerMenu } from '@/hooks/Mapper/components/contexts/hooks';
|
||||
import { Route } from '@/hooks/Mapper/types/routes.ts';
|
||||
import { Route, RouteStationSummary } from '@/hooks/Mapper/types/routes.ts';
|
||||
import { isWormholeSpace } from '@/hooks/Mapper/components/map/helpers/isWormholeSpace.ts';
|
||||
import { MapAddIcon, MapDeleteIcon } from '@/hooks/Mapper/icons';
|
||||
import { useRouteProvider } from '@/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/RoutesProvider.tsx';
|
||||
import { useGetOwnOnlineCharacters } from '@/hooks/Mapper/components/hooks/useGetOwnOnlineCharacters.ts';
|
||||
import { sortStationsByDistance } from './sortStationsByDistance.ts';
|
||||
|
||||
export interface ContextMenuSystemInfoProps {
|
||||
systemStatics: Map<number, SolarSystemStaticInfoRaw>;
|
||||
hubs: string[];
|
||||
contextMenuRef: RefObject<ContextMenu>;
|
||||
systemId: string | undefined;
|
||||
systemIdFrom?: string | undefined;
|
||||
@@ -37,11 +39,106 @@ export const ContextMenuSystemInfo: React.FC<ContextMenuSystemInfoProps> = ({
|
||||
onWaypointSet,
|
||||
systemId,
|
||||
systemIdFrom,
|
||||
hubs,
|
||||
routes,
|
||||
}) => {
|
||||
const getWaypointMenu = useWaypointMenu(onWaypointSet);
|
||||
const getJumpPlannerMenu = useJumpPlannerMenu(systems, systemIdFrom);
|
||||
const { toggleHubCommand, hubs } = useRouteProvider();
|
||||
const getOwnOnlineCharacters = useGetOwnOnlineCharacters();
|
||||
|
||||
const getStationWaypointItems = useCallback(
|
||||
(destinationId: string, chars: CharacterTypeRaw[]): MenuItem[] => [
|
||||
{
|
||||
label: 'Set Destination',
|
||||
icon: PrimeIcons.SEND,
|
||||
command: () => {
|
||||
onWaypointSet({
|
||||
fromBeginning: true,
|
||||
clearWay: true,
|
||||
destination: destinationId,
|
||||
charIds: chars.map(char => char.eve_id),
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Add Waypoint',
|
||||
icon: PrimeIcons.DIRECTIONS_ALT,
|
||||
command: () => {
|
||||
onWaypointSet({
|
||||
fromBeginning: false,
|
||||
clearWay: false,
|
||||
destination: destinationId,
|
||||
charIds: chars.map(char => char.eve_id),
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Add Waypoint Front',
|
||||
icon: PrimeIcons.DIRECTIONS,
|
||||
command: () => {
|
||||
onWaypointSet({
|
||||
fromBeginning: true,
|
||||
clearWay: false,
|
||||
destination: destinationId,
|
||||
charIds: chars.map(char => char.eve_id),
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
[onWaypointSet],
|
||||
);
|
||||
|
||||
const getStationsMenu = useCallback(
|
||||
(stations: RouteStationSummary[]) => {
|
||||
const chars = getOwnOnlineCharacters().filter(x => x.online);
|
||||
const sortedStations = sortStationsByDistance(stations);
|
||||
|
||||
return [
|
||||
{
|
||||
label: 'Stations',
|
||||
icon: PrimeIcons.MAP_MARKER,
|
||||
items: sortedStations.map(station => {
|
||||
const destinationId = station.station_id.toString();
|
||||
const specialClass = station.special ? '[&_.p-menuitem-text]:text-orange-400' : '';
|
||||
|
||||
if (chars.length === 0) {
|
||||
return {
|
||||
label: station.station_name,
|
||||
className: specialClass || undefined,
|
||||
items: [{ label: 'No online characters', disabled: true }],
|
||||
};
|
||||
}
|
||||
|
||||
if (chars.length === 1) {
|
||||
return {
|
||||
label: station.station_name,
|
||||
className: specialClass || undefined,
|
||||
items: getStationWaypointItems(destinationId, chars.slice(0, 1)),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
label: station.station_name,
|
||||
className: `${specialClass} w-[500px]`.trim(),
|
||||
items: [
|
||||
{
|
||||
label: 'All',
|
||||
icon: PrimeIcons.USERS,
|
||||
items: getStationWaypointItems(destinationId, chars),
|
||||
},
|
||||
...chars.map(char => ({
|
||||
label: char.name,
|
||||
icon: PrimeIcons.USER,
|
||||
items: getStationWaypointItems(destinationId, [char]),
|
||||
})),
|
||||
],
|
||||
};
|
||||
}),
|
||||
},
|
||||
];
|
||||
},
|
||||
[getOwnOnlineCharacters, getStationWaypointItems],
|
||||
);
|
||||
|
||||
const items: MenuItem[] = useMemo(() => {
|
||||
const system = systemId ? systemStatics.get(parseInt(systemId)) : undefined;
|
||||
@@ -50,6 +147,10 @@ export const ContextMenuSystemInfo: React.FC<ContextMenuSystemInfoProps> = ({
|
||||
if (!systemId || !system) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const route = routes.find(x => x.destination?.toString() === systemId);
|
||||
const stationItems = route?.stations?.length ? getStationsMenu(route.stations) : [];
|
||||
|
||||
return [
|
||||
{
|
||||
className: classes.FastActions,
|
||||
@@ -69,15 +170,20 @@ export const ContextMenuSystemInfo: React.FC<ContextMenuSystemInfoProps> = ({
|
||||
{ separator: true },
|
||||
...getJumpPlannerMenu(system, routes),
|
||||
...getWaypointMenu(systemId, system.system_class),
|
||||
{
|
||||
label: !hubs.includes(systemId) ? 'Add Route' : 'Remove Route',
|
||||
icon: !hubs.includes(systemId) ? (
|
||||
<MapAddIcon className="mr-1 relative left-[-2px]" />
|
||||
) : (
|
||||
<MapDeleteIcon className="mr-1 relative left-[-2px]" />
|
||||
),
|
||||
command: onHubToggle,
|
||||
},
|
||||
...stationItems,
|
||||
...(toggleHubCommand
|
||||
? [
|
||||
{
|
||||
label: !hubs.includes(systemId) ? 'Add Route' : 'Remove Route',
|
||||
icon: !hubs.includes(systemId) ? (
|
||||
<MapAddIcon className="mr-1 relative left-[-2px]" />
|
||||
) : (
|
||||
<MapDeleteIcon className="mr-1 relative left-[-2px]" />
|
||||
),
|
||||
command: onHubToggle,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(!systemOnMap
|
||||
? [
|
||||
{
|
||||
@@ -94,15 +200,18 @@ export const ContextMenuSystemInfo: React.FC<ContextMenuSystemInfoProps> = ({
|
||||
systems,
|
||||
getJumpPlannerMenu,
|
||||
getWaypointMenu,
|
||||
getStationsMenu,
|
||||
hubs,
|
||||
onHubToggle,
|
||||
onAddSystem,
|
||||
onOpenSettings,
|
||||
toggleHubCommand,
|
||||
routes,
|
||||
]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<ContextMenu model={items} ref={contextMenuRef} breakpoint="767px" />
|
||||
<ContextMenu className={classes.ContextMenu} model={items} ref={contextMenuRef} breakpoint="767px" />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
import { RouteStationSummary } from '@/hooks/Mapper/types/routes.ts';
|
||||
|
||||
const ROMAN_VALUES: Record<string, number> = {
|
||||
I: 1,
|
||||
V: 5,
|
||||
X: 10,
|
||||
L: 50,
|
||||
C: 100,
|
||||
D: 500,
|
||||
M: 1000,
|
||||
};
|
||||
|
||||
const MAX_DISTANCE = Number.MAX_SAFE_INTEGER;
|
||||
|
||||
const romanToInt = (value: string): number | null => {
|
||||
const chars = value.toUpperCase().split('');
|
||||
|
||||
if (chars.length === 0 || chars.some(char => ROMAN_VALUES[char] === undefined)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let total = 0;
|
||||
let prev = 0;
|
||||
|
||||
for (let i = chars.length - 1; i >= 0; i--) {
|
||||
const current = ROMAN_VALUES[chars[i]];
|
||||
if (current < prev) {
|
||||
total -= current;
|
||||
} else {
|
||||
total += current;
|
||||
prev = current;
|
||||
}
|
||||
}
|
||||
|
||||
return total;
|
||||
};
|
||||
|
||||
const parseOrbitIndex = (value: string | undefined): number | null => {
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const trimmed = value.trim();
|
||||
const asInt = Number.parseInt(trimmed, 10);
|
||||
|
||||
if (!Number.isNaN(asInt) && `${asInt}` === trimmed) {
|
||||
return asInt;
|
||||
}
|
||||
|
||||
return romanToInt(trimmed);
|
||||
};
|
||||
|
||||
const extractPlanetOrbit = (name: string): number | null => {
|
||||
const firstPart = name.split(' - ')[0] ?? '';
|
||||
const match = firstPart.match(/([IVXLCDM]+|\d+)(?:\s*\([^)]*\))?$/i);
|
||||
return parseOrbitIndex(match?.[1]);
|
||||
};
|
||||
|
||||
const extractMoonOrbit = (name: string): number | null => {
|
||||
const match = name.match(/\bMoon\s+([IVXLCDM]+|\d+)\b/i);
|
||||
return parseOrbitIndex(match?.[1]);
|
||||
};
|
||||
|
||||
const stationSortKey = (station: RouteStationSummary): [number, number, string, number] => {
|
||||
return [
|
||||
extractPlanetOrbit(station.station_name) ?? MAX_DISTANCE,
|
||||
// If there is no moon in the station name, treat it as closer than moon orbits.
|
||||
extractMoonOrbit(station.station_name) ?? 0,
|
||||
station.station_name.toLowerCase(),
|
||||
station.station_id,
|
||||
];
|
||||
};
|
||||
|
||||
export const sortStationsByDistance = (stations: RouteStationSummary[]): RouteStationSummary[] => {
|
||||
return [...stations].sort((a, b) => {
|
||||
const aKey = stationSortKey(a);
|
||||
const bKey = stationSortKey(b);
|
||||
|
||||
for (let i = 0; i < aKey.length; i++) {
|
||||
if (aKey[i] < bKey[i]) {
|
||||
return -1;
|
||||
}
|
||||
if (aKey[i] > bKey[i]) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
};
|
||||
@@ -38,7 +38,7 @@ export const useContextMenuSystemInfoHandlers = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
ref.current.toggleHubCommand(system);
|
||||
ref.current.toggleHubCommand?.(system);
|
||||
setSystem(undefined);
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ export const useDetectSettingsChanged = () => {
|
||||
storedSettings: {
|
||||
interfaceSettings,
|
||||
settingsRoutes,
|
||||
settingsRoutesBy,
|
||||
settingsLocal,
|
||||
settingsSignatures,
|
||||
settingsOnTheMap,
|
||||
@@ -16,7 +17,15 @@ export const useDetectSettingsChanged = () => {
|
||||
|
||||
useEffect(
|
||||
() => setCounter(x => x + 1),
|
||||
[interfaceSettings, settingsRoutes, settingsLocal, settingsSignatures, settingsOnTheMap, settingsKills],
|
||||
[
|
||||
interfaceSettings,
|
||||
settingsRoutes,
|
||||
settingsRoutesBy,
|
||||
settingsLocal,
|
||||
settingsSignatures,
|
||||
settingsOnTheMap,
|
||||
settingsKills,
|
||||
],
|
||||
);
|
||||
|
||||
return counter;
|
||||
|
||||
@@ -72,7 +72,7 @@ export const useSolarSystemNode = (props: NodeProps<MapSolarSystemType>): SolarS
|
||||
|
||||
const {
|
||||
storedSettings: { interfaceSettings },
|
||||
data: { systemSignatures: mapSystemSignatures },
|
||||
data: { systemSignatures: mapSystemSignatures, pings },
|
||||
} = useMapRootState();
|
||||
|
||||
const systemStaticInfo = useMemo(() => {
|
||||
@@ -108,7 +108,6 @@ export const useSolarSystemNode = (props: NodeProps<MapSolarSystemType>): SolarS
|
||||
visibleNodes,
|
||||
showKSpaceBG,
|
||||
isThickConnections,
|
||||
pings,
|
||||
systemHighlighted,
|
||||
},
|
||||
outCommand,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { MarkdownComment } from '@/hooks/Mapper/components/mapInterface/components/Comments/components';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { CommentType } from '@/hooks/Mapper/types';
|
||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||
import { CommentType } from '@/hooks/Mapper/types';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
|
||||
export interface CommentsProps {}
|
||||
|
||||
@@ -14,7 +14,9 @@ export const Comments = ({}: CommentsProps) => {
|
||||
comments: { loadComments, comments, lastUpdateKey },
|
||||
} = useMapRootState();
|
||||
|
||||
const [systemId] = selectedSystems;
|
||||
const systemId = useMemo(() => {
|
||||
return +selectedSystems[0];
|
||||
}, [selectedSystems]);
|
||||
|
||||
const ref = useRef({ loadComments, systemId });
|
||||
ref.current = { loadComments, systemId };
|
||||
|
||||
@@ -3,7 +3,7 @@ import clsx from 'clsx';
|
||||
import { PrimeIcons } from 'primereact/api';
|
||||
import { MarkdownEditor } from '@/hooks/Mapper/components/mapInterface/components/MarkdownEditor';
|
||||
import { useHotkey } from '@/hooks/Mapper/hooks';
|
||||
import { useCallback, useRef, useState } from 'react';
|
||||
import { useCallback, useMemo, useRef, useState } from 'react';
|
||||
import { OutCommand } from '@/hooks/Mapper/types';
|
||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||
import classes from './CommentsEditor.module.scss';
|
||||
@@ -19,7 +19,9 @@ export const CommentsEditor = ({}: CommentsEditorProps) => {
|
||||
outCommand,
|
||||
} = useMapRootState();
|
||||
|
||||
const [systemId] = selectedSystems;
|
||||
const systemId = useMemo(() => {
|
||||
return +selectedSystems[0];
|
||||
}, [selectedSystems]);
|
||||
|
||||
const ref = useRef({ outCommand, systemId, textVal });
|
||||
ref.current = { outCommand, systemId, textVal };
|
||||
|
||||
@@ -121,6 +121,7 @@ export const PingsInterface = ({ hasLeftOffset }: PingsInterfaceProps) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (!ping) {
|
||||
setIsShow(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -161,27 +162,26 @@ export const PingsInterface = ({ hasLeftOffset }: PingsInterfaceProps) => {
|
||||
};
|
||||
}, [interfaceSettings]);
|
||||
|
||||
if (!ping) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const isShowSelectedSystem = selectedSystem != null && selectedSystem !== ping.solar_system_id;
|
||||
const isShowSelectedSystem = ping && selectedSystem != null && selectedSystem !== ping.solar_system_id;
|
||||
|
||||
// Only render Toast when there's a ping
|
||||
return (
|
||||
<>
|
||||
<Toast
|
||||
position={placement as never}
|
||||
className={clsx('!max-w-[initial] w-[500px]', hasLeftOffset ? offsets.withLeftMenu : offsets.default)}
|
||||
ref={toast}
|
||||
content={({ message }) => (
|
||||
<section
|
||||
className={clsx(
|
||||
'flex flex-col p-3 w-full border border-stone-800 shadow-md animate-fadeInDown rounded-[5px]',
|
||||
'bg-gradient-to-tr from-transparent to-sky-700/60 bg-stone-900/70',
|
||||
)}
|
||||
>
|
||||
<div className="flex gap-3">
|
||||
<i className={clsx('pi text-yellow-500 text-2xl', 'relative top-[2px]', ICONS[ping.type])}></i>
|
||||
{ping && (
|
||||
<Toast
|
||||
key={ping.id}
|
||||
position={placement as never}
|
||||
className={clsx('!max-w-[initial] w-[500px]', hasLeftOffset ? offsets.withLeftMenu : offsets.default)}
|
||||
ref={toast}
|
||||
content={({ message }) => (
|
||||
<section
|
||||
className={clsx(
|
||||
'flex flex-col p-3 w-full border border-stone-800 shadow-md animate-fadeInDown rounded-[5px]',
|
||||
'bg-gradient-to-tr from-transparent to-sky-700/60 bg-stone-900/70',
|
||||
)}
|
||||
>
|
||||
<div className="flex gap-3">
|
||||
<i className={clsx('pi text-yellow-500 text-2xl', 'relative top-[2px]', ICONS[ping.type])}></i>
|
||||
<div className="flex flex-col gap-1 w-full">
|
||||
<div className="flex justify-between">
|
||||
<div>
|
||||
@@ -253,28 +253,33 @@ export const PingsInterface = ({ hasLeftOffset }: PingsInterfaceProps) => {
|
||||
{/*/>*/}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
></Toast>
|
||||
)}
|
||||
></Toast>
|
||||
)}
|
||||
|
||||
<WdButton
|
||||
icon="pi pi-bell"
|
||||
severity="warning"
|
||||
aria-label="Notification"
|
||||
size="small"
|
||||
className="w-[33px] h-[33px]"
|
||||
outlined
|
||||
onClick={handleClickShow}
|
||||
disabled={isShow}
|
||||
/>
|
||||
{ping && (
|
||||
<>
|
||||
<WdButton
|
||||
icon="pi pi-bell"
|
||||
severity="warning"
|
||||
aria-label="Notification"
|
||||
size="small"
|
||||
className="w-[33px] h-[33px]"
|
||||
outlined
|
||||
onClick={handleClickShow}
|
||||
disabled={isShow}
|
||||
/>
|
||||
|
||||
<ConfirmPopup
|
||||
target={cfRef.current}
|
||||
visible={cfVisible}
|
||||
onHide={cfHide}
|
||||
message="Are you sure you want to delete ping?"
|
||||
icon="pi pi-exclamation-triangle text-orange-400"
|
||||
accept={removePing}
|
||||
/>
|
||||
<ConfirmPopup
|
||||
target={cfRef.current}
|
||||
visible={cfVisible}
|
||||
onHide={cfHide}
|
||||
message="Are you sure you want to delete ping?"
|
||||
icon="pi pi-exclamation-triangle text-orange-400"
|
||||
accept={removePing}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -3,9 +3,9 @@ import { useCallback, useEffect, useMemo, useRef } from 'react';
|
||||
|
||||
import { useSystemInfo } from '@/hooks/Mapper/components/hooks';
|
||||
import {
|
||||
SOLAR_SYSTEM_CLASS_IDS,
|
||||
SOLAR_SYSTEM_CLASSES_TO_CLASS_GROUPS,
|
||||
WORMHOLES_ADDITIONAL_INFO_BY_SHORT_NAME,
|
||||
SOLAR_SYSTEM_CLASS_IDS,
|
||||
SOLAR_SYSTEM_CLASSES_TO_CLASS_GROUPS,
|
||||
WORMHOLES_ADDITIONAL_INFO_BY_SHORT_NAME,
|
||||
} from '@/hooks/Mapper/components/map/constants.ts';
|
||||
import { SystemSignaturesContent } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/SystemSignaturesContent';
|
||||
import { K162_TYPES_MAP } from '@/hooks/Mapper/constants.ts';
|
||||
@@ -91,7 +91,7 @@ export const SystemLinkSignatureDialog = ({ data, setVisible }: SystemLinkSignat
|
||||
|
||||
if (k162TypeInfo) {
|
||||
// Check if the k162Type matches our target system class
|
||||
return customInfo.k162Type === targetSystemClassGroup;
|
||||
return k162TypeInfo.value.includes(targetSystemClassGroup);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
SystemStructures,
|
||||
WRoutesPublic,
|
||||
WRoutesUser,
|
||||
WRoutesBy,
|
||||
WSystemKills,
|
||||
} from '@/hooks/Mapper/components/mapInterface/widgets';
|
||||
|
||||
@@ -18,6 +19,7 @@ export enum WidgetsIds {
|
||||
signatures = 'signatures',
|
||||
local = 'local',
|
||||
routes = 'routes',
|
||||
routesBy = 'routesBy',
|
||||
structures = 'structures',
|
||||
kills = 'kills',
|
||||
comments = 'comments',
|
||||
@@ -60,6 +62,13 @@ export const DEFAULT_WIDGETS: WindowProps[] = [
|
||||
zIndex: 0,
|
||||
content: () => <WRoutesPublic />,
|
||||
},
|
||||
{
|
||||
id: WidgetsIds.routesBy,
|
||||
position: { x: 10, y: 740 },
|
||||
size: { width: 510, height: 200 },
|
||||
zIndex: 0,
|
||||
content: () => <WRoutesBy />,
|
||||
},
|
||||
{
|
||||
id: WidgetsIds.userRoutes,
|
||||
position: { x: 10, y: 10 },
|
||||
@@ -112,6 +121,10 @@ export const WIDGETS_CHECKBOXES_PROPS: WidgetsCheckboxesType = [
|
||||
id: WidgetsIds.routes,
|
||||
label: 'Routes',
|
||||
},
|
||||
{
|
||||
id: WidgetsIds.routesBy,
|
||||
label: 'Routes By',
|
||||
},
|
||||
{
|
||||
id: WidgetsIds.userRoutes,
|
||||
label: 'User Routes',
|
||||
|
||||
@@ -41,7 +41,7 @@ export const RoutesWidgetContent = () => {
|
||||
const {
|
||||
data: { selectedSystems, systems, isSubscriptionActive },
|
||||
} = useMapRootState();
|
||||
const { hubs = [], routesList, isRestricted, loading } = useRouteProvider();
|
||||
const { hubs = [], routesList, isRestricted, loading, nohubsPlaceholder } = useRouteProvider();
|
||||
|
||||
const [systemId] = selectedSystems;
|
||||
|
||||
@@ -105,7 +105,11 @@ export const RoutesWidgetContent = () => {
|
||||
}
|
||||
|
||||
if (hubs.length === 0) {
|
||||
return <div className="w-full h-full flex justify-center items-center select-none">Routes not set</div>;
|
||||
return (
|
||||
<div className="w-full h-full flex justify-center items-center select-none">
|
||||
{nohubsPlaceholder ?? 'Routes not set'}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -129,7 +133,6 @@ export const RoutesWidgetContent = () => {
|
||||
offset: 10,
|
||||
}}
|
||||
/>
|
||||
|
||||
<SystemView
|
||||
systemId={route.destination.toString()}
|
||||
className={clsx('select-none text-center cursor-context-menu')}
|
||||
@@ -138,7 +141,7 @@ export const RoutesWidgetContent = () => {
|
||||
showCustomName
|
||||
/>
|
||||
</div>
|
||||
<div className="text-right pl-1">{route.has_connection ? route.systems?.length ?? 2 : ''}</div>
|
||||
<div className="text-right pl-1">{route.has_connection ? (route.systems?.length ?? 2) : ''}</div>
|
||||
<div className="pl-2 pb-0.5">
|
||||
<RoutesList data={route} onContextMenu={handleContextMenu} />
|
||||
</div>
|
||||
@@ -147,9 +150,7 @@ export const RoutesWidgetContent = () => {
|
||||
})}
|
||||
</div>
|
||||
</LoadingWrapper>
|
||||
|
||||
<ContextMenuSystemInfo
|
||||
hubs={hubs}
|
||||
routes={preparedRoutes}
|
||||
systems={systems}
|
||||
systemStatics={systemStatics}
|
||||
@@ -162,9 +163,10 @@ export const RoutesWidgetContent = () => {
|
||||
|
||||
type RoutesWidgetCompProps = {
|
||||
title: ReactNode | string;
|
||||
renderContent?: (content: ReactNode, compact: boolean) => ReactNode;
|
||||
};
|
||||
|
||||
export const RoutesWidgetComp = ({ title }: RoutesWidgetCompProps) => {
|
||||
export const RoutesWidgetComp = ({ title, renderContent }: RoutesWidgetCompProps) => {
|
||||
const [routeSettingsVisible, setRouteSettingsVisible] = useState(false);
|
||||
const { data, update, addHubCommand } = useRouteProvider();
|
||||
|
||||
@@ -183,7 +185,7 @@ export const RoutesWidgetComp = ({ title }: RoutesWidgetCompProps) => {
|
||||
const onAddSystem = useCallback(() => setOpenAddSystem(true), []);
|
||||
|
||||
const handleSubmitAddSystem: SearchOnSubmitCallback = useCallback(
|
||||
async item => addHubCommand(item.value.toString()),
|
||||
async item => addHubCommand?.(item.value.toString()),
|
||||
[addHubCommand],
|
||||
);
|
||||
|
||||
@@ -191,15 +193,17 @@ export const RoutesWidgetComp = ({ title }: RoutesWidgetCompProps) => {
|
||||
<Widget
|
||||
label={
|
||||
<div className="flex justify-between items-center text-xs w-full" ref={ref}>
|
||||
<span className="select-none">{title}</span>
|
||||
<div className="select-none flex items-center gap-2">{title}</div>
|
||||
<LayoutEventBlocker className="flex items-center gap-2">
|
||||
<WdImgButton
|
||||
className={PrimeIcons.PLUS_CIRCLE}
|
||||
onClick={onAddSystem}
|
||||
tooltip={{
|
||||
content: 'Click here to add new system to routes',
|
||||
}}
|
||||
/>
|
||||
{addHubCommand && (
|
||||
<WdImgButton
|
||||
className={PrimeIcons.PLUS_CIRCLE}
|
||||
onClick={onAddSystem}
|
||||
tooltip={{
|
||||
content: 'Click here to add new system to routes',
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
<WdTooltipWrapper content="Show shortest route" position={TooltipPosition.top}>
|
||||
<WdCheckbox
|
||||
@@ -223,24 +227,38 @@ export const RoutesWidgetComp = ({ title }: RoutesWidgetCompProps) => {
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<RoutesWidgetContent />
|
||||
{renderContent ? (
|
||||
renderContent(
|
||||
<div className="h-full overflow-auto bg-opacity-5 custom-scrollbar">
|
||||
<RoutesWidgetContent />
|
||||
</div>,
|
||||
compact,
|
||||
)
|
||||
) : (
|
||||
<div className="h-full overflow-auto bg-opacity-5 custom-scrollbar">
|
||||
<RoutesWidgetContent />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<RoutesSettingsDialog visible={routeSettingsVisible} setVisible={setRouteSettingsVisible} />
|
||||
|
||||
<AddSystemDialog
|
||||
title="Add system to routes"
|
||||
visible={openAddSystem}
|
||||
setVisible={() => setOpenAddSystem(false)}
|
||||
onSubmit={handleSubmitAddSystem}
|
||||
/>
|
||||
{addHubCommand && (
|
||||
<AddSystemDialog
|
||||
title="Add system to routes"
|
||||
visible={openAddSystem}
|
||||
setVisible={() => setOpenAddSystem(false)}
|
||||
onSubmit={handleSubmitAddSystem}
|
||||
/>
|
||||
)}
|
||||
</Widget>
|
||||
);
|
||||
};
|
||||
|
||||
export const RoutesWidget = forwardRef<RoutesImperativeHandle, RoutesWidgetProps & RoutesWidgetCompProps>(
|
||||
({ title, ...props }, ref) => {
|
||||
({ title, renderContent, ...props }, ref) => {
|
||||
return (
|
||||
<RoutesProvider {...props} ref={ref}>
|
||||
<RoutesWidgetComp title={title} />
|
||||
<RoutesWidgetComp title={title} renderContent={renderContent} />
|
||||
</RoutesProvider>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export * from './useLoadRoutes';
|
||||
export * from './useLoadRoutesBy';
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||
import { RoutesType } from '@/hooks/Mapper/mapRootProvider/types.ts';
|
||||
import { LoadRoutesCommand } from '@/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/types.ts';
|
||||
import { RoutesList } from '@/hooks/Mapper/types/routes.ts';
|
||||
import { flattenValues } from '@/hooks/Mapper/utils/flattenValues.ts';
|
||||
import { useMapEventListener } from '@/hooks/Mapper/events';
|
||||
import { Commands } from '@/hooks/Mapper/types';
|
||||
|
||||
function usePrevious<T>(value: T): T | undefined {
|
||||
const ref = useRef<T>();
|
||||
|
||||
useEffect(() => {
|
||||
ref.current = value;
|
||||
}, [value]);
|
||||
|
||||
return ref.current;
|
||||
}
|
||||
|
||||
type UseLoadRoutesByProps = {
|
||||
loadRoutesCommand: LoadRoutesCommand;
|
||||
routesList: RoutesList | undefined;
|
||||
data: RoutesType;
|
||||
deps?: unknown[];
|
||||
};
|
||||
|
||||
export const useLoadRoutesBy = ({
|
||||
data: routesSettings,
|
||||
loadRoutesCommand,
|
||||
routesList,
|
||||
deps = [],
|
||||
}: UseLoadRoutesByProps) => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const {
|
||||
data: { selectedSystems },
|
||||
} = useMapRootState();
|
||||
|
||||
const prevSys = usePrevious(selectedSystems);
|
||||
const ref = useRef({ prevSys, selectedSystems });
|
||||
ref.current = { prevSys, selectedSystems };
|
||||
|
||||
const loadRoutes = useCallback(
|
||||
(systemId: string, settings: RoutesType) => {
|
||||
loadRoutesCommand(systemId, settings);
|
||||
setLoading(true);
|
||||
},
|
||||
[loadRoutesCommand],
|
||||
);
|
||||
|
||||
useMapEventListener(event => {
|
||||
if (event.name === Commands.routesListBy) {
|
||||
setLoading(false);
|
||||
}
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(false);
|
||||
}, [routesList]);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedSystems.length !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
const [systemId] = selectedSystems;
|
||||
loadRoutes(systemId, routesSettings);
|
||||
}, [loadRoutes, selectedSystems, ...flattenValues(routesSettings), ...deps]);
|
||||
|
||||
return { loading, loadRoutes, setLoading };
|
||||
};
|
||||
@@ -12,9 +12,10 @@ export type RoutesWidgetProps = {
|
||||
routesList: RoutesList | undefined;
|
||||
loading: boolean;
|
||||
|
||||
addHubCommand: AddHubCommand;
|
||||
toggleHubCommand: ToggleHubCommand;
|
||||
addHubCommand?: AddHubCommand;
|
||||
toggleHubCommand?: ToggleHubCommand;
|
||||
isRestricted?: boolean;
|
||||
nohubsPlaceholder?: string;
|
||||
};
|
||||
|
||||
export type RoutesProviderInnerProps = RoutesWidgetProps;
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
import { ExtendedSystemSignature, SystemSignature } from '@/hooks/Mapper/types';
|
||||
import { FINAL_DURATION_MS } from '../constants';
|
||||
|
||||
// Strip frontend-only fields that should never be sent to the backend.
|
||||
// "linked_system" is an object the frontend uses; the backend expects "linked_system_id" (integer)
|
||||
// which is set via a separate linkSignatureToSystem call.
|
||||
function stripFrontendFields(s: ExtendedSystemSignature) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { linked_system, pendingDeletion, pendingAddition, pendingUntil, finalTimeoutId, character_name, ...rest } =
|
||||
s as any;
|
||||
return rest;
|
||||
}
|
||||
|
||||
export function prepareUpdatePayload(
|
||||
systemId: string,
|
||||
added: ExtendedSystemSignature[],
|
||||
@@ -9,9 +19,9 @@ export function prepareUpdatePayload(
|
||||
) {
|
||||
return {
|
||||
system_id: systemId,
|
||||
added: added.map(s => ({ ...s })),
|
||||
updated: updated.map(s => ({ ...s })),
|
||||
removed: removed.map(s => ({ ...s })),
|
||||
added: added.map(stripFrontendFields),
|
||||
updated: updated.map(stripFrontendFields),
|
||||
removed: removed.map(stripFrontendFields),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useCallback, ClipboardEvent, useRef } from 'react';
|
||||
import React, { useCallback, ClipboardEvent, useRef, useState } from 'react';
|
||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||
import useMaxWidth from '@/hooks/Mapper/hooks/useMaxWidth';
|
||||
import {
|
||||
@@ -13,7 +13,9 @@ import { Widget } from '@/hooks/Mapper/components/mapInterface/components';
|
||||
|
||||
import { SystemStructuresContent } from './SystemStructuresContent/SystemStructuresContent';
|
||||
import { useSystemStructures } from './hooks/useSystemStructures';
|
||||
import { processSnippetText } from './helpers';
|
||||
import { processSnippetText, StructureItem } from './helpers';
|
||||
import { SystemStructuresOwnersDialog } from './SystemStructuresOwnersDialog/SystemStructuresOwnersDialog';
|
||||
import clsx from 'clsx';
|
||||
|
||||
export const SystemStructures: React.FC = () => {
|
||||
const {
|
||||
@@ -24,6 +26,7 @@ export const SystemStructures: React.FC = () => {
|
||||
const isNotSelectedSystem = selectedSystems.length !== 1;
|
||||
|
||||
const { structures, handleUpdateStructures } = useSystemStructures({ systemId, outCommand });
|
||||
const [showEditDialog, setShowEditDialog] = useState(false);
|
||||
|
||||
const labelRef = useRef<HTMLDivElement>(null);
|
||||
const isCompact = useMaxWidth(labelRef, 260);
|
||||
@@ -48,6 +51,18 @@ export const SystemStructures: React.FC = () => {
|
||||
[processClipboard],
|
||||
);
|
||||
|
||||
const handleSave = (updatedStructures: StructureItem[]) => {
|
||||
handleUpdateStructures(updatedStructures)
|
||||
}
|
||||
|
||||
const handleOpenDialog = useCallback(() => {
|
||||
setShowEditDialog(true)
|
||||
}, [])
|
||||
|
||||
const handleCloseDialog = useCallback(() => {
|
||||
setShowEditDialog(false)
|
||||
}, [])
|
||||
|
||||
const handlePasteTimer = useCallback(async () => {
|
||||
try {
|
||||
const text = await navigator.clipboard.readText();
|
||||
@@ -71,8 +86,19 @@ export const SystemStructures: React.FC = () => {
|
||||
</div>
|
||||
|
||||
<LayoutEventBlocker className="flex gap-2.5">
|
||||
{structures.length > 1 && (
|
||||
<WdImgButton
|
||||
className={clsx(PrimeIcons.USER_EDIT, 'text-sky-400 hover:text-sky-200 transition duration-300')}
|
||||
onClick={handleOpenDialog}
|
||||
tooltip={{
|
||||
position: TooltipPosition.left,
|
||||
// @ts-ignore
|
||||
content: 'Update all structure owners',
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<WdImgButton
|
||||
className={`${PrimeIcons.CLOCK} text-sky-400 hover:text-sky-200 transition duration-300`}
|
||||
className={clsx(PrimeIcons.CLOCK, 'text-sky-400 hover:text-sky-200 transition duration-300')}
|
||||
onClick={handlePasteTimer}
|
||||
tooltip={{
|
||||
position: TooltipPosition.left,
|
||||
@@ -117,6 +143,15 @@ export const SystemStructures: React.FC = () => {
|
||||
<SystemStructuresContent structures={structures} onUpdateStructures={handleUpdateStructures} />
|
||||
)}
|
||||
</Widget>
|
||||
|
||||
{showEditDialog && (
|
||||
<SystemStructuresOwnersDialog
|
||||
visible={showEditDialog}
|
||||
structures={structures}
|
||||
onClose={handleCloseDialog}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -4,7 +4,14 @@ import { AutoComplete } from 'primereact/autocomplete';
|
||||
import { Calendar } from 'primereact/calendar';
|
||||
import clsx from 'clsx';
|
||||
|
||||
import { formatToISO, statusesRequiringTimer, StructureItem, StructureStatus } from '../helpers';
|
||||
import {
|
||||
calendarDateToUtcIso,
|
||||
formatToISO,
|
||||
statusesRequiringTimer,
|
||||
StructureItem,
|
||||
StructureStatus,
|
||||
utcToCalendarDate,
|
||||
} from '../helpers';
|
||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||
import { OutCommand } from '@/hooks/Mapper/types';
|
||||
import { WdButton } from '@/hooks/Mapper/components/ui-kit';
|
||||
@@ -72,7 +79,7 @@ export const SystemStructuresDialog: React.FC<StructuresEditDialogProps> = ({
|
||||
|
||||
// If this is the endTime (Date from Calendar), we store as ISO or string:
|
||||
if (field === 'endTime' && val instanceof Date) {
|
||||
return { ...prev, endTime: val.toISOString() };
|
||||
return { ...prev, endTime: calendarDateToUtcIso(val) };
|
||||
}
|
||||
|
||||
return { ...prev, [field]: val };
|
||||
@@ -188,7 +195,7 @@ export const SystemStructuresDialog: React.FC<StructuresEditDialogProps> = ({
|
||||
Timer <br /> (Eve Time):
|
||||
</span>
|
||||
<Calendar
|
||||
value={editData.endTime ? new Date(editData.endTime) : undefined}
|
||||
value={editData.endTime ? utcToCalendarDate(editData.endTime) : undefined}
|
||||
onChange={e => handleChange('endTime', e.value ?? '')}
|
||||
showTime
|
||||
hourFormat="24"
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
.systemStructuresOwnersDialog {
|
||||
|
||||
.p-dialog-content {
|
||||
background-color: var(--surface-800) !important;
|
||||
}
|
||||
|
||||
.p-dialog-header {
|
||||
background-color: var(--surface-700);
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.p-dialog-header-icon,
|
||||
.p-dialog-header-title {
|
||||
color: var(--gray-200);
|
||||
}
|
||||
|
||||
.p-inputtext {
|
||||
background-color: #2a2a2a !important;
|
||||
color: #ddd !important;
|
||||
font-size: 12px !important;
|
||||
padding: 0.25rem 0.5rem !important;
|
||||
}
|
||||
|
||||
.p-dialog-footer {
|
||||
.p-button {
|
||||
font-size: 12px !important;
|
||||
padding: 0.3rem 0.75rem !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
import clsx from 'clsx';
|
||||
import { AutoComplete } from 'primereact/autocomplete';
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
import React, { useCallback, useState } from 'react';
|
||||
|
||||
import { WdButton } from '@/hooks/Mapper/components/ui-kit';
|
||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||
import { useToast } from '@/hooks/Mapper/ToastProvider';
|
||||
import { OutCommand } from '@/hooks/Mapper/types';
|
||||
import { StructureItem } from '../helpers';
|
||||
|
||||
interface StructuresOwnersEditDialogProps {
|
||||
visible: boolean;
|
||||
structures: StructureItem[];
|
||||
onClose: () => void;
|
||||
onSave: (updatedStuctures: StructureItem[]) => void;
|
||||
}
|
||||
|
||||
export const SystemStructuresOwnersDialog: React.FC<StructuresOwnersEditDialogProps> = ({
|
||||
visible,
|
||||
structures,
|
||||
onClose,
|
||||
onSave,
|
||||
}) => {
|
||||
const [ownerInput, setOwnerInput] = useState('');
|
||||
const [ownerSuggestions, setOwnerSuggestions] = useState<{ label: string; value: string }[]>([]);
|
||||
|
||||
const { outCommand } = useMapRootState();
|
||||
const { show } = useToast();
|
||||
|
||||
const [prevQuery, setPrevQuery] = useState('');
|
||||
const [prevResults, setPrevResults] = useState<{ label: string; value: string }[]>([]);
|
||||
const [editData, setEditData] = useState<StructureItem[]>(structures);
|
||||
|
||||
// Searching corporation owners via auto-complete
|
||||
const searchOwners = useCallback(
|
||||
async (e: { query: string }) => {
|
||||
const newQuery = e.query.trim();
|
||||
if (!newQuery) {
|
||||
setOwnerSuggestions([]);
|
||||
return;
|
||||
}
|
||||
|
||||
// If user typed more text but we have partial match in prevResults
|
||||
if (newQuery.startsWith(prevQuery) && prevResults.length > 0) {
|
||||
const filtered = prevResults.filter(item => item.label.toLowerCase().includes(newQuery.toLowerCase()));
|
||||
setOwnerSuggestions(filtered);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// TODO fix it
|
||||
const { results = [] } = await outCommand({
|
||||
type: OutCommand.getCorporationNames,
|
||||
data: { search: newQuery },
|
||||
});
|
||||
setOwnerSuggestions(results);
|
||||
setPrevQuery(newQuery);
|
||||
setPrevResults(results);
|
||||
} catch (err) {
|
||||
show({
|
||||
severity: 'error',
|
||||
summary: 'Failed to fetch owners',
|
||||
detail: `${err}`,
|
||||
life: 10000,
|
||||
});
|
||||
}
|
||||
},
|
||||
[prevQuery, prevResults, outCommand],
|
||||
);
|
||||
|
||||
// when user picks a corp from auto-complete
|
||||
const handleSelectOwner = (selected: { label: string; value: string }) => {
|
||||
setOwnerInput(selected.label);
|
||||
|
||||
setEditData(
|
||||
structures.map(item => {
|
||||
return { ...item, ownerName: selected.label, ownerId: selected.value };
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
const handleSaveClick = async () => {
|
||||
if (!editData) return;
|
||||
|
||||
// Get all unique owner IDs that need ticker lookup
|
||||
const allOwnerIds = editData.filter(x => x.ownerId != null).map(x => x.ownerId as string);
|
||||
|
||||
const uniqueOwnerIds = [...new Set(allOwnerIds)];
|
||||
|
||||
// Fetch all tickers in parallel
|
||||
const tickerResults = await Promise.all(
|
||||
uniqueOwnerIds.map(async ownerId => {
|
||||
try {
|
||||
const { ticker } = await outCommand({
|
||||
type: OutCommand.getCorporationTicker,
|
||||
data: { corp_id: ownerId },
|
||||
});
|
||||
return { ownerId, ticker: ticker ?? '' };
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch ticker for ownerId:', ownerId, err);
|
||||
return { ownerId, ticker: '' };
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
// Create a map of ownerId -> ticker for quick lookup
|
||||
const tickerMap = new Map(tickerResults.map(r => [r.ownerId, r.ticker]));
|
||||
|
||||
// Create new array with updated values (no mutation)
|
||||
const updatedStructures = editData.map(structure => {
|
||||
if (!structure.ownerId) {
|
||||
return structure;
|
||||
}
|
||||
|
||||
return {
|
||||
...structure,
|
||||
ownerTicker: tickerMap.get(structure.ownerId) ?? '',
|
||||
};
|
||||
});
|
||||
|
||||
onSave(updatedStructures);
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
visible={visible}
|
||||
onHide={onClose}
|
||||
header={'Update All Structure Owners'}
|
||||
className={clsx('myStructuresOwnersDialog', 'text-stone-200 w-full max-w-md')}
|
||||
>
|
||||
<div className="flex flex-col gap-2 text-[14px]">
|
||||
<div className="flex gap-2">
|
||||
Updating the corporation name below will update all structures currently saved within the system.
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<label className="grid grid-cols-[100px_1fr] gap-2 items-start mt-2">
|
||||
<span className="mt-1">Structures to update:</span>
|
||||
<ul>
|
||||
{structures &&
|
||||
structures.map((item, i) => (
|
||||
<li key={i}>
|
||||
{item.structureType || 'Unknown Type'} - {item.name}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<label className="grid grid-cols-[100px_250px_1fr] gap-2 items-center">
|
||||
<span>Owner:</span>
|
||||
<AutoComplete
|
||||
id="owner"
|
||||
value={ownerInput}
|
||||
suggestions={ownerSuggestions}
|
||||
completeMethod={searchOwners}
|
||||
minLength={3}
|
||||
delay={400}
|
||||
field="label"
|
||||
placeholder="Corporation name..."
|
||||
onChange={e => setOwnerInput(e.value)}
|
||||
onSelect={e => handleSelectOwner(e.value)}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end items-center gap-2 mt-4">
|
||||
<WdButton label="Save" className="p-button-sm" onClick={handleSaveClick} />
|
||||
</div>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
@@ -43,6 +43,29 @@ export function mapServerStructure(serverData: any): StructureItem {
|
||||
};
|
||||
}
|
||||
|
||||
export function utcToCalendarDate(utcIso: string): Date {
|
||||
// Parse ISO components manually to avoid browser quirks with
|
||||
// 6-digit microsecond precision from Elixir's :utc_datetime_usec.
|
||||
const m = utcIso.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/);
|
||||
if (m) {
|
||||
const [, yr, mo, dy, hr, mi, sc] = m;
|
||||
return new Date(+yr, +mo - 1, +dy, +hr, +mi, +sc);
|
||||
}
|
||||
// Fallback for non-ISO strings
|
||||
const d = new Date(utcIso);
|
||||
return new Date(d.getTime() + d.getTimezoneOffset() * 60_000);
|
||||
}
|
||||
|
||||
export function calendarDateToUtcIso(localDate: Date): string {
|
||||
// Read local-time components (which represent EVE/UTC time) and
|
||||
// build the ISO string directly — no timezone arithmetic needed.
|
||||
const pad = (n: number) => String(n).padStart(2, '0');
|
||||
return (
|
||||
`${localDate.getFullYear()}-${pad(localDate.getMonth() + 1)}-${pad(localDate.getDate())}` +
|
||||
`T${pad(localDate.getHours())}:${pad(localDate.getMinutes())}:${pad(localDate.getSeconds())}.000Z`
|
||||
);
|
||||
}
|
||||
|
||||
export function formatToISO(datetimeLocal: string): string {
|
||||
if (!datetimeLocal) return '';
|
||||
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
import { useCallback, useMemo, useRef } from 'react';
|
||||
import { RoutesWidget } from '@/hooks/Mapper/components/mapInterface/widgets';
|
||||
import { LoadRoutesCommand } from '@/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/types.ts';
|
||||
import { useLoadRoutesBy } from '@/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/hooks';
|
||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||
import { OutCommand } from '@/hooks/Mapper/types';
|
||||
import { Dropdown } from 'primereact/dropdown';
|
||||
import { SelectItemOptionsType } from 'primereact/selectitem';
|
||||
import useMaxWidth from '@/hooks/Mapper/hooks/useMaxWidth.ts';
|
||||
import clsx from 'clsx';
|
||||
import { RoutesByCategoryType, RoutesByScopeType, RoutesType } from '@/hooks/Mapper/mapRootProvider/types.ts';
|
||||
import { DEFAULT_ROUTES_SETTINGS } from '@/hooks/Mapper/mapRootProvider/constants.ts';
|
||||
import { TooltipPosition, WdImgButton } from '@/hooks/Mapper/components/ui-kit';
|
||||
import { PrimeIcons } from 'primereact/api';
|
||||
|
||||
export type RoutesByType = RoutesByCategoryType;
|
||||
|
||||
type WRoutesByProps = {
|
||||
type?: RoutesByType;
|
||||
title?: string;
|
||||
};
|
||||
|
||||
const ROUTES_BY_OPTIONS: SelectItemOptionsType = [
|
||||
{
|
||||
label: 'Blue Loot',
|
||||
value: 'blueLoot',
|
||||
icon: 'images/30747_64.png',
|
||||
},
|
||||
{
|
||||
label: 'Red Loot',
|
||||
value: 'redLoot',
|
||||
icon: 'images/89219_64.png',
|
||||
},
|
||||
{
|
||||
label: 'Thera',
|
||||
value: 'thera',
|
||||
icon: 'images/map.png',
|
||||
},
|
||||
{
|
||||
label: 'Turnur',
|
||||
value: 'turnur',
|
||||
icon: 'images/map.png',
|
||||
},
|
||||
{
|
||||
label: 'Security Office',
|
||||
value: 'so_cleaning',
|
||||
icon: 'images/concord-so.png',
|
||||
},
|
||||
{
|
||||
label: 'Trade Hubs',
|
||||
value: 'trade_hubs',
|
||||
icon: 'images/market.png',
|
||||
},
|
||||
];
|
||||
const ROUTES_BY_SECURITY_OPTIONS = [
|
||||
{ label: 'All', value: 'ALL' },
|
||||
{ label: 'High', value: 'HIGH' },
|
||||
];
|
||||
|
||||
export const WRoutesBy = ({ type = 'blueLoot', title = 'Routes By' }: WRoutesByProps) => {
|
||||
const {
|
||||
outCommand,
|
||||
storedSettings: { settingsRoutesBy, settingsRoutesByUpdate },
|
||||
data,
|
||||
} = useMapRootState();
|
||||
|
||||
const criteriaType = settingsRoutesBy.type ?? type;
|
||||
const securityType = settingsRoutesBy.scope ?? 'ALL';
|
||||
const routesSettings = settingsRoutesBy.routes ?? DEFAULT_ROUTES_SETTINGS;
|
||||
const routesListBy = data.routesListBy;
|
||||
const availableRoutesBy = data.availableRoutesBy;
|
||||
|
||||
const routesByOptions = useMemo(() => {
|
||||
if (!availableRoutesBy || availableRoutesBy.length === 0) {
|
||||
return ROUTES_BY_OPTIONS;
|
||||
}
|
||||
|
||||
return ROUTES_BY_OPTIONS.filter(option => availableRoutesBy.includes(option.value as RoutesByType));
|
||||
}, [availableRoutesBy]);
|
||||
|
||||
const resolvedCriteriaType = useMemo(() => {
|
||||
const optionValues = routesByOptions.map(option => option.value as RoutesByType);
|
||||
|
||||
if (optionValues.length === 0) {
|
||||
return criteriaType;
|
||||
}
|
||||
|
||||
return optionValues.includes(criteriaType) ? criteriaType : optionValues[0];
|
||||
}, [routesByOptions, criteriaType]);
|
||||
|
||||
const loadRoutesCommand: LoadRoutesCommand = useCallback(
|
||||
async (systemId, currentRoutesSettings) => {
|
||||
await outCommand({
|
||||
type: OutCommand.getRoutesBy,
|
||||
data: {
|
||||
system_id: systemId,
|
||||
type: resolvedCriteriaType,
|
||||
securityType: securityType === 'HIGH' ? 'high' : 'both',
|
||||
routes_settings: currentRoutesSettings,
|
||||
},
|
||||
});
|
||||
},
|
||||
[outCommand, resolvedCriteriaType, securityType],
|
||||
);
|
||||
|
||||
const hubs = useMemo(() => routesListBy?.routes?.map(route => route.destination.toString()) ?? [], [routesListBy]);
|
||||
|
||||
const { loading: internalLoading } = useLoadRoutesBy({
|
||||
data: routesSettings,
|
||||
loadRoutesCommand,
|
||||
routesList: routesListBy,
|
||||
deps: [resolvedCriteriaType, securityType],
|
||||
});
|
||||
|
||||
const updateRoutesSettings = useCallback(
|
||||
(next: RoutesType) => settingsRoutesByUpdate(prev => ({ ...prev, routes: next })),
|
||||
[settingsRoutesByUpdate],
|
||||
);
|
||||
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
|
||||
const compactSmall = useMaxWidth(ref, 180);
|
||||
const compactMiddle = useMaxWidth(ref, 245);
|
||||
|
||||
const titleNode = useMemo(
|
||||
() => (
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="select-none">{title}</span>
|
||||
<WdImgButton
|
||||
className={PrimeIcons.QUESTION_CIRCLE}
|
||||
tooltip={{
|
||||
position: TooltipPosition.top,
|
||||
content: 'Alpha map users can access only 1 route',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
[title],
|
||||
);
|
||||
|
||||
return (
|
||||
<RoutesWidget
|
||||
title={titleNode}
|
||||
nohubsPlaceholder="Not found any destinations"
|
||||
renderContent={(content /*, compact*/) => (
|
||||
<div className="h-full grid grid-rows-[1fr_auto]" ref={ref}>
|
||||
{content}
|
||||
<div className="flex items-center gap-2 justify-end mb-2 px-2 pt-2">
|
||||
{!compactSmall && (
|
||||
<Dropdown
|
||||
value={securityType}
|
||||
options={ROUTES_BY_SECURITY_OPTIONS}
|
||||
onChange={e => settingsRoutesByUpdate(prev => ({ ...prev, scope: e.value as RoutesByScopeType }))}
|
||||
className="w-[90px] [&_span]:!text-[12px]"
|
||||
/>
|
||||
)}
|
||||
<Dropdown
|
||||
value={resolvedCriteriaType}
|
||||
itemTemplate={e => (
|
||||
<div className="flex items-center gap-2">
|
||||
{e.icon && <img src={e.icon} height="18" width="18" />}
|
||||
<span className="text-[12px]">{e.label}</span>
|
||||
</div>
|
||||
)}
|
||||
valueTemplate={e => {
|
||||
if (!e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (compactMiddle) {
|
||||
return (
|
||||
<div className="flex items-center gap-2 min-w-[50px]">
|
||||
{e.icon ? <img src={e.icon} height="18" width="18" /> : <span>{e.label}</span>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
{e.icon && <img src={e.icon} height="18" width="18" />}
|
||||
<span className="text-[12px]">{e.label}</span>
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
options={routesByOptions}
|
||||
onChange={e => settingsRoutesByUpdate(prev => ({ ...prev, type: e.value as RoutesByCategoryType }))}
|
||||
className={clsx({
|
||||
['w-[130px]']: !compactMiddle,
|
||||
['w-[65px]']: compactMiddle,
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
data={routesSettings}
|
||||
update={updateRoutesSettings}
|
||||
hubs={hubs}
|
||||
routesList={routesListBy}
|
||||
loading={internalLoading}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,2 @@
|
||||
export { WRoutesBy } from './WRoutesBy';
|
||||
export type { RoutesByType } from './WRoutesBy';
|
||||
@@ -31,7 +31,7 @@ export function useSystemKills({ systemId, outCommand, showAllVisible = false, s
|
||||
storedSettings: { settingsKills },
|
||||
} = useMapRootState();
|
||||
|
||||
const excludedSystems = useStableValue(settingsKills.excludedSystems);
|
||||
const excludedSystems = useStableValue(settingsKills.excludedSystems ?? []);
|
||||
|
||||
const effectiveSystemIds = useMemo(() => {
|
||||
if (showAllVisible) {
|
||||
|
||||
@@ -6,4 +6,5 @@ export * from './SystemStructures';
|
||||
export * from './WSystemKills';
|
||||
export * from './WRoutesUser';
|
||||
export * from './WRoutesPublic';
|
||||
export * from './WRoutesBy';
|
||||
export * from './CommentsWidget';
|
||||
|
||||
@@ -9,6 +9,7 @@ import { MapContextMenu } from '@/hooks/Mapper/components/mapRootContent/compone
|
||||
import { useSkipContextMenu } from '@/hooks/Mapper/hooks/useSkipContextMenu';
|
||||
import { MapSettings } from '@/hooks/Mapper/components/mapRootContent/components/MapSettings';
|
||||
import { CharacterActivity } from '@/hooks/Mapper/components/mapRootContent/components/CharacterActivity';
|
||||
import { WormholeSignaturesDialog } from '@/hooks/Mapper/components/mapRootContent/components/WormholeSignaturesDialog';
|
||||
import { useCharacterActivityHandlers } from './hooks/useCharacterActivityHandlers';
|
||||
import { TrackingDialog } from '@/hooks/Mapper/components/mapRootContent/components/TrackingDialog';
|
||||
import { useMapEventListener } from '@/hooks/Mapper/events';
|
||||
@@ -34,6 +35,7 @@ export const MapRootContent = ({}: MapRootContentProps) => {
|
||||
const [showOnTheMap, setShowOnTheMap] = useState(false);
|
||||
const [showMapSettings, setShowMapSettings] = useState(false);
|
||||
const [showTrackingDialog, setShowTrackingDialog] = useState(false);
|
||||
const [showWormholeList, setShowWormholeList] = useState(false);
|
||||
|
||||
/* Important Notice - this solution needs for use one instance of MapInterface */
|
||||
const mapInterface = isReady ? <MapInterface /> : null;
|
||||
@@ -41,6 +43,7 @@ export const MapRootContent = ({}: MapRootContentProps) => {
|
||||
const handleShowOnTheMap = useCallback(() => setShowOnTheMap(true), []);
|
||||
const handleShowMapSettings = useCallback(() => setShowMapSettings(true), []);
|
||||
const handleShowTrackingDialog = useCallback(() => setShowTrackingDialog(true), []);
|
||||
const handleShowWormholesReference = useCallback(() => setShowWormholeList(true), []);
|
||||
|
||||
useMapEventListener(event => {
|
||||
if (event.name === Commands.showTracking) {
|
||||
@@ -65,6 +68,7 @@ export const MapRootContent = ({}: MapRootContentProps) => {
|
||||
onShowOnTheMap={handleShowOnTheMap}
|
||||
onShowMapSettings={handleShowMapSettings}
|
||||
onShowTrackingDialog={handleShowTrackingDialog}
|
||||
onShowWormholesReference={handleShowWormholesReference}
|
||||
additionalContent={<PingsInterface hasLeftOffset />}
|
||||
/>
|
||||
</div>
|
||||
@@ -79,6 +83,7 @@ export const MapRootContent = ({}: MapRootContentProps) => {
|
||||
onShowOnTheMap={handleShowOnTheMap}
|
||||
onShowMapSettings={handleShowMapSettings}
|
||||
onShowTrackingDialog={handleShowTrackingDialog}
|
||||
onShowWormholesReference={handleShowWormholesReference}
|
||||
/>
|
||||
</div>
|
||||
</Topbar>
|
||||
@@ -93,6 +98,7 @@ export const MapRootContent = ({}: MapRootContentProps) => {
|
||||
{showTrackingDialog && (
|
||||
<TrackingDialog visible={showTrackingDialog} onHide={() => setShowTrackingDialog(false)} />
|
||||
)}
|
||||
<WormholeSignaturesDialog visible={showWormholeList} onHide={() => setShowWormholeList(false)} />
|
||||
|
||||
{hasOldSettings && <OldSettingsDialog />}
|
||||
</Layout>
|
||||
|
||||
@@ -12,9 +12,15 @@ export interface MapContextMenuProps {
|
||||
onShowOnTheMap?: () => void;
|
||||
onShowMapSettings?: () => void;
|
||||
onShowTrackingDialog?: () => void;
|
||||
onShowWormholesReference?: () => void;
|
||||
}
|
||||
|
||||
export const MapContextMenu = ({ onShowOnTheMap, onShowMapSettings, onShowTrackingDialog }: MapContextMenuProps) => {
|
||||
export const MapContextMenu = ({
|
||||
onShowOnTheMap,
|
||||
onShowMapSettings,
|
||||
onShowTrackingDialog,
|
||||
onShowWormholesReference,
|
||||
}: MapContextMenuProps) => {
|
||||
const {
|
||||
outCommand,
|
||||
storedSettings: { setInterfaceSettings },
|
||||
@@ -52,6 +58,12 @@ export const MapContextMenu = ({ onShowOnTheMap, onShowMapSettings, onShowTracki
|
||||
command: onShowOnTheMap,
|
||||
visible: canTrackCharacters,
|
||||
},
|
||||
{
|
||||
label: 'Wormholes Ref.',
|
||||
icon: 'pi pi-bullseye',
|
||||
command: onShowWormholesReference,
|
||||
visible: canTrackCharacters,
|
||||
},
|
||||
{ separator: true, visible: true },
|
||||
{
|
||||
label: 'Settings',
|
||||
|
||||
@@ -38,9 +38,11 @@ export const OldSettingsDialog = () => {
|
||||
localWidget: createSettings(widgetLocal, {}),
|
||||
widgets: createSettings(widgetsOld, {}),
|
||||
routes: createSettings(widgetRoutes, {}),
|
||||
routesBy: createSettings(widgetRoutes, {}),
|
||||
onTheMap: createSettings(onTheMapOld, {}),
|
||||
signaturesWidget: createSettings(signatures, {}),
|
||||
interface: createSettings(interfaceSettings, {}),
|
||||
map: createSettings(null, { viewport: { zoom: 1, x: 0, y: 0 } }),
|
||||
};
|
||||
|
||||
if (asFile) {
|
||||
|
||||
@@ -14,6 +14,7 @@ interface RightBarProps {
|
||||
onShowOnTheMap?: () => void;
|
||||
onShowMapSettings?: () => void;
|
||||
onShowTrackingDialog?: () => void;
|
||||
onShowWormholesReference?: () => void;
|
||||
additionalContent?: ReactNode;
|
||||
}
|
||||
|
||||
@@ -21,6 +22,7 @@ export const RightBar = ({
|
||||
onShowOnTheMap,
|
||||
onShowMapSettings,
|
||||
onShowTrackingDialog,
|
||||
onShowWormholesReference,
|
||||
additionalContent,
|
||||
}: RightBarProps) => {
|
||||
const {
|
||||
@@ -90,6 +92,16 @@ export const RightBar = ({
|
||||
<i className="pi pi-hashtag"></i>
|
||||
</button>
|
||||
</WdTooltipWrapper>
|
||||
|
||||
<WdTooltipWrapper content="Wormholes Reference" position={TooltipPosition.left}>
|
||||
<button
|
||||
className="btn bg-transparent text-gray-400 hover:text-white border-transparent hover:bg-transparent py-2 h-auto min-h-auto"
|
||||
type="button"
|
||||
onClick={onShowWormholesReference}
|
||||
>
|
||||
<i className="pi pi-bullseye"></i>
|
||||
</button>
|
||||
</WdTooltipWrapper>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -13,6 +13,26 @@ export const renderK162Type = (option: K162Type) => {
|
||||
return renderNoValue();
|
||||
}
|
||||
|
||||
if (['c1_c2_c3', 'c4_c5'].includes(value)) {
|
||||
const arr = whClassName.split('_');
|
||||
|
||||
return (
|
||||
<div className="flex gap-1 items-center">
|
||||
{arr.map(x => (
|
||||
<WHClassView
|
||||
key={x}
|
||||
classNameWh="!text-[11px] !font-bold"
|
||||
hideWhClassName
|
||||
hideTooltip
|
||||
whClassName={x}
|
||||
noOffset
|
||||
useShortTitle
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<WHClassView
|
||||
classNameWh="!text-[11px] !font-bold"
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { createContext, useCallback, useContext, useRef, useState } from 'react';
|
||||
import { OutCommand, TrackingCharacter } from '@/hooks/Mapper/types';
|
||||
import { createContext, useCallback, useContext, useRef, useState, useEffect } from 'react';
|
||||
import { Commands, OutCommand, TrackingCharacter } from '@/hooks/Mapper/types';
|
||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||
import { IncomingEvent, WithChildren } from '@/hooks/Mapper/types/common.ts';
|
||||
import { CommandInCharactersTrackingInfo } from '@/hooks/Mapper/types/commandsIn.ts';
|
||||
import { useMapEventListener } from '@/hooks/Mapper/events';
|
||||
|
||||
type DiffTrackingInfo = { characterId: string; tracked: boolean };
|
||||
|
||||
@@ -122,6 +123,14 @@ export const TrackingProvider = ({ children }: WithChildren) => {
|
||||
[outCommand],
|
||||
);
|
||||
|
||||
// Listen for refresh_tracking_data event (triggered when ACL members change)
|
||||
useMapEventListener(event => {
|
||||
if (event.name === Commands.refreshTrackingData) {
|
||||
loadTracking();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<TrackingContext.Provider
|
||||
value={{
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
import { DataTable } from 'primereact/datatable';
|
||||
import { Column } from 'primereact/column';
|
||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||
import { WormholeDataRaw } from '@/hooks/Mapper/types';
|
||||
import { RespawnTag, WHClassView } from '@/hooks/Mapper/components/ui-kit';
|
||||
import { kgToTons } from '@/hooks/Mapper/utils/kgToTons.ts';
|
||||
import { WORMHOLE_CLASS_STYLES, WORMHOLES_ADDITIONAL_INFO } from '@/hooks/Mapper/components/map/constants.ts';
|
||||
import clsx from 'clsx';
|
||||
import { InputText } from 'primereact/inputtext';
|
||||
import { IconField } from 'primereact/iconfield';
|
||||
import { InputIcon } from 'primereact/inputicon';
|
||||
|
||||
const renderSpawns = (w: WormholeDataRaw) => (
|
||||
<div className="flex gap-1 flex-wrap">
|
||||
{w.src.map(s => {
|
||||
const group = s.split('-')[0];
|
||||
const info = WORMHOLES_ADDITIONAL_INFO[group];
|
||||
|
||||
if (!info) {
|
||||
return (
|
||||
<span
|
||||
key={s}
|
||||
className="px-[4px] py-[1px] rounded bg-stone-800 text-stone-300 text-xs border border-stone-700"
|
||||
>
|
||||
{s}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
const cls = WORMHOLE_CLASS_STYLES[String(info.wormholeClassID)] || '';
|
||||
const label = `${info.shortName}`;
|
||||
return (
|
||||
<span
|
||||
key={s}
|
||||
className={clsx(cls, 'px-[4px] py-[1px] rounded text-xs border border-stone-700 bg-stone-900/40')}
|
||||
>
|
||||
{label}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
|
||||
const renderName = (w: WormholeDataRaw) => (
|
||||
<div className="flex items-center gap-2">
|
||||
<WHClassView
|
||||
whClassName={w.name}
|
||||
noOffset
|
||||
useShortTitle
|
||||
classNameWh="overflow-hidden text-ellipsis whitespace-nowrap"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
const renderRespawn = (w: WormholeDataRaw) => (
|
||||
<div className="flex gap-1 flex-wrap">
|
||||
{w.respawn.map(r => (
|
||||
<RespawnTag key={r} value={r} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
||||
export interface WormholeSignaturesDialogProps {
|
||||
visible: boolean;
|
||||
onHide: () => void;
|
||||
}
|
||||
|
||||
export const WormholeSignaturesDialog = ({ visible, onHide }: WormholeSignaturesDialogProps) => {
|
||||
const {
|
||||
data: { wormholes },
|
||||
} = useMapRootState();
|
||||
|
||||
const [filter, setFilter] = useState('');
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
const q = filter.trim().toLowerCase();
|
||||
|
||||
if (!q) return wormholes;
|
||||
|
||||
return wormholes.filter(w => {
|
||||
const destInfo = WORMHOLES_ADDITIONAL_INFO[w.dest];
|
||||
const spawnsLabels = w.src
|
||||
.map(s => {
|
||||
const group = s.split('-')[0];
|
||||
const info = WORMHOLES_ADDITIONAL_INFO[group];
|
||||
if (!info) return s;
|
||||
return `${info.title} ${info.shortName}`.trim();
|
||||
})
|
||||
.join(' ');
|
||||
|
||||
return [
|
||||
w.name,
|
||||
destInfo?.title,
|
||||
destInfo?.shortName,
|
||||
spawnsLabels,
|
||||
String(w.total_mass),
|
||||
String(w.max_mass_per_jump),
|
||||
w.lifetime,
|
||||
w.respawn.join(','),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')
|
||||
.toLowerCase()
|
||||
.includes(q);
|
||||
});
|
||||
}, [wormholes, filter]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
header="Wormholes Reference"
|
||||
visible={visible}
|
||||
draggable={false}
|
||||
resizable={false}
|
||||
className="w-[950px] h-[600px]"
|
||||
onHide={onHide}
|
||||
contentClassName="!p-0 flex flex-col h-full"
|
||||
>
|
||||
<div className="p-3 flex items-center justify-between gap-2 border-b border-stone-800">
|
||||
<div className="font-semibold text-sm text-stone-200">Reference list of all wormhole types</div>
|
||||
<IconField iconPosition="right">
|
||||
<InputIcon
|
||||
className={clsx('pi pi-times', {
|
||||
['cursor-pointer text-stone-400 hover:text-stone-200']: filter,
|
||||
['text-stone-700 opacity-50 cursor-default']: !filter,
|
||||
})}
|
||||
onClick={() => filter && setFilter('')}
|
||||
role="button"
|
||||
aria-label="Clear search"
|
||||
aria-disabled={!filter}
|
||||
title={filter ? 'Clear' : 'Nothing to clear'}
|
||||
/>
|
||||
<InputText className="w-64" placeholder="Search" value={filter} onChange={e => setFilter(e.target.value)} />
|
||||
</IconField>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 p-3 overflow-x-hidden">
|
||||
<DataTable value={filtered} size="small" scrollable scrollHeight="flex" stripedRows>
|
||||
<Column header="Type" body={renderName} className="w-[160px]" bodyClassName="whitespace-normal break-words" />
|
||||
<Column header="Spawns In" body={renderSpawns} bodyClassName="whitespace-normal break-words text-[13px]" />
|
||||
<Column
|
||||
field="lifetime"
|
||||
header="Lifetime"
|
||||
className="w-[90px]"
|
||||
bodyClassName="whitespace-normal break-words text-[13px]"
|
||||
/>
|
||||
<Column
|
||||
header="Total Mass"
|
||||
className="w-[120px]"
|
||||
body={(w: WormholeDataRaw) => kgToTons(w.total_mass)}
|
||||
bodyClassName="whitespace-normal break-words text-[13px]"
|
||||
/>
|
||||
<Column
|
||||
header="Max/jump"
|
||||
className="w-[120px]"
|
||||
body={(w: WormholeDataRaw) => kgToTons(w.max_mass_per_jump)}
|
||||
bodyClassName="whitespace-normal break-words text-[13px]"
|
||||
/>
|
||||
<Column
|
||||
header="Respawn"
|
||||
className="w-[150px]"
|
||||
body={renderRespawn}
|
||||
bodyClassName="whitespace-normal break-words text-[13px]"
|
||||
/>
|
||||
</DataTable>
|
||||
</div>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export * from './WormholeSignaturesDialog';
|
||||
20
assets/js/hooks/Mapper/components/ui-kit/RespawnTag.tsx
Normal file
20
assets/js/hooks/Mapper/components/ui-kit/RespawnTag.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Respawn } from '@/hooks/Mapper/types';
|
||||
import clsx from 'clsx';
|
||||
|
||||
export const WORMHOLE_SPAWN_CLASSES_BG = {
|
||||
[Respawn.static]: 'bg-lime-400/80 text-stone-950',
|
||||
[Respawn.wandering]: 'bg-stone-800',
|
||||
[Respawn.reverse]: 'bg-blue-400 text-stone-950',
|
||||
};
|
||||
|
||||
type RespawnTagProps = { value: string };
|
||||
export const RespawnTag = ({ value }: RespawnTagProps) => (
|
||||
<span
|
||||
className={clsx(
|
||||
'px-[6px] py-[0px] rounded text-stone-300 text-[12px] font-[500] border border-stone-700',
|
||||
WORMHOLE_SPAWN_CLASSES_BG[value as Respawn],
|
||||
)}
|
||||
>
|
||||
{value}
|
||||
</span>
|
||||
);
|
||||
@@ -13,7 +13,7 @@ export type SystemViewProps = {
|
||||
|
||||
export const SystemView = ({ systemId, systemInfo: customSystemInfo, showCustomName, ...rest }: SystemViewProps) => {
|
||||
const memSystems = useMemo(() => [systemId], [systemId]);
|
||||
const { systems, loading } = useLoadSystemStatic({ systems: memSystems });
|
||||
const { systems, lastUpdateKey, loading } = useLoadSystemStatic({ systems: memSystems });
|
||||
|
||||
const {
|
||||
data: { systems: mapSystems },
|
||||
@@ -23,9 +23,10 @@ export const SystemView = ({ systemId, systemInfo: customSystemInfo, showCustomN
|
||||
if (!systemId) {
|
||||
return customSystemInfo;
|
||||
}
|
||||
|
||||
return systems.get(parseInt(systemId));
|
||||
// eslint-disable-next-line
|
||||
}, [customSystemInfo, systemId, systems, loading]);
|
||||
}, [customSystemInfo, systemId, systems, lastUpdateKey, loading]);
|
||||
|
||||
const mapSystemInfo = useMemo(() => {
|
||||
if (!showCustomName) {
|
||||
|
||||
@@ -23,3 +23,4 @@ export * from './MenuItemWithInfo';
|
||||
export * from './MarkdownTextViewer.tsx';
|
||||
export * from './WdButton.tsx';
|
||||
export * from './constants.ts';
|
||||
export * from './RespawnTag';
|
||||
|
||||
@@ -133,6 +133,16 @@ export const K162_TYPES: K162Type[] = [
|
||||
value: 'pochven',
|
||||
whClassName: 'F216',
|
||||
},
|
||||
{
|
||||
label: 'C1/C2/C3',
|
||||
value: 'c1_c2_c3',
|
||||
whClassName: 'E004_D382_L477',
|
||||
},
|
||||
{
|
||||
label: 'C4/C5',
|
||||
value: 'c4_c5',
|
||||
whClassName: 'M001_L614',
|
||||
},
|
||||
];
|
||||
|
||||
export const K162_TYPES_MAP: { [key: string]: K162Type } = K162_TYPES.reduce(
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
MapUnionTypes,
|
||||
OutCommandHandler,
|
||||
SolarSystemConnection,
|
||||
StringBoolean,
|
||||
TrackingCharacter,
|
||||
UseCharactersCacheData,
|
||||
UseCommentsData,
|
||||
@@ -28,12 +27,14 @@ import {
|
||||
MapSettings,
|
||||
MapUserSettings,
|
||||
OnTheMapSettingsType,
|
||||
RoutesByType,
|
||||
RoutesType,
|
||||
} from '@/hooks/Mapper/mapRootProvider/types.ts';
|
||||
import {
|
||||
DEFAULT_KILLS_WIDGET_SETTINGS,
|
||||
DEFAULT_MAP_SETTINGS,
|
||||
DEFAULT_ON_THE_MAP_SETTINGS,
|
||||
DEFAULT_ROUTES_BY_SETTINGS,
|
||||
DEFAULT_ROUTES_SETTINGS,
|
||||
DEFAULT_WIDGET_LOCAL_SETTINGS,
|
||||
STORED_INTERFACE_DEFAULT_VALUES,
|
||||
@@ -76,6 +77,8 @@ const INITIAL_DATA: MapRootData = {
|
||||
userHubs: [],
|
||||
routes: undefined,
|
||||
userRoutes: undefined,
|
||||
routesListBy: undefined,
|
||||
availableRoutesBy: [],
|
||||
kills: [],
|
||||
connections: [],
|
||||
detailedKills: {},
|
||||
@@ -132,6 +135,8 @@ export interface MapRootContextProps {
|
||||
setInterfaceSettings: Dispatch<SetStateAction<InterfaceStoredSettings>>;
|
||||
settingsRoutes: RoutesType;
|
||||
settingsRoutesUpdate: Dispatch<SetStateAction<RoutesType>>;
|
||||
settingsRoutesBy: RoutesByType;
|
||||
settingsRoutesByUpdate: Dispatch<SetStateAction<RoutesByType>>;
|
||||
settingsLocal: LocalWidgetSettings;
|
||||
settingsLocalUpdate: Dispatch<SetStateAction<LocalWidgetSettings>>;
|
||||
settingsSignatures: SignatureSettingsType;
|
||||
@@ -179,6 +184,8 @@ const MapRootContext = createContext<MapRootContextProps>({
|
||||
setInterfaceSettings: () => null,
|
||||
settingsRoutes: DEFAULT_ROUTES_SETTINGS,
|
||||
settingsRoutesUpdate: () => null,
|
||||
settingsRoutesBy: { ...DEFAULT_ROUTES_BY_SETTINGS, routes: { ...DEFAULT_ROUTES_BY_SETTINGS.routes } },
|
||||
settingsRoutesByUpdate: () => null,
|
||||
settingsLocal: DEFAULT_WIDGET_LOCAL_SETTINGS,
|
||||
settingsLocalUpdate: () => null,
|
||||
settingsSignatures: DEFAULT_SIGNATURE_SETTINGS,
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
MiniMapPlacement,
|
||||
OnTheMapSettingsType,
|
||||
PingsPlacement,
|
||||
RoutesByType,
|
||||
RoutesType,
|
||||
} from '@/hooks/Mapper/mapRootProvider/types.ts';
|
||||
import { DEFAULT_WIDGETS, STORED_VISIBLE_WIDGETS_DEFAULT } from '@/hooks/Mapper/components/mapInterface/constants.tsx';
|
||||
@@ -43,6 +44,12 @@ export const DEFAULT_WIDGET_LOCAL_SETTINGS: LocalWidgetSettings = {
|
||||
showShipName: false,
|
||||
};
|
||||
|
||||
export const DEFAULT_ROUTES_BY_SETTINGS: RoutesByType = {
|
||||
routes: DEFAULT_ROUTES_SETTINGS,
|
||||
scope: 'ALL',
|
||||
type: 'blueLoot',
|
||||
};
|
||||
|
||||
export const DEFAULT_ON_THE_MAP_SETTINGS: OnTheMapSettingsType = {
|
||||
hideOffline: false,
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
DEFAULT_KILLS_WIDGET_SETTINGS,
|
||||
DEFAULT_MAP_SETTINGS,
|
||||
DEFAULT_ON_THE_MAP_SETTINGS,
|
||||
DEFAULT_ROUTES_BY_SETTINGS,
|
||||
DEFAULT_ROUTES_SETTINGS,
|
||||
DEFAULT_WIDGET_LOCAL_SETTINGS,
|
||||
getDefaultWidgetProps,
|
||||
@@ -17,6 +18,11 @@ export const createWidgetSettings = <T>(settings: T) => {
|
||||
};
|
||||
|
||||
export const createDefaultStoredSettings = (): MapUserSettings => {
|
||||
const defaultRoutesBy = {
|
||||
...DEFAULT_ROUTES_BY_SETTINGS,
|
||||
routes: { ...DEFAULT_ROUTES_BY_SETTINGS.routes },
|
||||
};
|
||||
|
||||
return {
|
||||
version: STORED_SETTINGS_VERSION,
|
||||
migratedFromOld: false,
|
||||
@@ -24,6 +30,7 @@ export const createDefaultStoredSettings = (): MapUserSettings => {
|
||||
localWidget: createWidgetSettings(DEFAULT_WIDGET_LOCAL_SETTINGS),
|
||||
widgets: createWidgetSettings(getDefaultWidgetProps()),
|
||||
routes: createWidgetSettings(DEFAULT_ROUTES_SETTINGS),
|
||||
routesBy: createWidgetSettings(defaultRoutesBy),
|
||||
onTheMap: createWidgetSettings(DEFAULT_ON_THE_MAP_SETTINGS),
|
||||
signaturesWidget: createWidgetSettings(DEFAULT_SIGNATURE_SETTINGS),
|
||||
interface: createWidgetSettings(STORED_INTERFACE_DEFAULT_VALUES),
|
||||
@@ -43,6 +50,11 @@ export const getDefaultSettingsByType = (type: SettingsTypes): SettingsWrapper<a
|
||||
return createWidgetSettings(getDefaultWidgetProps());
|
||||
case SettingsTypes.routes:
|
||||
return createWidgetSettings(DEFAULT_ROUTES_SETTINGS);
|
||||
case SettingsTypes.routesBy:
|
||||
return createWidgetSettings({
|
||||
...DEFAULT_ROUTES_BY_SETTINGS,
|
||||
routes: { ...DEFAULT_ROUTES_BY_SETTINGS.routes },
|
||||
});
|
||||
case SettingsTypes.onTheMap:
|
||||
return createWidgetSettings(DEFAULT_ON_THE_MAP_SETTINGS);
|
||||
case SettingsTypes.signaturesWidget:
|
||||
|
||||
@@ -10,3 +10,4 @@ export * from './useCommandComments';
|
||||
export * from './useGetCacheCharacter';
|
||||
export * from './useCommandsActivity';
|
||||
export * from './useCommandPings';
|
||||
export * from './useCommandPingBlocked';
|
||||
|
||||
@@ -12,7 +12,7 @@ export const useCommandComments = () => {
|
||||
}, []);
|
||||
|
||||
const removeComment = useCallback((data: CommandCommentRemoved) => {
|
||||
ref.current.removeComment(data.solarSystemId.toString(), data.commentId);
|
||||
ref.current.removeComment(data.solarSystemId, data.commentId);
|
||||
}, []);
|
||||
|
||||
return { addComment, removeComment };
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { useToast } from '@/hooks/Mapper/ToastProvider';
|
||||
import { CommandPingBlocked } from '@/hooks/Mapper/types';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
export const useCommandPingBlocked = () => {
|
||||
const { show } = useToast();
|
||||
|
||||
const pingBlocked = useCallback(
|
||||
({ message }: CommandPingBlocked) => {
|
||||
show({
|
||||
severity: 'warn',
|
||||
summary: 'Cannot create ping',
|
||||
detail: message,
|
||||
life: 5000,
|
||||
});
|
||||
},
|
||||
[show],
|
||||
);
|
||||
|
||||
return { pingBlocked };
|
||||
};
|
||||
@@ -14,8 +14,8 @@ export const useCommandPings = () => {
|
||||
ref.current.update({ pings });
|
||||
}, []);
|
||||
|
||||
const pingCancelled = useCallback(({ type, id }: CommandPingCancelled) => {
|
||||
const newPings = ref.current.pings.filter(x => x.id !== id && x.type !== type);
|
||||
const pingCancelled = useCallback(({ id }: CommandPingCancelled) => {
|
||||
const newPings = ref.current.pings.filter(x => x.id !== id);
|
||||
ref.current.update({ pings: newPings });
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ export const useMapInit = () => {
|
||||
user_permissions,
|
||||
options,
|
||||
is_subscription_active,
|
||||
available_routes_by,
|
||||
main_character_eve_id,
|
||||
following_character_eve_id,
|
||||
user_hubs,
|
||||
@@ -85,6 +86,10 @@ export const useMapInit = () => {
|
||||
updateData.isSubscriptionActive = is_subscription_active;
|
||||
}
|
||||
|
||||
if (available_routes_by) {
|
||||
updateData.availableRoutesBy = available_routes_by;
|
||||
}
|
||||
|
||||
if (system_static_infos) {
|
||||
system_static_infos.forEach(static_info => {
|
||||
addSystemStatic(static_info);
|
||||
|
||||
@@ -112,3 +112,23 @@ export const useUserRoutes = () => {
|
||||
update({ userRoutes: value });
|
||||
}, []);
|
||||
};
|
||||
|
||||
export const useRoutesListBy = () => {
|
||||
const {
|
||||
update,
|
||||
data: { routesListBy },
|
||||
} = useMapRootState();
|
||||
|
||||
const ref = useRef({ update, routesListBy });
|
||||
ref.current = { update, routesListBy };
|
||||
|
||||
return useCallback((value: CommandRoutes) => {
|
||||
const { update, routesListBy } = ref.current;
|
||||
|
||||
if (areRoutesListsEqual(routesListBy, value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
update({ routesListBy: value });
|
||||
}, []);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useRef, useState } from 'react';
|
||||
import { CommentSystem, CommentType, OutCommand, OutCommandHandler, UseCommentsData } from '@/hooks/Mapper/types';
|
||||
import { useCallback, useRef, useState } from 'react';
|
||||
|
||||
interface UseCommentsProps {
|
||||
outCommand: OutCommandHandler;
|
||||
@@ -8,12 +8,12 @@ interface UseCommentsProps {
|
||||
export const useComments = ({ outCommand }: UseCommentsProps): UseCommentsData => {
|
||||
const [lastUpdateKey, setLastUpdateKey] = useState(0);
|
||||
|
||||
const commentBySystemsRef = useRef<Map<string, CommentSystem>>(new Map());
|
||||
const commentBySystemsRef = useRef<Map<number, CommentSystem>>(new Map());
|
||||
|
||||
const ref = useRef({ outCommand });
|
||||
ref.current = { outCommand };
|
||||
|
||||
const loadComments = useCallback(async (systemId: string) => {
|
||||
const loadComments = useCallback(async (systemId: number) => {
|
||||
let cSystem = commentBySystemsRef.current.get(systemId);
|
||||
if (cSystem?.loading || cSystem?.loaded) {
|
||||
return;
|
||||
@@ -45,7 +45,7 @@ export const useComments = ({ outCommand }: UseCommentsProps): UseCommentsData =
|
||||
setLastUpdateKey(x => x + 1);
|
||||
}, []);
|
||||
|
||||
const addComment = useCallback((systemId: string, comment: CommentType) => {
|
||||
const addComment = useCallback((systemId: number, comment: CommentType) => {
|
||||
const cSystem = commentBySystemsRef.current.get(systemId);
|
||||
if (cSystem) {
|
||||
cSystem.comments.push(comment);
|
||||
@@ -61,7 +61,7 @@ export const useComments = ({ outCommand }: UseCommentsProps): UseCommentsData =
|
||||
setLastUpdateKey(x => x + 1);
|
||||
}, []);
|
||||
|
||||
const removeComment = useCallback((systemId: string, commentId: string) => {
|
||||
const removeComment = useCallback((systemId: number, commentId: string) => {
|
||||
const cSystem = commentBySystemsRef.current.get(systemId);
|
||||
if (!cSystem) {
|
||||
return;
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
CommandLinkSignatureToSystem,
|
||||
CommandMapUpdated,
|
||||
CommandPingAdded,
|
||||
CommandPingBlocked,
|
||||
CommandPingCancelled,
|
||||
CommandPresentCharacters,
|
||||
CommandRemoveConnections,
|
||||
@@ -29,6 +30,7 @@ import { ForwardedRef, useImperativeHandle } from 'react';
|
||||
|
||||
import {
|
||||
useCommandComments,
|
||||
useCommandPingBlocked,
|
||||
useCommandPings,
|
||||
useCommandsCharacters,
|
||||
useCommandsConnections,
|
||||
@@ -36,6 +38,7 @@ import {
|
||||
useMapInit,
|
||||
useMapUpdated,
|
||||
useRoutes,
|
||||
useRoutesListBy,
|
||||
useUserRoutes,
|
||||
} from './api';
|
||||
|
||||
@@ -59,131 +62,134 @@ export const useMapRootHandlers = (ref: ForwardedRef<MapHandlers>) => {
|
||||
const mapUpdated = useMapUpdated();
|
||||
const mapRoutes = useRoutes();
|
||||
const mapUserRoutes = useUserRoutes();
|
||||
const mapRoutesListBy = useRoutesListBy();
|
||||
const { addComment, removeComment } = useCommandComments();
|
||||
const { pingAdded, pingCancelled } = useCommandPings();
|
||||
const { pingBlocked } = useCommandPingBlocked();
|
||||
const { characterActivityData, trackingCharactersData, userSettingsUpdated } = useCommandsActivity();
|
||||
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
() => {
|
||||
return {
|
||||
command(type, data) {
|
||||
switch (type) {
|
||||
case Commands.init: // USED
|
||||
mapInit(data as CommandInit);
|
||||
break;
|
||||
case Commands.addSystems: // USED
|
||||
addSystems(data as CommandAddSystems);
|
||||
break;
|
||||
case Commands.updateSystems: // USED
|
||||
updateSystems(data as CommandUpdateSystems);
|
||||
break;
|
||||
case Commands.removeSystems: // USED
|
||||
removeSystems(data as CommandRemoveSystems);
|
||||
break;
|
||||
case Commands.addConnections: // USED
|
||||
addConnections(data as CommandAddConnections);
|
||||
break;
|
||||
case Commands.removeConnections: // USED
|
||||
removeConnections(data as CommandRemoveConnections);
|
||||
break;
|
||||
case Commands.updateConnection: // USED
|
||||
updateConnection(data as CommandUpdateConnection);
|
||||
break;
|
||||
case Commands.charactersUpdated: // USED
|
||||
charactersUpdated(data as CommandCharactersUpdated);
|
||||
break;
|
||||
case Commands.characterAdded: // USED
|
||||
characterAdded(data as CommandCharacterAdded);
|
||||
break;
|
||||
case Commands.characterRemoved: // USED
|
||||
characterRemoved(data as CommandCharacterRemoved);
|
||||
break;
|
||||
case Commands.characterUpdated: // USED
|
||||
characterUpdated(data as CommandCharacterUpdated);
|
||||
break;
|
||||
case Commands.presentCharacters: // USED
|
||||
presentCharacters(data as CommandPresentCharacters);
|
||||
break;
|
||||
case Commands.mapUpdated: // USED
|
||||
mapUpdated(data as CommandMapUpdated);
|
||||
break;
|
||||
case Commands.routes:
|
||||
mapRoutes(data as CommandRoutes);
|
||||
break;
|
||||
case Commands.userRoutes:
|
||||
mapUserRoutes(data as CommandRoutes);
|
||||
break;
|
||||
useImperativeHandle(ref, () => {
|
||||
return {
|
||||
command(type, data) {
|
||||
switch (type) {
|
||||
case Commands.init: // USED
|
||||
mapInit(data as CommandInit);
|
||||
break;
|
||||
case Commands.addSystems: // USED
|
||||
addSystems(data as CommandAddSystems);
|
||||
break;
|
||||
case Commands.updateSystems: // USED
|
||||
updateSystems(data as CommandUpdateSystems);
|
||||
break;
|
||||
case Commands.removeSystems: // USED
|
||||
removeSystems(data as CommandRemoveSystems);
|
||||
break;
|
||||
case Commands.addConnections: // USED
|
||||
addConnections(data as CommandAddConnections);
|
||||
break;
|
||||
case Commands.removeConnections: // USED
|
||||
removeConnections(data as CommandRemoveConnections);
|
||||
break;
|
||||
case Commands.updateConnection: // USED
|
||||
updateConnection(data as CommandUpdateConnection);
|
||||
break;
|
||||
case Commands.charactersUpdated: // USED
|
||||
charactersUpdated(data as CommandCharactersUpdated);
|
||||
break;
|
||||
case Commands.characterAdded: // USED
|
||||
characterAdded(data as CommandCharacterAdded);
|
||||
break;
|
||||
case Commands.characterRemoved: // USED
|
||||
characterRemoved(data as CommandCharacterRemoved);
|
||||
break;
|
||||
case Commands.characterUpdated: // USED
|
||||
characterUpdated(data as CommandCharacterUpdated);
|
||||
break;
|
||||
case Commands.presentCharacters: // USED
|
||||
presentCharacters(data as CommandPresentCharacters);
|
||||
break;
|
||||
case Commands.mapUpdated: // USED
|
||||
mapUpdated(data as CommandMapUpdated);
|
||||
break;
|
||||
case Commands.routes:
|
||||
mapRoutes(data as CommandRoutes);
|
||||
break;
|
||||
case Commands.userRoutes:
|
||||
mapUserRoutes(data as CommandRoutes);
|
||||
break;
|
||||
case Commands.routesListBy:
|
||||
mapRoutesListBy(data as CommandRoutes);
|
||||
break;
|
||||
|
||||
case Commands.signaturesUpdated: // USED
|
||||
updateSystemSignatures(data as CommandSignaturesUpdated);
|
||||
break;
|
||||
case Commands.signaturesUpdated: // USED
|
||||
updateSystemSignatures(data as CommandSignaturesUpdated);
|
||||
break;
|
||||
|
||||
case Commands.linkSignatureToSystem: // USED
|
||||
setTimeout(() => {
|
||||
updateLinkSignatureToSystem(data as CommandLinkSignatureToSystem);
|
||||
}, 200);
|
||||
break;
|
||||
case Commands.linkSignatureToSystem: // USED
|
||||
setTimeout(() => {
|
||||
updateLinkSignatureToSystem(data as CommandLinkSignatureToSystem);
|
||||
}, 200);
|
||||
break;
|
||||
|
||||
case Commands.centerSystem: // USED
|
||||
// do nothing here
|
||||
break;
|
||||
case Commands.centerSystem: // USED
|
||||
// do nothing here
|
||||
break;
|
||||
|
||||
case Commands.selectSystem: // USED
|
||||
// do nothing here
|
||||
break;
|
||||
case Commands.selectSystem: // USED
|
||||
// do nothing here
|
||||
break;
|
||||
|
||||
case Commands.killsUpdated:
|
||||
// do nothing here
|
||||
break;
|
||||
case Commands.killsUpdated:
|
||||
// do nothing here
|
||||
break;
|
||||
|
||||
case Commands.detailedKillsUpdated:
|
||||
updateDetailedKills(data as Record<string, DetailedKill[]>);
|
||||
break;
|
||||
case Commands.detailedKillsUpdated:
|
||||
updateDetailedKills(data as Record<string, DetailedKill[]>);
|
||||
break;
|
||||
|
||||
case Commands.characterActivityData:
|
||||
characterActivityData(data as CommandCharacterActivityData);
|
||||
break;
|
||||
case Commands.characterActivityData:
|
||||
characterActivityData(data as CommandCharacterActivityData);
|
||||
break;
|
||||
|
||||
case Commands.trackingCharactersData:
|
||||
trackingCharactersData(data as CommandTrackingCharactersData);
|
||||
break;
|
||||
case Commands.trackingCharactersData:
|
||||
trackingCharactersData(data as CommandTrackingCharactersData);
|
||||
break;
|
||||
|
||||
case Commands.updateActivity:
|
||||
break;
|
||||
case Commands.updateActivity:
|
||||
break;
|
||||
|
||||
case Commands.updateTracking:
|
||||
break;
|
||||
case Commands.updateTracking:
|
||||
break;
|
||||
|
||||
case Commands.userSettingsUpdated:
|
||||
userSettingsUpdated(data as CommandUserSettingsUpdated);
|
||||
break;
|
||||
case Commands.userSettingsUpdated:
|
||||
userSettingsUpdated(data as CommandUserSettingsUpdated);
|
||||
break;
|
||||
|
||||
case Commands.systemCommentAdded:
|
||||
addComment(data as CommandCommentAdd);
|
||||
break;
|
||||
case Commands.systemCommentAdded:
|
||||
addComment(data as CommandCommentAdd);
|
||||
break;
|
||||
|
||||
case Commands.systemCommentRemoved:
|
||||
removeComment(data as CommandCommentRemoved);
|
||||
break;
|
||||
case Commands.systemCommentRemoved:
|
||||
removeComment(data as CommandCommentRemoved);
|
||||
break;
|
||||
|
||||
case Commands.pingAdded:
|
||||
pingAdded(data as CommandPingAdded);
|
||||
break;
|
||||
case Commands.pingAdded:
|
||||
pingAdded(data as CommandPingAdded);
|
||||
break;
|
||||
|
||||
case Commands.pingCancelled:
|
||||
pingCancelled(data as CommandPingCancelled);
|
||||
break;
|
||||
case Commands.pingCancelled:
|
||||
pingCancelled(data as CommandPingCancelled);
|
||||
break;
|
||||
case Commands.pingBlocked:
|
||||
pingBlocked(data as CommandPingBlocked);
|
||||
break;
|
||||
default:
|
||||
console.warn(`JOipP Interface handlers: Unknown command: ${type}`, data);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
console.warn(`JOipP Interface handlers: Unknown command: ${type}`, data);
|
||||
break;
|
||||
}
|
||||
|
||||
emitMapEvent({ name: type, data });
|
||||
},
|
||||
};
|
||||
},
|
||||
[],
|
||||
);
|
||||
emitMapEvent({ name: type, data });
|
||||
},
|
||||
};
|
||||
}, []);
|
||||
};
|
||||
|
||||
@@ -56,6 +56,12 @@ export const useMapUserSettings = ({ map_slug }: MapRootData, outCommand: OutCom
|
||||
map_slug,
|
||||
'routes',
|
||||
);
|
||||
const [settingsRoutesBy, settingsRoutesByUpdate] = useSettingsValueAndSetter(
|
||||
mapUserSettings,
|
||||
setMapUserSettings,
|
||||
map_slug,
|
||||
'routesBy',
|
||||
);
|
||||
|
||||
const [settingsLocal, settingsLocalUpdate] = useSettingsValueAndSetter(
|
||||
mapUserSettings,
|
||||
@@ -188,6 +194,8 @@ export const useMapUserSettings = ({ map_slug }: MapRootData, outCommand: OutCom
|
||||
setInterfaceSettings,
|
||||
settingsRoutes,
|
||||
settingsRoutesUpdate,
|
||||
settingsRoutesBy,
|
||||
settingsRoutesByUpdate,
|
||||
settingsLocal,
|
||||
settingsLocalUpdate,
|
||||
settingsSignatures,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { to_1 } from './to_1.ts';
|
||||
import { to_2 } from './to_2.ts';
|
||||
import { to_3 } from './to_3.ts';
|
||||
import { MigrationStructure } from '@/hooks/Mapper/mapRootProvider/types.ts';
|
||||
|
||||
export default [to_1, to_2] as MigrationStructure[];
|
||||
export default [to_1, to_2, to_3] as MigrationStructure[];
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { MigrationStructure } from '@/hooks/Mapper/mapRootProvider/types.ts';
|
||||
import { DEFAULT_ROUTES_BY_SETTINGS, DEFAULT_ROUTES_SETTINGS } from '@/hooks/Mapper/mapRootProvider/constants.ts';
|
||||
|
||||
export const to_3: MigrationStructure = {
|
||||
to: 3,
|
||||
up: (prev: any) => {
|
||||
const rawRoutesBy = prev?.routesBy;
|
||||
const hasStructuredRoutesBy =
|
||||
rawRoutesBy && typeof rawRoutesBy === 'object' && 'routes' in rawRoutesBy;
|
||||
|
||||
const routes = hasStructuredRoutesBy
|
||||
? { ...DEFAULT_ROUTES_SETTINGS, ...rawRoutesBy.routes }
|
||||
: { ...DEFAULT_ROUTES_SETTINGS, ...(rawRoutesBy ?? prev?.routes ?? {}) };
|
||||
|
||||
const scopeRaw = hasStructuredRoutesBy ? rawRoutesBy?.scope : undefined;
|
||||
const scope = scopeRaw === 'HIGH' ? 'HIGH' : 'ALL';
|
||||
|
||||
const type = hasStructuredRoutesBy && rawRoutesBy?.type ? rawRoutesBy.type : DEFAULT_ROUTES_BY_SETTINGS.type;
|
||||
|
||||
return {
|
||||
...prev,
|
||||
routesBy: {
|
||||
...DEFAULT_ROUTES_BY_SETTINGS,
|
||||
...(hasStructuredRoutesBy ? rawRoutesBy : {}),
|
||||
scope,
|
||||
type,
|
||||
routes,
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -47,6 +47,22 @@ export type RoutesType = {
|
||||
avoid: number[];
|
||||
};
|
||||
|
||||
export type RoutesByCategoryType =
|
||||
| 'blueLoot'
|
||||
| 'redLoot'
|
||||
| 'thera'
|
||||
| 'turnur'
|
||||
| 'so_cleaning'
|
||||
| 'trade_hubs';
|
||||
|
||||
export type RoutesByScopeType = 'ALL' | 'HIGH';
|
||||
|
||||
export type RoutesByType = {
|
||||
routes: RoutesType;
|
||||
scope: RoutesByScopeType;
|
||||
type: RoutesByCategoryType;
|
||||
};
|
||||
|
||||
export type LocalWidgetSettings = {
|
||||
compact: boolean;
|
||||
showOffline: boolean;
|
||||
@@ -79,6 +95,7 @@ export type MapUserSettings = {
|
||||
interface: SettingsWrapper<InterfaceStoredSettings>;
|
||||
onTheMap: SettingsWrapper<OnTheMapSettingsType>;
|
||||
routes: SettingsWrapper<RoutesType>;
|
||||
routesBy: SettingsWrapper<RoutesByType>;
|
||||
localWidget: SettingsWrapper<LocalWidgetSettings>;
|
||||
signaturesWidget: SettingsWrapper<SignatureSettingsType>;
|
||||
killsWidget: SettingsWrapper<KillsWidgetSettings>;
|
||||
@@ -98,6 +115,7 @@ export enum SettingsTypes {
|
||||
localWidget = 'localWidget',
|
||||
widgets = 'widgets',
|
||||
routes = 'routes',
|
||||
routesBy = 'routesBy',
|
||||
onTheMap = 'onTheMap',
|
||||
signaturesWidget = 'signaturesWidget',
|
||||
interface = 'interface',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const STORED_SETTINGS_VERSION = 2;
|
||||
export const STORED_SETTINGS_VERSION = 3;
|
||||
|
||||
export const LS_KEY_LEGASY = 'map-user-settings';
|
||||
export const LS_KEY = 'map-user-settings-v3';
|
||||
|
||||
@@ -13,9 +13,9 @@ export type CommentSystem = {
|
||||
};
|
||||
|
||||
export interface UseCommentsData {
|
||||
loadComments: (systemId: string) => Promise<void>;
|
||||
addComment: (systemId: string, comment: CommentType) => void;
|
||||
removeComment: (systemId: string, commentId: string) => void;
|
||||
comments: Map<string, CommentSystem>;
|
||||
loadComments: (systemId: number) => Promise<void>;
|
||||
addComment: (systemId: number, comment: CommentType) => void;
|
||||
removeComment: (systemId: number, commentId: string) => void;
|
||||
comments: Map<number, CommentSystem>;
|
||||
lastUpdateKey: number;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { ActivitySummary, CharacterTypeRaw, TrackingCharacter } from '@/hooks/Ma
|
||||
import { SolarSystemConnection } from '@/hooks/Mapper/types/connection.ts';
|
||||
import { DetailedKill, Kill } from '@/hooks/Mapper/types/kills.ts';
|
||||
import { RoutesList } from '@/hooks/Mapper/types/routes.ts';
|
||||
import { RoutesByCategoryType } from '@/hooks/Mapper/mapRootProvider/types.ts';
|
||||
import { SolarSystemRawType, SolarSystemStaticInfoRaw } from '@/hooks/Mapper/types/system.ts';
|
||||
import { WormholeDataRaw } from '@/hooks/Mapper/types/wormholes.ts';
|
||||
|
||||
@@ -25,6 +26,7 @@ export enum Commands {
|
||||
detailedKillsUpdated = 'detailed_kills_updated',
|
||||
routes = 'routes',
|
||||
userRoutes = 'user_routes',
|
||||
routesListBy = 'routes_list_by',
|
||||
centerSystem = 'center_system',
|
||||
selectSystem = 'select_system',
|
||||
selectSystems = 'select_systems',
|
||||
@@ -38,8 +40,10 @@ export enum Commands {
|
||||
updateTracking = 'update_tracking',
|
||||
userSettingsUpdated = 'user_settings_updated',
|
||||
showTracking = 'show_tracking',
|
||||
refreshTrackingData = 'refresh_tracking_data',
|
||||
pingAdded = 'ping_added',
|
||||
pingCancelled = 'ping_cancelled',
|
||||
pingBlocked = 'ping_blocked',
|
||||
}
|
||||
|
||||
export type Command =
|
||||
@@ -60,6 +64,7 @@ export type Command =
|
||||
| Commands.detailedKillsUpdated
|
||||
| Commands.routes
|
||||
| Commands.userRoutes
|
||||
| Commands.routesListBy
|
||||
| Commands.selectSystem
|
||||
| Commands.selectSystems
|
||||
| Commands.centerSystem
|
||||
@@ -74,8 +79,10 @@ export type Command =
|
||||
| Commands.updateActivity
|
||||
| Commands.updateTracking
|
||||
| Commands.showTracking
|
||||
| Commands.refreshTrackingData
|
||||
| Commands.pingAdded
|
||||
| Commands.pingCancelled;
|
||||
| Commands.pingCancelled
|
||||
| Commands.pingBlocked;
|
||||
|
||||
export type CommandInit = {
|
||||
systems: SolarSystemRawType[];
|
||||
@@ -97,6 +104,7 @@ export type CommandInit = {
|
||||
options: MapOptions;
|
||||
reset?: boolean;
|
||||
is_subscription_active?: boolean;
|
||||
available_routes_by?: RoutesByCategoryType[];
|
||||
main_character_eve_id?: string | null;
|
||||
following_character_eve_id?: string | null;
|
||||
map_slug?: string;
|
||||
@@ -117,6 +125,7 @@ export type CommandSignaturesUpdated = string;
|
||||
export type CommandMapUpdated = Partial<CommandInit>;
|
||||
export type CommandRoutes = RoutesList;
|
||||
export type CommandUserRoutes = RoutesList;
|
||||
export type CommandRoutesListBy = RoutesList;
|
||||
export type CommandKillsUpdated = Kill[];
|
||||
export type CommandDetailedKillsUpdated = Record<string, DetailedKill[]>;
|
||||
export type CommandSelectSystem = string | undefined;
|
||||
@@ -131,7 +140,7 @@ export type CommandLinkSignatureToSystem = {
|
||||
};
|
||||
export type CommandLinkSignaturesUpdated = number;
|
||||
export type CommandCommentAdd = {
|
||||
solarSystemId: string;
|
||||
solarSystemId: number;
|
||||
comment: CommentType;
|
||||
};
|
||||
export type CommandCommentRemoved = {
|
||||
@@ -145,6 +154,7 @@ export type CommandUserSettingsUpdated = {
|
||||
};
|
||||
|
||||
export type CommandShowTracking = null;
|
||||
export type CommandRefreshTrackingData = Record<string, never>;
|
||||
export type CommandUpdateActivity = {
|
||||
characterId: number;
|
||||
systemId: number;
|
||||
@@ -158,6 +168,10 @@ export type CommandUpdateTracking = {
|
||||
};
|
||||
export type CommandPingAdded = PingData[];
|
||||
export type CommandPingCancelled = Pick<PingData, 'type' | 'id'>;
|
||||
export type CommandPingBlocked = {
|
||||
reason: string;
|
||||
message: string;
|
||||
};
|
||||
|
||||
export interface UserSettings {
|
||||
primaryCharacterId?: string;
|
||||
@@ -190,6 +204,7 @@ export interface CommandData {
|
||||
[Commands.mapUpdated]: CommandMapUpdated;
|
||||
[Commands.routes]: CommandRoutes;
|
||||
[Commands.userRoutes]: CommandUserRoutes;
|
||||
[Commands.routesListBy]: CommandRoutesListBy;
|
||||
[Commands.killsUpdated]: CommandKillsUpdated;
|
||||
[Commands.detailedKillsUpdated]: CommandDetailedKillsUpdated;
|
||||
[Commands.selectSystem]: CommandSelectSystem;
|
||||
@@ -206,8 +221,10 @@ export interface CommandData {
|
||||
[Commands.systemCommentRemoved]: CommandCommentRemoved;
|
||||
[Commands.systemCommentsUpdated]: unknown;
|
||||
[Commands.showTracking]: CommandShowTracking;
|
||||
[Commands.refreshTrackingData]: CommandRefreshTrackingData;
|
||||
[Commands.pingAdded]: CommandPingAdded;
|
||||
[Commands.pingCancelled]: CommandPingCancelled;
|
||||
[Commands.pingBlocked]: CommandPingBlocked;
|
||||
}
|
||||
|
||||
export interface MapHandlers {
|
||||
@@ -221,6 +238,7 @@ export enum OutCommand {
|
||||
deleteUserHub = 'delete_user_hub',
|
||||
getRoutes = 'get_routes',
|
||||
getUserRoutes = 'get_user_routes',
|
||||
getRoutesBy = 'get_routes_by',
|
||||
getCharacterJumps = 'get_character_jumps',
|
||||
getStructures = 'get_structures',
|
||||
getSignatures = 'get_signatures',
|
||||
|
||||
@@ -6,6 +6,7 @@ import { RoutesList } from '@/hooks/Mapper/types/routes.ts';
|
||||
import { SolarSystemConnection } from '@/hooks/Mapper/types/connection.ts';
|
||||
import { MapOptions, PingData, UserPermissions } from '@/hooks/Mapper/types';
|
||||
import { SystemSignature } from '@/hooks/Mapper/types/signatures';
|
||||
import { RoutesByCategoryType } from '@/hooks/Mapper/mapRootProvider/types.ts';
|
||||
|
||||
export type MapUnionTypes = {
|
||||
wormholesData: Record<string, WormholeDataRaw>;
|
||||
@@ -20,6 +21,8 @@ export type MapUnionTypes = {
|
||||
systemSignatures: Record<string, SystemSignature[]>;
|
||||
routes?: RoutesList;
|
||||
userRoutes?: RoutesList;
|
||||
routesListBy?: RoutesList;
|
||||
availableRoutesBy?: RoutesByCategoryType[];
|
||||
kills: Record<number, number>;
|
||||
connections: SolarSystemConnection[];
|
||||
userPermissions: Partial<UserPermissions>;
|
||||
|
||||
@@ -13,12 +13,19 @@ export type SystemStaticInfoShort = Pick<
|
||||
|
||||
type MappedSystem = SolarSystemStaticInfoRaw | undefined;
|
||||
|
||||
export type RouteStationSummary = {
|
||||
station_id: number;
|
||||
station_name: string;
|
||||
special?: boolean;
|
||||
};
|
||||
|
||||
export type Route = {
|
||||
destination: number;
|
||||
has_connection: boolean;
|
||||
origin: number;
|
||||
systems?: number[];
|
||||
mapped_systems?: MappedSystem[];
|
||||
stations?: RouteStationSummary[];
|
||||
success?: boolean;
|
||||
};
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ export default {
|
||||
};
|
||||
|
||||
refreshZone.addEventListener('click', handleUpdate);
|
||||
refreshZone.addEventListener('mouseover', handleUpdate);
|
||||
// refreshZone.addEventListener('mouseover', handleUpdate);
|
||||
|
||||
this.updated();
|
||||
},
|
||||
|
||||
BIN
assets/static/images/news/2026/01-01-roadmap/cover.webp
Normal file
BIN
assets/static/images/news/2026/01-01-roadmap/cover.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
BIN
assets/static/images/news/2026/01-05-weekly-giveaway/cover.webp
Normal file
BIN
assets/static/images/news/2026/01-05-weekly-giveaway/cover.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
@@ -63,6 +63,7 @@ config :wanderer_app, WandererAppWeb.Endpoint,
|
||||
]
|
||||
|
||||
config :wanderer_app,
|
||||
environment: :dev,
|
||||
dev_routes: true
|
||||
|
||||
# Do not include metadata nor timestamps in development logs
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import Config
|
||||
|
||||
# Set environment at compile time for modules using Application.compile_env
|
||||
config :wanderer_app, environment: :prod
|
||||
|
||||
# Note we also include the path to a cache manifest
|
||||
# containing the digested version of static files. This
|
||||
# manifest is generated by the `mix assets.deploy` task,
|
||||
|
||||
@@ -92,6 +92,31 @@ map_subscription_extra_hubs_10_price =
|
||||
config_dir
|
||||
|> get_int_from_path_or_env("WANDERER_MAP_SUBSCRIPTION_EXTRA_HUBS_10_PRICE", 10_000_000)
|
||||
|
||||
# Parse promo codes from environment variable
|
||||
# Format: "CODE1:10,CODE2:20" where numbers are discount percentages
|
||||
promo_codes =
|
||||
config_dir
|
||||
|> get_var_from_path_or_env("WANDERER_PROMO_CODES", "")
|
||||
|> case do
|
||||
"" ->
|
||||
%{}
|
||||
|
||||
codes_string ->
|
||||
codes_string
|
||||
|> String.split(",")
|
||||
|> Enum.map(fn entry ->
|
||||
case String.split(String.trim(entry), ":") do
|
||||
[code, discount] ->
|
||||
{String.upcase(String.trim(code)), String.to_integer(String.trim(discount))}
|
||||
|
||||
_ ->
|
||||
nil
|
||||
end
|
||||
end)
|
||||
|> Enum.reject(&is_nil/1)
|
||||
|> Map.new()
|
||||
end
|
||||
|
||||
map_connection_auto_expire_hours =
|
||||
config_dir
|
||||
|> get_int_from_path_or_env("WANDERER_MAP_CONNECTION_AUTO_EXPIRE_HOURS", 24)
|
||||
@@ -176,7 +201,8 @@ config :wanderer_app,
|
||||
}
|
||||
],
|
||||
extra_characters_50: map_subscription_extra_characters_50_price,
|
||||
extra_hubs_10: map_subscription_extra_hubs_10_price
|
||||
extra_hubs_10: map_subscription_extra_hubs_10_price,
|
||||
promo_codes: promo_codes
|
||||
},
|
||||
# Finch pool configuration - separate pools for different services
|
||||
# ESI Character Tracking pool - high capacity for bulk character operations
|
||||
@@ -264,7 +290,7 @@ config :logger,
|
||||
case config_env() do
|
||||
:prod -> "info"
|
||||
:dev -> "info"
|
||||
:test -> "debug"
|
||||
:test -> "warning"
|
||||
end
|
||||
)
|
||||
)
|
||||
@@ -432,7 +458,7 @@ config :wanderer_app, :license_manager,
|
||||
config :wanderer_app, :sse,
|
||||
enabled:
|
||||
config_dir
|
||||
|> get_var_from_path_or_env("WANDERER_SSE_ENABLED", "true")
|
||||
|> get_var_from_path_or_env("WANDERER_SSE_ENABLED", "false")
|
||||
|> String.to_existing_atom(),
|
||||
max_connections_total:
|
||||
config_dir |> get_int_from_path_or_env("WANDERER_SSE_MAX_CONNECTIONS", 1000),
|
||||
@@ -447,6 +473,6 @@ config :wanderer_app, :sse,
|
||||
config :wanderer_app, :external_events,
|
||||
webhooks_enabled:
|
||||
config_dir
|
||||
|> get_var_from_path_or_env("WANDERER_WEBHOOKS_ENABLED", "true")
|
||||
|> get_var_from_path_or_env("WANDERER_WEBHOOKS_ENABLED", "false")
|
||||
|> String.to_existing_atom(),
|
||||
webhook_timeout_ms: config_dir |> get_int_from_path_or_env("WANDERER_WEBHOOK_TIMEOUT_MS", 15000)
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import Config
|
||||
|
||||
# Disable Ash async operations in tests to ensure transactional safety
|
||||
# This prevents Ash from spawning tasks that could bypass the Ecto sandbox
|
||||
config :ash, :disable_async?, true
|
||||
|
||||
# Configure your database
|
||||
#
|
||||
# The MIX_TEST_PARTITION environment variable can be used
|
||||
@@ -24,7 +28,11 @@ config :wanderer_app,
|
||||
pubsub_client: Test.PubSubMock,
|
||||
cached_info: WandererApp.CachedInfo.Mock,
|
||||
character_api_disabled: false,
|
||||
environment: :test
|
||||
environment: :test,
|
||||
map_subscriptions_enabled: false,
|
||||
wanderer_kills_service_enabled: false,
|
||||
sse: [enabled: false],
|
||||
external_events: [webhooks_enabled: false]
|
||||
|
||||
# We don't run a server during test. If one is required,
|
||||
# you can enable the server option below.
|
||||
|
||||
@@ -16,6 +16,11 @@ defmodule WandererApp.Api.AccessList do
|
||||
|
||||
includes([:owner, :members])
|
||||
|
||||
default_fields([
|
||||
:name,
|
||||
:description
|
||||
])
|
||||
|
||||
derive_filter?(true)
|
||||
derive_sort?(true)
|
||||
|
||||
@@ -60,19 +65,17 @@ defmodule WandererApp.Api.AccessList do
|
||||
# Added :api_key to the accepted attributes
|
||||
accept [:name, :description, :owner_id, :api_key]
|
||||
primary?(true)
|
||||
|
||||
argument :owner_id, :uuid, allow_nil?: false
|
||||
|
||||
change manage_relationship(:owner_id, :owner, on_lookup: :relate, on_no_match: nil)
|
||||
end
|
||||
|
||||
update :update do
|
||||
accept [:name, :description, :owner_id, :api_key]
|
||||
primary?(true)
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :assign_owner do
|
||||
accept [:owner_id]
|
||||
require_atomic? false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -81,12 +84,15 @@ defmodule WandererApp.Api.AccessList do
|
||||
|
||||
attribute :name, :string do
|
||||
allow_nil? false
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :description, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
# Note: api_key intentionally not public for security
|
||||
attribute :api_key, :string do
|
||||
allow_nil? true
|
||||
end
|
||||
|
||||
@@ -16,6 +16,14 @@ defmodule WandererApp.Api.AccessListMember do
|
||||
|
||||
includes([:access_list])
|
||||
|
||||
default_fields([
|
||||
:name,
|
||||
:eve_character_id,
|
||||
:eve_corporation_id,
|
||||
:eve_alliance_id,
|
||||
:role
|
||||
])
|
||||
|
||||
derive_filter?(true)
|
||||
derive_sort?(true)
|
||||
|
||||
@@ -53,7 +61,11 @@ defmodule WandererApp.Api.AccessListMember do
|
||||
:role
|
||||
]
|
||||
|
||||
defaults [:create, :read, :update, :destroy]
|
||||
defaults [:create, :read, :destroy]
|
||||
|
||||
update :update do
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
read :read_by_access_list do
|
||||
argument(:access_list_id, :string, allow_nil?: false)
|
||||
@@ -67,12 +79,14 @@ defmodule WandererApp.Api.AccessListMember do
|
||||
|
||||
update :block do
|
||||
accept([])
|
||||
require_atomic? false
|
||||
|
||||
change(set_attribute(:blocked, true))
|
||||
end
|
||||
|
||||
update :unblock do
|
||||
accept([])
|
||||
require_atomic? false
|
||||
|
||||
change(set_attribute(:blocked, false))
|
||||
end
|
||||
@@ -83,22 +97,27 @@ defmodule WandererApp.Api.AccessListMember do
|
||||
|
||||
attribute :name, :string do
|
||||
allow_nil? false
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :eve_character_id, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :eve_corporation_id, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :eve_alliance_id, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :role, :atom do
|
||||
default "viewer"
|
||||
public? true
|
||||
|
||||
constraints(
|
||||
one_of: [
|
||||
|
||||
80
lib/wanderer_app/api/actor_helpers.ex
Normal file
80
lib/wanderer_app/api/actor_helpers.ex
Normal file
@@ -0,0 +1,80 @@
|
||||
defmodule WandererApp.Api.ActorHelpers do
|
||||
@moduledoc """
|
||||
Utilities for extracting actor information from Ash contexts.
|
||||
|
||||
Provides helper functions for working with ActorWithMap and extracting
|
||||
user, map, and character information from various context formats.
|
||||
"""
|
||||
|
||||
alias WandererApp.Api.ActorWithMap
|
||||
|
||||
@doc """
|
||||
Extract map from actor or context.
|
||||
|
||||
Handles various context formats:
|
||||
- Direct ActorWithMap struct
|
||||
- Context map with :actor key
|
||||
- Context map with :map key
|
||||
- Ash.Resource.Change.Context struct
|
||||
"""
|
||||
def get_map(%{actor: %ActorWithMap{map: %{} = map}}), do: map
|
||||
def get_map(%{map: %{} = map}), do: map
|
||||
|
||||
# Handle Ash.Resource.Change.Context struct
|
||||
def get_map(%Ash.Resource.Change.Context{actor: %ActorWithMap{map: %{} = map}}), do: map
|
||||
def get_map(%Ash.Resource.Change.Context{actor: _}), do: nil
|
||||
|
||||
def get_map(context) when is_map(context) do
|
||||
# For plain maps, check private.actor
|
||||
with private when is_map(private) <- Map.get(context, :private),
|
||||
%ActorWithMap{map: %{} = map} <- Map.get(private, :actor) do
|
||||
map
|
||||
else
|
||||
_ -> nil
|
||||
end
|
||||
end
|
||||
|
||||
def get_map(_), do: nil
|
||||
|
||||
@doc """
|
||||
Extract user from actor.
|
||||
|
||||
Handles:
|
||||
- ActorWithMap struct
|
||||
- Direct user struct with :id field
|
||||
"""
|
||||
def get_user(%ActorWithMap{user: user}), do: user
|
||||
def get_user(%{id: _} = user), do: user
|
||||
def get_user(_), do: nil
|
||||
|
||||
@doc """
|
||||
Get character IDs for the actor.
|
||||
|
||||
Used for ACL filtering to determine which resources the user can access.
|
||||
Returns {:ok, list} or {:ok, []} if no characters found.
|
||||
"""
|
||||
def get_character_ids(%ActorWithMap{user: user}), do: get_character_ids(user)
|
||||
|
||||
def get_character_ids(%{characters: characters}) when is_list(characters) do
|
||||
{:ok, Enum.map(characters, & &1.id)}
|
||||
end
|
||||
|
||||
def get_character_ids(%{characters: %Ecto.Association.NotLoaded{}, id: user_id}) do
|
||||
# Load characters from database
|
||||
load_characters_by_id(user_id)
|
||||
end
|
||||
|
||||
def get_character_ids(%{id: user_id}) do
|
||||
# Fallback: load user with characters
|
||||
load_characters_by_id(user_id)
|
||||
end
|
||||
|
||||
def get_character_ids(_), do: {:ok, []}
|
||||
|
||||
defp load_characters_by_id(user_id) do
|
||||
case WandererApp.Api.User.by_id(user_id, load: [:characters]) do
|
||||
{:ok, user} -> {:ok, Enum.map(user.characters, & &1.id)}
|
||||
_ -> {:ok, []}
|
||||
end
|
||||
end
|
||||
end
|
||||
15
lib/wanderer_app/api/actor_with_map.ex
Normal file
15
lib/wanderer_app/api/actor_with_map.ex
Normal file
@@ -0,0 +1,15 @@
|
||||
defmodule WandererApp.Api.ActorWithMap do
|
||||
@moduledoc """
|
||||
Wraps a user and map together as an actor for token-based authentication.
|
||||
|
||||
When API requests use Bearer token auth, the token identifies both the user
|
||||
(map owner) and the map. This struct allows passing both through Ash's actor system.
|
||||
"""
|
||||
|
||||
@enforce_keys [:user, :map]
|
||||
defstruct [:user, :map]
|
||||
|
||||
def new(user, map) do
|
||||
%__MODULE__{user: user, map: map}
|
||||
end
|
||||
end
|
||||
40
lib/wanderer_app/api/changes/inject_map_from_actor.ex
Normal file
40
lib/wanderer_app/api/changes/inject_map_from_actor.ex
Normal file
@@ -0,0 +1,40 @@
|
||||
defmodule WandererApp.Api.Changes.InjectMapFromActor do
|
||||
@moduledoc """
|
||||
Ash change that injects map_id from the authenticated actor.
|
||||
|
||||
For token-based auth, the map is determined by the API token.
|
||||
This change automatically sets map_id, so clients don't need to provide it.
|
||||
"""
|
||||
|
||||
use Ash.Resource.Change
|
||||
|
||||
alias WandererApp.Api.ActorHelpers
|
||||
|
||||
@impl true
|
||||
def change(changeset, _opts, context) do
|
||||
case ActorHelpers.get_map(context) do
|
||||
%{id: map_id} ->
|
||||
Ash.Changeset.force_change_attribute(changeset, :map_id, map_id)
|
||||
|
||||
_other ->
|
||||
# nil or unexpected return shape - check for direct map_id
|
||||
# Check params (input), arguments, and attributes (in that order)
|
||||
map_id =
|
||||
Map.get(changeset.params, :map_id) ||
|
||||
Ash.Changeset.get_argument(changeset, :map_id) ||
|
||||
Ash.Changeset.get_attribute(changeset, :map_id)
|
||||
|
||||
case map_id do
|
||||
nil ->
|
||||
Ash.Changeset.add_error(changeset,
|
||||
field: :map_id,
|
||||
message: "map_id is required (provide via token or attribute)"
|
||||
)
|
||||
|
||||
_map_id ->
|
||||
# map_id provided directly (internal calls, tests)
|
||||
changeset
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -39,6 +39,8 @@ defmodule WandererApp.Api.Character do
|
||||
define(:active_by_user,
|
||||
action: :active_by_user
|
||||
)
|
||||
|
||||
define(:admin_all, action: :admin_all)
|
||||
end
|
||||
|
||||
actions do
|
||||
@@ -69,9 +71,8 @@ defmodule WandererApp.Api.Character do
|
||||
filter(expr(user_id == ^arg(:user_id) and deleted == false))
|
||||
end
|
||||
|
||||
read :available_by_map do
|
||||
argument(:map_id, :uuid, allow_nil?: false)
|
||||
filter(expr(user_id == ^arg(:user_id) and deleted == false))
|
||||
read :admin_all do
|
||||
prepare build(load: [:user])
|
||||
end
|
||||
|
||||
read :last_active do
|
||||
@@ -100,6 +101,7 @@ defmodule WandererApp.Api.Character do
|
||||
|
||||
update :mark_as_deleted do
|
||||
accept([])
|
||||
require_atomic? false
|
||||
|
||||
change(atomic_update(:deleted, true))
|
||||
change(atomic_update(:user_id, nil))
|
||||
@@ -107,6 +109,7 @@ defmodule WandererApp.Api.Character do
|
||||
|
||||
update :update_online do
|
||||
accept([:online])
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_location do
|
||||
|
||||
@@ -33,7 +33,11 @@ defmodule WandererApp.Api.CorpWalletTransaction do
|
||||
:ref_type
|
||||
]
|
||||
|
||||
defaults [:create, :read, :update, :destroy]
|
||||
defaults [:create, :read, :destroy]
|
||||
|
||||
update :update do
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
create :new do
|
||||
accept [
|
||||
|
||||
@@ -36,7 +36,11 @@ defmodule WandererApp.Api.License do
|
||||
:expire_at
|
||||
]
|
||||
|
||||
defaults [:read, :update, :destroy]
|
||||
defaults [:read, :destroy]
|
||||
|
||||
update :update do
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
create :create do
|
||||
primary? true
|
||||
@@ -58,12 +62,14 @@ defmodule WandererApp.Api.License do
|
||||
|
||||
update :invalidate do
|
||||
accept([])
|
||||
require_atomic? false
|
||||
|
||||
change(set_attribute(:is_valid, false))
|
||||
end
|
||||
|
||||
update :set_valid do
|
||||
accept([])
|
||||
require_atomic? false
|
||||
|
||||
change(set_attribute(:is_valid, true))
|
||||
end
|
||||
|
||||
@@ -8,9 +8,13 @@ defmodule WandererApp.Api.Map do
|
||||
|
||||
alias Ash.Resource.Change.Builtins
|
||||
|
||||
require Logger
|
||||
|
||||
postgres do
|
||||
repo(WandererApp.Repo)
|
||||
table("maps_v1")
|
||||
|
||||
migration_defaults scopes: "'{wormholes}'"
|
||||
end
|
||||
|
||||
json_api do
|
||||
@@ -44,6 +48,7 @@ defmodule WandererApp.Api.Map do
|
||||
code_interface do
|
||||
define(:available, action: :available)
|
||||
define(:get_map_by_slug, action: :by_slug, args: [:slug])
|
||||
define(:by_api_key, action: :by_api_key, args: [:api_key])
|
||||
define(:new, action: :new)
|
||||
define(:create, action: :create)
|
||||
define(:update, action: :update)
|
||||
@@ -54,6 +59,7 @@ defmodule WandererApp.Api.Map do
|
||||
define(:mark_as_deleted, action: :mark_as_deleted)
|
||||
define(:update_api_key, action: :update_api_key)
|
||||
define(:toggle_webhooks, action: :toggle_webhooks)
|
||||
define(:toggle_sse, action: :toggle_sse)
|
||||
|
||||
define(:by_id,
|
||||
get_by: [:id],
|
||||
@@ -61,6 +67,8 @@ defmodule WandererApp.Api.Map do
|
||||
)
|
||||
|
||||
define(:duplicate, action: :duplicate)
|
||||
define(:admin_all, action: :admin_all)
|
||||
define(:restore, action: :restore)
|
||||
end
|
||||
|
||||
calculations do
|
||||
@@ -90,22 +98,41 @@ defmodule WandererApp.Api.Map do
|
||||
filter expr(slug == ^arg(:slug))
|
||||
end
|
||||
|
||||
read :by_api_key do
|
||||
get? true
|
||||
argument :api_key, :string, allow_nil?: false
|
||||
|
||||
prepare WandererApp.Api.Preparations.SecureApiKeyLookup
|
||||
end
|
||||
|
||||
read :available do
|
||||
prepare WandererApp.Api.Preparations.FilterMapsByRoles
|
||||
end
|
||||
|
||||
create :new do
|
||||
accept [:name, :slug, :description, :scope, :only_tracked_characters, :owner_id]
|
||||
primary?(true)
|
||||
read :admin_all do
|
||||
# Admin-only action that bypasses FilterMapsByRoles
|
||||
# Returns ALL maps including soft-deleted ones with owner and ACLs loaded
|
||||
prepare build(load: [:owner, :acls])
|
||||
end
|
||||
|
||||
argument :owner_id, :uuid, allow_nil?: false
|
||||
create :new do
|
||||
accept [
|
||||
:name,
|
||||
:slug,
|
||||
:description,
|
||||
:scope,
|
||||
:scopes,
|
||||
:only_tracked_characters,
|
||||
:owner_id,
|
||||
:sse_enabled
|
||||
]
|
||||
|
||||
primary?(true)
|
||||
argument :create_default_acl, :boolean, allow_nil?: true
|
||||
argument :acls, {:array, :uuid}, allow_nil?: true
|
||||
argument :acls_text_input, :string, allow_nil?: true
|
||||
argument :scope_text_input, :string, allow_nil?: true
|
||||
argument :acls_empty_selection, :string, allow_nil?: true
|
||||
|
||||
change manage_relationship(:owner_id, :owner, on_lookup: :relate, on_no_match: nil)
|
||||
change manage_relationship(:acls, type: :append_and_remove)
|
||||
change WandererApp.Api.Changes.SlugifyName
|
||||
end
|
||||
@@ -113,7 +140,17 @@ defmodule WandererApp.Api.Map do
|
||||
update :update do
|
||||
primary? true
|
||||
require_atomic? false
|
||||
accept [:name, :slug, :description, :scope, :only_tracked_characters, :owner_id]
|
||||
|
||||
accept [
|
||||
:name,
|
||||
:slug,
|
||||
:description,
|
||||
:scope,
|
||||
:scopes,
|
||||
:only_tracked_characters,
|
||||
:owner_id,
|
||||
:sse_enabled
|
||||
]
|
||||
|
||||
argument :owner_id_text_input, :string, allow_nil?: true
|
||||
argument :acls_text_input, :string, allow_nil?: true
|
||||
@@ -128,6 +165,9 @@ defmodule WandererApp.Api.Map do
|
||||
)
|
||||
|
||||
change WandererApp.Api.Changes.SlugifyName
|
||||
|
||||
# Validate subscription when enabling SSE
|
||||
validate &validate_sse_subscription/2
|
||||
end
|
||||
|
||||
update :update_acls do
|
||||
@@ -142,33 +182,64 @@ defmodule WandererApp.Api.Map do
|
||||
|
||||
update :assign_owner do
|
||||
accept [:owner_id]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_hubs do
|
||||
accept [:hubs]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_options do
|
||||
accept [:options]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :mark_as_deleted do
|
||||
accept([])
|
||||
require_atomic? false
|
||||
|
||||
change(set_attribute(:deleted, true))
|
||||
end
|
||||
|
||||
update :restore do
|
||||
# Admin-only action to restore a soft-deleted map
|
||||
accept([])
|
||||
require_atomic? false
|
||||
|
||||
change(set_attribute(:deleted, false))
|
||||
end
|
||||
|
||||
update :update_api_key do
|
||||
accept [:public_api_key]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :toggle_webhooks do
|
||||
accept [:webhooks_enabled]
|
||||
require_atomic? false
|
||||
|
||||
change after_action(fn _changeset, record, _context ->
|
||||
WandererApp.Map.update_webhooks_enabled(record.id, record.webhooks_enabled)
|
||||
{:ok, record}
|
||||
end)
|
||||
end
|
||||
|
||||
update :toggle_sse do
|
||||
require_atomic? false
|
||||
accept [:sse_enabled]
|
||||
|
||||
# Validate subscription when enabling SSE
|
||||
validate &validate_sse_subscription/2
|
||||
|
||||
change after_action(fn _changeset, record, _context ->
|
||||
WandererApp.Map.update_sse_enabled(record.id, record.sse_enabled)
|
||||
{:ok, record}
|
||||
end)
|
||||
end
|
||||
|
||||
create :duplicate do
|
||||
accept [:name, :description, :scope, :only_tracked_characters]
|
||||
|
||||
accept [:name, :description, :scope, :scopes, :only_tracked_characters]
|
||||
argument :source_map_id, :uuid, allow_nil?: false
|
||||
argument :copy_acls, :boolean, default: true
|
||||
argument :copy_user_settings, :boolean, default: true
|
||||
@@ -184,9 +255,14 @@ defmodule WandererApp.Api.Map do
|
||||
description =
|
||||
Ash.Changeset.get_attribute(changeset, :description) || source_map.description
|
||||
|
||||
# Use provided scopes or fall back to source map scopes
|
||||
scopes =
|
||||
Ash.Changeset.get_attribute(changeset, :scopes) || source_map.scopes
|
||||
|
||||
changeset
|
||||
|> Ash.Changeset.change_attribute(:description, description)
|
||||
|> Ash.Changeset.change_attribute(:scope, source_map.scope)
|
||||
|> Ash.Changeset.change_attribute(:scopes, scopes)
|
||||
|> Ash.Changeset.change_attribute(
|
||||
:only_tracked_characters,
|
||||
source_map.only_tracked_characters
|
||||
@@ -312,12 +388,37 @@ defmodule WandererApp.Api.Map do
|
||||
public?(true)
|
||||
end
|
||||
|
||||
attribute :sse_enabled, :boolean do
|
||||
default(false)
|
||||
allow_nil?(false)
|
||||
public?(true)
|
||||
end
|
||||
|
||||
attribute :scopes, {:array, :atom} do
|
||||
default([:wormholes])
|
||||
allow_nil?(true)
|
||||
public?(true)
|
||||
|
||||
constraints(
|
||||
items: [
|
||||
one_of: [
|
||||
:wormholes,
|
||||
:hi,
|
||||
:low,
|
||||
:null,
|
||||
:pochven
|
||||
]
|
||||
]
|
||||
)
|
||||
end
|
||||
|
||||
create_timestamp(:inserted_at)
|
||||
update_timestamp(:updated_at)
|
||||
end
|
||||
|
||||
identities do
|
||||
identity :unique_slug, [:slug]
|
||||
identity :unique_public_api_key, [:public_api_key]
|
||||
end
|
||||
|
||||
relationships do
|
||||
@@ -344,4 +445,49 @@ defmodule WandererApp.Api.Map do
|
||||
public? false
|
||||
end
|
||||
end
|
||||
|
||||
# SSE Subscription Validation
|
||||
#
|
||||
# This validation ensures that SSE can only be enabled when:
|
||||
# 1. SSE is being disabled (always allowed)
|
||||
# 2. Map is being created (skip validation, will be checked on first update)
|
||||
# 3. Community Edition mode (always allowed)
|
||||
# 4. Enterprise mode with active subscription
|
||||
defp validate_sse_subscription(changeset, _context) do
|
||||
sse_enabled = Ash.Changeset.get_attribute(changeset, :sse_enabled)
|
||||
map_id = changeset.data.id
|
||||
subscriptions_enabled = WandererApp.Env.map_subscriptions_enabled?()
|
||||
|
||||
cond do
|
||||
# Not enabling SSE - no validation needed
|
||||
not sse_enabled ->
|
||||
:ok
|
||||
|
||||
# Map creation (no ID yet) - skip validation
|
||||
is_nil(map_id) ->
|
||||
:ok
|
||||
|
||||
# Community Edition mode - always allow
|
||||
not subscriptions_enabled ->
|
||||
:ok
|
||||
|
||||
# Enterprise mode - check subscription
|
||||
true ->
|
||||
validate_active_subscription(map_id)
|
||||
end
|
||||
end
|
||||
|
||||
defp validate_active_subscription(map_id) do
|
||||
case WandererApp.Map.is_subscription_active?(map_id) do
|
||||
{:ok, true} ->
|
||||
:ok
|
||||
|
||||
{:ok, false} ->
|
||||
{:error, field: :sse_enabled, message: "Active subscription required to enable SSE"}
|
||||
|
||||
{:error, reason} ->
|
||||
Logger.error("Error checking subscription status: #{inspect(reason)}")
|
||||
{:error, field: :sse_enabled, message: "Unable to verify subscription status"}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,7 +61,11 @@ defmodule WandererApp.Api.MapAccessList do
|
||||
:access_list_id
|
||||
]
|
||||
|
||||
defaults [:create, :read, :update, :destroy]
|
||||
defaults [:create, :read, :destroy]
|
||||
|
||||
update :update do
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
read :read_by_map do
|
||||
argument(:map_id, :string, allow_nil?: false)
|
||||
|
||||
@@ -27,7 +27,11 @@ defmodule WandererApp.Api.MapChainPassages do
|
||||
:solar_system_target_id
|
||||
]
|
||||
|
||||
defaults [:create, :read, :update, :destroy]
|
||||
defaults [:create, :read, :destroy]
|
||||
|
||||
update :update do
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
create :new do
|
||||
accept [
|
||||
@@ -40,12 +44,6 @@ defmodule WandererApp.Api.MapChainPassages do
|
||||
]
|
||||
|
||||
primary?(true)
|
||||
|
||||
argument :map_id, :uuid, allow_nil?: false
|
||||
argument :character_id, :uuid, allow_nil?: false
|
||||
|
||||
change manage_relationship(:map_id, :map, on_lookup: :relate, on_no_match: nil)
|
||||
change manage_relationship(:character_id, :character, on_lookup: :relate, on_no_match: nil)
|
||||
end
|
||||
|
||||
action :by_map_id, {:array, :struct} do
|
||||
|
||||
@@ -27,6 +27,11 @@ defmodule WandererApp.Api.MapCharacterSettings do
|
||||
|
||||
includes([:map, :character])
|
||||
|
||||
default_fields([
|
||||
:tracked,
|
||||
:followed
|
||||
])
|
||||
|
||||
derive_filter?(true)
|
||||
derive_sort?(true)
|
||||
|
||||
@@ -81,12 +86,6 @@ defmodule WandererApp.Api.MapCharacterSettings do
|
||||
:character_id,
|
||||
:tracked
|
||||
]
|
||||
|
||||
argument :map_id, :uuid, allow_nil?: false
|
||||
argument :character_id, :uuid, allow_nil?: false
|
||||
|
||||
change manage_relationship(:map_id, :map, on_lookup: :relate, on_no_match: nil)
|
||||
change manage_relationship(:character_id, :character, on_lookup: :relate, on_no_match: nil)
|
||||
end
|
||||
|
||||
read :by_map_filtered do
|
||||
@@ -134,6 +133,8 @@ defmodule WandererApp.Api.MapCharacterSettings do
|
||||
require_atomic? false
|
||||
|
||||
accept([
|
||||
:tracked,
|
||||
:followed,
|
||||
:ship,
|
||||
:ship_name,
|
||||
:ship_item_id,
|
||||
@@ -145,8 +146,7 @@ defmodule WandererApp.Api.MapCharacterSettings do
|
||||
|
||||
update :track do
|
||||
accept [:map_id, :character_id]
|
||||
argument :map_id, :string, allow_nil?: false
|
||||
argument :character_id, :uuid, allow_nil?: false
|
||||
require_atomic? false
|
||||
|
||||
# Load the record first
|
||||
load do
|
||||
@@ -159,8 +159,7 @@ defmodule WandererApp.Api.MapCharacterSettings do
|
||||
|
||||
update :untrack do
|
||||
accept [:map_id, :character_id]
|
||||
argument :map_id, :string, allow_nil?: false
|
||||
argument :character_id, :uuid, allow_nil?: false
|
||||
require_atomic? false
|
||||
|
||||
# Load the record first
|
||||
load do
|
||||
@@ -173,8 +172,7 @@ defmodule WandererApp.Api.MapCharacterSettings do
|
||||
|
||||
update :follow do
|
||||
accept [:map_id, :character_id]
|
||||
argument :map_id, :string, allow_nil?: false
|
||||
argument :character_id, :uuid, allow_nil?: false
|
||||
require_atomic? false
|
||||
|
||||
# Load the record first
|
||||
load do
|
||||
@@ -187,8 +185,7 @@ defmodule WandererApp.Api.MapCharacterSettings do
|
||||
|
||||
update :unfollow do
|
||||
accept [:map_id, :character_id]
|
||||
argument :map_id, :string, allow_nil?: false
|
||||
argument :character_id, :uuid, allow_nil?: false
|
||||
require_atomic? false
|
||||
|
||||
# Load the record first
|
||||
load do
|
||||
@@ -227,14 +224,17 @@ defmodule WandererApp.Api.MapCharacterSettings do
|
||||
|
||||
attribute :tracked, :boolean do
|
||||
default false
|
||||
public? true
|
||||
allow_nil? true
|
||||
end
|
||||
|
||||
attribute :followed, :boolean do
|
||||
default false
|
||||
public? true
|
||||
allow_nil? true
|
||||
end
|
||||
|
||||
# Note: These attributes are encrypted (AshCloak) and intentionally not public
|
||||
attribute :solar_system_id, :integer
|
||||
attribute :structure_id, :integer
|
||||
attribute :station_id, :integer
|
||||
|
||||
@@ -4,7 +4,8 @@ defmodule WandererApp.Api.MapConnection do
|
||||
use Ash.Resource,
|
||||
domain: WandererApp.Api,
|
||||
data_layer: AshPostgres.DataLayer,
|
||||
extensions: [AshJsonApi.Resource]
|
||||
extensions: [AshJsonApi.Resource],
|
||||
primary_read_warning?: false
|
||||
|
||||
postgres do
|
||||
repo(WandererApp.Repo)
|
||||
@@ -21,6 +22,19 @@ defmodule WandererApp.Api.MapConnection do
|
||||
|
||||
includes([:map])
|
||||
|
||||
default_fields([
|
||||
:solar_system_source,
|
||||
:solar_system_target,
|
||||
:mass_status,
|
||||
:time_status,
|
||||
:ship_size_type,
|
||||
:type,
|
||||
:wormhole_type,
|
||||
:count_of_passage,
|
||||
:locked,
|
||||
:custom_info
|
||||
])
|
||||
|
||||
derive_filter?(true)
|
||||
derive_sort?(true)
|
||||
|
||||
@@ -73,7 +87,56 @@ defmodule WandererApp.Api.MapConnection do
|
||||
:custom_info
|
||||
]
|
||||
|
||||
defaults [:create, :read, :update, :destroy]
|
||||
create :create do
|
||||
primary? true
|
||||
|
||||
accept [
|
||||
:map_id,
|
||||
:solar_system_source,
|
||||
:solar_system_target,
|
||||
:type,
|
||||
:ship_size_type,
|
||||
:mass_status,
|
||||
:time_status,
|
||||
:wormhole_type,
|
||||
:count_of_passage,
|
||||
:locked,
|
||||
:custom_info
|
||||
]
|
||||
|
||||
# Inject map_id from token
|
||||
change WandererApp.Api.Changes.InjectMapFromActor
|
||||
end
|
||||
|
||||
read :read do
|
||||
primary? true
|
||||
|
||||
# Security: Filter to only connections from actor's map
|
||||
prepare WandererApp.Api.Preparations.FilterConnectionsByActorMap
|
||||
end
|
||||
|
||||
update :update do
|
||||
primary? true
|
||||
|
||||
accept [
|
||||
:solar_system_source,
|
||||
:solar_system_target,
|
||||
:type,
|
||||
:ship_size_type,
|
||||
:mass_status,
|
||||
:time_status,
|
||||
:wormhole_type,
|
||||
:count_of_passage,
|
||||
:locked,
|
||||
:custom_info
|
||||
]
|
||||
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
destroy :destroy do
|
||||
primary? true
|
||||
end
|
||||
|
||||
read :read_by_map do
|
||||
argument(:map_id, :string, allow_nil?: false)
|
||||
@@ -110,45 +173,57 @@ defmodule WandererApp.Api.MapConnection do
|
||||
|
||||
update :update_mass_status do
|
||||
accept [:mass_status]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_time_status do
|
||||
accept [:time_status]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_ship_size_type do
|
||||
accept [:ship_size_type]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_locked do
|
||||
accept [:locked]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_custom_info do
|
||||
accept [:custom_info]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_type do
|
||||
accept [:type]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_wormhole_type do
|
||||
accept [:wormhole_type]
|
||||
require_atomic? false
|
||||
end
|
||||
end
|
||||
|
||||
attributes do
|
||||
uuid_primary_key :id
|
||||
|
||||
attribute :solar_system_source, :integer
|
||||
attribute :solar_system_target, :integer
|
||||
attribute :solar_system_source, :integer do
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :solar_system_target, :integer do
|
||||
public? true
|
||||
end
|
||||
|
||||
# where 0 - greater than half
|
||||
# where 1 - less than half
|
||||
# where 2 - critical less than 10%
|
||||
attribute :mass_status, :integer do
|
||||
default(0)
|
||||
|
||||
public? true
|
||||
allow_nil?(true)
|
||||
end
|
||||
|
||||
@@ -161,7 +236,7 @@ defmodule WandererApp.Api.MapConnection do
|
||||
# 6 - EOL 48h
|
||||
attribute :time_status, :integer do
|
||||
default(0)
|
||||
|
||||
public? true
|
||||
allow_nil?(true)
|
||||
end
|
||||
|
||||
@@ -172,7 +247,7 @@ defmodule WandererApp.Api.MapConnection do
|
||||
# where 4 - Capital
|
||||
attribute :ship_size_type, :integer do
|
||||
default(2)
|
||||
|
||||
public? true
|
||||
allow_nil?(true)
|
||||
end
|
||||
|
||||
@@ -181,21 +256,26 @@ defmodule WandererApp.Api.MapConnection do
|
||||
# where 2 - Bridge
|
||||
attribute :type, :integer do
|
||||
default(0)
|
||||
|
||||
public? true
|
||||
allow_nil?(true)
|
||||
end
|
||||
|
||||
attribute :wormhole_type, :string
|
||||
attribute :wormhole_type, :string do
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :count_of_passage, :integer do
|
||||
default(0)
|
||||
|
||||
public? true
|
||||
allow_nil?(true)
|
||||
end
|
||||
|
||||
attribute :locked, :boolean
|
||||
attribute :locked, :boolean do
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :custom_info, :string do
|
||||
public? true
|
||||
allow_nil? true
|
||||
end
|
||||
|
||||
|
||||
@@ -23,6 +23,10 @@ defmodule WandererApp.Api.MapDefaultSettings do
|
||||
:updated_by
|
||||
])
|
||||
|
||||
default_fields([
|
||||
:settings
|
||||
])
|
||||
|
||||
routes do
|
||||
base("/map_default_settings")
|
||||
|
||||
@@ -93,6 +97,7 @@ defmodule WandererApp.Api.MapDefaultSettings do
|
||||
|
||||
attribute :settings, :string do
|
||||
allow_nil? false
|
||||
public? true
|
||||
constraints min_length: 2
|
||||
description "JSON string containing the default map settings"
|
||||
end
|
||||
|
||||
@@ -30,7 +30,11 @@ defmodule WandererApp.Api.MapInvite do
|
||||
:token
|
||||
]
|
||||
|
||||
defaults [:read, :update, :destroy]
|
||||
defaults [:read, :destroy]
|
||||
|
||||
update :update do
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
create :new do
|
||||
accept [
|
||||
@@ -41,10 +45,6 @@ defmodule WandererApp.Api.MapInvite do
|
||||
]
|
||||
|
||||
primary?(true)
|
||||
|
||||
argument :map_id, :uuid, allow_nil?: true
|
||||
|
||||
change manage_relationship(:map_id, :map, on_lookup: :relate, on_no_match: nil)
|
||||
end
|
||||
|
||||
read :by_map do
|
||||
|
||||
@@ -3,7 +3,8 @@ defmodule WandererApp.Api.MapPing do
|
||||
|
||||
use Ash.Resource,
|
||||
domain: WandererApp.Api,
|
||||
data_layer: AshPostgres.DataLayer
|
||||
data_layer: AshPostgres.DataLayer,
|
||||
primary_read_warning?: false
|
||||
|
||||
postgres do
|
||||
repo(WandererApp.Repo)
|
||||
@@ -36,7 +37,18 @@ defmodule WandererApp.Api.MapPing do
|
||||
:message
|
||||
]
|
||||
|
||||
defaults [:read, :update, :destroy]
|
||||
defaults [:destroy]
|
||||
|
||||
update :update do
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
read :read do
|
||||
primary? true
|
||||
|
||||
# Security: Filter to only pings from actor's map
|
||||
prepare WandererApp.Api.Preparations.FilterPingsByActorMap
|
||||
end
|
||||
|
||||
create :new do
|
||||
accept [
|
||||
@@ -48,14 +60,6 @@ defmodule WandererApp.Api.MapPing do
|
||||
]
|
||||
|
||||
primary?(true)
|
||||
|
||||
argument :map_id, :uuid, allow_nil?: false
|
||||
argument :system_id, :uuid, allow_nil?: false
|
||||
argument :character_id, :uuid, allow_nil?: false
|
||||
|
||||
change manage_relationship(:map_id, :map, on_lookup: :relate, on_no_match: nil)
|
||||
change manage_relationship(:system_id, :system, on_lookup: :relate, on_no_match: nil)
|
||||
change manage_relationship(:character_id, :character, on_lookup: :relate, on_no_match: nil)
|
||||
end
|
||||
|
||||
read :by_map do
|
||||
@@ -76,6 +80,10 @@ defmodule WandererApp.Api.MapPing do
|
||||
|
||||
filter(expr(inserted_at <= ^arg(:inserted_before)))
|
||||
end
|
||||
|
||||
# Admin action for cleanup - no actor filtering
|
||||
read :all_pings do
|
||||
end
|
||||
end
|
||||
|
||||
attributes do
|
||||
|
||||
@@ -65,7 +65,11 @@ defmodule WandererApp.Api.MapSolarSystem do
|
||||
:sun_type_id
|
||||
]
|
||||
|
||||
defaults [:read, :destroy, :update]
|
||||
defaults [:read, :destroy]
|
||||
|
||||
update :update do
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
create :create do
|
||||
primary? true
|
||||
|
||||
@@ -24,7 +24,11 @@ defmodule WandererApp.Api.MapSolarSystemJumps do
|
||||
:to_solar_system_id
|
||||
]
|
||||
|
||||
defaults [:read, :destroy, :update]
|
||||
defaults [:read, :destroy]
|
||||
|
||||
update :update do
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
create :create do
|
||||
primary? true
|
||||
|
||||
@@ -45,7 +45,11 @@ defmodule WandererApp.Api.MapState do
|
||||
:connections_start_time
|
||||
]
|
||||
|
||||
defaults [:read, :update, :destroy]
|
||||
defaults [:read, :destroy]
|
||||
|
||||
update :update do
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
create :create do
|
||||
primary? true
|
||||
|
||||
@@ -18,6 +18,15 @@ defmodule WandererApp.Api.MapSubscription do
|
||||
:map
|
||||
])
|
||||
|
||||
default_fields([
|
||||
:plan,
|
||||
:status,
|
||||
:characters_limit,
|
||||
:hubs_limit,
|
||||
:active_till,
|
||||
:auto_renew?
|
||||
])
|
||||
|
||||
# Enable automatic filtering and sorting
|
||||
derive_filter?(true)
|
||||
derive_sort?(true)
|
||||
@@ -62,7 +71,11 @@ defmodule WandererApp.Api.MapSubscription do
|
||||
:auto_renew?
|
||||
]
|
||||
|
||||
defaults [:create, :read, :update, :destroy]
|
||||
defaults [:create, :read, :destroy]
|
||||
|
||||
update :update do
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
read :all_active do
|
||||
prepare build(sort: [updated_at: :asc], load: [:map])
|
||||
@@ -88,32 +101,39 @@ defmodule WandererApp.Api.MapSubscription do
|
||||
|
||||
update :update_plan do
|
||||
accept [:plan]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_characters_limit do
|
||||
accept [:characters_limit]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_hubs_limit do
|
||||
accept [:hubs_limit]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_active_till do
|
||||
accept [:active_till]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_auto_renew do
|
||||
accept [:auto_renew?]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :cancel do
|
||||
accept([])
|
||||
require_atomic? false
|
||||
|
||||
change(set_attribute(:status, :cancelled))
|
||||
end
|
||||
|
||||
update :expire do
|
||||
accept([])
|
||||
require_atomic? false
|
||||
|
||||
change(set_attribute(:status, :expired))
|
||||
end
|
||||
@@ -124,6 +144,7 @@ defmodule WandererApp.Api.MapSubscription do
|
||||
|
||||
attribute :plan, :atom do
|
||||
default "alpha"
|
||||
public? true
|
||||
|
||||
constraints(
|
||||
one_of: [
|
||||
@@ -139,6 +160,7 @@ defmodule WandererApp.Api.MapSubscription do
|
||||
|
||||
attribute :status, :atom do
|
||||
default "active"
|
||||
public? true
|
||||
|
||||
constraints(
|
||||
one_of: [
|
||||
@@ -153,22 +175,24 @@ defmodule WandererApp.Api.MapSubscription do
|
||||
|
||||
attribute :characters_limit, :integer do
|
||||
default(100)
|
||||
|
||||
public? true
|
||||
allow_nil?(true)
|
||||
end
|
||||
|
||||
attribute :hubs_limit, :integer do
|
||||
default(10)
|
||||
|
||||
public? true
|
||||
allow_nil?(true)
|
||||
end
|
||||
|
||||
attribute :active_till, :utc_datetime do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :auto_renew?, :boolean do
|
||||
allow_nil? false
|
||||
public? true
|
||||
end
|
||||
|
||||
create_timestamp(:inserted_at)
|
||||
|
||||
@@ -24,16 +24,12 @@ defmodule WandererApp.Api.MapSystem do
|
||||
use Ash.Resource,
|
||||
domain: WandererApp.Api,
|
||||
data_layer: AshPostgres.DataLayer,
|
||||
extensions: [AshJsonApi.Resource]
|
||||
extensions: [AshJsonApi.Resource],
|
||||
primary_read_warning?: false
|
||||
|
||||
postgres do
|
||||
repo(WandererApp.Repo)
|
||||
table("map_system_v1")
|
||||
|
||||
custom_indexes do
|
||||
# Partial index for efficient visible systems query
|
||||
index [:map_id], where: "visible = true", name: "map_system_v1_map_id_visible_index"
|
||||
end
|
||||
end
|
||||
|
||||
json_api do
|
||||
@@ -70,10 +66,7 @@ defmodule WandererApp.Api.MapSystem do
|
||||
define(:upsert, action: :upsert)
|
||||
define(:destroy, action: :destroy)
|
||||
|
||||
define(:by_id,
|
||||
get_by: [:id],
|
||||
action: :read
|
||||
)
|
||||
define :by_id, action: :get_by_id, args: [:id], get?: true
|
||||
|
||||
define(:by_solar_system_id,
|
||||
get_by: [:solar_system_id],
|
||||
@@ -103,6 +96,7 @@ defmodule WandererApp.Api.MapSystem do
|
||||
define(:update_status, action: :update_status)
|
||||
define(:update_tag, action: :update_tag)
|
||||
define(:update_temporary_name, action: :update_temporary_name)
|
||||
define(:update_custom_name, action: :update_custom_name)
|
||||
define(:update_labels, action: :update_labels)
|
||||
define(:update_linked_sig_eve_id, action: :update_linked_sig_eve_id)
|
||||
define(:update_position, action: :update_position)
|
||||
@@ -128,7 +122,56 @@ defmodule WandererApp.Api.MapSystem do
|
||||
:linked_sig_eve_id
|
||||
]
|
||||
|
||||
defaults [:create, :update, :destroy]
|
||||
create :create do
|
||||
primary? true
|
||||
|
||||
accept [
|
||||
:map_id,
|
||||
:name,
|
||||
:solar_system_id,
|
||||
:position_x,
|
||||
:position_y,
|
||||
:status,
|
||||
:visible,
|
||||
:locked,
|
||||
:custom_name,
|
||||
:description,
|
||||
:tag,
|
||||
:temporary_name,
|
||||
:labels,
|
||||
:added_at,
|
||||
:linked_sig_eve_id
|
||||
]
|
||||
|
||||
# Inject map_id from token
|
||||
change WandererApp.Api.Changes.InjectMapFromActor
|
||||
end
|
||||
|
||||
update :update do
|
||||
primary? true
|
||||
require_atomic? false
|
||||
|
||||
# Note: name and solar_system_id are not in accept
|
||||
# - solar_system_id should be immutable (identifier)
|
||||
# - name has allow_nil? false which makes it required in JSON:API
|
||||
accept [
|
||||
:position_x,
|
||||
:position_y,
|
||||
:status,
|
||||
:visible,
|
||||
:locked,
|
||||
:custom_name,
|
||||
:description,
|
||||
:tag,
|
||||
:temporary_name,
|
||||
:labels,
|
||||
:linked_sig_eve_id
|
||||
]
|
||||
end
|
||||
|
||||
destroy :destroy do
|
||||
primary? true
|
||||
end
|
||||
|
||||
create :upsert do
|
||||
primary? false
|
||||
@@ -158,6 +201,9 @@ defmodule WandererApp.Api.MapSystem do
|
||||
read :read do
|
||||
primary?(true)
|
||||
|
||||
# Security: Filter to only systems from actor's map
|
||||
prepare WandererApp.Api.Preparations.FilterSystemsByActorMap
|
||||
|
||||
pagination offset?: true,
|
||||
default_limit: 100,
|
||||
max_page_size: 500,
|
||||
@@ -165,6 +211,11 @@ defmodule WandererApp.Api.MapSystem do
|
||||
required?: false
|
||||
end
|
||||
|
||||
read :get_by_id do
|
||||
argument(:id, :string, allow_nil?: false)
|
||||
filter(expr(id == ^arg(:id)))
|
||||
end
|
||||
|
||||
read :read_all_by_map do
|
||||
argument(:map_id, :string, allow_nil?: false)
|
||||
filter(expr(map_id == ^arg(:map_id)))
|
||||
@@ -186,44 +237,59 @@ defmodule WandererApp.Api.MapSystem do
|
||||
|
||||
update :update_name do
|
||||
accept [:name]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_description do
|
||||
accept [:description]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_locked do
|
||||
accept [:locked]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_status do
|
||||
accept [:status]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_tag do
|
||||
accept [:tag]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_temporary_name do
|
||||
accept [:temporary_name]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_custom_name do
|
||||
accept [:custom_name]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_labels do
|
||||
accept [:labels]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_position do
|
||||
accept [:position_x, :position_y]
|
||||
require_atomic? false
|
||||
|
||||
change(set_attribute(:visible, true))
|
||||
end
|
||||
|
||||
update :update_linked_sig_eve_id do
|
||||
accept [:linked_sig_eve_id]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_visible do
|
||||
accept [:visible]
|
||||
require_atomic? false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -19,6 +19,10 @@ defmodule WandererApp.Api.MapSystemComment do
|
||||
:character
|
||||
])
|
||||
|
||||
default_fields([
|
||||
:text
|
||||
])
|
||||
|
||||
routes do
|
||||
base("/map_system_comments")
|
||||
|
||||
@@ -59,12 +63,6 @@ defmodule WandererApp.Api.MapSystemComment do
|
||||
:character_id,
|
||||
:text
|
||||
]
|
||||
|
||||
argument :system_id, :uuid, allow_nil?: false
|
||||
argument :character_id, :uuid, allow_nil?: false
|
||||
|
||||
change manage_relationship(:system_id, :system, on_lookup: :relate, on_no_match: nil)
|
||||
change manage_relationship(:character_id, :character, on_lookup: :relate, on_no_match: nil)
|
||||
end
|
||||
|
||||
read :by_system_id do
|
||||
@@ -79,6 +77,7 @@ defmodule WandererApp.Api.MapSystemComment do
|
||||
|
||||
attribute :text, :string do
|
||||
allow_nil? false
|
||||
public? true
|
||||
end
|
||||
|
||||
create_timestamp(:inserted_at)
|
||||
|
||||
@@ -16,6 +16,20 @@ defmodule WandererApp.Api.MapSystemSignature do
|
||||
|
||||
includes([:system])
|
||||
|
||||
default_fields([
|
||||
:eve_id,
|
||||
:character_eve_id,
|
||||
:name,
|
||||
:description,
|
||||
:temporary_name,
|
||||
:type,
|
||||
:linked_system_id,
|
||||
:kind,
|
||||
:group,
|
||||
:custom_info,
|
||||
:deleted
|
||||
])
|
||||
|
||||
derive_filter?(true)
|
||||
derive_sort?(true)
|
||||
|
||||
@@ -109,12 +123,9 @@ defmodule WandererApp.Api.MapSystemSignature do
|
||||
:group,
|
||||
:type,
|
||||
:custom_info,
|
||||
:deleted
|
||||
:deleted,
|
||||
:linked_system_id
|
||||
]
|
||||
|
||||
argument :system_id, :uuid, allow_nil?: false
|
||||
|
||||
change manage_relationship(:system_id, :system, on_lookup: :relate, on_no_match: nil)
|
||||
end
|
||||
|
||||
update :update do
|
||||
@@ -130,7 +141,8 @@ defmodule WandererApp.Api.MapSystemSignature do
|
||||
:type,
|
||||
:custom_info,
|
||||
:deleted,
|
||||
:update_forced_at
|
||||
:update_forced_at,
|
||||
:linked_system_id
|
||||
]
|
||||
|
||||
primary? true
|
||||
@@ -139,14 +151,17 @@ defmodule WandererApp.Api.MapSystemSignature do
|
||||
|
||||
update :update_linked_system do
|
||||
accept [:linked_system_id]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_type do
|
||||
accept [:type]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_group do
|
||||
accept [:group]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
read :by_system_id do
|
||||
@@ -185,42 +200,56 @@ defmodule WandererApp.Api.MapSystemSignature do
|
||||
|
||||
attribute :eve_id, :string do
|
||||
allow_nil? false
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :character_eve_id, :string do
|
||||
allow_nil? false
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :name, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :description, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :temporary_name, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :type, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :linked_system_id, :integer do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :kind, :string
|
||||
attribute :group, :string
|
||||
attribute :kind, :string do
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :group, :string do
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :custom_info, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :deleted, :boolean do
|
||||
allow_nil? false
|
||||
default false
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :update_forced_at, :utc_datetime do
|
||||
|
||||
@@ -41,6 +41,21 @@ defmodule WandererApp.Api.MapSystemStructure do
|
||||
:system
|
||||
])
|
||||
|
||||
default_fields([
|
||||
:structure_type_id,
|
||||
:structure_type,
|
||||
:character_eve_id,
|
||||
:solar_system_name,
|
||||
:solar_system_id,
|
||||
:name,
|
||||
:notes,
|
||||
:owner_name,
|
||||
:owner_ticker,
|
||||
:owner_id,
|
||||
:status,
|
||||
:end_time
|
||||
])
|
||||
|
||||
# Enable automatic filtering and sorting
|
||||
derive_filter?(true)
|
||||
derive_sort?(true)
|
||||
@@ -122,13 +137,6 @@ defmodule WandererApp.Api.MapSystemStructure do
|
||||
:status,
|
||||
:end_time
|
||||
]
|
||||
|
||||
argument :system_id, :uuid, allow_nil?: false
|
||||
|
||||
change manage_relationship(:system_id, :system,
|
||||
on_lookup: :relate,
|
||||
on_no_match: nil
|
||||
)
|
||||
end
|
||||
|
||||
update :update do
|
||||
@@ -158,50 +166,62 @@ defmodule WandererApp.Api.MapSystemStructure do
|
||||
|
||||
attribute :structure_type_id, :string do
|
||||
allow_nil? false
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :structure_type, :string do
|
||||
allow_nil? false
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :character_eve_id, :string do
|
||||
allow_nil? false
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :solar_system_name, :string do
|
||||
allow_nil? false
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :solar_system_id, :integer do
|
||||
allow_nil? false
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :name, :string do
|
||||
allow_nil? false
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :notes, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :owner_name, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :owner_ticker, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :owner_id, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :status, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :end_time, :utc_datetime_usec do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
create_timestamp :inserted_at
|
||||
|
||||
@@ -5,6 +5,8 @@ defmodule WandererApp.Api.MapTransaction do
|
||||
domain: WandererApp.Api,
|
||||
data_layer: AshPostgres.DataLayer
|
||||
|
||||
import Ecto.Query
|
||||
|
||||
postgres do
|
||||
repo(WandererApp.Repo)
|
||||
table("map_transactions_v1")
|
||||
@@ -19,6 +21,7 @@ defmodule WandererApp.Api.MapTransaction do
|
||||
define(:by_map, action: :by_map)
|
||||
define(:by_user, action: :by_user)
|
||||
define(:create, action: :create)
|
||||
define(:top_donators, action: :top_donators)
|
||||
end
|
||||
|
||||
actions do
|
||||
@@ -29,7 +32,11 @@ defmodule WandererApp.Api.MapTransaction do
|
||||
:amount
|
||||
]
|
||||
|
||||
defaults [:create, :read, :update, :destroy]
|
||||
defaults [:create, :read, :destroy]
|
||||
|
||||
update :update do
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
read :by_map do
|
||||
argument(:map_id, :string, allow_nil?: false)
|
||||
@@ -41,6 +48,35 @@ defmodule WandererApp.Api.MapTransaction do
|
||||
argument(:user_id, :uuid, allow_nil?: false)
|
||||
filter(expr(user_id == ^arg(:user_id)))
|
||||
end
|
||||
|
||||
action :top_donators, {:array, :struct} do
|
||||
argument(:map_id, :string, allow_nil?: false)
|
||||
argument(:after, :utc_datetime, allow_nil?: true)
|
||||
|
||||
run fn input, _context ->
|
||||
base =
|
||||
from(t in __MODULE__,
|
||||
where:
|
||||
t.map_id == ^input.arguments.map_id and
|
||||
t.type == :in and
|
||||
not is_nil(t.user_id),
|
||||
group_by: [t.user_id],
|
||||
select: %{user_id: t.user_id, total_amount: sum(t.amount)},
|
||||
order_by: [desc: sum(t.amount)],
|
||||
limit: 10
|
||||
)
|
||||
|
||||
query =
|
||||
case input.arguments[:after] do
|
||||
nil -> base
|
||||
after_date -> base |> where([t], t.inserted_at >= ^after_date)
|
||||
end
|
||||
|
||||
query
|
||||
|> WandererApp.Repo.all()
|
||||
|> then(&{:ok, &1})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
attributes do
|
||||
|
||||
@@ -24,6 +24,13 @@ defmodule WandererApp.Api.MapUserSettings do
|
||||
:user
|
||||
])
|
||||
|
||||
default_fields([
|
||||
:settings,
|
||||
:main_character_eve_id,
|
||||
:following_character_eve_id,
|
||||
:hubs
|
||||
])
|
||||
|
||||
routes do
|
||||
base("/map_user_settings")
|
||||
|
||||
@@ -53,22 +60,30 @@ defmodule WandererApp.Api.MapUserSettings do
|
||||
:settings
|
||||
]
|
||||
|
||||
defaults [:create, :read, :update, :destroy]
|
||||
defaults [:create, :read, :destroy]
|
||||
|
||||
update :update do
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_settings do
|
||||
accept [:settings]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_main_character do
|
||||
accept [:main_character_eve_id]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_following_character do
|
||||
accept [:following_character_eve_id]
|
||||
require_atomic? false
|
||||
end
|
||||
|
||||
update :update_hubs do
|
||||
accept [:hubs]
|
||||
require_atomic? false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -77,19 +92,22 @@ defmodule WandererApp.Api.MapUserSettings do
|
||||
|
||||
attribute :settings, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :main_character_eve_id, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :following_character_eve_id, :string do
|
||||
allow_nil? true
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :hubs, {:array, :string} do
|
||||
allow_nil?(true)
|
||||
|
||||
public? true
|
||||
default([])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -45,7 +45,17 @@ defmodule WandererApp.Api.MapWebhookSubscription do
|
||||
:active?
|
||||
]
|
||||
|
||||
defaults [:read, :destroy]
|
||||
defaults [:read]
|
||||
|
||||
# Custom destroy to invalidate cache
|
||||
destroy :destroy do
|
||||
require_atomic? false
|
||||
|
||||
change after_action(fn _changeset, record, _context ->
|
||||
WandererApp.ExternalEvents.WebhookDispatcher.invalidate_cache(record.map_id)
|
||||
{:ok, record}
|
||||
end)
|
||||
end
|
||||
|
||||
update :update do
|
||||
accept [
|
||||
@@ -58,6 +68,14 @@ defmodule WandererApp.Api.MapWebhookSubscription do
|
||||
:consecutive_failures,
|
||||
:secret
|
||||
]
|
||||
|
||||
require_atomic? false
|
||||
|
||||
# Invalidate cache when subscription is updated
|
||||
change after_action(fn _changeset, record, _context ->
|
||||
WandererApp.ExternalEvents.WebhookDispatcher.invalidate_cache(record.map_id)
|
||||
{:ok, record}
|
||||
end)
|
||||
end
|
||||
|
||||
read :by_map do
|
||||
@@ -122,6 +140,12 @@ defmodule WandererApp.Api.MapWebhookSubscription do
|
||||
secret = generate_webhook_secret()
|
||||
Ash.Changeset.force_change_attribute(changeset, :secret, secret)
|
||||
end
|
||||
|
||||
# Invalidate cache when subscription is created
|
||||
change after_action(fn _changeset, record, _context ->
|
||||
WandererApp.ExternalEvents.WebhookDispatcher.invalidate_cache(record.map_id)
|
||||
{:ok, record}
|
||||
end)
|
||||
end
|
||||
|
||||
update :rotate_secret do
|
||||
@@ -132,6 +156,11 @@ defmodule WandererApp.Api.MapWebhookSubscription do
|
||||
new_secret = generate_webhook_secret()
|
||||
Ash.Changeset.change_attribute(changeset, :secret, new_secret)
|
||||
end
|
||||
|
||||
change after_action(fn _changeset, record, _context ->
|
||||
WandererApp.ExternalEvents.WebhookDispatcher.invalidate_cache(record.map_id)
|
||||
{:ok, record}
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
64
lib/wanderer_app/api/preparations/filter_by_actor_map.ex
Normal file
64
lib/wanderer_app/api/preparations/filter_by_actor_map.ex
Normal file
@@ -0,0 +1,64 @@
|
||||
defmodule WandererApp.Api.Preparations.FilterByActorMap do
|
||||
@moduledoc """
|
||||
Shared filtering logic for actor map context.
|
||||
|
||||
Filters queries to only return resources belonging to the actor's map.
|
||||
Used by preparations for MapSystem, MapConnection, and MapPing resources.
|
||||
"""
|
||||
|
||||
require Ash.Query
|
||||
|
||||
alias WandererApp.Api.ActorHelpers
|
||||
|
||||
@doc """
|
||||
Filter a query by the actor's map context.
|
||||
|
||||
If a map is found in the context, filters the query to only return
|
||||
resources where map_id matches. If no map context exists, returns
|
||||
a query that will return no results.
|
||||
|
||||
## Parameters
|
||||
|
||||
* `query` - The Ash query to filter
|
||||
* `context` - The Ash context containing actor/map information
|
||||
* `resource_name` - Name of the resource for telemetry (atom)
|
||||
|
||||
## Examples
|
||||
|
||||
iex> query = Ash.Query.new(WandererApp.Api.MapSystem)
|
||||
iex> context = %{map: %{id: "map-123"}}
|
||||
iex> result = FilterByActorMap.filter_by_map(query, context, :map_system)
|
||||
# Returns query filtered by map_id == "map-123"
|
||||
"""
|
||||
def filter_by_map(query, context, resource_name) do
|
||||
case ActorHelpers.get_map(context) do
|
||||
%{id: map_id} ->
|
||||
emit_telemetry(resource_name, map_id)
|
||||
Ash.Query.filter(query, map_id == ^map_id)
|
||||
|
||||
nil ->
|
||||
emit_telemetry_no_context(resource_name)
|
||||
Ash.Query.filter(query, false)
|
||||
|
||||
_other ->
|
||||
emit_telemetry_no_context(resource_name)
|
||||
Ash.Query.filter(query, false)
|
||||
end
|
||||
end
|
||||
|
||||
defp emit_telemetry(resource_name, map_id) do
|
||||
:telemetry.execute(
|
||||
[:wanderer_app, :ash, :preparation, :filter_by_map],
|
||||
%{count: 1},
|
||||
%{resource: resource_name, map_id: map_id}
|
||||
)
|
||||
end
|
||||
|
||||
defp emit_telemetry_no_context(resource_name) do
|
||||
:telemetry.execute(
|
||||
[:wanderer_app, :ash, :preparation, :filter_by_map, :no_context],
|
||||
%{count: 1},
|
||||
%{resource: resource_name}
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
defmodule WandererApp.Api.Preparations.FilterConnectionsByActorMap do
|
||||
@moduledoc """
|
||||
Ash preparation that filters connections to only those from the actor's map.
|
||||
|
||||
For token-based auth, this ensures the API only returns connections
|
||||
from the map associated with the token.
|
||||
"""
|
||||
|
||||
use Ash.Resource.Preparation
|
||||
|
||||
alias WandererApp.Api.Preparations.FilterByActorMap
|
||||
|
||||
@impl true
|
||||
def prepare(query, _opts, context) do
|
||||
FilterByActorMap.filter_by_map(query, context, :map_connection)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
defmodule WandererApp.Api.Preparations.FilterPingsByActorMap do
|
||||
@moduledoc """
|
||||
Ash preparation that filters pings to only those from the actor's map.
|
||||
|
||||
For token-based auth, this ensures the API only returns pings
|
||||
from the map associated with the token.
|
||||
"""
|
||||
|
||||
use Ash.Resource.Preparation
|
||||
|
||||
alias WandererApp.Api.Preparations.FilterByActorMap
|
||||
|
||||
@impl true
|
||||
def prepare(query, _opts, context) do
|
||||
FilterByActorMap.filter_by_map(query, context, :map_ping)
|
||||
end
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user