contract 0.18.0: one name per display role, the kiosk's own

Core called the roles dashboard / lobby / partskiosk. The kiosks call them
Dashboard / Lobby / 3DPrintRoom, which are the literal contents of
C:\Enrollment\display-type.txt, read by the GE-Enforce dispatcher to pick a
target. Two vocabularies for three kiosks, each with its own copy of the same
route map.

That is not cosmetic. A display reporting its own type sends what its file
says, so it could report a role core would not accept, and core could store
'partskiosk', a value no dispatcher would ever match. The enforcement report
column would have shown one vocabulary from the device and the other from the
DashboardDefault fallback, in the same column.

The machine's file wins, because that is what a person edits. DISPLAY_ROLE_PATHS
takes the kiosk spelling and the display scope now uses that dict rather than
holding a second one, so the two cannot drift again. normalize_display_role
resolves any casing and the retired 'partskiosk' forward; the dispatcher already
matched its map case-insensitively and the server now agrees with it.

Nothing is turned away over a capital: the API accepts any spelling and stores
the canonical one, displaypath resolves through the normalizer so rows written
before this keep working, and the settings dropdown canonicalises on open so an
old value does not render as a blank select.

A reported subtype is normalised on the way in, but an UNRECOGNISED one is kept
verbatim. That is a kiosk with a typo in its file or a role nobody declared, and
both are worth seeing in the fleet table rather than blanked or guessed at.

Contract bumped for the added names. DashboardDefault is finally listed in
__all__ too - 0.17.0 put it on the surface and never exported it.
This commit is contained in:
cproudlock
2026-08-13 09:28:26 -04:00
parent 9336577abe
commit 20a95013ad
12 changed files with 307 additions and 45 deletions

View File

@@ -77,10 +77,10 @@
<option v-for="r in roleOptions" :key="r.value" :value="r.value">{{ r.label }}</option>
</select>
</div>
<div class="form-group" v-if="form.displayrole === 'dashboard'">
<div class="form-group" v-if="form.displayrole === 'Dashboard'">
<label for="businessunitid">Location *</label>
<select id="businessunitid" v-model="form.businessunitid" class="form-control"
:required="form.displayrole === 'dashboard'">
:required="form.displayrole === 'Dashboard'">
<option value="">Select location...</option>
<option v-for="bu in businessUnits" :key="bu.businessunitid" :value="bu.businessunitid">
{{ bu.businessunit }}
@@ -127,13 +127,33 @@ import { useToast } from '../../composables/toast'
import { apiError } from '../../utils/apiError'
const toast = useToast()
// Values are the kiosk's own vocabulary - the literal contents of
// C:\Enrollment\display-type.txt - so what is picked here is what a display
// reports. Must stay in step with DISPLAY_ROLE_PATHS in
// shopdb/core/models/dashboarddefault.py.
const roleOptions = [
{ value: 'dashboard', label: 'Shopfloor Dashboard' },
{ value: 'lobby', label: 'Lobby Slideshow' },
{ value: 'partskiosk', label: '3D Parts Kiosk' },
{ value: 'Dashboard', label: 'Shopfloor Dashboard' },
{ value: 'Lobby', label: 'Lobby Slideshow' },
{ value: '3DPrintRoom', label: '3D Print Room Kiosk' },
]
// Rows written before the vocabularies merged still carry the old spelling, so
// match case-insensitively and fall back to the retired name.
const legacyRoleLabels = { partskiosk: '3D Print Room Kiosk' }
const legacyRoleValues = { partskiosk: '3DPrintRoom' }
// Canonical value for any stored spelling. Without this, opening a row saved
// before the merge puts a value in the select that matches no option, and the
// dropdown renders blank as if the row had no role.
function canonicalRole(value) {
const wanted = (value || '').toLowerCase()
return roleOptions.find(r => r.value.toLowerCase() === wanted)?.value
|| legacyRoleValues[wanted]
|| 'Dashboard'
}
function roleLabel(value) {
return roleOptions.find(r => r.value === value)?.label || value
const wanted = (value || '').toLowerCase()
return roleOptions.find(r => r.value.toLowerCase() === wanted)?.label
|| legacyRoleLabels[wanted]
|| value
}
const items = ref([])
@@ -149,7 +169,7 @@ const error = ref('')
const showDeleteModal = ref(false)
const toDelete = ref(null)
const form = ref({ fqdn: '', ipaddress: '', displayrole: 'dashboard', businessunitid: '', description: '' })
const form = ref({ fqdn: '', ipaddress: '', displayrole: 'Dashboard', businessunitid: '', description: '' })
onMounted(async () => {
try {
@@ -184,10 +204,10 @@ function openModal(item = null) {
form.value = item ? {
fqdn: item.fqdn || '',
ipaddress: item.ipaddress || '',
displayrole: item.displayrole || 'dashboard',
displayrole: canonicalRole(item.displayrole),
businessunitid: item.businessunitid || '',
description: item.description || ''
} : { fqdn: '', ipaddress: '', displayrole: 'dashboard', businessunitid: '', description: '' }
} : { fqdn: '', ipaddress: '', displayrole: 'Dashboard', businessunitid: '', description: '' }
error.value = ''
showModal.value = true
}