main was 16 days and 259 commits behind the line the product is actually built on, at contract 0.30.0 against 0.35.0, with no per-PC credential code at all. It was neither current nor curated - just stale. This brings it forward and, at the same time, makes it mean something: main is what a receiving site installs, and nothing else. WHAT IT CARRIES. Twelve plugins - backups, computers, endpoints, guides, knowledgebase, machines, network, notifications, printers, slides, tools, warranty - plus applications, which is manifest-less core and always ships. The only manifest dependency inside that set is endpoints on computers, and both are in it, so the closure is self-contained. WHAT IT DOES NOT. employees, geenforce, measuringtools, printedparts and usb stay on the site line. So do the Windows installer tree, the VM rehearsal helpers, the agent tooling config, one site's data loader, the internal audit and findings records, and the planner spreadsheet. 1,135 tracked files against 1,438. A REMOVAL THAT BREAKS THE APP IS NOT A REMOVAL, and two nearly shipped: deploy/site-profile-universal.json still named all seventeen plugins. It is the file docs/DEPLOY.md tells a site to provision from, so a fresh install would have failed at `flask plugin apply-profile` with PluginError - the first thing a receiving site does, broken by the branch meant to serve them. It now names the twelve that exist, and its comment says the two must agree. agent/ was never refreshed. Whoever populated this branch copied shopdb/, plugins/, frontend/ and tests/ from the site line and left the agent tree at its September state: 22 C# and PowerShell sources missing, including AgentCredentials, EnrollmentService, AgentHttpFactory and the fleet-alert client, plus one file the site line had deleted still present. The old tree is internally consistent, so it compiles, and nothing in CI builds it - every gate was green over a server that speaks enrollment and per-PC credentials to a bundled agent source that cannot. Resynced whole. DECISIONS THIS ENCODES, rather than defers: - The plugin-authoring lab builds printedparts, whose manifest depends on employees, so it could not stay. The lab remains on the site line and main ships no build-along tutorial. That is a real loss for an adopting developer and is recorded here rather than discovered later. - Recognition, Training and Recertification notifications are no longer seeded. Each splits one notification into a card per employee and renders a photo, which needs a plugin this branch does not bundle. Seeding them would offer an author a type that cannot resolve anybody. A site that installs employees gets them from that plugin's own seed. - Windows/IIS is documented as the legacy path throughout, and the README leads with Docker, because that is what a receiving site gets. The API description is regenerated for THIS branch - 347 paths and 483 operations, down from 415 and 573 - so the published contract describes what is here rather than what the site line serves. docs/CONFIG.md lost the two measuring-tool label keys the code no longer declares, which two lanes had decided opposite ways. Suite: 3124 passed, 6 skipped. Naming and style gates pass. The docs gates run rather than skip, and every index line count is derived from the file it names.
108 lines
5.0 KiB
Python
108 lines
5.0 KiB
Python
"""Dashboard default model: display-PC-IP -> display role (+ business unit).
|
|
|
|
A single "display" PC image resolves what it should show from its own IP: the
|
|
role (shopfloor dashboard, lobby slideshow, or 3D-parts kiosk) and, for the
|
|
dashboard role, which business unit. Powers the visitor-location + display-role
|
|
lookups the kiosks call at launch.
|
|
"""
|
|
|
|
from shopdb.extensions import db
|
|
from .base import BaseModel
|
|
|
|
# Display role -> the frontend kiosk path it maps to. THE one place a role is
|
|
# named, and the reason the names look like this: these are the literal values a
|
|
# person types into C:\Enrollment\display-type.txt on the display PC itself,
|
|
# which the launcher on that PC reads to pick a target. Two vocabularies used to
|
|
# exist - core said 'partskiosk' where the display said '3DPrintRoom' - so a
|
|
# display could report a role core could not store and core could store a role
|
|
# no display would ever match. The machine's own file wins, because that is what
|
|
# a person edits. The vocabulary is deliberately not trimmed to the pages this
|
|
# build happens to serve: a display reports what its file says, and core must be
|
|
# able to store that answer whether or not a plugin renders the page.
|
|
DISPLAY_ROLE_PATHS = {
|
|
'Dashboard': '/shopfloor',
|
|
'Lobby': '/tv',
|
|
'3DPrintRoom': '/parts-kiosk',
|
|
}
|
|
DISPLAY_ROLES = tuple(DISPLAY_ROLE_PATHS.keys())
|
|
|
|
# Retired spellings -> canonical. 'partskiosk' is what core called the 3D print
|
|
# room before the vocabularies were merged; rows and API callers still carry it.
|
|
LEGACY_DISPLAY_ROLES = {
|
|
'partskiosk': '3DPrintRoom',
|
|
}
|
|
|
|
|
|
def normalize_display_role(value):
|
|
"""Canonical role for any spelling, or None if it names no role.
|
|
|
|
Case-insensitive on purpose. The authoritative value is one line of a text
|
|
file edited by hand on the kiosk, so 'lobby', 'Lobby' and 'LOBBY' all arrive
|
|
in practice; the dispatcher already matches its own map case-insensitively
|
|
(-ieq) and this keeps the server agreeing with it. Retired spellings map
|
|
forward. Returns None rather than guessing, so an unrecognised value can be
|
|
stored verbatim and SEEN rather than silently rewritten to a wrong role.
|
|
"""
|
|
text = (value or '').strip()
|
|
if not text:
|
|
return None
|
|
lowered = text.lower()
|
|
for role in DISPLAY_ROLES:
|
|
if role.lower() == lowered:
|
|
return role
|
|
return LEGACY_DISPLAY_ROLES.get(lowered)
|
|
|
|
# GE device naming: a PC's DNS name is 'F' + its BIOS serial under the device
|
|
# domain, e.g. FABC1234.device.geaerospace.net. The domain is a setting so other # ADR-015-OK: GE Aerospace-wide domain, and only the DEFAULT of a documented setting every site can override.
|
|
# sites can point elsewhere; the collector already reports the serial, so the
|
|
# server derives the stable FQDN without the kiosk having to report it.
|
|
DEFAULT_DISPLAY_FQDN_DOMAIN = 'device.geaerospace.net' # ADR-015-OK: GE Aerospace-wide domain, and only the DEFAULT of a documented setting every site can override.
|
|
|
|
|
|
def derive_display_fqdn(serialnumber):
|
|
"""FQDN for a display PC from its BIOS serial: F<serial>.<domain> (lower).
|
|
|
|
Returns None when there is no serial. Domain from the display_fqdn_domain
|
|
setting, falling back to DEFAULT_DISPLAY_FQDN_DOMAIN.
|
|
"""
|
|
serial = (serialnumber or '').strip()
|
|
if not serial:
|
|
return None
|
|
from .setting import Setting
|
|
domain = (Setting.get('display_fqdn_domain', DEFAULT_DISPLAY_FQDN_DOMAIN)
|
|
or DEFAULT_DISPLAY_FQDN_DOMAIN).strip().strip('.')
|
|
return f'F{serial}.{domain}'.lower()
|
|
|
|
|
|
class DashboardDefault(BaseModel):
|
|
"""Maps a display PC (by FQDN, or IP) to its display role (+ location)."""
|
|
__tablename__ = 'dashboarddefaults'
|
|
|
|
dashboarddefaultid = db.Column(db.Integer, primary_key=True)
|
|
# A mapping is keyed by FQDN (stable, DHCP-proof) and/or IP. At least one is
|
|
# required (enforced in the API). FQDN is preferred; IP is the fallback for a
|
|
# manual entry or a PC not yet reporting a serial.
|
|
# 191 = the utf8mb4-safe unique-index length (191*4 < 767) so the index does
|
|
# not depend on innodb_large_prefix; FQDNs (F<serial>.<domain>) fit easily.
|
|
fqdn = db.Column(db.String(191), unique=True, nullable=True, index=True)
|
|
ipaddress = db.Column(db.String(50), unique=True, nullable=True)
|
|
# Which display the mapping drives. Only the Dashboard role uses businessunitid.
|
|
displayrole = db.Column(db.String(20), nullable=False, default='Dashboard')
|
|
businessunitid = db.Column(
|
|
db.Integer,
|
|
db.ForeignKey('businessunits.businessunitid'),
|
|
nullable=True
|
|
)
|
|
description = db.Column(db.String(255))
|
|
|
|
businessunit = db.relationship('BusinessUnit')
|
|
|
|
@property
|
|
def displaypath(self):
|
|
# Resolve through the normalizer so a legacy or oddly-cased stored value
|
|
# still finds its path instead of silently returning None.
|
|
return DISPLAY_ROLE_PATHS.get(normalize_display_role(self.displayrole))
|
|
|
|
def __repr__(self):
|
|
return f"<DashboardDefault {self.fqdn or self.ipaddress} -> {self.displayrole}>"
|