Add environment infrastructure drill-down

This commit is contained in:
2026-11-05 22:59:37 +00:00
parent 4318454a7a
commit 163f99be54
5 changed files with 40 additions and 5 deletions
+11 -2
View File
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
import { LGraph, LGraphCanvas, LiteGraph } from 'litegraph.js'
import { cloneCapabilities, demoLandscape, SYSTEM_PRESETS, systemFromPreset, type CapabilityModel, type ConnectionModel, type DefinitionActionModel, type EndpointModel, type EndpointResponseModel, type EnvironmentContainerModel, type LandscapeModel, type ScenarioModel, type ScenarioStep, type SystemDefinition, type SystemModel, type SystemPreset, uid, validateLandscape } from './model'
import { cloneCapabilities, demoLandscape, SYSTEM_PRESETS, systemFromPreset, type CapabilityModel, type ComponentRole, type ConnectionModel, type DefinitionActionModel, type EndpointModel, type EndpointResponseModel, type EnvironmentContainerModel, type EnvironmentModel, type InfrastructureComponent, type LandscapeModel, type ScenarioModel, type ScenarioStep, type SystemDefinition, type SystemModel, type SystemPreset, uid, validateLandscape } from './model'
const STORAGE_KEY = 'dumas-system-landscape-v1'
const PRESET_STORAGE_KEY = 'dumas-system-presets-v1'
@@ -45,6 +45,8 @@ const transferHistory = ref<TransferRecord[]>([])
const dataTab = ref<TransferKind>('received')
const selectedContainerId = ref('')
const selectedContainer = computed(() => landscape.value.containers.find((item) => item.id === selectedContainerId.value))
const selectedEnvironmentId = ref('')
const selectedEnvironment = computed(() => { const system = selectedSystem.value; return system?.environments?.find((item) => item.id === selectedEnvironmentId.value) || system?.environments?.[0] })
const allTags = computed(() => [...new Set(landscape.value.systems.flatMap((system) => system.tags || []))].sort())
function loadLandscape(): LandscapeModel {
@@ -60,13 +62,18 @@ const isRunning = computed(() => playing.value || stepIndex.value >= 0)
function persist() { localStorage.setItem(STORAGE_KEY, JSON.stringify(landscape.value)) }
function persistPresets() { localStorage.setItem(PRESET_STORAGE_KEY, JSON.stringify(customPresets.value)) }
function selectSystem(id: string) { selectedSystemId.value = id; selectedConnectionId.value = '' }
function selectSystem(id: string) { selectedSystemId.value = id; selectedConnectionId.value = ''; selectedEnvironmentId.value = landscape.value.systems.find((item) => item.id === id)?.environments?.[0]?.id || '' }
function selectContainer(id: string) { selectedContainerId.value = id; selectedSystemId.value = ''; selectedConnectionId.value = '' }
function selectConnection(id: string) { selectedConnectionId.value = id; selectedSystemId.value = ''; const connection = landscape.value.connections.find((item) => item.id === id); if (connection) { connection.transformation ||= { incoming: connection.payload, outgoing: connection.payload, note: '' }; connection.protocol ||= 'HTTPS'; connection.dataType ||= 'JSON'; connection.deliveryMethod ||= 'immediate'; connection.exchangeType ||= 'event-transfer'; connection.responsePayload ||= '{}'; connection.responseStatus ||= 200; connection.showCableLabel ??= true } }
function addSystem() {
const id = uid('system'); landscape.value.systems.push({ id, name: 'New system', description: 'Describe this system.', category: 'service', color: '#6d7cff', position: [160, 160], containerId: landscape.value.containers[0]?.id, tags: ['Test'], capabilities: [] }); selectSystem(id); persist(); rebuildGraph()
}
function addContainer() { const id = uid('container'); landscape.value.containers.push({ id, name: 'New environment', color: '#2879d0', position: [80, 80], size: [500, 320] }); selectContainer(id); persist(); rebuildGraph() }
function selectEnvironment(id: string) { selectedEnvironmentId.value = id }
function cloneEnvironment(environment: EnvironmentModel) { if (!selectedSystem.value) return; const clone = structuredClone(environment); clone.id = uid('environment'); clone.name = `${environment.name} copy`; selectedSystem.value.environments ||= []; selectedSystem.value.environments.push(clone); selectedEnvironmentId.value = clone.id; persist() }
function addEnvironment() { if (!selectedSystem.value) return; const environment: EnvironmentModel = { id: uid('environment'), name: 'New environment', systemId: selectedSystem.value.id, configuration: { properties: { example: 'true', secret: '<SECRET_PLACEHOLDER>' } }, components: [], connections: [] }; selectedSystem.value.environments ||= []; selectedSystem.value.environments.push(environment); selectedEnvironmentId.value = environment.id; persist() }
function addComponent() { const environment = selectedEnvironment.value; if (!environment) return; const component: InfrastructureComponent = { id: uid('component'), name: 'New component', role: 'web-application', instanceName: 'Instance-01', configuration: { properties: { example: 'true', secret: '<SECRET_PLACEHOLDER>' } }, exampleConfiguration: true, position: [80, 100 + environment.components.length * 90] }; environment.components.push(component); persist() }
function deleteComponent(componentId: string) { const environment = selectedEnvironment.value; if (!environment) return; environment.components = environment.components.filter((item) => item.id !== componentId); environment.connections = environment.connections.filter((item) => item.sourceComponentId !== componentId && item.targetComponentId !== componentId); persist() }
function moveContainer(container: EnvironmentContainerModel, dx: number, dy: number) { container.position = [container.position[0] + dx, container.position[1] + dy]; for (const system of landscape.value.systems.filter((item) => item.containerId === container.id)) system.position = [system.position[0] + dx, system.position[1] + dy]; for (const child of landscape.value.containers.filter((item) => item.parentId === container.id)) child.position = [child.position[0] + dx, child.position[1] + dy]; persist(); rebuildGraph() }
function deleteContainer(id: string) { landscape.value.systems.forEach((system) => { if (system.containerId === id) delete system.containerId }); landscape.value.containers = landscape.value.containers.filter((item) => item.id !== id && item.parentId !== id); selectedContainerId.value = ''; persist(); rebuildGraph() }
function openPreset(preset: SystemPreset) { placingPreset.value = preset; selectedCapabilityIds.value = preset.capabilities.map((capability) => capability.id) }
@@ -275,5 +282,7 @@ onUnmounted(stopAnimation)
<section v-if="activeTab === 'containers'" class="container-editor panel"><div class="section-heading"><span>Environment containers</span><button class="primary" @click="addContainer">Add container</button></div><div class="container-list"><button v-for="container in landscape.containers" :key="container.id" class="list-item" :class="{selected: selectedContainerId === container.id}" @click="selectContainer(container.id)"><span class="system-dot" :style="{background: container.color}"></span><span><strong>{{ container.name }}</strong><small>{{ container.collapsed ? 'Collapsed' : 'Expanded' }} · {{ landscape.systems.filter((system) => system.containerId === container.id).length }} systems</small></span></button></div><div v-if="selectedContainer" class="container-form"><label>Name<input v-model="selectedContainer.name" @change="rebuildGraph" /></label><label>Colour<input v-model="selectedContainer.color" type="color" @change="rebuildGraph" /></label><label>Parent<select v-model="selectedContainer.parentId" @change="rebuildGraph"><option value="">No parent</option><option v-for="parent in landscape.containers.filter((item) => item.id !== selectedContainer.id)" :key="parent.id" :value="parent.id">{{ parent.name }}</option></select></label><label>Position X<input v-model.number="selectedContainer.position[0]" type="number" @change="rebuildGraph" /></label><label>Position Y<input v-model.number="selectedContainer.position[1]" type="number" @change="rebuildGraph" /></label><label>Width<input v-model.number="selectedContainer.size[0]" type="number" min="180" @change="rebuildGraph" /></label><label>Height<input v-model.number="selectedContainer.size[1]" type="number" min="120" @change="rebuildGraph" /></label><label class="checkbox-label"><input v-model="selectedContainer.collapsed" type="checkbox" @change="rebuildGraph" /> Collapse to summary</label><div class="container-move"><button class="ghost" @click="moveContainer(selectedContainer, -20, 0)">← Move</button><button class="ghost" @click="moveContainer(selectedContainer, 20, 0)">Move →</button><button class="ghost" @click="moveContainer(selectedContainer, 0, -20)">↑ Move</button><button class="ghost" @click="moveContainer(selectedContainer, 0, 20)">↓ Move</button></div><button class="text-danger" @click="deleteContainer(selectedContainer.id)">Delete container</button></div></section>
<section class="tag-panel panel"><label>Filter by system tag<select v-model="tagFilter"><option value="all">All tags</option><option v-for="tag in allTags" :key="tag">{{ tag }}</option></select></label><label v-if="selectedSystem">Selected system tags<input :value="(selectedSystem.tags || []).join(', ')" @change="selectedSystem.tags = $event.target.value.split(',').map((tag) => tag.trim()).filter(Boolean); persist()" /></label></section>
<section class="category-panel panel"><label>Filter by category<select v-model="categoryFilter"><option value="all">All categories</option><option value="application">Application</option><option value="saas-service">SaaS Service</option><option value="cloud-service">Cloud Service</option><option value="development-tool">Development Tool</option><option value="data-store">Data Store</option><option value="service">Service</option><option value="data">Data</option><option value="human">Human</option><option value="external">External</option></select></label><label>Filter connections<select v-model="connectionTypeFilter" @change="rebuildGraph"><option value="all">All relationship types</option><option value="data-flow">Data Flow</option><option value="deployment">Deployment</option><option value="dependency">Dependency</option><option value="source-repository">Source Repository</option></select></label><label v-if="selectedConnection">Selected relationship type<select v-model="selectedConnection.connectionType"><option value="data-flow">Data Flow</option><option value="deployment">Deployment</option><option value="dependency">Dependency</option><option value="source-repository">Source Repository</option></select></label></section>
<section v-if="selectedSystem && (selectedSystem.environments?.length || activeTab === 'systems')" class="environment-panel panel"><div class="environment-header"><div><span class="eyebrow">INFRASTRUCTURE DRILL-DOWN</span><strong>{{ selectedSystem.name }} environments</strong></div><div class="environment-actions"><button class="ghost" @click="addEnvironment">+ Environment</button><button v-if="selectedEnvironment" class="ghost" @click="cloneEnvironment(selectedEnvironment)">Clone environment</button></div></div><div class="environment-tabs"><button v-for="environment in (selectedSystem.environments || [])" :key="environment.id" :class="{active: selectedEnvironment?.id === environment.id}" @click="selectEnvironment(environment.id)">{{ environment.name }}</button><span v-if="!selectedSystem.environments?.length" class="muted">No environments yet. Add Dev, QA, UAT or Prod.</span></div><div v-if="selectedEnvironment" class="environment-detail"><div class="environment-config"><label>Name<input v-model="selectedEnvironment.name" /></label><label>Hosting location<input v-model="selectedEnvironment.configuration.hostingLocation" placeholder="Azure, on-prem, etc." /></label><label>Software/version<input v-model="selectedEnvironment.configuration.softwareVersion" /></label><label>Example configuration<input :value="selectedEnvironment.exampleConfiguration ? 'Yes — fictional values' : 'No'" readonly /></label><label>Properties JSON<textarea :value="JSON.stringify(selectedEnvironment.configuration.properties, null, 2)" @change="(event) => { try { selectedEnvironment.configuration.properties = JSON.parse(event.target.value); persist() } catch { importError = 'Environment properties must be valid JSON.' } }" rows="3" class="code"></textarea></label></div><div class="environment-components"><div class="steps-head"><span>Components and instances</span><button class="icon-button" @click="addComponent">+</button></div><article v-for="component in selectedEnvironment.components" :key="component.id" class="component-card"><div class="component-head"><strong>{{ component.name }}</strong><small>{{ component.role }} · {{ component.instanceName }}</small><button class="text-danger" @click="deleteComponent(component.id)">Remove</button></div><div class="definition-grid"><label>Name<input v-model="component.name" /></label><label>Instance<input v-model="component.instanceName" /></label><label>Role<select v-model="component.role"><option value="web-application">Web Application</option><option value="content-management">Content Management</option><option value="content-delivery">Content Delivery</option><option value="database-server">Database Server</option><option value="database">Database</option><option value="search-service">Search Service</option></select></label><label>Hosting location<input v-model="component.configuration.hostingLocation" /></label><label>Hostname<input v-model="component.configuration.hostname" /></label><label>URL<input v-model="component.configuration.url" /></label><label>Software/version<input v-model="component.configuration.softwareVersion" /></label><label>Properties JSON<textarea :value="JSON.stringify(component.configuration.properties, null, 2)" @change="(event) => { try { component.configuration.properties = JSON.parse(event.target.value); persist() } catch { importError = 'Component properties must be valid JSON.' } }" rows="2" class="code"></textarea></label></div></article></div><div class="environment-topology"><div class="steps-head"><span>Internal topology</span><small>Editable example connections</small></div><div v-for="link in selectedEnvironment.connections" :key="link.id" class="topology-row"><select v-model="link.sourceComponentId"><option v-for="component in selectedEnvironment.components" :key="component.id" :value="component.id">{{ component.name }}</option></select><input v-model="link.label" /><select v-model="link.targetComponentId"><option v-for="component in selectedEnvironment.components" :key="component.id" :value="component.id">{{ component.name }}</option></select></div></div></div></section>
<section v-if="selectedScenario" class="scenario-environment panel"><span class="eyebrow">SCENARIO ENVIRONMENT</span><label>Environment<select v-model="selectedScenario.environmentId"><option value="">Logical system view</option><option v-for="system in landscape.systems" :key="system.id" :value="system.environments?.[0]?.id" :disabled="!system.environments?.length">{{ system.name }} · {{ system.environments?.[0]?.name || 'No environment' }}</option></select></label><label class="checkbox-label"><input v-model="selectedScenario.traceInternal" type="checkbox" /> Trace internal component connections when available</label></section>
</main>
</template>