feat: double mock data and configure edge obstacle avoidance
All checks were successful
continuous-integration/drone/push Build is passing

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 <noreply@anthropic.com>
This commit is contained in:
Alina
2026-02-18 09:18:01 +03:00
parent 542317ecda
commit 76a9710516
3 changed files with 114 additions and 4 deletions

View File

@ -21,7 +21,15 @@ export function createEdgeConfig(
const router = const router =
routerType === 'manhattan' 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 }; : { name: 'normal' as const };
return { return {

View File

@ -36,7 +36,15 @@ export function initGraph(
allowMulti: true, allowMulti: true,
allowPort: true, allowPort: true,
highlight: 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 } }, connector: { name: 'rounded', args: { radius: 8 } },
connectionPoint: 'anchor', connectionPoint: 'anchor',
anchor: 'center', anchor: 'center',
@ -52,7 +60,15 @@ export function initGraph(
sourceMarker: null, 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 } }, connector: { name: 'rounded', args: { radius: 8 } },
}); });
}, },

View File

@ -8,7 +8,7 @@ import {
LineType, LineType,
} from '../types/index'; } from '../types/index';
export const mockData: SchemaData = { const baseMockData: SchemaData = {
sites: [ sites: [
{ {
id: 'site-1', 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' }, { id: 'fiber-3', name: 'Волокно 3', status: EntityStatus.Active, lineId: 'line-14', portAId: 'p-c3-l6', portZId: 'p-xdsl-4' },
], ],
}; };
const SITE_NAMES: Record<string, { name: string; address: string }> = {
'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);