backups: show a kind's panels only when that asset has data
Some checks failed
CI / backend (push) Failing after 8s
CI / naming (push) Successful in 2s
CI / frontend (push) Successful in 9s
CI / migrations-mysql (push) Failing after 7s

Every machine was getting a Part Marker Configuration panel, and only two of
the 147 known machines are part markers. A kind applies to an asset TYPE, but
whether a given asset ever carries that kind of backup is a property of the
individual machine, so type alone cannot decide what to show.

The generic renderer already handled this: a list panel is visible when it has
rows OR declares empty text. Declaring emptytext on both kinds defeated it and
forced them to render everywhere. emptytext now defaults to None on the base
class, neither bundled kind sets one, and the panel builder OMITS the key
rather than emitting null - a present-but-null 'empty' would still have kept
the panel on screen.

The DNC Info card carried empty text that could never be displayed, since
keyvalue visibility is decided purely on field count. Removed rather than left
to mislead.

A lathe now shows DNC Info and NTLARS history; 0600 and 0614 additionally show
Part Marker once something collects for them; a machine with no NTLARS data
shows no backup panels at all. The emptytext mechanism stays available for a
kind that genuinely wants to say "expected here, nothing yet".
This commit is contained in:
cproudlock
2026-08-07 14:53:37 -04:00
parent 565611e3d0
commit efe2f7e6ca
3 changed files with 56 additions and 8 deletions

View File

@@ -59,8 +59,13 @@ class BackupKind:
displayname = None
storagebackend = 'shopdb'
assettypes = ['*']
# Human note shown on the panel when there is nothing yet.
emptytext = 'No backups on record.'
# Text shown when the kind has no revisions for an asset. None means the
# panel HIDES entirely instead (the generic list renderer shows a panel
# only when it has rows or declares empty text). Default to hiding: a kind
# applies to an asset TYPE, but whether a given asset ever has this kind of
# backup is a property of the individual machine. A part marker panel on
# every one of 144 machines is noise, not information.
emptytext = None
def parse(self, raw):
"""Opaque kinds return None; parseable kinds return the projection."""
@@ -118,7 +123,6 @@ class NtlarsKind(BackupKind):
displayname = 'NTLARS / DNC Settings'
storagebackend = 'shopdb'
assettypes = ['machine']
emptytext = 'No NTLARS settings captured yet.'
@staticmethod
def embeddedmachineno(projection):
@@ -176,8 +180,10 @@ class NtlarsKind(BackupKind):
'title': 'DNC Info',
'assettypes': ['machine'],
'endpoint': '/api/backups/asset/{assetid}/info?kind=ntlars',
# No 'empty' key: the keyvalue renderer decides visibility purely on
# field count and never displays empty text, so a machine with no
# NTLARS revision simply has no DNC Info card at all.
'render': 'keyvalue',
'empty': 'No NTLARS settings captured for this machine yet.',
# Above the history panels: this answers the question a tech
# arrives with, while history is for the rarer restore case.
'position': 38,
@@ -214,7 +220,6 @@ class PartMarkerKind(BackupKind):
displayname = 'Part Marker Configuration'
storagebackend = 'share'
assettypes = ['machine', 'measuring_tool']
emptytext = 'No part marker backups on record.'
def resolveassetid(self, payload):
from shopdb.api import db, Asset