feat: F4.7 the data exchange window, measured against Java's
One row per frame (its highest layer's), Java's detail tree, the table as Java's text file, "Tabellen löschen" for every card (clearCapture in the room), a tab per card with Java's title, Java's layer colours as tokens, the chosen frame and autoscroll per tab. New oracle ExchangeWindowRun. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,7 @@ import {
|
||||
import { modemPort } from '@mdg-filius/fls';
|
||||
import { inOrder, ROOTS } from './projectDoc.js';
|
||||
import { fromY } from './values.js';
|
||||
import { nodeLabel } from './view.js';
|
||||
import { cardAddress, nodeLabel } from './view.js';
|
||||
|
||||
/** A device's DHCP server as Java's dialog shows it (JDHCPKonfiguration). */
|
||||
export interface DhcpServerSheet {
|
||||
@@ -147,22 +147,6 @@ const setting = (node: Y.Map<unknown>, key: string) => settingsOf(node).get(key)
|
||||
|
||||
const text = (map: Y.Map<unknown> | undefined, key: string) => (map?.get(key) as string | undefined) ?? '';
|
||||
|
||||
/** The address of a device's card at a port, as Java's NetzwerkInterface holds it; null for a device without cards (InternetKnoten). */
|
||||
function cardAddress(node: Y.Map<unknown>, portId: string): string | null {
|
||||
switch (node.get('kind') as NodeKind) {
|
||||
case 'pc':
|
||||
case 'notebook':
|
||||
return text(setting(node, 'device'), 'ipAddress');
|
||||
case 'router':
|
||||
case 'gateway': {
|
||||
const port = (node.get('ports') as Y.Array<Y.Map<unknown>>).toArray().find((each) => each.get('id') === portId);
|
||||
return text(port?.get('config') as Y.Map<unknown> | undefined, 'ipAddress');
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** A router's or home router's cards, each with what its cable joins. */
|
||||
function interfacesOf(doc: Y.Doc, id: string, node: Y.Map<unknown>): InterfaceSheet[] {
|
||||
const all = doc.getMap<Y.Map<unknown>>(ROOTS.nodes);
|
||||
|
||||
@@ -69,6 +69,51 @@ export function nodeLabel(node: Y.Map<unknown>): string {
|
||||
return `${ip} (${mac})`;
|
||||
}
|
||||
|
||||
/** The address of a device's card at a port, as Java's NetzwerkInterface holds it; null for a device without cards (InternetKnoten). */
|
||||
export function cardAddress(node: Y.Map<unknown>, portId: string): string | null {
|
||||
const text = (map: Y.Map<unknown> | undefined) => (map?.get('ipAddress') as string | undefined) ?? '';
|
||||
switch (node.get('kind') as NodeKind) {
|
||||
case 'pc':
|
||||
case 'notebook':
|
||||
return text(settingsOf(node)?.get('device'));
|
||||
case 'router':
|
||||
case 'gateway': {
|
||||
const port = (node.get('ports') as Y.Array<Y.Map<unknown>>).toArray().find((each) => each.get('id') === portId);
|
||||
return text(port?.get('config') as Y.Map<unknown> | undefined);
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** A card whose frames the data exchange window shows: its port, address and the title of its tab. */
|
||||
export interface CaptureCard {
|
||||
readonly portId: string;
|
||||
readonly ipAddress: string;
|
||||
readonly title: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A device's cards in the order of its ports, as Java's menu offers their
|
||||
* data exchange (GUIEvents.kontextMenueAktionsmodus); empty for a device
|
||||
* without cards. A tab's title is the card's address where the label is the
|
||||
* address (Host.isUseIPAsName), else the label, " - " and the address
|
||||
* (AggregatedExchangePanel.updateTabTitle).
|
||||
*/
|
||||
export function captureCards(doc: Y.Doc, id: string): CaptureCard[] {
|
||||
const node = doc.getMap<Y.Map<unknown>>(ROOTS.nodes).get(id);
|
||||
if (node === undefined) return [];
|
||||
const policy = node.get('labelPolicy') as HostLabelPolicy;
|
||||
const kind = node.get('kind') as NodeKind;
|
||||
const addressAsName = (kind === 'pc' || kind === 'notebook') && (policy === 'ipAddress' || policy === 'ipAndMAC');
|
||||
return (node.get('ports') as Y.Array<Y.Map<unknown>>).toArray().flatMap((port) => {
|
||||
const portId = port.get('id') as string;
|
||||
const ipAddress = cardAddress(node, portId);
|
||||
if (ipAddress === null) return [];
|
||||
return [{ portId, ipAddress, title: addressAsName ? ipAddress : `${nodeLabel(node)} - ${ipAddress}` }];
|
||||
});
|
||||
}
|
||||
|
||||
/** The drawing of the document, in the order of its devices and cables. */
|
||||
export function topologyView(doc: Y.Doc): TopologyView {
|
||||
const kinds = new Map<string, NodeKind>();
|
||||
|
||||
Reference in New Issue
Block a user