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:
1 parent
25e944ada7
commit
4a4bf52a28
11 files changed
+39
-8
No files matched your search
@@ -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.
|
||||
|
||||

|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| **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.
|
||||
- **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.
|
||||
|
||||

|
||||
|
||||
**View mode:** racks coloured by status, with a tooltip that shows status, role, tenant and device count.
|
||||
|
||||

|
||||
|
||||
**Location page:** clickable previews of all floor plans of the location.
|
||||
|
||||

|
||||
|
||||
**Dark mode:**
|
||||
|
||||

|
||||
|
||||
### Keyboard shortcuts (designer)
|
||||
|
||||
| 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,7 +1,7 @@
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from netbox.plugins import PluginConfig
|
||||
|
||||
__version__ = '0.1.4'
|
||||
__version__ = '0.1.5'
|
||||
|
||||
|
||||
class FloorPlannerConfig(PluginConfig):
|
||||
|
||||
@@ -61,8 +61,10 @@ def _item_svg(item):
|
||||
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)
|
||||
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}" '
|
||||
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 ''
|
||||
return f'<g{transform}>{"".join(parts)}</g>'
|
||||
|
||||
@@ -815,10 +815,19 @@
|
||||
'pointer-events': 'none',
|
||||
}, g);
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
// Darken a hex color by ~30 % for borders
|
||||
const m = /^#?([0-9a-f]{6})$/i.exec(hex || '');
|
||||
@@ -959,7 +968,7 @@
|
||||
const o = i.object;
|
||||
const rows = [
|
||||
[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.tenant ? [this.t('Tenant'), o.tenant] : 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('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.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 }));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% 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>
|
||||
{{ 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 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">
|
||||
<h2 class="card-header">{% trans "Floor Plans" %}</h2>
|
||||
<div class="card-body fp-preview-list">
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "netbox-floorplanner"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
description = "Modern drag & drop floor plan designer for NetBox 4.7+"
|
||||
readme = "README.md"
|
||||
license = "Apache-2.0"
|
||||
|
||||
Reference in new issue
Block a user