diff --git a/src/App.vue b/src/App.vue index cbe218f..36809b7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -22,6 +22,10 @@ const eventLog = ref([]) const packetProgress = ref(0) const importError = ref('') const fileInput = ref(null) +const minimapEl = ref(null) +const searchQuery = ref('') +const categoryFilter = ref('all') +const dataTypeFilter = ref('all') const placingPreset = ref(null) const selectedCapabilityIds = ref([]) const presentationMode = ref(false) @@ -118,6 +122,8 @@ function enableTransformation() { if (selectedConnection.value && !selectedConne function recordsForSelectedSystem(kind: TransferKind) { if (!selectedSystem.value) return []; return transferHistory.value.filter((record) => kind === 'sent' ? record.senderId === selectedSystem.value?.id : record.destinationId === selectedSystem.value?.id) } function systemName(id: string) { return landscape.value.systems.find((system) => system.id === id)?.name || id } const latestSelectedRecord = computed(() => selectedSystem.value ? transferHistory.value.filter((record) => record.destinationId === selectedSystem.value?.id).slice(-1)[0] : undefined) +const matchesSystem = (system: SystemModel) => { const query = searchQuery.value.trim().toLowerCase(); const queryMatch = !query || `${system.name} ${system.description}`.toLowerCase().includes(query); const categoryMatch = categoryFilter.value === 'all' || system.category === categoryFilter.value; const dataMatch = dataTypeFilter.value === 'all' || landscape.value.connections.some((connection) => connection.dataType === dataTypeFilter.value && (connection.sourceId === system.id || connection.targetId === system.id)); return queryMatch && categoryMatch && dataMatch } +function isSystemDimmed(system: SystemModel) { if (!matchesSystem(system)) return true; if (!playing.value || !currentConnections.value.length) return false; return !currentConnections.value.some((connection) => connection.sourceId === system.id || connection.targetId === system.id) } function animatePacket(duration: number) { stopAnimation(); const started = performance.now() const tick = (now: number) => { packetProgress.value = Math.min(1, (now - started) / duration); drawPackets(); if (packetProgress.value < 1) animationFrame = requestAnimationFrame(tick); else if (playing.value) setTimeout(finishStep, 180 / speed.value) } @@ -142,7 +148,7 @@ function buildNode(system: SystemModel) { if (system.capabilities.length) node.addWidget('button', 'Actions ▸', null, () => { node.showActions = !node.showActions; node.widgets[0].name = node.showActions ? 'Actions ▾' : 'Actions ▸'; graphCanvas?.draw(true, true) }) node.onDblClick = () => selectSystem(system.id) node.onMouseDown = () => selectSystem(system.id) - node.onDrawForeground = function(ctx: CanvasRenderingContext2D) { ctx.fillStyle = '#8d9bb8'; ctx.font = '11px Inter, sans-serif'; ctx.fillText(system.category.toUpperCase(), 12, 76); if (node.showActions) { ctx.fillStyle = '#c9d3e8'; ctx.font = '10px Inter, sans-serif'; system.capabilities.forEach((capability: CapabilityModel, index: number) => ctx.fillText(`${capability.name}: ${capability.actions.map((item) => item.name).join(', ')}`, 12, 92 + index * 13)) } } + node.onDrawForeground = function(ctx: CanvasRenderingContext2D) { const dimmed = isSystemDimmed(system); ctx.save(); ctx.globalAlpha = dimmed ? .28 : 1; ctx.fillStyle = '#8d9bb8'; ctx.font = '11px Inter, sans-serif'; ctx.fillText(system.category.toUpperCase(), 12, 76); if (node.showActions) { ctx.fillStyle = '#c9d3e8'; ctx.font = '10px Inter, sans-serif'; system.capabilities.forEach((capability: CapabilityModel, index: number) => ctx.fillText(`${capability.name}: ${capability.actions.map((item) => item.name).join(', ')}`, 12, 92 + index * 13)) } ctx.restore() } graph.add(node); return node } function connectionLabel(connection: ConnectionModel) { return connection.showCableLabel === false ? '' : `${connection.label} · ${connection.protocol || 'HTTPS'} · ${connection.dataType || 'JSON'} · ${connection.deliveryMethod || 'immediate'}` } @@ -176,6 +182,8 @@ function drawPackets() { const packetColor = failureState.value === 'none' ? '#f8c15c' : '#ef627d'; ctx.save(); ctx.fillStyle = packetColor; ctx.shadowColor = packetColor; ctx.shadowBlur = 18; ctx.beginPath(); ctx.arc(x, y, failureState.value === 'none' ? 7 : 9, 0, Math.PI * 2); ctx.fill(); ctx.restore() } } +function fitToScreen() { if (!graphCanvas || !canvasEl.value || !landscape.value.systems.length) return; const xs = landscape.value.systems.map((system) => system.position[0]); const ys = landscape.value.systems.map((system) => system.position[1]); const minX = Math.min(...xs); const minY = Math.min(...ys); const maxX = Math.max(...xs) + 220; const maxY = Math.max(...ys) + 130; graphCanvas.ds.scale = Math.min(.95, Math.max(.45, Math.min((canvasEl.value.width - 80) / (maxX - minX), (canvasEl.value.height - 80) / (maxY - minY)))); graphCanvas.ds.offset = [40 - minX * graphCanvas.ds.scale, 40 - minY * graphCanvas.ds.scale]; graphCanvas.draw(true, true); drawMinimap() } +function drawMinimap() { const canvas = minimapEl.value; if (!canvas) return; const ctx = canvas.getContext('2d'); if (!ctx) return; ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = '#0d121e'; ctx.fillRect(0, 0, canvas.width, canvas.height); const scale = Math.min(canvas.width / 1200, canvas.height / 670); for (const system of landscape.value.systems) { ctx.fillStyle = isSystemDimmed(system) ? '#283248' : system.color; ctx.fillRect(system.position[0] * scale, system.position[1] * scale, 34, 20) } } function exportJson() { const blob = new Blob([JSON.stringify(landscape.value, null, 2)], { type: 'application/json' }); const url = URL.createObjectURL(blob); const link = document.createElement('a'); link.href = url; link.download = 'system-landscape.json'; link.click(); URL.revokeObjectURL(url) } @@ -184,7 +192,8 @@ function importJson(event: Event) { const reader = new FileReader(); reader.onload = () => { try { landscape.value = validateLandscape(JSON.parse(String(reader.result))); selectedScenarioId.value = landscape.value.scenarios[0]?.id || ''; importError.value = ''; persist(); rebuildGraph() } catch (error) { importError.value = error instanceof Error ? error.message : 'Invalid landscape file.' } }; reader.readAsText(file); input.value = '' } watch(landscape, persist, { deep: true }) -onMounted(() => { if (!canvasEl.value) return; graphCanvas = new LGraphCanvas(canvasEl.value, graph); graphCanvas.background_image = null; graphCanvas.render_shadows = false; graphCanvas.ds.scale = 0.85; graphCanvas.onDrawForeground = drawPackets; rebuildGraph() }) +watch([searchQuery, categoryFilter, dataTypeFilter, playing, currentStep], () => { graphCanvas?.draw(true, true); drawMinimap() }) +onMounted(() => { if (!canvasEl.value) return; graphCanvas = new LGraphCanvas(canvasEl.value, graph); graphCanvas.background_image = null; graphCanvas.render_shadows = false; graphCanvas.ds.scale = 0.85; graphCanvas.onDrawForeground = drawPackets; rebuildGraph(); drawMinimap() }) onUnmounted(stopAnimation) @@ -216,5 +225,6 @@ onUnmounted(stopAnimation)
GUIDED STEP {{ stepIndex + 1 }}{{ currentStep.explanation }}

{{ selectedScenario?.description }}

STEP OUTCOMESFailure and recovery routing

Choose how a simulated step behaves. Retry is limited to one automatic attempt per reset.

{{ index + 1 }}. {{ step.explanation }}
CONNECTION PROPERTIES
+ diff --git a/src/main.ts b/src/main.ts index a0010ba..02bca4a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,6 +6,7 @@ import './transformation.css' import './presentation.css' import './failure.css' import './connection.css' +import './navigation.css' import './style.css' createApp(App).mount('#app') diff --git a/src/navigation.css b/src/navigation.css new file mode 100644 index 0000000..d749b6f --- /dev/null +++ b/src/navigation.css @@ -0,0 +1 @@ +.navigation-panel{display:flex;justify-content:space-between;gap:18px;padding:12px 16px}.nav-fields{display:flex;align-items:end;gap:10px;flex:1}.nav-fields label{color:#8996af;font-size:10px;font-weight:700;flex:1}.nav-fields input,.nav-fields select{display:block;width:100%;margin-top:5px;background:#0d1320;color:#dce4f4;border:1px solid #303d58;border-radius:4px;padding:7px;font-size:11px}.nav-fields button{height:31px;white-space:nowrap}.minimap-wrap{flex:0 0 220px}.minimap-wrap canvas{display:block;width:220px;height:120px;border:1px solid #303d58;border-radius:4px;margin-top:5px}@media(max-width:800px){.navigation-panel{display:block}.nav-fields{display:grid;grid-template-columns:1fr 1fr}.minimap-wrap{margin-top:12px}.minimap-wrap canvas{width:100%}}