Carry the level everywhere a position is drawn, and gate it per occurrence
The hover mini-map said "This asset has a position (2835, 1410) but no level" for every asset in the product. When 0.11.0 gave LocationMapTooltip a levelid prop, NONE of its seven call sites were taught to pass one - printer, machine and PC detail pages, the toner report, enforcement reports, the warranty chip and the dashboard cards - so the component correctly reported a missing level and the preview never drew. Two payloads behind those views also emitted mapx/mapy with no level: the toner report and the enforcement report. The map PDF export had the ORIGINAL bug still in it: it plotted every filtered asset onto the sheet, so exporting the ground floor printed second-floor markers on it. Worse than on screen, because nobody can correct a sheet once it has been printed and carried onto the floor. It now exports only the level being viewed. The legacy import loader sent mapleft/maptop with no level at three call sites. That loader is the one still to run against production, and every marker it created would have been undrawable. It now resolves the site's default level - the legacy schema predates levels and has one floor plan, so that is what its coordinates mean. THE GATE MISSED ALL OF THIS because it asked whether a FILE mentions 'levelid', not whether each position does: one module emitted 'mapx' six times and 'levelid' once and passed. It now checks per occurrence, covers scripts/ as well as shopdb/ and plugins/, and fails any Vue file that binds tooltip coordinates without :levelid. Both new rules were confirmed to fail the build against planted violations before being relied on. Printer QR labels: the asset number is no longer printed. A label now reads name (8201-HPLaserJetPro), QR, FQDN, then IP. The name falls back to the assetnumber because that is where sites actually keep it - every printer here has an empty name field, so preferring the Windows queue name alone would have printed a blank line on every label.
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
<!-- With coordinates, the name carries the same floor-plan preview
|
<!-- With coordinates, the name carries the same floor-plan preview
|
||||||
the asset's own page uses. Without them, a plain link. -->
|
the asset's own page uses. Without them, a plain link. -->
|
||||||
<LocationMapTooltip v-if="row.link && row.maphover"
|
<LocationMapTooltip v-if="row.link && row.maphover"
|
||||||
:left="row.maphover.x" :top="row.maphover.y"
|
:left="row.maphover.x" :top="row.maphover.y" :levelid="row.maphover.levelid"
|
||||||
:machineName="row.maphover.label">
|
:machineName="row.maphover.label">
|
||||||
<router-link :to="row.link" class="dc-row-title"
|
<router-link :to="row.link" class="dc-row-title"
|
||||||
:title="row.titletip || undefined">
|
:title="row.titletip || undefined">
|
||||||
|
|||||||
@@ -127,7 +127,15 @@ export function mapHover(card, item) {
|
|||||||
const x = item[spec.x]
|
const x = item[spec.x]
|
||||||
const y = item[spec.y]
|
const y = item[spec.y]
|
||||||
if (x === null || x === undefined || y === null || y === undefined) return null
|
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) {
|
export function cardRows(card) {
|
||||||
|
|||||||
@@ -289,7 +289,12 @@ async function exportPdf() {
|
|||||||
try {
|
try {
|
||||||
await loadMapConfig()
|
await loadMapConfig()
|
||||||
await exportMapPdf({
|
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
|
// blueprintUrlFor applies withBase - the raw setting value is a
|
||||||
// root-relative /api path, which 404s under a subpath mount like /ops.
|
// root-relative /api path, which 404s under a subpath mount like /ops.
|
||||||
// The PDF always uses the light blueprint: it prints on white paper.
|
// The PDF always uses the light blueprint: it prints on white paper.
|
||||||
|
|||||||
@@ -185,6 +185,7 @@
|
|||||||
v-if="computer.mapx != null && computer.mapy != null"
|
v-if="computer.mapx != null && computer.mapy != null"
|
||||||
:left="computer.mapx"
|
:left="computer.mapx"
|
||||||
:top="computer.mapy"
|
:top="computer.mapy"
|
||||||
|
:levelid="computer.levelid"
|
||||||
:machineName="computer.assetnumber"
|
:machineName="computer.assetnumber"
|
||||||
>
|
>
|
||||||
<span class="location-link">{{ computer.locationname || 'On Map' }}</span>
|
<span class="location-link">{{ computer.locationname || 'On Map' }}</span>
|
||||||
|
|||||||
@@ -1223,6 +1223,9 @@ def list_reports():
|
|||||||
'location': known.get('location'),
|
'location': known.get('location'),
|
||||||
'mapx': known.get('mapx'),
|
'mapx': known.get('mapx'),
|
||||||
'mapy': known.get('mapy'),
|
'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'),
|
'machinenumber': known.get('machinenumber'),
|
||||||
'machineassetid': known.get('machineassetid'),
|
'machineassetid': known.get('machineassetid'),
|
||||||
'machinepluginid': known.get('machinepluginid'),
|
'machinepluginid': known.get('machinepluginid'),
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
empty map would be worse than none. -->
|
empty map would be worse than none. -->
|
||||||
<LocationMapTooltip
|
<LocationMapTooltip
|
||||||
v-if="report.mapx != null && report.mapy != null"
|
v-if="report.mapx != null && report.mapy != null"
|
||||||
:left="report.mapx" :top="report.mapy"
|
:left="report.mapx" :top="report.mapy" :levelid="report.levelid"
|
||||||
:machineName="report.hostname"
|
:machineName="report.hostname"
|
||||||
>
|
>
|
||||||
<span class="map-pin" :title="report.location || 'On the floor plan'">◎</span>
|
<span class="map-pin" :title="report.location || 'On the floor plan'">◎</span>
|
||||||
|
|||||||
@@ -167,6 +167,7 @@
|
|||||||
v-if="machine.mapx != null && machine.mapy != null"
|
v-if="machine.mapx != null && machine.mapy != null"
|
||||||
:left="machine.mapx"
|
:left="machine.mapx"
|
||||||
:top="machine.mapy"
|
:top="machine.mapy"
|
||||||
|
:levelid="machine.levelid"
|
||||||
:machineName="machine.assetnumber"
|
:machineName="machine.assetnumber"
|
||||||
>
|
>
|
||||||
<span class="location-link">{{ machine.locationname || 'On Map' }}</span>
|
<span class="location-link">{{ machine.locationname || 'On Map' }}</span>
|
||||||
|
|||||||
@@ -1479,6 +1479,10 @@ def dashboard_supplies():
|
|||||||
# card, it just has nothing to preview.
|
# card, it just has nothing to preview.
|
||||||
'mapx': printer.get('mapx'),
|
'mapx': printer.get('mapx'),
|
||||||
'mapy': printer.get('mapy'),
|
'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),
|
'iscritical': any(s['status'] == 'critical' for s in depleted),
|
||||||
'supplies': [{
|
'supplies': [{
|
||||||
'text': '{} {}%'.format(_shortsupplyname(supply.get('name')),
|
'text': '{} {}%'.format(_shortsupplyname(supply.get('name')),
|
||||||
|
|||||||
@@ -169,6 +169,7 @@
|
|||||||
v-if="printer.mapx != null && printer.mapy != null"
|
v-if="printer.mapx != null && printer.mapy != null"
|
||||||
:left="printer.mapx"
|
:left="printer.mapx"
|
||||||
:top="printer.mapy"
|
:top="printer.mapy"
|
||||||
|
:levelid="printer.levelid"
|
||||||
:machineName="printer.name || printer.assetnumber"
|
:machineName="printer.name || printer.assetnumber"
|
||||||
>
|
>
|
||||||
<span class="location-link">View on Map</span>
|
<span class="location-link">View on Map</span>
|
||||||
|
|||||||
@@ -43,14 +43,13 @@
|
|||||||
:class="[`pos-${pos}`, page[pos - 1] ? 'filled' : 'empty']"
|
:class="[`pos-${pos}`, page[pos - 1] ? 'filled' : 'empty']"
|
||||||
>
|
>
|
||||||
<template v-if="page[pos - 1]">
|
<template v-if="page[pos - 1]">
|
||||||
<div class="model-name">{{ page[pos - 1].printer?.modelname || '' }}</div>
|
<div class="csf-name">{{ labelName(page[pos - 1]) }}</div>
|
||||||
<div class="qr-container">
|
<div class="qr-container">
|
||||||
<img v-if="qrImages[`${pageIdx}-${pos}`]" :src="qrImages[`${pageIdx}-${pos}`]" class="qr-img" alt="QR" />
|
<img v-if="qrImages[`${pageIdx}-${pos}`]" :src="qrImages[`${pageIdx}-${pos}`]" class="qr-img" alt="QR" />
|
||||||
</div>
|
</div>
|
||||||
<div class="info-section">
|
<div class="info-section">
|
||||||
<div class="csf-name">{{ page[pos - 1].assetnumber }}</div>
|
|
||||||
<div class="info-inner">
|
<div class="info-inner">
|
||||||
<div v-if="page[pos - 1].printer?.windowsname" class="info-row">{{ page[pos - 1].printer.windowsname }}</div>
|
<div v-if="fqdnFor(page[pos - 1])" class="info-row">{{ fqdnFor(page[pos - 1]) }}</div>
|
||||||
<div v-if="getIp(page[pos - 1])" class="info-row">{{ getIp(page[pos - 1]) }}</div>
|
<div v-if="getIp(page[pos - 1])" class="info-row">{{ getIp(page[pos - 1]) }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -67,6 +66,7 @@ import { ref, computed, onMounted, watch, nextTick } from 'vue'
|
|||||||
import { printersApi } from '@/api'
|
import { printersApi } from '@/api'
|
||||||
import { renderQrDataUrl } from '@/utils/codes'
|
import { renderQrDataUrl } from '@/utils/codes'
|
||||||
import { buildQrUrl } from '@/utils/qrTarget'
|
import { buildQrUrl } from '@/utils/qrTarget'
|
||||||
|
import { getPrinterHostnameTemplate } from '@/utils/siteSettings'
|
||||||
|
|
||||||
const printers = ref([])
|
const printers = ref([])
|
||||||
const selectedPrinters = ref([])
|
const selectedPrinters = ref([])
|
||||||
@@ -91,6 +91,7 @@ const pages = computed(() => {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
|
hostnameTemplate.value = await getPrinterHostnameTemplate()
|
||||||
// listAll: perpage is clamped to 100, and a batch sheet must cover every
|
// listAll: perpage is clamped to 100, and a batch sheet must cover every
|
||||||
// printer, not the first page of them.
|
// printer, not the first page of them.
|
||||||
printers.value = await printersApi.listAll()
|
printers.value = await printersApi.listAll()
|
||||||
@@ -129,6 +130,29 @@ async function generateQRCodes() {
|
|||||||
qrImages.value = next
|
qrImages.value = next
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The printer's FQDN. A stored hostname wins; otherwise the site builds one
|
||||||
|
// from the IP through the printer_hostname_template setting (ADR-015), which is
|
||||||
|
// how PrinterForm and the toner report derive it.
|
||||||
|
const hostnameTemplate = ref('')
|
||||||
|
|
||||||
|
function fqdnFor(item) {
|
||||||
|
const stored = item?.printer?.hostname
|
||||||
|
if (stored) return stored
|
||||||
|
const ip = getIp(item)
|
||||||
|
if (!ip || !hostnameTemplate.value) return ''
|
||||||
|
return hostnameTemplate.value.replace('{ip}', ip.replace(/\./g, '-'))
|
||||||
|
}
|
||||||
|
|
||||||
|
// What goes on the label's prominent top line: the printer's NAME, e.g.
|
||||||
|
// 8201-HPLaserJetPro. Sites keep that name in different places - the Windows
|
||||||
|
// queue name when one is set, otherwise the asset's name, and in practice most
|
||||||
|
// printers carry it as the assetnumber and nothing else, so that is the last
|
||||||
|
// fallback rather than a blank label. This is a name, not an identifier line:
|
||||||
|
// the label deliberately carries no separate "Asset #".
|
||||||
|
function labelName(item) {
|
||||||
|
return item?.printer?.windowsname || item?.name || item?.assetnumber || ''
|
||||||
|
}
|
||||||
|
|
||||||
function displayName(printer) {
|
function displayName(printer) {
|
||||||
return printer.assetnumber || printer.name || `Printer-${printer.assetid}`
|
return printer.assetnumber || printer.name || `Printer-${printer.assetid}`
|
||||||
}
|
}
|
||||||
@@ -286,7 +310,7 @@ function print() {
|
|||||||
.info-section { margin-top: 0.1in; display: flex; flex-direction: column; align-items: center; }
|
.info-section { margin-top: 0.1in; display: flex; flex-direction: column; align-items: center; }
|
||||||
.info-inner { text-align: left; }
|
.info-inner { text-align: left; }
|
||||||
.info-row { font-size: 9pt; color: #333; margin: 1px 0; white-space: nowrap; }
|
.info-row { font-size: 9pt; color: #333; margin: 1px 0; white-space: nowrap; }
|
||||||
.csf-name { font-size: 12pt; font-weight: bold; font-family: monospace; text-align: center; margin-bottom: 2px; color: #000; }
|
.csf-name { font-size: 12pt; font-weight: bold; font-family: monospace; text-align: center; margin-bottom: 0.06in; color: #000; }
|
||||||
.empty-label { color: #999; font-size: 14px; }
|
.empty-label { color: #999; font-size: 14px; }
|
||||||
|
|
||||||
@media print {
|
@media print {
|
||||||
|
|||||||
@@ -24,14 +24,13 @@
|
|||||||
:class="[`pos-${pos}`, pos === parseInt(position) ? 'active' : 'inactive']"
|
:class="[`pos-${pos}`, pos === parseInt(position) ? 'active' : 'inactive']"
|
||||||
>
|
>
|
||||||
<template v-if="pos === parseInt(position)">
|
<template v-if="pos === parseInt(position)">
|
||||||
<div class="model-name">{{ printer.printer?.modelname || '' }}</div>
|
<div class="csf-name">{{ labelName }}</div>
|
||||||
<div class="qr-container">
|
<div class="qr-container">
|
||||||
<img v-if="qrImage" :src="qrImage" class="qr-img" alt="QR" />
|
<img v-if="qrImage" :src="qrImage" class="qr-img" alt="QR" />
|
||||||
</div>
|
</div>
|
||||||
<div class="info-section">
|
<div class="info-section">
|
||||||
<div class="csf-name">{{ printer.assetnumber }}</div>
|
|
||||||
<div class="info-inner">
|
<div class="info-inner">
|
||||||
<div v-if="printer.printer?.windowsname" class="info-row">{{ printer.printer.windowsname }}</div>
|
<div v-if="fqdn" class="info-row">{{ fqdn }}</div>
|
||||||
<div v-if="ipAddress" class="info-row">{{ ipAddress }}</div>
|
<div v-if="ipAddress" class="info-row">{{ ipAddress }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -49,6 +48,7 @@ import { useRoute } from 'vue-router'
|
|||||||
import { printersApi } from '@/api'
|
import { printersApi } from '@/api'
|
||||||
import { renderQrDataUrl } from '@/utils/codes'
|
import { renderQrDataUrl } from '@/utils/codes'
|
||||||
import { buildQrUrl } from '@/utils/qrTarget'
|
import { buildQrUrl } from '@/utils/qrTarget'
|
||||||
|
import { getPrinterHostnameTemplate } from '@/utils/siteSettings'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
@@ -58,6 +58,18 @@ const position = ref('1')
|
|||||||
// in print output, images print every time.
|
// in print output, images print every time.
|
||||||
const qrImage = ref('')
|
const qrImage = ref('')
|
||||||
|
|
||||||
|
// What goes on the label's prominent top line: the printer's NAME, e.g.
|
||||||
|
// 8201-HPLaserJetPro. Sites keep that name in different places - the Windows
|
||||||
|
// queue name when one is set, otherwise the asset's name, and in practice most
|
||||||
|
// printers carry it as the assetnumber and nothing else, so that is the last
|
||||||
|
// fallback rather than a blank label. This is a name, not an identifier line:
|
||||||
|
// the label deliberately carries no separate "Asset #".
|
||||||
|
const labelName = computed(() =>
|
||||||
|
printer.value?.printer?.windowsname
|
||||||
|
|| printer.value?.name
|
||||||
|
|| printer.value?.assetnumber
|
||||||
|
|| '')
|
||||||
|
|
||||||
const ipAddress = computed(() => {
|
const ipAddress = computed(() => {
|
||||||
// Check direct ipaddress field first (from list API)
|
// Check direct ipaddress field first (from list API)
|
||||||
if (printer.value?.ipaddress && printer.value.ipaddress !== 'USB') return printer.value.ipaddress
|
if (printer.value?.ipaddress && printer.value.ipaddress !== 'USB') return printer.value.ipaddress
|
||||||
@@ -67,8 +79,21 @@ const ipAddress = computed(() => {
|
|||||||
return primary?.ipaddress || primary?.address || null
|
return primary?.ipaddress || primary?.address || null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// The printer's FQDN. A stored hostname wins; otherwise the site builds one from
|
||||||
|
// the IP through the printer_hostname_template setting (ADR-015), the same way
|
||||||
|
// PrinterForm and the toner report derive it.
|
||||||
|
const hostnameTemplate = ref('')
|
||||||
|
|
||||||
|
const fqdn = computed(() => {
|
||||||
|
const stored = printer.value?.printer?.hostname
|
||||||
|
if (stored) return stored
|
||||||
|
if (!ipAddress.value || !hostnameTemplate.value) return ''
|
||||||
|
return hostnameTemplate.value.replace('{ip}', ipAddress.value.replace(/\./g, '-'))
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
|
hostnameTemplate.value = await getPrinterHostnameTemplate()
|
||||||
const response = await printersApi.get(route.params.id)
|
const response = await printersApi.get(route.params.id)
|
||||||
printer.value = response.data.data
|
printer.value = response.data.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -169,7 +194,7 @@ function print() {
|
|||||||
.info-section { margin-top: 0.1in; display: flex; flex-direction: column; align-items: center; }
|
.info-section { margin-top: 0.1in; display: flex; flex-direction: column; align-items: center; }
|
||||||
.info-inner { text-align: left; }
|
.info-inner { text-align: left; }
|
||||||
.info-row { font-size: 9pt; color: #333; margin: 1px 0; white-space: nowrap; }
|
.info-row { font-size: 9pt; color: #333; margin: 1px 0; white-space: nowrap; }
|
||||||
.csf-name { font-size: 12pt; font-weight: bold; font-family: monospace; text-align: center; margin-bottom: 2px; color: #000; }
|
.csf-name { font-size: 12pt; font-weight: bold; font-family: monospace; text-align: center; margin-bottom: 0.06in; color: #000; }
|
||||||
|
|
||||||
@media print {
|
@media print {
|
||||||
/* Force rendered images/colors to print even when "Background graphics" is
|
/* Force rendered images/colors to print even when "Background graphics" is
|
||||||
|
|||||||
@@ -66,6 +66,7 @@
|
|||||||
v-if="printer.mapx != null && printer.mapy != null"
|
v-if="printer.mapx != null && printer.mapy != null"
|
||||||
:left="printer.mapx"
|
:left="printer.mapx"
|
||||||
:top="printer.mapy"
|
:top="printer.mapy"
|
||||||
|
:levelid="printer.levelid"
|
||||||
:machineName="printer.printername || printer.assetnumber"
|
:machineName="printer.printername || printer.assetnumber"
|
||||||
>
|
>
|
||||||
<router-link :to="`/printers/${printer.printerid}`">
|
<router-link :to="`/printers/${printer.printerid}`">
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
v-if="machine && hasPosition"
|
v-if="machine && hasPosition"
|
||||||
:left="machine.mapx"
|
:left="machine.mapx"
|
||||||
:top="machine.mapy"
|
:top="machine.mapy"
|
||||||
|
:levelid="machine.levelid"
|
||||||
:machineName="machine.machinenumber || machine.name || ''"
|
:machineName="machine.machinenumber || machine.name || ''"
|
||||||
>
|
>
|
||||||
<span class="mmc-chip" :title="hoverTitle">
|
<span class="mmc-chip" :title="hoverTitle">
|
||||||
|
|||||||
@@ -169,21 +169,44 @@ fi
|
|||||||
# whether all of them travel with their level, because reading them by eye is
|
# whether all of them travel with their level, because reading them by eye is
|
||||||
# how the twentieth gets missed.
|
# how the twentieth gets missed.
|
||||||
echo "==> Checking that emitted map positions carry their level (ADR-017)..."
|
echo "==> Checking that emitted map positions carry their level (ADR-017)..."
|
||||||
POSITION_FILES=$(grep -rln "'mapx':" --include='*.py' shopdb/ plugins/ 2>/dev/null \
|
# PER OCCURRENCE, not per file. The file-level form passed a module that emitted
|
||||||
| grep -v '/tests\?/' || true)
|
# 'mapx' six times and 'levelid' once, and two payloads shipped without a level:
|
||||||
|
# the toner report and the enforcement report, both feeding a hover preview that
|
||||||
|
# then said "no level". Every 'mapx' must have a 'levelid' in the same literal -
|
||||||
|
# the window is wide enough for a comment between them, and no wider.
|
||||||
MISSING_LEVEL=""
|
MISSING_LEVEL=""
|
||||||
for candidate in $POSITION_FILES; do
|
while IFS= read -r hit; do
|
||||||
if ! grep -q "'levelid'" "$candidate"; then
|
[ -z "$hit" ] && continue
|
||||||
MISSING_LEVEL="$MISSING_LEVEL$candidate"$'\n'
|
file=${hit%%:*}
|
||||||
|
line=${hit#*:}; line=${line%%:*}
|
||||||
|
if ! sed -n "${line},$((line + 8))p" "$file" | grep -q "'levelid'"; then
|
||||||
|
MISSING_LEVEL="$MISSING_LEVEL$file:$line"$'\n'
|
||||||
fi
|
fi
|
||||||
done
|
done <<EOF
|
||||||
|
$(grep -rn "'mapx':" --include='*.py' shopdb/ plugins/ scripts/ 2>/dev/null | grep -v '/tests\?/' || true)
|
||||||
|
EOF
|
||||||
if [ -n "$MISSING_LEVEL" ]; then
|
if [ -n "$MISSING_LEVEL" ]; then
|
||||||
echo "FAIL: these emit 'mapx' but never 'levelid' - a position with no level"
|
echo "FAIL: these emit 'mapx' with no 'levelid' beside it - a position with no"
|
||||||
echo " cannot be rendered on the right drawing:"
|
echo " level cannot be drawn on the right floor plan (ADR-017):"
|
||||||
echo "$MISSING_LEVEL" | sed 's/^/ /'
|
echo "$MISSING_LEVEL" | sed 's/^/ /'
|
||||||
VIOLATIONS=$((VIOLATIONS + 1))
|
VIOLATIONS=$((VIOLATIONS + 1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# The same rule for the hover preview: binding coordinates into
|
||||||
|
# LocationMapTooltip without a level makes it report "no level" for every asset,
|
||||||
|
# which is exactly what shipped in 0.11.0 - all seven call sites missed it.
|
||||||
|
TOOLTIP_MISSING=""
|
||||||
|
for candidate in $(grep -rl "LocationMapTooltip" --include='*.vue' frontend/src plugins/ 2>/dev/null | grep -v plugins-staged || true); do
|
||||||
|
grep -q ':left=' "$candidate" || continue
|
||||||
|
grep -q ':levelid=' "$candidate" || TOOLTIP_MISSING="$TOOLTIP_MISSING$candidate"$'\n'
|
||||||
|
done
|
||||||
|
if [ -n "$TOOLTIP_MISSING" ]; then
|
||||||
|
echo "FAIL: these bind LocationMapTooltip coordinates without :levelid, so the"
|
||||||
|
echo " preview cannot know which drawing to use (ADR-017):"
|
||||||
|
echo "$TOOLTIP_MISSING" | sed 's/^/ /'
|
||||||
|
VIOLATIONS=$((VIOLATIONS + 1))
|
||||||
|
fi
|
||||||
|
|
||||||
# ENFORCING. It was report-only while the backlog was worked off, and the hit
|
# ENFORCING. It was report-only while the backlog was worked off, and the hit
|
||||||
# count then did not move for weeks - a rule that only prints is read as no rule.
|
# count then did not move for weeks - a rule that only prints is read as no rule.
|
||||||
# Set SITE_LITERALS_ENFORCE=0 to drop back to reporting for a local run.
|
# Set SITE_LITERALS_ENFORCE=0 to drop back to reporting for a local run.
|
||||||
|
|||||||
@@ -100,6 +100,22 @@ class Harness:
|
|||||||
self.ids = IdMap(idmap_path or default)
|
self.ids = IdMap(idmap_path or default)
|
||||||
self.source = Source()
|
self.source = Source()
|
||||||
self.errors = []
|
self.errors = []
|
||||||
|
self._defaultlevelid = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def defaultlevelid(self):
|
||||||
|
"""The level imported map positions belong to (ADR-017).
|
||||||
|
|
||||||
|
The legacy schema predates levels: it has ONE floor plan, so every
|
||||||
|
mapleft/maptop it carries is a coordinate on this site's default level.
|
||||||
|
Importing them without a level produces markers the map refuses to draw
|
||||||
|
- it will not guess a drawing for coordinates that do not name one.
|
||||||
|
"""
|
||||||
|
if self._defaultlevelid is None:
|
||||||
|
from shopdb.core.models import MapLevel
|
||||||
|
level = MapLevel.default_level()
|
||||||
|
self._defaultlevelid = level.levelid if level else None
|
||||||
|
return self._defaultlevelid
|
||||||
|
|
||||||
def _silence_sql_logging(self):
|
def _silence_sql_logging(self):
|
||||||
import logging
|
import logging
|
||||||
|
|||||||
@@ -287,6 +287,7 @@ def stage_assets(h):
|
|||||||
'serialnumber': (m['serialnumber'] or '').strip() or None,
|
'serialnumber': (m['serialnumber'] or '').strip() or None,
|
||||||
'businessunitid': h.ids.get('businessunit', m['businessunitid']),
|
'businessunitid': h.ids.get('businessunit', m['businessunitid']),
|
||||||
'mapx': m['mapleft'], 'mapy': m['maptop'],
|
'mapx': m['mapleft'], 'mapy': m['maptop'],
|
||||||
|
'levelid': h.defaultlevelid,
|
||||||
'notes': m['machinenotes'],
|
'notes': m['machinenotes'],
|
||||||
'dateadded': str(m['dateadded']) if m['dateadded'] else None,
|
'dateadded': str(m['dateadded']) if m['dateadded'] else None,
|
||||||
'modifieddate': str(m['lastupdated']) if m['lastupdated'] else None,
|
'modifieddate': str(m['lastupdated']) if m['lastupdated'] else None,
|
||||||
@@ -345,6 +346,7 @@ def stage_printers(h):
|
|||||||
'iscsf': _truthy_bit(p['iscsf']),
|
'iscsf': _truthy_bit(p['iscsf']),
|
||||||
'installpath': p['installpath'], 'pin': p['printerpin'],
|
'installpath': p['installpath'], 'pin': p['printerpin'],
|
||||||
'notes': p['printernotes'], 'mapx': p['mapleft'], 'mapy': p['maptop'],
|
'notes': p['printernotes'], 'mapx': p['mapleft'], 'mapy': p['maptop'],
|
||||||
|
'levelid': h.defaultlevelid,
|
||||||
'modelnumberid': h.ids.get('model', p['modelid']),
|
'modelnumberid': h.ids.get('model', p['modelid']),
|
||||||
'locationid': h.ids.get('location', p['machineid']),
|
'locationid': h.ids.get('location', p['machineid']),
|
||||||
}
|
}
|
||||||
@@ -386,7 +388,8 @@ def stage_metrology(h):
|
|||||||
'name': (f"{pcname} {toolname}").strip() or toolname,
|
'name': (f"{pcname} {toolname}").strip() or toolname,
|
||||||
'measuringtooltypeid': typeid,
|
'measuringtooltypeid': typeid,
|
||||||
'businessunitid': h.ids.get('businessunit', m['businessunitid']),
|
'businessunitid': h.ids.get('businessunit', m['businessunitid']),
|
||||||
'mapx': m['mapleft'], 'mapy': m['maptop']})
|
'mapx': m['mapleft'], 'mapy': m['maptop'],
|
||||||
|
'levelid': h.defaultlevelid})
|
||||||
if status not in (200, 201):
|
if status not in (200, 201):
|
||||||
continue
|
continue
|
||||||
tool_assetid = _id_of(data, 'assetid')
|
tool_assetid = _id_of(data, 'assetid')
|
||||||
|
|||||||
Reference in New Issue
Block a user