diff --git a/frontend/src/components/DashboardCards.vue b/frontend/src/components/DashboardCards.vue index 72c37ab..90ced35 100644 --- a/frontend/src/components/DashboardCards.vue +++ b/frontend/src/components/DashboardCards.vue @@ -22,7 +22,7 @@ diff --git a/frontend/src/components/dashboardCards.js b/frontend/src/components/dashboardCards.js index b4315c1..d35e5ed 100644 --- a/frontend/src/components/dashboardCards.js +++ b/frontend/src/components/dashboardCards.js @@ -127,7 +127,15 @@ export function mapHover(card, item) { const x = item[spec.x] const y = item[spec.y] if (x === null || x === undefined || y === null || y === undefined) return null - return { x, y, label: spec.label ? (item[spec.label] || '') : '' } + // The level travels with the coordinates (ADR-017) - they are pixels of ONE + // drawing. Read `levelid` unless the card names another field, so a card that + // predates levels still previews on the right floor instead of none. + const levelid = item[spec.level || 'levelid'] + return { + x, y, + levelid: levelid === undefined ? null : levelid, + label: spec.label ? (item[spec.label] || '') : '', + } } export function cardRows(card) { diff --git a/frontend/src/views/MapView.vue b/frontend/src/views/MapView.vue index 724204a..9e2b6ca 100644 --- a/frontend/src/views/MapView.vue +++ b/frontend/src/views/MapView.vue @@ -289,7 +289,12 @@ async function exportPdf() { try { await loadMapConfig() await exportMapPdf({ - assets: filteredAssets.value, + // Only this level's markers. The sheet is one drawing, so a marker + // positioned against another level would be printed on the wrong floor + // plan - the same failure the on-screen map had, in a form nobody can + // correct after it is printed and carried onto the floor. + assets: filteredAssets.value.filter( + asset => (asset.levelid ?? null) === shownLevelId.value), // blueprintUrlFor applies withBase - the raw setting value is a // root-relative /api path, which 404s under a subpath mount like /ops. // The PDF always uses the light blueprint: it prints on white paper. diff --git a/plugins/computers/frontend/views/PCDetail.vue b/plugins/computers/frontend/views/PCDetail.vue index ce28eaa..633aa2e 100644 --- a/plugins/computers/frontend/views/PCDetail.vue +++ b/plugins/computers/frontend/views/PCDetail.vue @@ -185,6 +185,7 @@ v-if="computer.mapx != null && computer.mapy != null" :left="computer.mapx" :top="computer.mapy" + :levelid="computer.levelid" :machineName="computer.assetnumber" > {{ computer.locationname || 'On Map' }} diff --git a/plugins/geenforce/api/routes.py b/plugins/geenforce/api/routes.py index 606ed33..4e69133 100644 --- a/plugins/geenforce/api/routes.py +++ b/plugins/geenforce/api/routes.py @@ -1223,6 +1223,9 @@ def list_reports(): 'location': known.get('location'), 'mapx': known.get('mapx'), 'mapy': known.get('mapy'), + # Coordinates are pixels of ONE level (ADR-017), so the level goes + # with them or the hover preview has nothing to draw on. + 'levelid': known.get('levelid'), 'machinenumber': known.get('machinenumber'), 'machineassetid': known.get('machineassetid'), 'machinepluginid': known.get('machinepluginid'), diff --git a/plugins/geenforce/frontend/views/EnforcementReports.vue b/plugins/geenforce/frontend/views/EnforcementReports.vue index a9ae87a..0fd4d3e 100644 --- a/plugins/geenforce/frontend/views/EnforcementReports.vue +++ b/plugins/geenforce/frontend/views/EnforcementReports.vue @@ -51,7 +51,7 @@ empty map would be worse than none. --> diff --git a/plugins/machines/frontend/views/MachineDetail.vue b/plugins/machines/frontend/views/MachineDetail.vue index f1e8b51..4e7810c 100644 --- a/plugins/machines/frontend/views/MachineDetail.vue +++ b/plugins/machines/frontend/views/MachineDetail.vue @@ -167,6 +167,7 @@ v-if="machine.mapx != null && machine.mapy != null" :left="machine.mapx" :top="machine.mapy" + :levelid="machine.levelid" :machineName="machine.assetnumber" > {{ machine.locationname || 'On Map' }} diff --git a/plugins/printers/api/asset_routes.py b/plugins/printers/api/asset_routes.py index abe0998..e84282c 100644 --- a/plugins/printers/api/asset_routes.py +++ b/plugins/printers/api/asset_routes.py @@ -1042,7 +1042,7 @@ def _get_low_supplies_data(): 'model': model_number, 'location': location_name, 'mapx': asset.mapx, - 'levelid': asset.levelid, + 'levelid': asset.levelid, 'mapy': asset.mapy, 'supplies': annotated }) @@ -1479,6 +1479,10 @@ def dashboard_supplies(): # card, it just has nothing to preview. 'mapx': printer.get('mapx'), 'mapy': printer.get('mapy'), + # The level those pixels belong to (ADR-017). Without it the hover + # preview cannot draw the marker and says so, which is what the + # dashboard card and the toner report were both doing. + 'levelid': printer.get('levelid'), 'iscritical': any(s['status'] == 'critical' for s in depleted), 'supplies': [{ 'text': '{} {}%'.format(_shortsupplyname(supply.get('name')), diff --git a/plugins/printers/frontend/views/PrinterDetail.vue b/plugins/printers/frontend/views/PrinterDetail.vue index b5c4229..a57b780 100644 --- a/plugins/printers/frontend/views/PrinterDetail.vue +++ b/plugins/printers/frontend/views/PrinterDetail.vue @@ -169,6 +169,7 @@ v-if="printer.mapx != null && printer.mapy != null" :left="printer.mapx" :top="printer.mapy" + :levelid="printer.levelid" :machineName="printer.name || printer.assetnumber" > View on Map diff --git a/plugins/printers/frontend/views/PrinterQRBatch.vue b/plugins/printers/frontend/views/PrinterQRBatch.vue index 2a09231..be2e6dc 100644 --- a/plugins/printers/frontend/views/PrinterQRBatch.vue +++ b/plugins/printers/frontend/views/PrinterQRBatch.vue @@ -43,14 +43,13 @@ :class="[`pos-${pos}`, page[pos - 1] ? 'filled' : 'empty']" >