mirror of
https://github.com/jcreek/OpenNetworkDiagram.git
synced 2026-07-14 19:43:44 +00:00
feat(#2): replace card layout with cytoscape network graph
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
<script lang="ts">
|
||||
import type { NetworkDevice } from '../../lib/types';
|
||||
export let device: NetworkDevice;
|
||||
</script>
|
||||
|
||||
<div class="device-card">
|
||||
<h3>{device.name}</h3>
|
||||
<p><strong>Type:</strong> {device.type}</p>
|
||||
<p><strong>IP:</strong> {device.ipAddress}</p>
|
||||
{#if device.notes}
|
||||
<p><em>{device.notes}</em></p>
|
||||
{/if}
|
||||
|
||||
{#if device.ports && device.ports.length}
|
||||
<h4>Ports:</h4>
|
||||
<div class="ports-container">
|
||||
{#each device.ports as port}
|
||||
<div class="port-item" data-port-key={device.name + '-' + port.portName}>
|
||||
<p>{port.portName} ({port.speedGbps ?? 1}GbE)</p>
|
||||
{#if port.connectedTo}
|
||||
<p>Connected to: {port.connectedTo}</p>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.device-card {
|
||||
border: 1px dashed #aaa;
|
||||
padding: 1rem;
|
||||
border-radius: 5px;
|
||||
max-width: 300px;
|
||||
}
|
||||
.ports-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.port-item {
|
||||
background-color: #ffe7d6;
|
||||
padding: 0.5rem;
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,59 +0,0 @@
|
||||
<script lang="ts">
|
||||
import type { Machine } from '../../lib/types';
|
||||
import VMCard from './VMCard.svelte';
|
||||
|
||||
export let machine: Machine;
|
||||
</script>
|
||||
|
||||
<div class="machine-card">
|
||||
<h2>{machine.machineName}</h2>
|
||||
<p><strong>Role:</strong> {machine.role}</p>
|
||||
<p><strong>IP Address:</strong> {machine.ipAddress}</p>
|
||||
<p><strong>OS:</strong> {machine.operatingSystem}</p>
|
||||
|
||||
{#if machine.ports && machine.ports.length}
|
||||
<h4>Ports:</h4>
|
||||
<div class="ports-container">
|
||||
{#each machine.ports as port}
|
||||
<div class="port-item" data-port-key="{machine.machineName}-{port.portName}">
|
||||
<p>{port.portName} ({port.speedGbps ?? 1}GbE)</p>
|
||||
{#if port.connectedTo}
|
||||
<p>Connected to: {port.connectedTo}</p>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- VMs -->
|
||||
{#if machine.software?.vms?.length}
|
||||
<details>
|
||||
<summary>Show VMs (Total: {machine.software.vms.length})</summary>
|
||||
<div class="vm-list">
|
||||
{#each machine.software.vms as vm}
|
||||
<VMCard {vm} />
|
||||
{/each}
|
||||
</div>
|
||||
</details>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.machine-card {
|
||||
border: 2px solid #ddd;
|
||||
padding: 1rem;
|
||||
border-radius: 8px;
|
||||
max-width: 300px;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
.ports-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.port-item {
|
||||
background-color: #e7f1f9;
|
||||
padding: 0.5rem;
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,120 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
export let isOpen = false;
|
||||
export let title = '';
|
||||
export let maxWidth = '680px';
|
||||
|
||||
const dispatch = createEventDispatcher<{ close: void }>();
|
||||
|
||||
function closeModal() {
|
||||
dispatch('close');
|
||||
}
|
||||
|
||||
function onBackdropClick(event: MouseEvent) {
|
||||
if (event.target === event.currentTarget) {
|
||||
closeModal();
|
||||
}
|
||||
}
|
||||
|
||||
function onWindowKeydown(event: KeyboardEvent) {
|
||||
if (event.key === 'Escape' && isOpen) {
|
||||
closeModal();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window on:keydown={onWindowKeydown} />
|
||||
|
||||
{#if isOpen}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||
<div class="modal-backdrop" on:click={onBackdropClick}>
|
||||
<div class="modal-container" style={`max-width: ${maxWidth}`}>
|
||||
<header class="modal-header">
|
||||
{#if title}
|
||||
<h2>{title}</h2>
|
||||
{/if}
|
||||
<button type="button" class="close-button" on:click={closeModal} aria-label="Close">×</button>
|
||||
</header>
|
||||
<div class="modal-body">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 1rem;
|
||||
background: rgba(15, 23, 42, 0.58);
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.modal-container {
|
||||
width: min(100%, 680px);
|
||||
max-height: 90vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 24px 48px rgba(15, 23, 42, 0.24);
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
padding: 0.9rem 1rem;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.modal-header h2 {
|
||||
margin: 0;
|
||||
font-size: 1.05rem;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
.close-button {
|
||||
border: 1px solid transparent;
|
||||
background: transparent;
|
||||
color: #475569;
|
||||
font-size: 1.7rem;
|
||||
line-height: 1;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.close-button:hover {
|
||||
background: #e2e8f0;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 1rem;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.modal-backdrop {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.modal-container {
|
||||
height: 100vh;
|
||||
max-height: 100vh;
|
||||
border-radius: 0;
|
||||
border-left: 0;
|
||||
border-right: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +0,0 @@
|
||||
<script lang="ts">
|
||||
import type { VMInfo } from '../../stores/networkStore';
|
||||
export let vm: VMInfo;
|
||||
</script>
|
||||
|
||||
<div class="vm-card">
|
||||
<p><strong>{vm.name}</strong></p>
|
||||
<p>Role: {vm.role}</p>
|
||||
<p>IP: {vm.ipAddress}</p>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.vm-card {
|
||||
padding: 0.5rem;
|
||||
background-color: #eaeaea;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 5px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user