Schaubild: neues Design, Konzept v0.7

- Dunkles Thema als Standard, hell umschaltbar (ganze App)
- Icons je Gerätetyp (Bootstrap Icons 1.13.2, lokal), Name über dem Icon
- Linienfarbe = Netz (neues Feld Netz.farbe, Vorgabe je Typ/VLAN),
  Strichart = Linienart; eckige Linien mit runden Ecken
- Beschriftung standardmäßig aus, beim Überfahren/Anklicken sichtbar
- Internet-Knoten am DSL-Port (neues Feld Schnittstelle.anbieter)
- Hinweis ⚠ bei "(prüfen)" in Notizen oder fehlender Verbindung
- Netz-Filter über Netzliste der Linie statt Beschriftung
- 73 Tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
H4nSoloandClaude Opus 5.5 committed 2026-11-24 15:00:06 +01:00
1 parent ae15a0aba8
commit 5877d4a2f3
29 files changed
+422 -87

No files matched your search

+1
View File
@@ -106,6 +106,7 @@ _Reihenfolge v0.5: Schaubild vor Formularen, damit Lücken in den Daten früh si
- [x] Klick auf Knoten → Details mit Link (vorerst Admin, ab Phase 3 Detailseite)
- [x] Filter: Netz, Status
- [x] Positionen per Drag & Drop, Rahmen nehmen Inhalt mit; „Anordnung zurücksetzen“
- [x] Design: dunkel/hell, Icons je Typ, Linienfarbe = Netz, eckige Linien, Internet-Knoten, ⚠-Hinweise
**Fertig, wenn:** Das Homelab-Beispiel vollständig und korrekt als Schaubild erscheint. _(Darstellung umgesetzt; Abnahme mit deinen Daten offen)_
+14 -9
View File
@@ -6,7 +6,7 @@
|---|---|
| **Projekt** | Netzwerk Planer |
| **Autor** | Christian Bergs |
| **Version** | 0.6 |
| **Version** | 0.7 |
| **Stand** | 24.11.2026 |
| **Status** | Konzeptphase |
| **Ergänzende Dateien** | [AUFBAUPLAN.md](AUFBAUPLAN.md) · [CLAUDE.md](CLAUDE.md) |
@@ -84,9 +84,9 @@ Der Netzwerk Planer dokumentiert die eigene Infrastruktur (Hosts, VMs, LXCs, Net
| **Standort** | Gruppierung, z. B. Homelab | Name, Beschreibung | `homelab` |
| **Gerät** | Hardware **und** Gäste (VM/LXC) in einem Objekt | Art (Hardware/VM/LXC), Typ und Rolle (nur Hardware), Name, Hersteller/Modell, Standort, **Host**, Proxmox-ID, Betriebssystem, **verwaltet von**, Status, Notizen | global: `pve1`, `vm-1000`, `ct-105` |
| **Bridge** | Virtueller Switch im Hypervisor | Host, Name, VLAN-aware, Notizen | je Host: `pve1/vmbr1` |
| **Schnittstelle** | Port, Netzwerkkarte, Switch-Port | Gerät, Name, Art (physisch/virtuell/WLAN/DSL), MAC, **Bridge**, VLAN-Tag, **durchgereicht an**, **SSID**, Switch-Felder (Modus, untagged VLAN, tagged VLANs, PoE), Notizen | je Gerät: `pve1/nic1`, `ct-105/net0` |
| **Schnittstelle** | Port, Netzwerkkarte, Switch-Port | Gerät, Name, Art (physisch/virtuell/WLAN/DSL), MAC, Anbieter (nur DSL), **Bridge**, VLAN-Tag, **durchgereicht an**, **SSID**, Switch-Felder (Modus, untagged VLAN, tagged VLANs, PoE), Notizen | je Gerät: `pve1/nic1`, `ct-105/net0` |
| **Verbindung** | Kabel oder VPN zwischen zwei Schnittstellen | Schnittstelle A, Schnittstelle B, Typ, Notiz | – |
| **Netz** | Subnetz | Name, CIDR, Typ (Transfer/LAN/VLAN/VPN), VLAN-ID, Gateway, DHCP von/bis, Standort (bei VPN leer) | global: `lan`, `transfer`, `wireguard` |
| **Netz** | Subnetz | Name, CIDR, Typ (Transfer/LAN/VLAN/VPN), VLAN-ID, Gateway, DHCP von/bis, Standort (bei VPN leer), Farbe (optional) | global: `lan`, `transfer`, `wireguard` |
| **IP-Adresse** | Belegte Adresse | IP, Netz, Schnittstelle **oder** Bridge (Host-IP, z. B. pve1 auf vmbr0), Art (statisch/DHCP-Reservierung/DHCP), Notiz | – |
| **SSID** | WLAN-Netz eines AP oder Routers | Name, Band, Netz, AP | global: `wlan-5ghz` |
@@ -125,15 +125,17 @@ Jedes Gerät (auch VM/LXC) hat einen Status:
## 5 Verbindungstypen
Jede Linie im Schaubild entsteht aus den Daten – entweder aus einem Feld oder aus einem Verbindungs-Objekt.
**Farbe = Netz** (Feld `farbe` am Netz, sonst Vorgabe je Typ bzw. je VLAN), **Strichart = Linienart** (Spalte „Linie“).
| Typ | Bedeutung | Quelle in den Daten | Linie |
|---|---|---|---|
| **Kabel** | Physische Verbindung zwischen zwei Ports | Verbindung, Typ Kabel | durchgezogen, grau |
| **Bridge** | Schnittstelle hängt an einer Bridge (Gast oder Bridge-Port) | Feld `bridge` der Schnittstelle | durchgezogen, grau |
| **Passthrough** | Physischer Port **exklusiv** an einen Gast durchgereicht | Feld `durchgereicht_an` der Schnittstelle | gestrichelt, orange |
| **Kabel** | Physische Verbindung zwischen zwei Ports | Verbindung, Typ Kabel | durchgezogen, kräftig |
| **Bridge** | Schnittstelle hängt an einer Bridge (Gast oder Bridge-Port) | Feld `bridge` der Schnittstelle | durchgezogen |
| **Passthrough** | Physischer Port **exklusiv** an einen Gast durchgereicht | Feld `durchgereicht_an` der Schnittstelle | gestrichelt |
| **WLAN** | Endgerät ist einer SSID zugeordnet | Feld `ssid` der Schnittstelle | kurz gestrichelt |
| **VPN** | Tunnel zwischen zwei Endpunkten (z. B. WireGuard) | Verbindung, Typ VPN | farbig, gestrichelt |
| **verwaltet von** | Logische Management-Beziehung (z. B. AP → Controller) | Feld `verwaltet_von` des Geräts | gepunktet |
| **VPN** | Tunnel zwischen zwei Endpunkten (z. B. WireGuard) | Verbindung, Typ VPN | gestrichelt |
| **Internet** | DSL-Port → Knoten „Internet“ (mit Anbieter) | Art DSL der Schnittstelle | durchgezogen, gelb |
| **verwaltet von** | Logische Management-Beziehung (z. B. AP → Controller) | Feld `verwaltet_von` des Geräts | gepunktet, neutral, mit Pfeil |
**Bridge-Port vs. Passthrough**
- **Bridge-Port:** `pve1/nic1` hat `bridge = vmbr1`. pfSense-LAN, weitere Gäste und das physische Netz teilen sich die Bridge.
@@ -187,7 +189,10 @@ Die Regeln liegen im Model (Fat Models) und greifen bei jedem Speichern – auch
- Hosts **auf- und zuklappbar**; zugeklappt mit Anzahl der Gäste, Linien nach außen bleiben erhalten
- **Drag & Drop ändert nur die Position, nie die Daten.** Gäste bleiben in ihrem Host-Rahmen, Linien folgen den Knoten.
- **Positionen werden gespeichert** (App `topologie`, Schlüssel über logische IDs, z. B. `geraet:ct-105`, `bridge:pve1/vmbr0`). Neue Objekte ohne Position werden automatisch platziert; „Anordnung zurücksetzen“ ordnet alles neu.
- Klick auf einen Knoten oder eine Linie zeigt die Details mit Link zur Bearbeitung (bis Phase 2: Admin)
- Klick auf einen Knoten oder eine Linie zeigt die Details mit Link zur Bearbeitung (bis Phase 3: Admin)
- **Design:** dunkel als Standard, hell umschaltbar (Navigationsleiste, gespeichert im Browser); **Icons je Gerätetyp** (Bootstrap Icons, lokal), Name über dem Icon; Gäste als „[LXC 105] pihole“; Bridges als kleine Switch-Icons; Hypervisor-Rahmen mit Hersteller/Modell
- **Linien** eckig mit runden Ecken; Beschriftung standardmäßig aus, sichtbar beim Überfahren/Anklicken oder per Schalter „Beschriftung immer“
- **⚠ am Gerät** bei „(prüfen)“ in Notizen von Gerät, Schnittstellen, Bridges oder IPs oder wenn keine Linie am Gerät hängt; Gründe im Detailbereich
- Filter: Netz, Status
**Beschriftung der Linien** – abgeleitet, nicht gepflegt (Format: CIDR und VLAN, z. B. `192.168.178.0/24 · VLAN 20`):
+3 -3
View File
@@ -11,7 +11,7 @@ class SchnittstelleInline(admin.TabularInline):
model = Schnittstelle
fk_name = "geraet"
extra = 0
fields = ["name", "art", "mac", "bridge", "vlan_tag", "durchgereicht_an", "ssid"]
fields = ["name", "art", "mac", "bridge", "vlan_tag", "durchgereicht_an", "ssid", "anbieter"]
show_change_link = True
@@ -89,7 +89,7 @@ class SchnittstelleAdmin(admin.ModelAdmin):
autocomplete_fields = ["geraet", "durchgereicht_an"]
inlines = [IPAdresseInline]
fieldsets = [
(None, {"fields": ["geraet", "name", "art", "mac", "notizen"]}),
(None, {"fields": ["geraet", "name", "art", "mac", "anbieter", "notizen"]}),
("Anbindung", {"fields": ["bridge", "vlan_tag", "durchgereicht_an", "ssid"]}),
("Switch-Port", {"fields": ["switch_modus", "untagged_vlan", "tagged_vlans", "poe"], "classes": ["collapse"]}),
]
@@ -106,7 +106,7 @@ class VerbindungAdmin(admin.ModelAdmin):
@admin.register(Netz)
class NetzAdmin(admin.ModelAdmin):
form = GeprueftesModelForm
list_display = ["name", "slug", "cidr", "typ", "vlan_id", "gateway", "dhcp_von", "dhcp_bis", "standort"]
list_display = ["name", "slug", "cidr", "typ", "vlan_id", "gateway", "dhcp_von", "dhcp_bis", "standort", "anzeige_farbe"]
list_filter = ["typ", "standort"]
prepopulated_fields = {"slug": ["name"]}
inlines = [IPAdresseImNetzInline]
@@ -0,0 +1,24 @@
# Generated by Django 5.2.19 on 2026-11-24 13:53
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('inventar', '0004_netz_typ_vpn'),
]
operations = [
migrations.AddField(
model_name='netz',
name='farbe',
field=models.CharField(blank=True, help_text='Linienfarbe im Schaubild (#rrggbb). Leer: Vorgabe je Typ bzw. je VLAN.', max_length=7, validators=[django.core.validators.RegexValidator('^#[0-9a-fA-F]{6}$', 'Farbe als #rrggbb, z. B. #22d3ee.')]),
),
migrations.AddField(
model_name='schnittstelle',
name='anbieter',
field=models.CharField(blank=True, help_text='Nur bei DSL: Internetanbieter, z. B. 1und1.', max_length=50),
),
]
+23 -1
View File
@@ -9,12 +9,13 @@ import ipaddress
import re
from django.core.exceptions import ValidationError
from django.core.validators import MaxValueValidator, MinValueValidator, validate_slug
from django.core.validators import MaxValueValidator, MinValueValidator, RegexValidator, validate_slug
from django.db import models
from django.utils.text import slugify
VLAN_VALIDATOREN = [MinValueValidator(1), MaxValueValidator(4094)]
MAC_MUSTER = re.compile(r"^[0-9a-f]{12}$")
FARBE_VALIDATOR = RegexValidator(r"^#[0-9a-fA-F]{6}$", "Farbe als #rrggbb, z. B. #22d3ee.")
class GeprueftesModel(models.Model):
@@ -239,6 +240,14 @@ class Netz(GeprueftesModel):
Standort, on_delete=models.PROTECT, null=True, blank=True, related_name="netze",
help_text="Bei VPN-Netzen leer lassen – ein Tunnelnetz gehört beiden Seiten.",
)
farbe = models.CharField(
max_length=7, blank=True, validators=[FARBE_VALIDATOR],
help_text="Linienfarbe im Schaubild (#rrggbb). Leer: Vorgabe je Typ bzw. je VLAN.",
)
# Vorgaben für das Schaubild, gut lesbar auf hellem und dunklem Hintergrund
FARBE_JE_TYP = {"transfer": "#a78bfa", "lan": "#22d3ee", "vpn": "#e879f9"}
VLAN_PALETTE = ["#34d399", "#fb923c", "#f472b6", "#60a5fa", "#facc15", "#4ade80", "#f87171", "#2dd4bf"]
class Meta:
ordering = ["cidr"]
@@ -262,6 +271,14 @@ class Netz(GeprueftesModel):
def netzwerk(self):
return ipaddress.ip_network(self.cidr)
@property
def anzeige_farbe(self):
if self.farbe:
return self.farbe.lower()
if self.typ == self.Typ.VLAN and self.vlan_id:
return self.VLAN_PALETTE[self.vlan_id % len(self.VLAN_PALETTE)]
return self.FARBE_JE_TYP.get(self.typ, "#94a3b8")
def enthaelt(self, ip):
return ipaddress.ip_address(ip) in self.netzwerk
@@ -337,6 +354,9 @@ class Schnittstelle(GeprueftesModel):
name = models.CharField(max_length=30, validators=[validate_slug], help_text="z. B. nic0, net0, WAN, port-3")
art = models.CharField(max_length=10, choices=Art.choices)
mac = models.CharField("MAC", max_length=17, blank=True)
anbieter = models.CharField(
max_length=50, blank=True, help_text="Nur bei DSL: Internetanbieter, z. B. 1und1.",
)
bridge = models.ForeignKey(Bridge, on_delete=models.SET_NULL, null=True, blank=True, related_name="schnittstellen")
vlan_tag = models.PositiveSmallIntegerField("VLAN-Tag", null=True, blank=True, validators=VLAN_VALIDATOREN)
@@ -451,6 +471,8 @@ class Schnittstelle(GeprueftesModel):
if self.art == self.Art.DSL and geraet and geraet.typ != Geraet.Typ.ROUTER:
fehler["art"] = "DSL-Anschlüsse gibt es nur an Routern/Modems."
if self.anbieter and self.art != self.Art.DSL:
fehler["anbieter"] = "Ein Anbieter wird nur am DSL-Anschluss eingetragen."
if self.ssid_id and self.art != self.Art.WLAN:
fehler["ssid"] = "SSID nur an WLAN-Schnittstellen."
+16
View File
@@ -192,6 +192,13 @@ class DSLTests(Homelab):
with self.subTest(typ=typ), self.assertRaises(ValidationError):
Verbindung.objects.create(a=self.dsl, b=self.nic1, typ=typ)
def test_anbieter_nur_an_dsl(self):
self.dsl.anbieter = "1und1"
self.dsl.save()
with self.assertRaises(ValidationError) as f:
Schnittstelle.objects.create(geraet=self.fritzbox, name="LAN1", art=Schnittstelle.Art.PHYSISCH, anbieter="1und1")
self.assertIn("anbieter", f.exception.message_dict)
def test_dsl_ohne_ip(self):
netz = Netz.objects.create(name="T", slug="t", cidr="192.168.5.0/24", typ=Netz.Typ.TRANSFER, standort=self.homelab)
with self.assertRaises(ValidationError):
@@ -286,6 +293,15 @@ class NetzTests(Homelab):
self.netz(standort=None)
self.assertIn("standort", f.exception.message_dict)
def test_farbe(self):
self.assertEqual(self.netz().anzeige_farbe, Netz.FARBE_JE_TYP["lan"])
vlan = self.netz(slug="iot", cidr="10.0.20.0/24", typ=Netz.Typ.VLAN, vlan_id=20)
self.assertEqual(vlan.anzeige_farbe, Netz.VLAN_PALETTE[20 % len(Netz.VLAN_PALETTE)])
eigen = self.netz(slug="x", cidr="10.0.30.0/24", farbe="#ABCDEF")
self.assertEqual(eigen.anzeige_farbe, "#abcdef")
with self.assertRaises(ValidationError):
self.netz(slug="y", cidr="10.0.40.0/24", farbe="rot")
def test_vlan_netz_braucht_vlan_id(self):
with self.assertRaises(ValidationError):
self.netz(typ=Netz.Typ.VLAN)
+125 -49
View File
@@ -23,50 +23,111 @@
// --- Darstellung ------------------------------------------------------------
const STIL = [
{ selector: "node", style: {
"shape": "round-rectangle", "background-color": "#ffffff",
"border-width": 1.5, "border-color": "#6c757d",
"label": "data(label)", "text-wrap": "wrap", "font-size": 11,
"text-valign": "center", "text-halign": "center",
"width": "data(breite)", "height": "data(hoehe)", "padding": 8,
} },
{ selector: ":parent", style: {
"background-color": "#f8f9fa", "border-color": "#adb5bd",
"text-valign": "top", "text-halign": "center", "text-margin-y": -4,
"font-weight": "bold", "padding": 16,
} },
{ selector: "node.hypervisor", style: { "background-color": "#eef4ff", "border-color": "#0d6efd", "border-width": 2 } },
{ selector: "node.gast", style: { "border-color": "#198754" } },
{ selector: "node.bridge", style: { "shape": "ellipse", "background-color": "#fff3cd", "border-color": "#fd7e14", "padding": 10 } },
{ selector: "node.port", style: { "shape": "rectangle", "font-size": 9, "padding": 4, "background-color": "#e9ecef" } },
{ selector: "node.art-dsl", style: { "background-color": "#f8d7da", "border-color": "#dc3545" } },
{ selector: "node.unbenutzt", style: { "border-style": "dashed", "color": "#adb5bd", "border-color": "#ced4da" } },
{ selector: "node.status-geplant", style: { "border-style": "dashed" } },
{ selector: "node.status-auslaufend", style: { "opacity": 0.45 } },
{ selector: "node.zugeklappt", style: { "background-color": "#eef4ff", "border-color": "#0d6efd", "border-width": 3, "font-weight": "bold" } },
{ selector: "node:selected", style: { "border-color": "#0d6efd", "border-width": 3 } },
// Farben je Thema; Linienfarbe kommt vom Netz (data.farbe), Strichart von der Linienart
const PALETTE = {
dark: {
flaeche: "#0b1120", text: "#e2e8f0", leise: "#94a3b8", rahmen: "#141c2e", rahmenLinie: "#334155",
host: "#0f1a33", hostLinie: "#3b82f6", port: "#1e293b", portLinie: "#475569", neutral: "#64748b",
labelGrund: "#0b1120", auswahl: "#60a5fa", warnung: "#fbbf24",
},
light: {
flaeche: "#ffffff", text: "#1f2937", leise: "#6b7280", rahmen: "#f8fafc", rahmenLinie: "#cbd5e1",
host: "#eff6ff", hostLinie: "#2563eb", port: "#e5e7eb", portLinie: "#9ca3af", neutral: "#9ca3af",
labelGrund: "#ffffff", auswahl: "#2563eb", warnung: "#b45309",
},
};
const ICON_FARBE = { gast: "#34d399", hypervisor: "#60a5fa", bridge: "#fb923c", internet: "#facc15" };
{ selector: "edge", style: {
"curve-style": "bezier", "width": 2, "line-color": "#adb5bd",
"label": "data(label)", "font-size": 9, "color": "#495057",
"text-background-color": "#ffffff", "text-background-opacity": 0.9, "text-background-padding": 2,
} },
{ selector: "edge.kabel", style: { "line-color": "#6c757d", "width": 3 } },
{ selector: "edge.passthrough", style: { "line-color": "#fd7e14", "line-style": "dashed", "width": 3 } },
{ selector: "edge.wlan", style: { "line-style": "dashed", "line-dash-pattern": [4, 4] } },
{ selector: "edge.vpn", style: { "line-color": "#6f42c1", "line-style": "dashed", "width": 3 } },
{ selector: "edge.verwaltet", style: {
"line-style": "dotted", "line-color": "#6c757d",
"target-arrow-shape": "triangle", "target-arrow-color": "#6c757d",
} },
{ selector: "edge.meta", style: { "width": 4 } },
{ selector: "edge:selected", style: { "line-color": "#0d6efd" } },
const iconTexte = new Map(); // Icon-Name → SVG-Text
const iconCache = new Map(); // "name|farbe" → data-URI
{ selector: ".gedimmt", style: { "opacity": 0.12 } },
{ selector: ".ausgeblendet", style: { "display": "none" } },
{ selector: "edge.ohne-label", style: { "label": "" } },
];
function iconUri(name, farbe) {
const schluessel = `${name}|${farbe}`;
if (!iconCache.has(schluessel)) {
const svg = (iconTexte.get(name) || "").replace(/currentColor/g, farbe);
iconCache.set(schluessel, "data:image/svg+xml;utf8," + encodeURIComponent(svg));
}
return iconCache.get(schluessel);
}
function thema() {
return document.documentElement.dataset.bsTheme === "light" ? "light" : "dark";
}
function stil() {
const p = PALETTE[thema()];
const iconFarbe = (ele) => {
for (const k of Object.keys(ICON_FARBE)) if (ele.hasClass(k)) return ICON_FARBE[k];
return p.text;
};
return [
{ selector: "node", style: {
"shape": "round-rectangle", "background-color": p.port, "border-width": 1, "border-color": p.portLinie,
"label": "data(label)", "text-wrap": "wrap", "font-size": 11, "color": p.text,
"text-valign": "center", "text-halign": "center",
"width": "data(breite)", "height": "data(hoehe)", "padding": 6,
} },
// Geräte, Gäste, Bridges, Internet: Icon, Name darüber
{ selector: "node[icon]", style: {
"width": 34, "height": 34, "padding": 0, "background-opacity": 0, "border-width": 0,
"background-image": (ele) => iconUri(ele.data("icon"), iconFarbe(ele)),
"background-fit": "contain", "background-clip": "none",
"text-valign": "top", "text-margin-y": -6, "text-background-color": p.flaeche,
"text-background-opacity": 0.6, "text-background-padding": 1,
} },
{ selector: "node.gast", style: { "width": 28, "height": 28 } },
{ selector: "node.bridge", style: { "width": 24, "height": 24, "font-size": 10, "color": p.leise } },
// Rahmen (Hypervisor mit Gästen, Geräte mit Ports)
{ selector: ":parent", style: {
"background-image": "none", "background-opacity": 1, "background-color": p.rahmen,
"border-width": 1, "border-color": p.rahmenLinie, "shape": "round-rectangle",
"text-valign": "top", "text-halign": "center", "text-margin-y": -4,
"font-weight": "bold", "padding": 18, "text-background-opacity": 0,
} },
{ selector: "node.hypervisor:parent", style: { "background-color": p.host, "border-color": p.hostLinie, "border-width": 1.5, "color": p.hostLinie } },
{ selector: "node.port", style: { "shape": "round-rectangle", "font-size": 9, "padding": 4 } },
{ selector: "node.art-dsl", style: { "border-color": "#facc15", "color": "#facc15" } },
{ selector: "node.unbenutzt", style: { "border-style": "dashed", "color": p.leise, "background-opacity": 0.4 } },
{ selector: "node.warnung", style: { "color": p.warnung } },
{ selector: "node.status-geplant", style: { "border-width": 1.5, "border-style": "dashed", "border-color": p.leise } },
{ selector: "node.status-auslaufend", style: { "opacity": 0.45 } },
{ selector: "node.zugeklappt", style: { "font-weight": "bold", "color": p.hostLinie } },
{ selector: "node:selected", style: { "overlay-color": p.auswahl, "overlay-opacity": 0.25, "overlay-padding": 6 } },
{ selector: "edge", style: {
"curve-style": "round-taxi", "taxi-direction": "auto", "taxi-radius": 10, "taxi-turn": "50%",
"width": 2.5, "line-color": (ele) => ele.data("farbe") || p.neutral,
"label": "", "font-size": 9, "color": p.text, "text-wrap": "wrap",
"text-background-color": p.labelGrund, "text-background-opacity": 0.9, "text-background-padding": 2,
} },
{ selector: "edge.kabel", style: { "width": 3.5 } },
{ selector: "edge.passthrough", style: { "line-style": "dashed", "width": 3 } },
{ selector: "edge.wlan", style: { "line-style": "dashed", "line-dash-pattern": [4, 4] } },
{ selector: "edge.vpn", style: { "line-style": "dashed", "width": 3 } },
{ selector: "edge.internet", style: { "width": 3 } },
{ selector: "edge.verwaltet", style: {
"curve-style": "bezier", "line-style": "dotted", "line-color": p.leise,
"target-arrow-shape": "triangle", "target-arrow-color": p.leise,
} },
{ selector: "edge.meta", style: { "width": 4 } },
{ selector: "edge.mit-label, edge.zeige-label, edge:selected", style: { "label": "data(label)" } },
{ selector: "edge:selected", style: { "overlay-color": p.auswahl, "overlay-opacity": 0.2, "overlay-padding": 4 } },
{ selector: ".gedimmt", style: { "opacity": 0.12 } },
{ selector: ".ausgeblendet", style: { "display": "none" } },
];
}
function themaAnwenden() {
document.getElementById("schaubild").style.background = PALETTE[thema()].flaeche;
if (cy) cy.style(stil());
}
function iconsLaden(namen) {
return Promise.all([...namen].map((name) =>
fetch(`${URLS.icons}${name}.svg`).then((r) => (r.ok ? r.text() : "")).then((t) => iconTexte.set(name, t))
));
}
// --- Hilfen -----------------------------------------------------------------
@@ -183,10 +244,12 @@
const schluessel = `meta:${q}|${z}|${e.classes}`;
if (!meta.has(schluessel)) {
meta.set(schluessel, { group: "edges", classes: `${e.classes} meta`,
data: { id: schluessel, source: q, target: z, labels: [], info: [["Art", "zusammengefasst"]], url: "" } });
data: { id: schluessel, source: q, target: z, labels: [], netze: [], farbe: e.data.farbe,
info: [["Art", "zusammengefasst"]], url: "" } });
}
const m = meta.get(schluessel);
if (!m.data.labels.includes(e.data.label)) m.data.labels.push(e.data.label);
(e.data.netze || []).forEach((n) => { if (!m.data.netze.includes(n)) m.data.netze.push(n); });
m.data.info.push(["Linie", `${e.data.source} → ${e.data.target}`]);
});
meta.forEach((m) => { m.data.label = m.data.labels.join("\n"); kanten.push(m); });
@@ -219,8 +282,15 @@
versatz.set(parent, i);
pos = { x: b.x + 70 * (i - 1), y: b.y + 50 };
} else {
pos = { x: rechts, y: Number.isFinite(bb.y1) ? bb.y1 : 0 };
rechts += 160;
// ohne Rahmen: über einen platzierten Nachbarn (z. B. Internet über dem DSL-Port), sonst rechts daneben
const nachbar = n.neighborhood("node").filter((x) => positionen.has(x.id()) || x.isParent())[0];
if (nachbar) {
const np = nachbar.isParent() ? nachbar.position() : positionen.get(nachbar.id());
pos = { x: np.x, y: np.y - 110 };
} else {
pos = { x: rechts, y: Number.isFinite(bb.y1) ? bb.y1 : 0 };
rechts += 160;
}
}
n.position(pos);
positionen.set(n.id(), pos);
@@ -276,13 +346,12 @@
const netz = document.getElementById("filter-netz").value;
if (netz) {
const passend = cy.edges().filter((e) => (e.data("label") || "").includes(netz));
const passend = cy.edges().filter((e) => (e.data("netze") || []).includes(netz));
const behalten = passend.union(passend.connectedNodes()).union(passend.connectedNodes().ancestors());
cy.elements().not(behalten).addClass("gedimmt");
}
const ohneLabel = !document.getElementById("beschriftung").checked;
cy.edges().toggleClass("ohne-label", ohneLabel);
cy.edges().toggleClass("mit-label", document.getElementById("beschriftung").checked);
}
// --- Details ----------------------------------------------------------------
@@ -339,6 +408,9 @@
function ereignisse() {
cy.on("tap", "node, edge", (e) => details(e.target));
cy.on("mouseover", "edge", (e) => e.target.addClass("zeige-label"));
cy.on("mouseout", "edge", (e) => e.target.removeClass("zeige-label"));
window.addEventListener("themawechsel", themaAnwenden);
cy.on("dbltap", "node.hypervisor", (e) => umschalten(e.target.id()));
cy.on("grab", "node", (e) => { griff = { ...e.target.position() }; });
@@ -413,8 +485,12 @@
const auswahl = document.getElementById("filter-netz");
daten.netze.forEach((cidr) => auswahl.add(new Option(cidr, cidr)));
return iconsLaden(new Set([...alle.knoten.values()].map((k) => k.data.icon).filter(Boolean))).then(() => daten);
})
.then(() => {
const ersterAufruf = positionen.size === 0;
cy = cytoscape({ container: document.getElementById("schaubild"), style: STIL });
themaAnwenden();
cy = cytoscape({ container: document.getElementById("schaubild"), style: stil() });
cy.add(sichtbareElemente());
ereignisse();
if (ersterAufruf) {
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2019-2024 The Bootstrap Authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+1
View File
@@ -0,0 +1 @@
Bootstrap Icons 1.13.2 (MIT), nur benötigte Icons
+3
View File
@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box" viewBox="0 0 16 16">
<path d="M8.186 1.113a.5.5 0 0 0-.372 0L1.846 3.5 8 5.961 14.154 3.5zM15 4.239l-6.5 2.6v7.922l6.5-2.6V4.24zM7.5 14.762V6.838L1 4.239v7.923zM7.443.184a1.5 1.5 0 0 1 1.114 0l7.129 2.852A.5.5 0 0 1 16 3.5v8.662a1 1 0 0 1-.629.928l-7.185 2.874a.5.5 0 0 1-.372 0L.63 13.09a1 1 0 0 1-.63-.928V3.5a.5.5 0 0 1 .314-.464z"/>
</svg>

After

Width:  |  Height:  |  Size: 446 B

+3
View File
@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-broadcast-pin" viewBox="0 0 16 16">
<path d="M3.05 3.05a7 7 0 0 0 0 9.9.5.5 0 0 1-.707.707 8 8 0 0 1 0-11.314.5.5 0 0 1 .707.707m2.122 2.122a4 4 0 0 0 0 5.656.5.5 0 1 1-.708.708 5 5 0 0 1 0-7.072.5.5 0 0 1 .708.708m5.656-.708a.5.5 0 0 1 .708 0 5 5 0 0 1 0 7.072.5.5 0 1 1-.708-.708 4 4 0 0 0 0-5.656.5.5 0 0 1 0-.708m2.122-2.12a.5.5 0 0 1 .707 0 8 8 0 0 1 0 11.313.5.5 0 0 1-.707-.707 7 7 0 0 0 0-9.9.5.5 0 0 1 0-.707zM6 8a2 2 0 1 1 2.5 1.937V15.5a.5.5 0 0 1-1 0V9.937A2 2 0 0 1 6 8"/>
</svg>

After

Width:  |  Height:  |  Size: 590 B

+3
View File
@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cpu" viewBox="0 0 16 16">
<path d="M5 0a.5.5 0 0 1 .5.5V2h1V.5a.5.5 0 0 1 1 0V2h1V.5a.5.5 0 0 1 1 0V2h1V.5a.5.5 0 0 1 1 0V2A2.5 2.5 0 0 1 14 4.5h1.5a.5.5 0 0 1 0 1H14v1h1.5a.5.5 0 0 1 0 1H14v1h1.5a.5.5 0 0 1 0 1H14v1h1.5a.5.5 0 0 1 0 1H14a2.5 2.5 0 0 1-2.5 2.5v1.5a.5.5 0 0 1-1 0V14h-1v1.5a.5.5 0 0 1-1 0V14h-1v1.5a.5.5 0 0 1-1 0V14h-1v1.5a.5.5 0 0 1-1 0V14A2.5 2.5 0 0 1 2 11.5H.5a.5.5 0 0 1 0-1H2v-1H.5a.5.5 0 0 1 0-1H2v-1H.5a.5.5 0 0 1 0-1H2v-1H.5a.5.5 0 0 1 0-1H2A2.5 2.5 0 0 1 4.5 2V.5A.5.5 0 0 1 5 0m-.5 3A1.5 1.5 0 0 0 3 4.5v7A1.5 1.5 0 0 0 4.5 13h7a1.5 1.5 0 0 0 1.5-1.5v-7A1.5 1.5 0 0 0 11.5 3zM5 6.5A1.5 1.5 0 0 1 6.5 5h3A1.5 1.5 0 0 1 11 6.5v3A1.5 1.5 0 0 1 9.5 11h-3A1.5 1.5 0 0 1 5 9.5zM6.5 6a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5z"/>
</svg>

After

Width:  |  Height:  |  Size: 887 B

+3
View File
@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-diagram-3" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M6 3.5A1.5 1.5 0 0 1 7.5 2h1A1.5 1.5 0 0 1 10 3.5v1A1.5 1.5 0 0 1 8.5 6v1H14a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-1 0V8h-5v.5a.5.5 0 0 1-1 0V8h-5v.5a.5.5 0 0 1-1 0v-1A.5.5 0 0 1 2 7h5.5V6A1.5 1.5 0 0 1 6 4.5zM8.5 5a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5zM0 11.5A1.5 1.5 0 0 1 1.5 10h1A1.5 1.5 0 0 1 4 11.5v1A1.5 1.5 0 0 1 2.5 14h-1A1.5 1.5 0 0 1 0 12.5zm1.5-.5a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5zm4.5.5A1.5 1.5 0 0 1 7.5 10h1a1.5 1.5 0 0 1 1.5 1.5v1A1.5 1.5 0 0 1 8.5 14h-1A1.5 1.5 0 0 1 6 12.5zm1.5-.5a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5zm4.5.5a1.5 1.5 0 0 1 1.5-1.5h1a1.5 1.5 0 0 1 1.5 1.5v1a1.5 1.5 0 0 1-1.5 1.5h-1a1.5 1.5 0 0 1-1.5-1.5zm1.5-.5a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5z"/>
</svg>

After

Width:  |  Height:  |  Size: 993 B

+3
View File
@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-display" viewBox="0 0 16 16">
<path d="M0 4s0-2 2-2h12s2 0 2 2v6s0 2-2 2h-4q0 1 .25 1.5H11a.5.5 0 0 1 0 1H5a.5.5 0 0 1 0-1h.75Q6 13 6 12H2s-2 0-2-2zm1.398-.855a.76.76 0 0 0-.254.302A1.5 1.5 0 0 0 1 4.01V10c0 .325.078.502.145.602q.105.156.302.254a1.5 1.5 0 0 0 .538.143L2.01 11H14c.325 0 .502-.078.602-.145a.76.76 0 0 0 .254-.302 1.5 1.5 0 0 0 .143-.538L15 9.99V4c0-.325-.078-.502-.145-.602a.76.76 0 0 0-.302-.254A1.5 1.5 0 0 0 13.99 3H2c-.325 0-.502.078-.602.145"/>
</svg>

After

Width:  |  Height:  |  Size: 570 B

+3
View File
@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-globe2" viewBox="0 0 16 16">
<path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8m7.5-6.923c-.67.204-1.335.82-1.887 1.855q-.215.403-.395.872c.705.157 1.472.257 2.282.287zM4.249 3.539q.214-.577.481-1.078a7 7 0 0 1 .597-.933A7 7 0 0 0 3.051 3.05q.544.277 1.198.49zM3.509 7.5c.036-1.07.188-2.087.436-3.008a9 9 0 0 1-1.565-.667A6.96 6.96 0 0 0 1.018 7.5zm1.4-2.741a12.3 12.3 0 0 0-.4 2.741H7.5V5.091c-.91-.03-1.783-.145-2.591-.332M8.5 5.09V7.5h2.99a12.3 12.3 0 0 0-.399-2.741c-.808.187-1.681.301-2.591.332zM4.51 8.5c.035.987.176 1.914.399 2.741A13.6 13.6 0 0 1 7.5 10.91V8.5zm3.99 0v2.409c.91.03 1.783.145 2.591.332.223-.827.364-1.754.4-2.741zm-3.282 3.696q.18.469.395.872c.552 1.035 1.218 1.65 1.887 1.855V11.91c-.81.03-1.577.13-2.282.287zm.11 2.276a7 7 0 0 1-.598-.933 9 9 0 0 1-.481-1.079 8.4 8.4 0 0 0-1.198.49 7 7 0 0 0 2.276 1.522zm-1.383-2.964A13.4 13.4 0 0 1 3.508 8.5h-2.49a6.96 6.96 0 0 0 1.362 3.675c.47-.258.995-.482 1.565-.667m6.728 2.964a7 7 0 0 0 2.275-1.521 8.4 8.4 0 0 0-1.197-.49 9 9 0 0 1-.481 1.078 7 7 0 0 1-.597.933M8.5 11.909v3.014c.67-.204 1.335-.82 1.887-1.855q.216-.403.395-.872A12.6 12.6 0 0 0 8.5 11.91zm3.555-.401c.57.185 1.095.409 1.565.667A6.96 6.96 0 0 0 14.982 8.5h-2.49a13.4 13.4 0 0 1-.437 3.008M14.982 7.5a6.96 6.96 0 0 0-1.362-3.675c-.47.258-.995.482-1.565.667.248.92.4 1.938.437 3.008zM11.27 2.461q.266.502.482 1.078a8.4 8.4 0 0 0 1.196-.49 7 7 0 0 0-2.275-1.52c.218.283.418.597.597.932m-.488 1.343a8 8 0 0 0-.395-.872C9.835 1.897 9.17 1.282 8.5 1.077V4.09c.81-.03 1.577-.13 2.282-.287z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

+4
View File
@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-hdd-network" viewBox="0 0 16 16">
<path d="M4.5 5a.5.5 0 1 0 0-1 .5.5 0 0 0 0 1M3 4.5a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0"/>
<path d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v1a2 2 0 0 1-2 2H8.5v3a1.5 1.5 0 0 1 1.5 1.5h5.5a.5.5 0 0 1 0 1H10A1.5 1.5 0 0 1 8.5 14h-1A1.5 1.5 0 0 1 6 12.5H.5a.5.5 0 0 1 0-1H6A1.5 1.5 0 0 1 7.5 10V7H2a2 2 0 0 1-2-2zm1 0v1a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1H2a1 1 0 0 0-1 1m6 7.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5"/>
</svg>

After

Width:  |  Height:  |  Size: 595 B

+4
View File
@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-hdd-rack" viewBox="0 0 16 16">
<path d="M4.5 5a.5.5 0 1 0 0-1 .5.5 0 0 0 0 1M3 4.5a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0m2 7a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0m-2.5.5a.5.5 0 1 0 0-1 .5.5 0 0 0 0 1"/>
<path d="M2 2a2 2 0 0 0-2 2v1a2 2 0 0 0 2 2h1v2H2a2 2 0 0 0-2 2v1a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-1a2 2 0 0 0-2-2h-1V7h1a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2zm13 2v1a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1m0 7v1a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1m-3-4v2H4V7z"/>
</svg>

After

Width:  |  Height:  |  Size: 600 B

+3
View File
@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-laptop" viewBox="0 0 16 16">
<path d="M13.5 3a.5.5 0 0 1 .5.5V11H2V3.5a.5.5 0 0 1 .5-.5zm-11-1A1.5 1.5 0 0 0 1 3.5V12h14V3.5A1.5 1.5 0 0 0 13.5 2zM0 12.5h16a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 0 12.5"/>
</svg>

After

Width:  |  Height:  |  Size: 311 B

+3
View File
@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-lightbulb" viewBox="0 0 16 16">
<path d="M2 6a6 6 0 1 1 10.174 4.31c-.203.196-.359.4-.453.619l-.762 1.769A.5.5 0 0 1 10.5 13a.5.5 0 0 1 0 1 .5.5 0 0 1 0 1l-.224.447a1 1 0 0 1-.894.553H6.618a1 1 0 0 1-.894-.553L5.5 15a.5.5 0 0 1 0-1 .5.5 0 0 1 0-1 .5.5 0 0 1-.46-.302l-.761-1.77a2 2 0 0 0-.453-.618A5.98 5.98 0 0 1 2 6m6-5a5 5 0 0 0-3.479 8.592c.263.254.514.564.676.941L5.83 12h4.342l.632-1.467c.162-.377.413-.687.676-.941A5 5 0 0 0 8 1"/>
</svg>

After

Width:  |  Height:  |  Size: 543 B

+3
View File
@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pc-display" viewBox="0 0 16 16">
<path d="M8 1a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1zm1 13.5a.5.5 0 1 0 1 0 .5.5 0 0 0-1 0m2 0a.5.5 0 1 0 1 0 .5.5 0 0 0-1 0M9.5 1a.5.5 0 0 0 0 1h5a.5.5 0 0 0 0-1zM9 3.5a.5.5 0 0 0 .5.5h5a.5.5 0 0 0 0-1h-5a.5.5 0 0 0-.5.5M1.5 2A1.5 1.5 0 0 0 0 3.5v7A1.5 1.5 0 0 0 1.5 12H6v2h-.5a.5.5 0 0 0 0 1H7v-4H1.5a.5.5 0 0 1-.5-.5v-7a.5.5 0 0 1 .5-.5H7V2z"/>
</svg>

After

Width:  |  Height:  |  Size: 509 B

+4
View File
@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-phone" viewBox="0 0 16 16">
<path d="M11 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM5 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z"/>
<path d="M8 14a1 1 0 1 0 0-2 1 1 0 0 0 0 2"/>
</svg>

After

Width:  |  Height:  |  Size: 330 B

+4
View File
@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-printer" viewBox="0 0 16 16">
<path d="M2.5 8a.5.5 0 1 0 0-1 .5.5 0 0 0 0 1"/>
<path d="M5 1a2 2 0 0 0-2 2v2H2a2 2 0 0 0-2 2v3a2 2 0 0 0 2 2h1v1a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2v-1h1a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-1V3a2 2 0 0 0-2-2zM4 3a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2H4zm1 5a2 2 0 0 0-2 2v1H2a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v-1a2 2 0 0 0-2-2zm7 2v3a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1"/>
</svg>

After

Width:  |  Height:  |  Size: 553 B

+6
View File
@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-router" viewBox="0 0 16 16">
<path d="M5.525 3.025a3.5 3.5 0 0 1 4.95 0 .5.5 0 1 0 .707-.707 4.5 4.5 0 0 0-6.364 0 .5.5 0 0 0 .707.707"/>
<path d="M6.94 4.44a1.5 1.5 0 0 1 2.12 0 .5.5 0 0 0 .708-.708 2.5 2.5 0 0 0-3.536 0 .5.5 0 0 0 .707.707ZM2.5 11a.5.5 0 1 1 0-1 .5.5 0 0 1 0 1m4.5-.5a.5.5 0 1 0 1 0 .5.5 0 0 0-1 0m2.5.5a.5.5 0 1 1 0-1 .5.5 0 0 1 0 1m1.5-.5a.5.5 0 1 0 1 0 .5.5 0 0 0-1 0m2 0a.5.5 0 1 0 1 0 .5.5 0 0 0-1 0"/>
<path d="M2.974 2.342a.5.5 0 1 0-.948.316L3.806 8H1.5A1.5 1.5 0 0 0 0 9.5v2A1.5 1.5 0 0 0 1.5 13H2a.5.5 0 0 0 .5.5h2A.5.5 0 0 0 5 13h6a.5.5 0 0 0 .5.5h2a.5.5 0 0 0 .5-.5h.5a1.5 1.5 0 0 0 1.5-1.5v-2A1.5 1.5 0 0 0 14.5 8h-2.306l1.78-5.342a.5.5 0 1 0-.948-.316L11.14 8H4.86zM14.5 9a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-.5.5h-13a.5.5 0 0 1-.5-.5v-2a.5.5 0 0 1 .5-.5z"/>
<path d="M8.5 5.5a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0"/>
</svg>

After

Width:  |  Height:  |  Size: 946 B

+4
View File
@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-window-stack" viewBox="0 0 16 16">
<path d="M4.5 6a.5.5 0 1 0 0-1 .5.5 0 0 0 0 1M6 6a.5.5 0 1 0 0-1 .5.5 0 0 0 0 1m2-.5a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0"/>
<path d="M12 1a2 2 0 0 1 2 2 2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2 2 2 0 0 1-2-2V3a2 2 0 0 1 2-2zM2 12V5a2 2 0 0 1 2-2h9a1 1 0 0 0-1-1H2a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1m1-4v5a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1V8zm12-1V5a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v2z"/>
</svg>

After

Width:  |  Height:  |  Size: 517 B

+22 -7
View File
@@ -1,33 +1,48 @@
{% load static %}<!doctype html>
<html lang="de">
<html lang="de" data-bs-theme="dark">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}Netzwerk Planer{% endblock %}</title>
<script>
// Thema vor dem ersten Zeichnen setzen (Standard: dunkel), kein Aufblitzen
document.documentElement.dataset.bsTheme = localStorage.getItem("netzwerk-planer:thema") || "dark";
</script>
<link rel="stylesheet" href="{% static 'vendor/bootstrap/bootstrap.min.css' %}">
</head>
<body class="bg-body-tertiary">
<nav class="navbar navbar-expand bg-dark" data-bs-theme="dark">
<div class="container">
<nav class="navbar navbar-expand bg-dark border-bottom border-secondary-subtle" data-bs-theme="dark">
<div class="container-fluid px-4">
<a class="navbar-brand" href="{% url 'start' %}">Netzwerk Planer</a>
{% if user.is_authenticated %}
<div class="navbar-nav me-auto">
<a class="nav-link{% if request.resolver_match.url_name == 'schaubild' %} active{% endif %}" href="{% url 'schaubild' %}">Schaubild</a>
</div>
<div class="navbar-nav align-items-center">
{% endif %}
<div class="navbar-nav align-items-center gap-2">
<button type="button" id="thema-umschalten" class="btn btn-sm btn-outline-light" title="Hell/Dunkel umschalten">◐ Thema</button>
{% if user.is_authenticated %}
<a class="nav-link" href="{% url 'admin:index' %}">Admin</a>
<form method="post" action="{% url 'logout' %}" class="ms-2">
<form method="post" action="{% url 'logout' %}">
{% csrf_token %}
<button type="submit" class="btn btn-sm btn-outline-light">Abmelden ({{ user.username }})</button>
</form>
</div>
{% endif %}
{% endif %}
</div>
</div>
</nav>
<main class="{% block main_klasse %}container py-4{% endblock %}">
{% block content %}{% endblock %}
</main>
<script src="{% static 'vendor/bootstrap/bootstrap.bundle.min.js' %}"></script>
<script>
document.getElementById("thema-umschalten").addEventListener("click", () => {
const neu = document.documentElement.dataset.bsTheme === "dark" ? "light" : "dark";
document.documentElement.dataset.bsTheme = neu;
localStorage.setItem("netzwerk-planer:thema", neu);
window.dispatchEvent(new CustomEvent("themawechsel", { detail: neu }));
});
</script>
{% block skripte %}{% endblock %}
</body>
</html>
+81 -15
View File
@@ -2,7 +2,8 @@
Erzeugt die Cytoscape-Elemente (Knoten und Kanten) aus den Daten in `inventar`.
Knoten-IDs sind logische IDs (README Kapitel 2), z. B. `geraet:pve1`,
`bridge:pve1/vmbr0`, `port:pve1/nic1`. Beschriftungen nach README Kapitel 7.1.
`bridge:pve1/vmbr0`, `port:pve1/nic1`, `internet:fritzbox-7430/DSL`.
Beschriftungen, Farben und Hinweise nach README Kapitel 7.1.
"""
from django.db.models import Prefetch
@@ -13,6 +14,23 @@ from inventar.models import Bridge, Geraet, Netz, Schnittstelle, Verbindung
from .models import Position
UNBEKANNT = "?"
PRUEFEN = "(prüfen)"
FARBE_INTERNET = "#facc15"
# Icon je Gerät (Dateiname in static/vendor/bootstrap-icons/)
ICON_JE_TYP = {
"router": "router", "hypervisor": "hdd-rack", "switch": "hdd-network", "ap": "broadcast-pin",
}
ICON_JE_ROLLE = {"pc": "pc-display", "laptop": "laptop", "handy": "phone", "drucker": "printer", "iot": "lightbulb"}
ICON_JE_ART = {"vm": "window-stack", "lxc": "box"}
def icon(g):
if g.ist_gast:
return ICON_JE_ART[g.art]
if g.typ == "endgeraet":
return ICON_JE_ROLLE.get(g.rolle, "display")
return ICON_JE_TYP.get(g.typ, "cpu")
def geraet_id(g):
@@ -67,10 +85,14 @@ class Schaubild:
element["position"] = self.positionen[id]
self.elemente.append(element)
def kante(self, id, quelle, ziel, typ, label, info, url):
def kante(self, id, quelle, ziel, typ, label, info, url, netze=(), farbe=None):
"""Farbe der Linie = Farbe des (ersten) Netzes; ohne Netz neutral."""
netze = list(netze)
self.elemente.append({
"group": "edges",
"data": {"id": id, "source": quelle, "target": ziel, "label": label, "info": info, "url": url},
"data": {"id": id, "source": quelle, "target": ziel, "label": label, "info": info, "url": url,
"netze": [n.cidr for n in netze],
"farbe": farbe or (netze[0].anzeige_farbe if netze else "")},
"classes": typ,
})
@@ -85,7 +107,7 @@ class Schaubild:
klassen = ["geraet", f"status-{g.status}"]
if g.ist_gast:
klassen.append("gast")
titel = f"{g.get_art_display()} {g.proxmox_id} {g.name}"
titel = f"[{g.get_art_display()} {g.proxmox_id}] {g.name}"
adressen = [ip for s in g.schnittstellen.all() for ip in ips(s)]
info = [("Art", g.get_art_display()), ("Proxmox-ID", g.proxmox_id), ("Host", g.host.name),
("Betriebssystem", g.betriebssystem or "–")]
@@ -100,10 +122,13 @@ class Schaubild:
("Hersteller/Modell", g.hersteller_modell or "–")]
parent = None
info += [("IP", ", ".join(adressen) or "–")] + self.status_info(g)
label = titel if g.ist_hypervisor else "\n".join([titel, *adressen])
gaeste = sum(1 for x in self.geraete if x.host_id == g.pk)
if g.ist_hypervisor and gaeste:
label = " · ".join(filter(None, [titel, g.hersteller_modell])) # Rahmen
else:
label = "\n".join([titel, *adressen])
self.knoten(geraet_id(g), klassen, label, info, admin_url(g), parent,
titel=titel, status=g.status, gaeste=gaeste)
titel=titel, status=g.status, gaeste=gaeste, icon=icon(g))
for s in g.schnittstellen.all():
if g.ist_gast:
@@ -117,8 +142,12 @@ class Schaubild:
if s.switch_modus:
info += [("Modus", s.get_switch_modus_display()), ("VLAN", ", ".join(s.vlan_angaben()) or "–"),
("PoE", "ja" if s.poe else "nein")]
if s.anbieter:
info.append(("Anbieter", s.anbieter))
label = f"{s.name} ↗" if s.art == Schnittstelle.Art.DSL else s.name
self.knoten(port_id(s), klassen, label, info, admin_url(s), geraet_id(g), titel=f"{g.name}/{s.name}")
if s.art == Schnittstelle.Art.DSL:
self.internet(s)
for b in g.bridges.all():
adressen = ips(b)
@@ -128,7 +157,16 @@ class Schaubild:
if b.notizen:
info.append(("Notizen", b.notizen))
self.knoten(bridge_id(b), ["bridge"], "\n".join([b.name, *adressen]), info, admin_url(b),
geraet_id(g), titel=str(b))
geraet_id(g), titel=str(b), icon="hdd-network")
def internet(self, dsl):
"""Knoten „Internet“ am DSL-Port; Gegenstelle selbst wird nicht dokumentiert."""
id = f"internet:{dsl.geraet.slug}/{dsl.name}"
titel = f"{dsl.anbieter} Internet" if dsl.anbieter else "Internet"
info = [("Art", "Internetanschluss"), ("Anbieter", dsl.anbieter or "–"), ("Über", str(dsl))]
self.knoten(id, ["internet"], titel, info, admin_url(dsl), titel=titel, icon="globe2")
self.kante(f"anschluss:{dsl}", port_id(dsl), id, "internet", "Internet", info, admin_url(dsl),
farbe=FARBE_INTERNET)
# --- Kanten ---------------------------------------------------------------
@@ -145,28 +183,31 @@ class Schaubild:
netze = list(s.bridge.netze())
label = beschriftung(netze, s.vlan_angaben() if g.ist_gast else ())
info = [("Art", art), ("Schnittstelle", str(s)), ("Bridge", str(s.bridge)), ("Netz", label)]
self.kante(f"bridge:{s.geraet.slug}/{s.name}", von, bridge_id(s.bridge), typ, label, info, admin_url(s))
self.kante(f"bridge:{s.geraet.slug}/{s.name}", von, bridge_id(s.bridge), typ, label, info,
admin_url(s), netze)
if s.durchgereicht_an_id:
label = beschriftung(s.abgeleitete_netze())
netze = s.abgeleitete_netze()
label = beschriftung(netze)
info = [("Art", "Passthrough"), ("Port", str(s)), ("Gast", s.durchgereicht_an.name), ("Netz", label)]
self.kante(f"passthrough:{s.geraet.slug}/{s.name}", von, geraet_id(s.durchgereicht_an),
"passthrough", label, info, admin_url(s))
"passthrough", label, info, admin_url(s), netze)
if s.ssid_id:
label = beschriftung([s.ssid.netz] if s.ssid.netz else [])
netze = [s.ssid.netz] if s.ssid.netz else []
label = beschriftung(netze)
info = [("Art", "WLAN"), ("SSID", str(s.ssid)), ("Netz", label)]
self.kante(f"wlan:{s.geraet.slug}/{s.name}", von, geraet_id(s.ssid.ap), "wlan",
f"{s.ssid.name} · {label}", info, admin_url(s))
f"{s.ssid.name} · {label}", info, admin_url(s), netze)
def verbindungs_kanten(self):
for v in self.verbindungen:
netze = {n.pk: n for s in (v.a, v.b) for n in s.abgeleitete_netze()}
netze = sorted({n.pk: n for s in (v.a, v.b) for n in s.abgeleitete_netze()}.values(), key=lambda n: n.cidr)
vlans = list(dict.fromkeys(x for s in (v.a, v.b) for x in s.vlan_angaben()))
label = beschriftung(sorted(netze.values(), key=lambda n: n.cidr), vlans)
label = beschriftung(netze, vlans)
info = [("Art", v.get_typ_display()), ("A", str(v.a)), ("B", str(v.b)), ("Netz", label)]
if v.notiz:
info.append(("Notiz", v.notiz))
self.kante(f"verbindung:{v.a}|{v.b}", self.endpunkt[v.a_id], self.endpunkt[v.b_id],
v.typ, label, info, admin_url(v))
v.typ, label, info, admin_url(v), netze)
def verwaltet_kanten(self):
for g in self.geraete:
@@ -175,6 +216,30 @@ class Schaubild:
self.kante(f"verwaltet:{g.slug}", geraet_id(g), geraet_id(g.verwaltet_von), "verwaltet",
"verwaltet von", info, admin_url(g))
# --- Hinweise (⚠) ----------------------------------------------------------
def hinweise(self):
"""⚠ an Geräten mit „(prüfen)“ in Notizen (Gerät, Schnittstellen, IPs) oder ganz ohne Linie."""
knoten = {e["data"]["id"]: e for e in self.elemente if e["group"] == "nodes"}
mit_linie = {e["data"][k] for e in self.elemente if e["group"] == "edges" for k in ("source", "target")}
for g in self.geraete:
gruende = []
texte = [g.notizen] + [s.notizen for s in g.schnittstellen.all()] + [b.notizen for b in g.bridges.all()]
texte += [ip.notiz for s in g.schnittstellen.all() for ip in s.ip_adressen.all()]
texte += [ip.notiz for b in g.bridges.all() for ip in b.ip_adressen.all()]
if any(PRUEFEN in t for t in texte if t):
gruende.append("Offene Angaben „(prüfen)“ in den Notizen")
eigene = {geraet_id(g)} | {port_id(s) for s in g.schnittstellen.all() if not g.ist_gast} \
| {bridge_id(b) for b in g.bridges.all()}
if not g.ist_hypervisor or not g.bridges.exists():
if not eigene & mit_linie:
gruende.append("Keine Verbindung dokumentiert")
if gruende:
k = knoten[geraet_id(g)]
k["classes"] += " warnung"
k["data"]["label"] = "⚠ " + k["data"]["label"]
k["data"]["info"] = [("⚠", grund) for grund in gruende] + k["data"]["info"]
# --- Ergebnis -------------------------------------------------------------
def als_json(self):
@@ -182,6 +247,7 @@ class Schaubild:
self.schnittstellen_kanten()
self.verbindungs_kanten()
self.verwaltet_kanten()
self.hinweise()
for e in self.elemente:
e["data"]["info"] = [[k, str(v)] for k, v in e["data"]["info"]]
# Rahmen (ohne parent) vor ihrem Inhalt, Knoten vor Kanten
+5 -3
View File
@@ -30,8 +30,8 @@
<label class="form-check-label" for="alle-ports">Alle Ports zeigen</label>
</div>
<div class="form-check form-switch mb-0 small">
<input class="form-check-input" type="checkbox" id="beschriftung" checked>
<label class="form-check-label" for="beschriftung">Beschriftung</label>
<input class="form-check-input" type="checkbox" id="beschriftung">
<label class="form-check-label" for="beschriftung">Beschriftung immer</label>
</div>
<div class="ms-auto d-flex gap-2">
@@ -42,7 +42,7 @@
<div class="row g-2">
<div class="col-lg-9">
<div id="schaubild" class="border rounded bg-white" style="height: calc(100vh - 150px); min-height: 420px"></div>
<div id="schaubild" class="border rounded" style="height: calc(100vh - 150px); min-height: 420px"></div>
</div>
<div class="col-lg-3">
<div class="card h-100">
@@ -51,7 +51,9 @@
<ul class="text-secondary ps-3 mb-0">
<li>Ziehen verschiebt nur die Anordnung, nie die Daten.</li>
<li>Doppelklick auf einen Host klappt ihn auf oder zu.</li>
<li>Linienfarbe = Netz; Maus über eine Linie zeigt CIDR und VLAN.</li>
<li>„?“ an einer Linie: Netz lässt sich aus den Daten nicht ableiten.</li>
<li>⚠ am Gerät: offene Angaben „(prüfen)“ oder keine Verbindung.</li>
</ul>
</div>
</div>
+31
View File
@@ -76,6 +76,37 @@ class SchaubildDaten(TestCase):
kanten = {(e["data"]["source"], e["data"]["target"]): e for e in Schaubild().als_json()["elemente"] if e["group"] == "edges"}
self.assertEqual(kanten[("geraet:ct-107", "bridge:pve1/vmbr9")]["data"]["label"], "?")
def test_ids_eindeutig(self):
ids = [e["data"]["id"] for e in self.daten["elemente"]]
self.assertEqual(len(ids), len(set(ids)))
def test_linienfarbe_vom_netz(self):
kante = self.kanten[("geraet:ct-105", "bridge:pve1/vmbr0")]
self.assertEqual(kante["data"]["farbe"], self.lan.anzeige_farbe)
self.assertEqual(kante["data"]["netze"], ["192.168.178.0/24"])
def test_icons(self):
self.assertEqual(self.knoten["geraet:pve1"]["data"]["icon"], "hdd-rack")
self.assertEqual(self.knoten["geraet:ct-105"]["data"]["icon"], "box")
self.assertEqual(self.knoten["geraet:switch"]["data"]["icon"], "hdd-network")
def test_internet_am_dsl_port(self):
fb = Geraet.objects.create(name="FritzBox", typ=Geraet.Typ.ROUTER, standort=self.pve1.standort)
Schnittstelle.objects.create(geraet=fb, name="DSL", art=Schnittstelle.Art.DSL, anbieter="1und1")
daten = Schaubild().als_json()["elemente"]
knoten = {e["data"]["id"]: e for e in daten if e["group"] == "nodes"}
kanten = {(e["data"]["source"], e["data"]["target"]) for e in daten if e["group"] == "edges"}
self.assertEqual(knoten["internet:fritzbox/DSL"]["data"]["label"], "1und1 Internet")
self.assertIn(("port:fritzbox/DSL", "internet:fritzbox/DSL"), kanten)
def test_warnung_ohne_verbindung_und_bei_pruefen(self):
self.assertIn("warnung", self.knoten["geraet:ct-107"]["classes"]) # keine Linie
self.assertNotIn("warnung", self.knoten["geraet:ct-105"]["classes"])
self.switch.notizen = "Modell (prüfen)"
self.switch.save()
knoten = {e["data"]["id"]: e for e in Schaubild().als_json()["elemente"] if e["group"] == "nodes"}
self.assertTrue(knoten["geraet:switch"]["data"]["label"].startswith("⚠ "))
def test_gespeicherte_position(self):
Position.objects.create(schluessel="geraet:ct-105", x=10, y=20)
knoten = {e["data"]["id"]: e for e in Schaubild().als_json()["elemente"] if e["group"] == "nodes"}
+2
View File
@@ -3,6 +3,7 @@ import json
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseBadRequest, JsonResponse
from django.shortcuts import render
from django.templatetags.static import static
from django.urls import reverse
from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.decorators.http import require_GET, require_POST
@@ -23,6 +24,7 @@ def schaubild(request):
"daten": reverse("schaubild_daten"),
"speichern": reverse("positionen_speichern"),
"zuruecksetzen": reverse("positionen_zuruecksetzen"),
"icons": static("vendor/bootstrap-icons/"),
}
return render(request, "topologie/schaubild.html", {"urls": urls, "status_auswahl": Status.choices})