feat(tours): paddle obstacle card, admin regions panel and obstacle marks on the route band

PAD-05B: a click on an obstacle on the map or on the route band opens its card in the look of the via ferrata card: the kind with its glyph, the name, how it stands to the route (on it at a distance along it, near it with the link marked unclear, or only in the area), the paddling rule its tags give with canoe read before boat, a condition as written, height, grade, hours and fees, the source with the date of the data and the OpenStreetMap link. A missing rule reads as unknown, never as allowed, and a portage way recorded as private says so. Objects only in the area show from zoom 13 on, on Leaflet and GL alike; on GL the lines only near the route are dashed as on Leaflet, one click handler picks the marker over the line, and a picked marker no longer flickers. The route band marks the obstacles on and near the route by their share of the measured line. The obstacle notice also names an answer cut at its limit.

PAD-05A: the admin area gets a Paddle water data card under the addons, on desktop and phone: a search in Geofabrik's list with each region's path, the regions with their state (waiting, reading with its progress, ready with objects and data date, failed with the reason), reading again and removing after a confirmation. The list follows a read without reloading. Region changes write audit rows.

Map colours of paddle objects and portages come from theme tokens read at draw time, as the via ferratas do; the ferrata layer now shares that reader. The rail takes the planner page's parts as one bag, the map hit tests of the tour layers are one helper, and the unused noWaterData string is gone from every locale.
This commit is contained in:
Maurice
2026-10-16 23:03:09 +00:00
parent 89ad4ec56a
commit 03d6457bde
97 changed files with 1924 additions and 492 deletions
@@ -1,13 +1,17 @@
import { ADDON_IDS } from '../../addons';
import type { User } from '../../types';
import { AddonGuard } from '../addons/addon.guard';
import { RequireAddon } from '../addons/require-addon.decorator';
import { AuditService } from '../audit/audit.service';
import { getClientIp } from '../audit/client-ip';
import { AdminGuard } from '../auth-core/admin.guard';
import { CurrentUser } from '../auth-core/current-user.decorator';
import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';
import { ResponseContract } from '../common/response-contract';
import { PaddleObstaclesQueryDto, PaddleRegionCatalogQueryDto, PaddleRegionRequestDto } from './paddle-obstacles.dto';
import { PaddleObstaclesService } from './paddle-obstacles.service';
import { PaddleRegionsService } from './paddle-regions.service';
import { Body, Controller, Get, HttpCode, Post, Query, UseGuards } from '@nestjs/common';
import { Body, Controller, Get, HttpCode, Post, Query, Req, UseGuards } from '@nestjs/common';
import {
paddleObstaclesResponseSchema,
paddleRegionCatalogResponseSchema,
@@ -16,6 +20,8 @@ import {
successResponseSchema,
} from '@trek/shared';
import type { Request } from 'express';
/**
* GET /api/paddle/obstacles?bbox=: the paddle objects of a map area and its
* coverage (PAD-05A), for anyone signed in while Tours is on. The data is
@@ -37,14 +43,17 @@ export class PaddleObstaclesController {
/**
* /api/admin/paddle-regions: which regions TREK reads paddle data for. The
* list, Geofabrik's catalogue to pick from, adding (which starts the first
* read), reading again and removing. Ids travel in the body or the query:
* Geofabrik's are plain words, but a route segment is no place for a choice
* that names an outside source.
* read), reading again and removing, each change with its audit row. Ids
* travel in the body or the query: some of Geofabrik's hold a slash, and a
* route segment is no place for a choice that names an outside source.
*/
@Controller('api/admin/paddle-regions')
@UseGuards(JwtAuthGuard, AdminGuard)
export class PaddleRegionsController {
constructor(private readonly regions: PaddleRegionsService) {}
constructor(
private readonly regions: PaddleRegionsService,
private readonly audit: AuditService,
) {}
@Get()
@ResponseContract(paddleRegionListResponseSchema)
@@ -60,22 +69,31 @@ export class PaddleRegionsController {
@Post()
@ResponseContract(paddleRegionSchema)
async add(@Body() body: PaddleRegionRequestDto) {
return await this.regions.add(body.id);
async add(@CurrentUser() user: User, @Body() body: PaddleRegionRequestDto, @Req() req: Request) {
const region = await this.regions.add(body.id);
await this.record(user, 'admin.paddle_region_add', body.id, req);
return region;
}
@Post('refresh')
@HttpCode(200)
@ResponseContract(paddleRegionSchema)
async refresh(@Body() body: PaddleRegionRequestDto) {
return await this.regions.refresh(body.id);
async refresh(@CurrentUser() user: User, @Body() body: PaddleRegionRequestDto, @Req() req: Request) {
const region = await this.regions.refresh(body.id);
await this.record(user, 'admin.paddle_region_refresh', body.id, req);
return region;
}
@Post('remove')
@HttpCode(200)
@ResponseContract(successResponseSchema)
async remove(@Body() body: PaddleRegionRequestDto) {
async remove(@CurrentUser() user: User, @Body() body: PaddleRegionRequestDto, @Req() req: Request) {
await this.regions.remove(body.id);
await this.record(user, 'admin.paddle_region_remove', body.id, req);
return { success: true as const };
}
private async record(user: User, action: string, region: string, req: Request): Promise<void> {
await this.audit.writeAudit({ userId: user.id, action, ip: getClientIp(req), details: { region } });
}
}
@@ -1,6 +1,7 @@
import { PaddleFeatures } from '../../db/entities/PaddleFeatures.entity';
import { PaddleRegions } from '../../db/entities/PaddleRegions.entity';
import { AddonsModule } from '../addons/addons.module';
import { AuditModule } from '../audit/audit.module';
import { SchedulingModule } from '../scheduling/scheduling.module';
import { GeofabrikClient } from './geofabrik.client';
import { PaddleObstaclesController, PaddleRegionsController } from './paddle-obstacles.controller';
@@ -17,7 +18,7 @@ import { Module } from '@nestjs/common';
* domain's route checks (PAD-06, PAD-09).
*/
@Module({
imports: [AddonsModule, SchedulingModule, MikroOrmModule.forFeature([PaddleRegions, PaddleFeatures])],
imports: [AddonsModule, AuditModule, SchedulingModule, MikroOrmModule.forFeature([PaddleRegions, PaddleFeatures])],
controllers: [PaddleObstaclesController, PaddleRegionsController],
providers: [GeofabrikClient, PaddleObstaclesService, PaddleRegionsService, PaddleRegionsJob],
exports: [PaddleObstaclesService],