diff --git a/README.md b/README.md
index fc71d49..535c957 100644
--- a/README.md
+++ b/README.md
@@ -275,6 +275,11 @@ interface and port names, and LLDP neighbors.
- **Outlets** (PDUs, UPS, power strip): per-outlet state, power, and auto power-cycle setting; readings
UniFi has frozen are marked stale (see Topology)
- **Port inspector** (switches, routers): see below
+- **Hardware drawing** (hosts, modem, AP): a server shows the same front the rack page draws, from its
+ cutsheet item's *Front drawing* (a ZimaBoard's NIC lights follow its interfaces), with where it sits
+ ("U5-U8, full depth", "Rear shelf (U22-U23), slot 1") linking to the rack page; Overview lists the
+ location too. A host with no cutsheet item, or one with no Front drawing, shows no picture. The
+ modem and AP use the drawings from the topology page.
- **Interfaces / Ports**: one row each with state, speed, RX/TX rate, and neighbor, filterable.
Expanding a host's row shows duplex, auto-negotiation, carrier changes, error and drop rates,
traffic bars, PoE, LLDP detail, and the **SFP / optical panel** (vendor/PN, temperature, voltage,
diff --git a/app.py b/app.py
index e398292..3f703c6 100644
--- a/app.py
+++ b/app.py
@@ -682,16 +682,18 @@ def api_devices():
@require_auth
def api_device(name: str):
"""Everything known about one device, for its detail page."""
- detail = devices.device_detail(
- name, _state_json('network_snapshot'), _state_json('link_stats'), _state_json('modem_stats'),
- )
+ snapshot = _state_json('network_snapshot')
+ detail = devices.device_detail(name, snapshot, _state_json('link_stats'), _state_json('modem_stats'))
if detail is None:
return jsonify({'error': f'No device named "{name}"'}), 404
events = db.get_events_for_target(name)
_annotate_suppressions(events, db.get_active_suppressions())
detail['events'] = events
+ detail['hardware'] = None
try:
- detail['cutsheet'] = _cutsheet_for_device(name)
+ view = _cutsheet_view()
+ detail['cutsheet'] = _cutsheet_for_device(name, view)
+ detail['hardware'] = _hardware_for(name, view['items'], snapshot)
except Exception as e:
logger.error(f'Cutsheet unavailable for {name}: {e}')
detail['cutsheet'] = []
@@ -1126,9 +1128,8 @@ def _cutsheet_view() -> dict:
return data
-def _cutsheet_for_device(name: str) -> list:
+def _cutsheet_for_device(name: str, view: dict) -> list:
"""The cables that end on one device, for its port panel."""
- view = _cutsheet_view()
# Cables may name the device or a cutsheet item linked to it
names = {name} | {i['name'] for i in view['items'] if i.get('device') == name}
out = []
@@ -1143,6 +1144,26 @@ def _cutsheet_for_device(name: str) -> list:
return out
+def _hardware_for(name: str, items: list, snapshot: dict) -> Optional[dict]:
+ """What a device looks like and where it sits, from its cutsheet item, for its page's drawing.
+
+ chassis is the item's Front drawing (a key of RACK_FRONTS, SHELF_GEAR or CHASSIS_FACEPLATES
+ in static/fronts.js); interfaces drive the NIC lights on drawings that have them.
+ """
+ item = cutsheet.item_for_device(name, items)
+ if not item:
+ return None
+ rack = item.get('rack') or ''
+ if not rack and item.get('shelf'):
+ rack = next((i.get('rack') or '' for i in items if i['name'] == item['shelf']), '')
+ return {
+ 'item': item['name'], 'item_id': item['id'], 'chassis': item.get('chassis') or '',
+ 'location': cutsheet.location_text(item, items),
+ 'rack_url': '/rack' + (f'?rack={quote(rack, safe="")}' if rack else ''),
+ 'interfaces': _physical_interfaces(name, snapshot),
+ }
+
+
def _json_body() -> dict:
"""The request's JSON object. Requiring a JSON content type also keeps another
site's plain form post from reaching these write endpoints (no CORS preflight)."""
diff --git a/cutsheet.py b/cutsheet.py
index 9921c94..44afbb5 100644
--- a/cutsheet.py
+++ b/cutsheet.py
@@ -617,6 +617,39 @@ def problems(cables: List[dict], items: Dict[str, dict], switches: dict) -> List
# ── Rack elevation ──────────────────────────────────────────────────────────
+def item_for_device(name: str, items: List[dict]) -> Optional[dict]:
+ """The cutsheet item that stands for a live device: one linked to it, or one named after it."""
+ linked = next((i for i in items if i.get('device') == name), None)
+ return linked or next((i for i in items if not i.get('device') and i['name'] == name), None)
+
+
+def _units_text(item: dict) -> str:
+ low, height = item.get('rack_u'), item.get('rack_height') or 1
+ if not low:
+ return ''
+ return f'U{low}' if height == 1 else f'U{low}-U{low + height - 1}'
+
+
+def location_text(item: dict, items: List[dict]) -> str:
+ """Where an item sits, in words: "U14-U17, full depth" or "Rear shelf (U22-U23), slot 1"."""
+ rack = item.get('rack') or ''
+ shelf_name = item.get('shelf') or ''
+ if shelf_name:
+ shelf = next((i for i in items if i['name'] == shelf_name), {})
+ units = _units_text(shelf)
+ rack = rack or shelf.get('rack') or ''
+ text = f'{shelf_name} ({units})' if units else shelf_name
+ if item.get('slot'):
+ text += f', slot {item["slot"]}'
+ else:
+ text = _units_text(item)
+ mount = item.get('mount') or 'front'
+ if text and mount != 'front':
+ text += ', full depth' if mount == 'full' else ', rear posts'
+ text = text or item.get('location') or ''
+ return f'{rack}: {text}' if rack and text else text
+
+
def _sides(item: dict) -> Tuple[str, ...]:
mount = item.get('mount') or 'front'
return ('front', 'rear') if mount == 'full' else (mount,)
diff --git a/static/device.js b/static/device.js
index 865d97a..cb33683 100644
--- a/static/device.js
+++ b/static/device.js
@@ -1,5 +1,6 @@
'use strict';
-/* global DEVICE_NAME, CAN_EDIT, deviceUrl, refreshModem, _toIso, fmtRate, fmtErrors, renderPortInspector, selectPortByIdx, highlightSelectedPort, FACEPLATES */
+/* global DEVICE_NAME, CAN_EDIT, deviceUrl, refreshModem, _toIso, fmtRate, fmtErrors, renderPortInspector, selectPortByIdx, highlightSelectedPort, FACEPLATES,
+ RACK_FRONTS, SHELF_GEAR, rackFrontSvg, modemFront, apFront */
// Per-device page: overview, alerts, and a compact interface/port table. Host
// rows expand in place; switch and router rows open the port inspector panel.
@@ -241,6 +242,7 @@ function renderOverview(d) {
['IP', d.ip],
['MAC', d.mac],
['Model', d.model],
+ ['Location', d.hardware && d.hardware.location],
['Firmware', info.firmware],
['Uptime', info.uptime_s === undefined ? null : fmtUptime(info.uptime_s)],
['CPU', pct(info.cpu_pct)],
@@ -354,6 +356,51 @@ function updateInterfaceSection(rows, title, hasChassis) {
document.getElementById('device-error-count').textContent = rows.filter(rowHasProblem).length;
}
+// ── Hardware drawing, for devices without a live faceplate ──────────────
+// A server's front comes from its cutsheet item's Front drawing (the same picture the rack page
+// shows); the modem and the access point have drawings of their own. Each is shown at a size
+// that suits its real shape: a 19" front wide, a small board or an upright gateway narrow.
+function hardwareArt(d) {
+ const hw = d.hardware || {};
+ const ctx = { name: d.name, status: d.status, interfaces: hw.interfaces || [] };
+ const key = hw.chassis || '';
+ const wrap = (w, h, inner) => ``;
+ if (RACK_FRONTS[key]) {
+ const spec = RACK_FRONTS[key];
+ return { label: spec.label, w: spec.width, h: spec.height, max: 900, svg: rackFrontSvg(key, ctx) };
+ }
+ if (SHELF_GEAR[key]) {
+ const gear = SHELF_GEAR[key];
+ return { label: gear.label, specs: gear.specs, w: gear.width, h: gear.height, max: 560, side: 'Port side',
+ svg: wrap(gear.width, gear.height, gear.draw(ctx)) };
+ }
+ if (d.kind === 'modem') {
+ const art = modemFront(d);
+ return { label: d.model, w: art.w, h: art.h, max: 110, svg: wrap(art.w, art.h, art.svg) };
+ }
+ if (d.kind === 'ap') {
+ const art = apFront(d);
+ return { label: d.model, w: art.w, h: art.h, max: 220, side: 'From below', svg: wrap(art.w, art.h, art.svg) };
+ }
+ return null;
+}
+
+function hardwareHtml(d, art) {
+ const hw = d.hardware || {};
+ const where = hw.location
+ ? ` · ${esc(hw.location)}` : '';
+ return `
`;
+}
+
// ── Inventory (HomeBox) link ────────────────────────────────────────────
function inventoryActions(d) {
const inv = d.inventory || {};
@@ -436,10 +483,15 @@ function render(d) {
const hasPorts = !!(d.ports && Object.keys(d.ports).length);
// A device like a UPS has a faceplate worth showing but no ports to list
- const hasChassis = hasPorts || !!FACEPLATES[d.model];
+ const hasFaceplate = hasPorts || !!FACEPLATES[d.model];
+ const art = hasFaceplate ? null : hardwareArt(d);
+ const hasChassis = hasFaceplate || !!art;
document.getElementById('device-inspector').classList.toggle('has-chassis', hasChassis);
updateInterfaceSection(currentRows(), d.ports ? 'Ports' : 'Interfaces', hasChassis);
- if (hasChassis) renderPortInspector(d);
+ if (hasFaceplate) renderPortInspector(d);
+ else if (art) document.getElementById('device-chassis').innerHTML = hardwareHtml(d, art);
+ // A drawing has no ports to open, so the port panel takes no room beside it
+ document.getElementById('inspector-panel').style.display = hasFaceplate ? '' : 'none';
renderInterfaces();
if (d.kind === 'modem') refreshModem();
diff --git a/static/fronts.js b/static/fronts.js
index 545a285..1321c6f 100644
--- a/static/fronts.js
+++ b/static/fronts.js
@@ -1,5 +1,5 @@
'use strict';
-/* exported RACK_FRONTS, CHASSIS_FACEPLATES, rackFrontSvg, shelfSvg, SHELF_GEAR, DESK_FACEPLATES */
+/* exported RACK_FRONTS, CHASSIS_FACEPLATES, rackFrontSvg, shelfSvg, SHELF_GEAR, DESK_FACEPLATES, modemFront, apFront */
// Drawn fronts for rack gear Gandalf can't read a faceplate from: custom-built servers. Chosen per cutsheet item ("Front drawing"). Each one
// shows the device's live status on its power light when the item is linked to a device.
//
@@ -418,3 +418,36 @@ function shelfSvg(item, esc, faceplate) {
${esc(item.name)}
`;
}
+
+// ── Standalone gear (topology cards and device pages) ──────────────────
+// Each returns { w, h, svg } in its own units: the drawing's inner markup, no