Add README screenshots; fix upside-down labels and status badges

Labels on items rotated by more than 90 degrees are flipped to stay
readable (designer and location preview). Status badges use inline
colors because NetBox color names are not Bootstrap badge classes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
MrBlakeandClaude Opus 5.5 committed 2026-11-04 14:20:37 +01:00
1 parent 25e944ada7
commit 4a4bf52a28
11 files changed
+39 -8

No files matched your search

+20
View File
@@ -4,6 +4,8 @@
It is a from-scratch alternative to the community `netbox-floorplan-plugin`, with a canvas-style editor in the spirit of draw.io instead of a form-based workflow. It is a from-scratch alternative to the community `netbox-floorplan-plugin`, with a canvas-style editor in the spirit of draw.io instead of a form-based workflow.
![Floor plan designer](docs/screenshots/designer.png)
| | | | | |
|---|---| |---|---|
| **Repository** | [git.mrblake.cc/MrBlake/NetBox-FloorPlan2.0](https://git.mrblake.cc/MrBlake/NetBox-FloorPlan2.0) | | **Repository** | [git.mrblake.cc/MrBlake/NetBox-FloorPlan2.0](https://git.mrblake.cc/MrBlake/NetBox-FloorPlan2.0) |
@@ -115,6 +117,24 @@ sudo systemctl restart netbox netbox-rq
- **Tenancy:** an optional tenant per floor plan, with tenant and tenant group filters and columns in the floor plan list. New plans inherit the tenant of their location or site, and existing plans are pre-filled from them during the migration. - **Tenancy:** an optional tenant per floor plan, with tenant and tenant group filters and columns in the floor plan list. New plans inherit the tenant of their location or site, and existing plans are pre-filled from them during the migration.
- **NetBox native:** change logging, journaling, tags, custom fields, global search, CSV/YAML import, bulk delete, object permissions, REST API, dark mode and fullscreen. - **NetBox native:** change logging, journaling, tags, custom fields, global search, CSV/YAML import, bulk delete, object permissions, REST API, dark mode and fullscreen.
### Screenshots
**Designer:** palette with shapes, racks and devices on the left, properties of the selected rack on the right.
![Designer](docs/screenshots/designer.png)
**View mode:** racks coloured by status, with a tooltip that shows status, role, tenant and device count.
![View mode](docs/screenshots/view.png)
**Location page:** clickable previews of all floor plans of the location.
![Location page previews](docs/screenshots/location.png)
**Dark mode:**
![Designer in dark mode](docs/screenshots/designer-dark.png)
### Keyboard shortcuts (designer) ### Keyboard shortcuts (designer)
| Key | Action | | Key | Action |
Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

+1 -1
View File
@@ -1,7 +1,7 @@
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from netbox.plugins import PluginConfig from netbox.plugins import PluginConfig
__version__ = '0.1.4' __version__ = '0.1.5'
class FloorPlannerConfig(PluginConfig): class FloorPlannerConfig(PluginConfig):
+3 -1
View File
@@ -61,8 +61,10 @@ def _item_svg(item):
fs = max(6, min(h * 0.3, (w * 1.6) / max(len(text), 3), 60)) fs = max(6, min(h * 0.3, (w * 1.6) / max(len(text), 3), 60))
fill = '#ffffff' if t in FILLED_TYPES else (item.color or 'currentColor') if t == 'label' else _shade(color) fill = '#ffffff' if t in FILLED_TYPES else (item.color or 'currentColor') if t == 'label' else _shade(color)
anchor, tx, ty = ('start', x + fs * 0.5, y + fs * 1.2) if t == 'area' else ('middle', cx, cy) anchor, tx, ty = ('start', x + fs * 0.5, y + fs * 1.2) if t == 'area' else ('middle', cx, cy)
# Keep text readable on items rotated upside down
flip = f' transform="rotate(180 {tx} {ty})"' if 90 < item.rotation % 360 <= 270 else ''
parts.append(f'<text x="{tx}" y="{ty}" font-size="{fs:.1f}" font-weight="600" text-anchor="{anchor}" ' parts.append(f'<text x="{tx}" y="{ty}" font-size="{fs:.1f}" font-weight="600" text-anchor="{anchor}" '
f'dominant-baseline="middle" fill="{fill}">{escape(text)}</text>') f'dominant-baseline="middle" fill="{fill}"{flip}>{escape(text)}</text>')
transform = f' transform="rotate({item.rotation} {cx} {cy})"' if item.rotation else '' transform = f' transform="rotate({item.rotation} {cx} {cy})"' if item.rotation else ''
return f'<g{transform}>{"".join(parts)}</g>' return f'<g{transform}>{"".join(parts)}</g>'
@@ -815,10 +815,19 @@
'pointer-events': 'none', 'pointer-events': 'none',
}, g); }, g);
tnode.textContent = text; tnode.textContent = text;
// Keep text readable on items rotated upside down
const rot = ((i.rotation || 0) % 360 + 360) % 360;
if (rot > 90 && rot <= 270) tnode.setAttribute('transform', `rotate(180 ${tx} ${ty})`);
} }
return g; return g;
} }
statusBadge(o) {
// Inline colors: NetBox color names (e.g. "green") are not Bootstrap badge classes
const bg = COLOR_NAMES[o.status_color] || o.status_color || COLOR_NAMES.gray;
return html('span', { class: 'badge', style: `background:${bg};color:#fff`, text: o.status_label });
}
shade(hex) { shade(hex) {
// Darken a hex color by ~30 % for borders // Darken a hex color by ~30 % for borders
const m = /^#?([0-9a-f]{6})$/i.exec(hex || ''); const m = /^#?([0-9a-f]{6})$/i.exec(hex || '');
@@ -959,7 +968,7 @@
const o = i.object; const o = i.object;
const rows = [ const rows = [
[this.t('Linked object'), html('a', { href: o.url, target: '_blank', text: o.name })], [this.t('Linked object'), html('a', { href: o.url, target: '_blank', text: o.name })],
o.status_label ? [this.t('Status'), html('span', { class: 'badge text-bg-' + (o.status_color || 'secondary'), text: o.status_label })] : null, o.status_label ? [this.t('Status'), this.statusBadge(o)] : null,
o.role ? [this.t('Role'), o.role] : null, o.role ? [this.t('Role'), o.role] : null,
o.tenant ? [this.t('Tenant'), o.tenant] : null, o.tenant ? [this.t('Tenant'), o.tenant] : null,
o.u_height ? [this.t('Height (U)'), String(o.u_height)] : null, o.u_height ? [this.t('Height (U)'), String(o.u_height)] : null,
@@ -1259,7 +1268,7 @@
html('strong', { text: this.itemText(i) || this.cfg.types[i.item_type] }), html('strong', { text: this.itemText(i) || this.cfg.types[i.item_type] }),
html('div', { class: 'fp-muted', text: this.cfg.types[i.item_type] + ` · ${roomSize(i.width, i.height)} m` }), html('div', { class: 'fp-muted', text: this.cfg.types[i.item_type] + ` · ${roomSize(i.width, i.height)} m` }),
]; ];
if (o.status_label) rows.push(html('div', {}, [this.t('Status') + ': ', html('span', { class: 'badge text-bg-' + (o.status_color || 'secondary'), text: o.status_label })])); if (o.status_label) rows.push(html('div', {}, [this.t('Status') + ': ', this.statusBadge(o)]));
if (o.role) rows.push(html('div', { text: this.t('Role') + ': ' + o.role })); if (o.role) rows.push(html('div', { text: this.t('Role') + ': ' + o.role }));
if (o.tenant) rows.push(html('div', { text: this.t('Tenant') + ': ' + o.tenant })); if (o.tenant) rows.push(html('div', { text: this.t('Tenant') + ': ' + o.tenant }));
if (o.u_height) rows.push(html('div', { text: this.t('Height (U)') + ': ' + o.u_height })); if (o.u_height) rows.push(html('div', { text: this.t('Height (U)') + ': ' + o.u_height }));
@@ -1,5 +1,5 @@
{% load static %} {% load static %}
<link rel="stylesheet" href="{% static 'netbox_floorplanner/floorplanner.css' %}?v=0.1.4"> <link rel="stylesheet" href="{% static 'netbox_floorplanner/floorplanner.css' %}?v=0.1.5">
<div class="fp-root" data-fp-config="fp-config">{% csrf_token %}</div> <div class="fp-root" data-fp-config="fp-config">{% csrf_token %}</div>
{{ designer_config|json_script:"fp-config" }} {{ designer_config|json_script:"fp-config" }}
<script src="{% static 'netbox_floorplanner/floorplanner.js' %}?v=0.1.4"></script> <script src="{% static 'netbox_floorplanner/floorplanner.js' %}?v=0.1.5"></script>
@@ -1,6 +1,6 @@
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
<link rel="stylesheet" href="{% static 'netbox_floorplanner/floorplanner.css' %}?v=0.1.4"> <link rel="stylesheet" href="{% static 'netbox_floorplanner/floorplanner.css' %}?v=0.1.5">
<div class="card"> <div class="card">
<h2 class="card-header">{% trans "Floor Plans" %}</h2> <h2 class="card-header">{% trans "Floor Plans" %}</h2>
<div class="card-body fp-preview-list"> <div class="card-body fp-preview-list">
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "netbox-floorplanner" name = "netbox-floorplanner"
version = "0.1.4" version = "0.1.5"
description = "Modern drag & drop floor plan designer for NetBox 4.7+" description = "Modern drag & drop floor plan designer for NetBox 4.7+"
readme = "README.md" readme = "README.md"
license = "Apache-2.0" license = "Apache-2.0"