diff --git a/README.md b/README.md index 62c02a5..f32ff54 100644 --- a/README.md +++ b/README.md @@ -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. +![Floor plan designer](docs/screenshots/designer.png) + | | | |---|---| | **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. + +![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) | Key | Action | diff --git a/docs/screenshots/designer-dark.png b/docs/screenshots/designer-dark.png new file mode 100644 index 0000000..0203d07 Binary files /dev/null and b/docs/screenshots/designer-dark.png differ diff --git a/docs/screenshots/designer.png b/docs/screenshots/designer.png new file mode 100644 index 0000000..cfc6eee Binary files /dev/null and b/docs/screenshots/designer.png differ diff --git a/docs/screenshots/location.png b/docs/screenshots/location.png new file mode 100644 index 0000000..46ee530 Binary files /dev/null and b/docs/screenshots/location.png differ diff --git a/docs/screenshots/view.png b/docs/screenshots/view.png new file mode 100644 index 0000000..660ce5b Binary files /dev/null and b/docs/screenshots/view.png differ diff --git a/netbox_floorplanner/__init__.py b/netbox_floorplanner/__init__.py index c748bec..fe9b384 100644 --- a/netbox_floorplanner/__init__.py +++ b/netbox_floorplanner/__init__.py @@ -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): diff --git a/netbox_floorplanner/preview.py b/netbox_floorplanner/preview.py index adb9bf5..57c23a4 100644 --- a/netbox_floorplanner/preview.py +++ b/netbox_floorplanner/preview.py @@ -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'{escape(text)}') + f'dominant-baseline="middle" fill="{fill}"{flip}>{escape(text)}') transform = f' transform="rotate({item.rotation} {cx} {cy})"' if item.rotation else '' return f'{"".join(parts)}' diff --git a/netbox_floorplanner/static/netbox_floorplanner/floorplanner.js b/netbox_floorplanner/static/netbox_floorplanner/floorplanner.js index d6305af..85392e6 100644 --- a/netbox_floorplanner/static/netbox_floorplanner/floorplanner.js +++ b/netbox_floorplanner/static/netbox_floorplanner/floorplanner.js @@ -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 })); diff --git a/netbox_floorplanner/templates/netbox_floorplanner/inc/designer.html b/netbox_floorplanner/templates/netbox_floorplanner/inc/designer.html index 135ddc7..685728f 100644 --- a/netbox_floorplanner/templates/netbox_floorplanner/inc/designer.html +++ b/netbox_floorplanner/templates/netbox_floorplanner/inc/designer.html @@ -1,5 +1,5 @@ {% load static %} - +
{% csrf_token %}
{{ designer_config|json_script:"fp-config" }} - + diff --git a/netbox_floorplanner/templates/netbox_floorplanner/inc/location_floorplans.html b/netbox_floorplanner/templates/netbox_floorplanner/inc/location_floorplans.html index 65e79fc..94b737d 100644 --- a/netbox_floorplanner/templates/netbox_floorplanner/inc/location_floorplans.html +++ b/netbox_floorplanner/templates/netbox_floorplanner/inc/location_floorplans.html @@ -1,6 +1,6 @@ {% load static %} {% load i18n %} - +

{% trans "Floor Plans" %}

diff --git a/pyproject.toml b/pyproject.toml index 8475a02..b0a94c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"