Create clean release database baseline

This commit is contained in:
Julian Appel 2026-07-31 14:07:26 +02:00
parent 5bee3cb103
commit 734a2bcfc4
129 changed files with 2121 additions and 30607 deletions

View file

@ -30,10 +30,8 @@ import {
formatPhaseTypeLabel,
formatValue,
getCircuitSectionLabel,
getLegacyProjectColumnLayoutStorageKey,
getProjectColumnLayoutStorageKey,
isGridEditorControlTarget,
migrateLegacyColumnLayout,
normalizeColumnOrder,
parseStoredColumnLayout,
} from "../utils/circuit-grid-model";
@ -191,9 +189,6 @@ type CircuitReorderDropIntent =
| { kind: "after-circuit"; sectionId: string; targetCircuitId: string; valid: boolean }
| { kind: "section-end"; sectionId: string; valid: boolean };
const LEGACY_COLUMN_LAYOUT_STORAGE_KEY =
"circuitTreeEditor.columnLayout.v1";
function normalizeUiError(err: unknown): string {
const message = err instanceof Error ? err.message : "Der Vorgang ist fehlgeschlagen.";
try {
@ -379,25 +374,11 @@ export function CircuitTreeEditor(props: { projectId: string; circuitListId: str
const currentLayout = parseStoredColumnLayout(
localStorage.getItem(getProjectColumnLayoutStorageKey(projectId))
);
const legacyLayout =
parseStoredColumnLayout(
localStorage.getItem(
getLegacyProjectColumnLayoutStorageKey(projectId)
)
) ??
parseStoredColumnLayout(
localStorage.getItem(LEGACY_COLUMN_LAYOUT_STORAGE_KEY)
);
const parsed =
currentLayout ??
(legacyLayout
? migrateLegacyColumnLayout(legacyLayout)
: null);
if (!parsed) {
if (!currentLayout) {
return;
}
setColumnOrder(parsed.order);
setVisibleColumnKeys(parsed.visible);
setColumnOrder(currentLayout.order);
setVisibleColumnKeys(currentLayout.visible);
} catch {
// ignore invalid local storage and use defaults
} finally {

View file

@ -114,11 +114,11 @@ function SectionRows(props: { section: CircuitTreeResponseDto["sections"][number
<td className="text-end">
{formatValue(circuit.circuitTotalPower, "circuitTotalPower")}
</td>
<td>{circuit.protectionType ?? "-"}</td>
<td>{circuit.protectionDevice?.type ?? "-"}</td>
<td className="text-end">
{formatValue(circuit.protectionRatedCurrent, "protectionRatedCurrent")}
{formatValue(circuit.protectionDevice?.ratedCurrentA, "protectionRatedCurrent")}
</td>
<td>{circuit.protectionCharacteristic ?? "-"}</td>
<td>{circuit.protectionDevice?.tripCharacteristic ?? circuit.protectionDevice?.fuseUtilizationCategory ?? "-"}</td>
<td>{circuit.cableType ?? "-"}</td>
<td>{circuit.cableCrossSection ?? "-"}</td>
<td className="text-end">{formatValue(circuit.cableLength, "cableLength")}</td>
@ -147,11 +147,11 @@ function SectionRows(props: { section: CircuitTreeResponseDto["sections"][number
</td>
<td className="text-end">{formatValue(row.cosPhi, "cosPhi")}</td>
<td className="text-end">{formatValue(row.rowTotalPower, "rowTotalPower")}</td>
<td>{circuit.protectionType ?? "-"}</td>
<td>{circuit.protectionDevice?.type ?? "-"}</td>
<td className="text-end">
{formatValue(circuit.protectionRatedCurrent, "protectionRatedCurrent")}
{formatValue(circuit.protectionDevice?.ratedCurrentA, "protectionRatedCurrent")}
</td>
<td>{circuit.protectionCharacteristic ?? "-"}</td>
<td>{circuit.protectionDevice?.tripCharacteristic ?? circuit.protectionDevice?.fuseUtilizationCategory ?? "-"}</td>
<td>{circuit.cableType ?? "-"}</td>
<td>{circuit.cableCrossSection ?? "-"}</td>
<td className="text-end">{formatValue(circuit.cableLength, "cableLength")}</td>
@ -169,11 +169,11 @@ function SectionRows(props: { section: CircuitTreeResponseDto["sections"][number
<td className="text-end">
{formatValue(circuit.circuitTotalPower, "circuitTotalPower")}
</td>
<td>{circuit.protectionType ?? "-"}</td>
<td>{circuit.protectionDevice?.type ?? "-"}</td>
<td className="text-end">
{formatValue(circuit.protectionRatedCurrent, "protectionRatedCurrent")}
{formatValue(circuit.protectionDevice?.ratedCurrentA, "protectionRatedCurrent")}
</td>
<td>{circuit.protectionCharacteristic ?? "-"}</td>
<td>{circuit.protectionDevice?.tripCharacteristic ?? circuit.protectionDevice?.fuseUtilizationCategory ?? "-"}</td>
<td>{circuit.cableType ?? "-"}</td>
<td>{circuit.cableCrossSection ?? "-"}</td>
<td className="text-end">{formatValue(circuit.cableLength, "cableLength")}</td>

View file

@ -267,7 +267,6 @@ export interface ProjectDeviceSyncCommandResultDto
export interface CircuitTreeDeviceRowDto {
id: string;
linkedProjectDeviceId?: string;
legacyConsumerId?: string;
sortOrder: number;
name: string;
displayName: string;
@ -316,9 +315,6 @@ export interface CircuitTreeCircuitDto {
equipmentIdentifier: string;
displayName?: string;
sortOrder: number;
protectionType?: string;
protectionRatedCurrent?: number;
protectionCharacteristic?: string;
cableType?: string;
cableCrossSection?: string;
cableLength?: number;
@ -347,17 +343,6 @@ export interface CircuitTreeSectionDto {
circuits: CircuitTreeCircuitDto[];
}
export interface CircuitTreeMigrationReportDto {
circuitListId: string;
legacyConsumerCount: number;
createdCircuitCount: number;
createdDeviceRowCount: number;
groupedDuplicateCircuitNumbers: Array<{ normalizedCircuitNumber: string; count: number }>;
generatedIdentifiers: string[];
unassignedRows: Array<{ consumerId: string; reason: string }>;
warnings: string[];
}
export interface CircuitTreeResponseDto {
circuitListId: string;
currentRevision: number;
@ -369,7 +354,6 @@ export interface CircuitTreeResponseDto {
headerComponents: CircuitTreeComponentDto[];
sections: CircuitTreeSectionDto[];
footerComponents: CircuitTreeComponentDto[];
migrationReport?: CircuitTreeMigrationReportDto;
}
export interface CreateCircuitInputDto {
@ -377,9 +361,6 @@ export interface CreateCircuitInputDto {
equipmentIdentifier: string;
displayName?: string;
sortOrder: number;
protectionType?: string;
protectionRatedCurrent?: number;
protectionCharacteristic?: string;
cableType?: string;
cableCrossSection?: string;
cableLength?: number;

View file

@ -130,8 +130,6 @@ export const defaultVisibleColumnKeys = allColumns
const projectColumnLayoutStoragePrefix =
"circuitTreeEditor.columnLayout.v3";
const legacyProjectColumnLayoutStoragePrefix =
"circuitTreeEditor.columnLayout.v2";
export interface CircuitColumnLayout {
order: CellKey[];
@ -164,12 +162,6 @@ export function getProjectColumnLayoutStorageKey(
return `${projectColumnLayoutStoragePrefix}.${projectId}`;
}
export function getLegacyProjectColumnLayoutStorageKey(
projectId: string
): string {
return `${legacyProjectColumnLayoutStoragePrefix}.${projectId}`;
}
export function normalizeColumnOrder(keys: CellKey[]): CellKey[] {
const unique = [...new Set(keys)];
const allKeys = allColumns.map((column) => column.key);
@ -233,28 +225,6 @@ export function parseStoredColumnLayout(
}
}
export function migrateLegacyColumnLayout(
layout: CircuitColumnLayout
): CircuitColumnLayout {
const newlyVisibleKey: CellKey = "protectionSummary";
const order = layout.order.filter(
(key) => key !== newlyVisibleKey
) as CellKey[];
const totalPowerIndex = order.indexOf("rowTotalPower");
order.splice(
totalPowerIndex >= 0 ? totalPowerIndex + 1 : order.length,
0,
newlyVisibleKey
);
return {
order,
visible: layout.visible.includes(newlyVisibleKey)
? layout.visible
: [...layout.visible, newlyVisibleKey],
};
}
const deviceOnlyColumns = new Set<CellKey>([
"quantity",
"powerPerUnit",
@ -422,11 +392,7 @@ export function buildCircuitEditPatch(
if (key === "protectionSummary" || key === "cableSummary") {
return { remark: draft.trim() || null };
}
if (
key === "protectionRatedCurrent" ||
key === "cableLength" ||
key === "voltage"
) {
if (key === "cableLength" || key === "voltage") {
return { [key]: parseNumeric(key, draft) ?? null };
}
if (key === "isReserve") {
@ -530,23 +496,14 @@ export function getCircuitValue(circuit: CircuitTreeCircuitDto, key: CellKey): G
case "protectionType":
return protection
? protectionDeviceTypeLabels[protection.type]
: circuit.protectionType;
: undefined;
case "protectionRatedCurrent":
return protection?.ratedCurrentA ?? circuit.protectionRatedCurrent;
return protection?.ratedCurrentA;
case "protectionCharacteristic":
return protectionCharacteristic || circuit.protectionCharacteristic;
return protectionCharacteristic || undefined;
case "protectionSummary": {
if (!protection) {
const legacyCurrent =
circuit.protectionRatedCurrent !== undefined &&
circuit.protectionRatedCurrent !== null
? `${circuit.protectionRatedCurrent}A`
: "";
return [
circuit.protectionType,
legacyCurrent,
circuit.protectionCharacteristic,
].filter(Boolean).join(" ").trim() || undefined;
return undefined;
}
const currentValue =
protection.ratedCurrentA;

View file

@ -117,11 +117,6 @@ export function buildCircuitGroupSubtreeSnapshot(
equipmentIdentifier: circuit.equipmentIdentifier,
displayName: circuit.displayName ?? null,
sortOrder: circuit.sortOrder,
protectionType: circuit.protectionType ?? null,
protectionRatedCurrent:
circuit.protectionRatedCurrent ?? null,
protectionCharacteristic:
circuit.protectionCharacteristic ?? null,
cableType: circuit.cableType ?? null,
cableCrossSection: circuit.cableCrossSection ?? null,
cableLength: circuit.cableLength ?? null,
@ -143,7 +138,6 @@ export function buildCircuitGroupSubtreeSnapshot(
circuitId: circuit.id,
linkedProjectDeviceId:
row.linkedProjectDeviceId ?? null,
legacyConsumerId: row.legacyConsumerId ?? null,
sortOrder: row.sortOrder,
name: row.name,
displayName: row.displayName,

View file

@ -22,7 +22,6 @@ export function buildCircuitDeviceRowInsertSnapshot(input: {
id,
circuitId,
linkedProjectDeviceId: values.linkedProjectDeviceId ?? null,
legacyConsumerId: null,
sortOrder: values.sortOrder ?? defaultSortOrder,
name: values.name,
displayName: values.displayName,
@ -61,9 +60,6 @@ export function buildCircuitInsertSnapshot(input: {
equipmentIdentifier: values.equipmentIdentifier,
displayName: values.displayName ?? null,
sortOrder: values.sortOrder,
protectionType: values.protectionType ?? null,
protectionRatedCurrent: values.protectionRatedCurrent ?? null,
protectionCharacteristic: values.protectionCharacteristic ?? null,
cableType: values.cableType ?? null,
cableCrossSection: values.cableCrossSection ?? null,
cableLength: values.cableLength ?? null,