From 76a9710516901d7d123bc3893c3654adc4ae639e Mon Sep 17 00:00:00 2001 From: Alina Date: Wed, 18 Feb 2026 09:18:01 +0300 Subject: [PATCH] feat: double mock data and configure edge obstacle avoidance Programmatically duplicate mock data (10 new sites with unique names and IDs). Configure Manhattan router to route edges around device nodes by excluding site containers and source/target terminals from obstacles. Co-Authored-By: Claude Opus 4.6 --- .../app/features/schema/edges/edge-config.ts | 10 ++- .../app/features/schema/graph/init-graph.ts | 20 ++++- frontend/src/app/mock/schema-data.ts | 88 ++++++++++++++++++- 3 files changed, 114 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/features/schema/edges/edge-config.ts b/frontend/src/app/features/schema/edges/edge-config.ts index 63f180a..10913c0 100644 --- a/frontend/src/app/features/schema/edges/edge-config.ts +++ b/frontend/src/app/features/schema/edges/edge-config.ts @@ -21,7 +21,15 @@ export function createEdgeConfig( const router = routerType === 'manhattan' - ? { name: 'manhattan' as const, args: { padding: 20 } } + ? { + name: 'manhattan' as const, + args: { + padding: 20, + excludeTerminals: ['source' as const, 'target' as const], + excludeShapes: ['site-node'], + step: 10, + }, + } : { name: 'normal' as const }; return { diff --git a/frontend/src/app/features/schema/graph/init-graph.ts b/frontend/src/app/features/schema/graph/init-graph.ts index 1a59ad3..232a7de 100644 --- a/frontend/src/app/features/schema/graph/init-graph.ts +++ b/frontend/src/app/features/schema/graph/init-graph.ts @@ -36,7 +36,15 @@ export function initGraph( allowMulti: true, allowPort: true, highlight: true, - router: { name: 'manhattan' }, + router: { + name: 'manhattan', + args: { + padding: 20, + excludeTerminals: ['source', 'target'], + excludeShapes: ['site-node'], + step: 10, + }, + }, connector: { name: 'rounded', args: { radius: 8 } }, connectionPoint: 'anchor', anchor: 'center', @@ -52,7 +60,15 @@ export function initGraph( sourceMarker: null, }, }, - router: { name: 'manhattan' }, + router: { + name: 'manhattan', + args: { + padding: 20, + excludeTerminals: ['source', 'target'], + excludeShapes: ['site-node'], + step: 10, + }, + }, connector: { name: 'rounded', args: { radius: 8 } }, }); }, diff --git a/frontend/src/app/mock/schema-data.ts b/frontend/src/app/mock/schema-data.ts index ac98777..d1863ea 100644 --- a/frontend/src/app/mock/schema-data.ts +++ b/frontend/src/app/mock/schema-data.ts @@ -8,7 +8,7 @@ import { LineType, } from '../types/index'; -export const mockData: SchemaData = { +const baseMockData: SchemaData = { sites: [ { id: 'site-1', @@ -1508,3 +1508,89 @@ export const mockData: SchemaData = { { id: 'fiber-3', name: 'Волокно 3', status: EntityStatus.Active, lineId: 'line-14', portAId: 'p-c3-l6', portZId: 'p-xdsl-4' }, ], }; + +const SITE_NAMES: Record = { + 'site-1': { name: 'Узел связи Промышленный', address: 'ул. Заводская, 101' }, + 'site-2': { name: 'Узел связи Речной', address: 'наб. Речная, 115' }, + 'site-3': { name: 'Узел связи Аэропорт', address: 'Аэропортовская, 142' }, + 'site-4': { name: 'Узел связи Университетский', address: 'пр. Науки, 107' }, + 'site-5': { name: 'Узел связи Вокзальный', address: 'Привокзальная пл., 122' }, + 'site-1-1': { name: 'Подузел Складской', address: 'ул. Заводская, 101а' }, + 'site-1-2': { name: 'Подузел Причальный', address: 'ул. Заводская, 101б' }, + 'site-2-1': { name: 'Подузел Терминальный', address: 'наб. Речная, 115а' }, + 'site-4-1': { name: 'Подузел Лабораторный', address: 'пр. Науки, 107а' }, + 'site-5-1': { name: 'Подузел Депо', address: 'Привокзальная пл., 122б' }, +}; + +function duplicateData(data: SchemaData): SchemaData { + const P = 'd-'; + const r = (id: string): string => P + id; + const rn = (id: string | null): string | null => (id ? r(id) : null); + + const shiftIp = (ip: string): string => { + if (!ip) return ''; + return ip.replace(/^10\.0\.(\d+)/, (_, n) => `10.1.${n}`); + }; + + const shiftCode = (code: string): string => + code.replace(/(\d+)$/, (m) => String(parseInt(m, 10) + 100).padStart(3, '0')); + + const newSites = data.sites.map((s) => ({ + ...s, + id: r(s.id), + name: SITE_NAMES[s.id]?.name ?? s.name, + address: SITE_NAMES[s.id]?.address ?? s.address, + erpCode: shiftCode(s.erpCode), + code1C: shiftCode(s.code1C), + parentSiteId: rn(s.parentSiteId), + })); + + const newDevices = data.devices.map((d) => ({ + ...d, + id: r(d.id), + ipAddress: shiftIp(d.ipAddress), + id1: shiftCode(d.id1), + id2: d.id2 ? shiftCode(d.id2) : '', + siteId: r(d.siteId), + })); + + const newCards = data.cards.map((c) => ({ + ...c, + id: r(c.id), + deviceId: r(c.deviceId), + })); + + const newPorts = data.ports.map((p) => ({ + ...p, + id: r(p.id), + deviceId: r(p.deviceId), + cardId: rn(p.cardId), + })); + + const newLines = data.lines.map((l) => ({ + ...l, + id: r(l.id), + name: l.name, + portAId: r(l.portAId), + portZId: r(l.portZId), + })); + + const newFibers = data.fibers.map((f) => ({ + ...f, + id: r(f.id), + lineId: r(f.lineId), + portAId: r(f.portAId), + portZId: r(f.portZId), + })); + + return { + sites: [...data.sites, ...newSites], + devices: [...data.devices, ...newDevices], + cards: [...data.cards, ...newCards], + ports: [...data.ports, ...newPorts], + lines: [...data.lines, ...newLines], + fibers: [...data.fibers, ...newFibers], + }; +} + +export const mockData: SchemaData = duplicateData(baseMockData);