refactor(devices): store hardware identity as hw_family / hw_revision
The firmware moved its NVS identity keys from hw_type / hw_version to
hw_family / hw_revision (NvsMigration.cpp), and the NVS generator, cloudflash
and the device models already used the new names. Firestore device docs and
the manufacturing code still wrote and read hw_type / hw_version, so the
device API's hw_family / hw_revision were always "" (0 of 14 docs had them)
and the console used two names for one value.
Device docs now use the firmware's names (schema v1.1.0, decision D2 in the
bellsystems-schema repo). The apps don't read these fields, so no app change.
- Manufacturing batch-create writes hw_family / hw_revision; the inventory
API exposes hw_family / hw_revision (filters: ?hw_family= / ?hw_families=).
Reads fall back to hw_type / hw_version so docs not yet migrated still work.
- devices/firestore_v1.py renames hw_type / hw_version on read and write and
rejects a hw_family that isn't a code (e.g. "Bell Plus"): when the console
generates NVS from it, the firmware builds its OTA URL from that value.
- Inventory, provisioning, onboarding and overview pages use the new names.
Unchanged on purpose: the firmware catalog and flash assets
(/api/firmware/{hw_type}/..., hw_type_override) — a separate store and the
URL devices call; same values, only the variable name differs. The public
cloudflash response keeps its hw_type field (public contract).
Data migration (rename + fix 3 display-label values) runs from the
bellsystems-schema repo AFTER this is deployed: the currently deployed
console still reads hw_type.
Verified: 118 backend tests pass; frontend builds; ESLint errors in
ProvisioningWizard.jsx (7) are pre-existing and unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -39,7 +39,8 @@ IP_KEYS = {"ipAddress", "gateway", "subnet", "dns1", "dns2"}
|
|||||||
|
|
||||||
# Misspelled key -> v1 key, per nested map. A value of None means "drop".
|
# Misspelled key -> v1 key, per nested map. A value of None means "drop".
|
||||||
LEGACY_KEYS: dict[str, dict[str, str | None]] = {
|
LEGACY_KEYS: dict[str, dict[str, str | None]] = {
|
||||||
"": {"users_list": None},
|
# hw_type / hw_version: pre-2026-11-08 names; the firmware NVS uses hw_family / hw_revision.
|
||||||
|
"": {"users_list": None, "hw_type": "hw_family", "hw_version": "hw_revision"},
|
||||||
"device_attributes": {"bellGuardSafetyOn": "bellguardSafetyOn"},
|
"device_attributes": {"bellGuardSafetyOn": "bellguardSafetyOn"},
|
||||||
"device_attributes.networkSettings": {"useStaticIP": "usesStaticIP"},
|
"device_attributes.networkSettings": {"useStaticIP": "usesStaticIP"},
|
||||||
}
|
}
|
||||||
@@ -51,6 +52,10 @@ _MELODY_ITEM_FORBIDDEN = {"information", "default_settings", "url"}
|
|||||||
# Still accepted on write so a browser tab opened before the deploy can't corrupt data.
|
# Still accepted on write so a browser tab opened before the deploy can't corrupt data.
|
||||||
_LEGACY_DISPLAY_FMT = "%d %B %Y at %H:%M:%S UTC%z"
|
_LEGACY_DISPLAY_FMT = "%d %B %Y at %H:%M:%S UTC%z"
|
||||||
|
|
||||||
|
# Board family code: a BoardType value ("vesper_plus") or a bespoke UID. Never a display
|
||||||
|
# label like "Bell Plus" — the firmware builds its OTA URL from this value.
|
||||||
|
_HW_FAMILY = re.compile(r"^[a-z0-9][a-z0-9_-]*$")
|
||||||
|
|
||||||
_IPV4 = re.compile(r"^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$")
|
_IPV4 = re.compile(r"^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$")
|
||||||
|
|
||||||
|
|
||||||
@@ -163,6 +168,10 @@ def to_firestore(data: dict, db=None) -> dict:
|
|||||||
if sn or did:
|
if sn or did:
|
||||||
out["serial_number"] = out["device_id"] = sn or did
|
out["serial_number"] = out["device_id"] = sn or did
|
||||||
|
|
||||||
|
fam = out.get("hw_family")
|
||||||
|
if fam not in (None, "") and not (isinstance(fam, str) and _HW_FAMILY.match(fam)):
|
||||||
|
raise ValidationError(f"hw_family: expected a board family code like \"vesper_plus\", got {fam!r}")
|
||||||
|
|
||||||
if "user_list" in out and db is not None:
|
if "user_list" in out and db is not None:
|
||||||
refs, seen = [], set()
|
refs, seen = [], set()
|
||||||
for e in out["user_list"] or []:
|
for e in out["user_list"] or []:
|
||||||
|
|||||||
@@ -89,8 +89,8 @@ class DeviceUserSummary(BaseModel):
|
|||||||
class DeviceInventoryItem(BaseModel):
|
class DeviceInventoryItem(BaseModel):
|
||||||
id: str
|
id: str
|
||||||
serial_number: str
|
serial_number: str
|
||||||
hw_type: str
|
hw_family: str # board family code (BoardType value or bespoke UID) = firmware NVS "hw_family"
|
||||||
hw_version: str
|
hw_revision: str # hardware revision, e.g. "1.0" = firmware NVS "hw_revision"
|
||||||
mfg_status: str
|
mfg_status: str
|
||||||
mfg_batch_id: Optional[str] = None
|
mfg_batch_id: Optional[str] = None
|
||||||
created_at: Optional[str] = None
|
created_at: Optional[str] = None
|
||||||
@@ -134,7 +134,7 @@ class CustomerSearchResult(BaseModel):
|
|||||||
|
|
||||||
class RecentActivityItem(BaseModel):
|
class RecentActivityItem(BaseModel):
|
||||||
serial_number: str
|
serial_number: str
|
||||||
hw_type: str
|
hw_family: str
|
||||||
mfg_status: str
|
mfg_status: str
|
||||||
owner: Optional[str] = None
|
owner: Optional[str] = None
|
||||||
updated_at: Optional[str] = None
|
updated_at: Optional[str] = None
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ async def create_batch(
|
|||||||
@router.get("/devices", response_model=DeviceInventoryListResponse)
|
@router.get("/devices", response_model=DeviceInventoryListResponse)
|
||||||
def list_devices(
|
def list_devices(
|
||||||
status: Optional[str] = Query(None),
|
status: Optional[str] = Query(None),
|
||||||
hw_type: Optional[str] = Query(None),
|
hw_family: Optional[str] = Query(None),
|
||||||
hw_types: Optional[list[str]] = Query(None, description="Multi-select board type filter — repeat param, e.g. ?hw_types=vesper&hw_types=chronos"),
|
hw_families: Optional[list[str]] = Query(None, description="Multi-select board family filter — repeat param, e.g. ?hw_families=vesper&hw_families=chronos"),
|
||||||
has_users: Optional[bool] = Query(None, description="Filter by whether the device has any app users assigned"),
|
has_users: Optional[bool] = Query(None, description="Filter by whether the device has any app users assigned"),
|
||||||
search: Optional[str] = Query(None),
|
search: Optional[str] = Query(None),
|
||||||
limit: int = Query(100, ge=1, le=500),
|
limit: int = Query(100, ge=1, le=500),
|
||||||
@@ -81,8 +81,8 @@ def list_devices(
|
|||||||
):
|
):
|
||||||
items = service.list_devices(
|
items = service.list_devices(
|
||||||
status=status,
|
status=status,
|
||||||
hw_type=hw_type,
|
hw_family=hw_family,
|
||||||
hw_types=hw_types,
|
hw_families=hw_families,
|
||||||
has_users=has_users,
|
has_users=has_users,
|
||||||
search=search,
|
search=search,
|
||||||
limit=limit,
|
limit=limit,
|
||||||
@@ -605,7 +605,7 @@ def download_bootloader(
|
|||||||
):
|
):
|
||||||
"""Return the bootloader.bin for this device's hw_type (flashed at 0x1000)."""
|
"""Return the bootloader.bin for this device's hw_type (flashed at 0x1000)."""
|
||||||
item = service.get_device_by_sn(sn)
|
item = service.get_device_by_sn(sn)
|
||||||
hw_type = hw_type_override or item.hw_type
|
hw_type = hw_type_override or item.hw_family
|
||||||
try:
|
try:
|
||||||
data = service.get_flash_asset(hw_type, "bootloader.bin")
|
data = service.get_flash_asset(hw_type, "bootloader.bin")
|
||||||
except NotFoundError as e:
|
except NotFoundError as e:
|
||||||
@@ -625,7 +625,7 @@ def download_partitions(
|
|||||||
):
|
):
|
||||||
"""Return the partitions.bin for this device's hw_type (flashed at 0x8000)."""
|
"""Return the partitions.bin for this device's hw_type (flashed at 0x8000)."""
|
||||||
item = service.get_device_by_sn(sn)
|
item = service.get_device_by_sn(sn)
|
||||||
hw_type = hw_type_override or item.hw_type
|
hw_type = hw_type_override or item.hw_family
|
||||||
try:
|
try:
|
||||||
data = service.get_flash_asset(hw_type, "partitions.bin")
|
data = service.get_flash_asset(hw_type, "partitions.bin")
|
||||||
except NotFoundError as e:
|
except NotFoundError as e:
|
||||||
|
|||||||
@@ -66,8 +66,9 @@ def _doc_to_inventory_item(doc, customer_names: dict | None = None, user_infos:
|
|||||||
return DeviceInventoryItem(
|
return DeviceInventoryItem(
|
||||||
id=doc.id,
|
id=doc.id,
|
||||||
serial_number=data.get("serial_number", ""),
|
serial_number=data.get("serial_number", ""),
|
||||||
hw_type=data.get("hw_type", ""),
|
# hw_type / hw_version: names used before 2026-11-08 (kept as read fallback)
|
||||||
hw_version=data.get("hw_version", ""),
|
hw_family=data.get("hw_family") or data.get("hw_type", ""),
|
||||||
|
hw_revision=data.get("hw_revision") or data.get("hw_version", ""),
|
||||||
mfg_status=data.get("mfg_status", "manufactured"),
|
mfg_status=data.get("mfg_status", "manufactured"),
|
||||||
mfg_batch_id=data.get("mfg_batch_id"),
|
mfg_batch_id=data.get("mfg_batch_id"),
|
||||||
created_at=created_str,
|
created_at=created_str,
|
||||||
@@ -136,8 +137,9 @@ def create_batch(data: BatchCreate) -> BatchResponse:
|
|||||||
"serial_number": sn,
|
"serial_number": sn,
|
||||||
"device_id": sn, # schema v1 / D1: both apps connect over MQTT with device_id
|
"device_id": sn, # schema v1 / D1: both apps connect over MQTT with device_id
|
||||||
|
|
||||||
"hw_type": data.board_type.value,
|
# Same names as the firmware NVS keys.
|
||||||
"hw_version": data.board_version,
|
"hw_family": data.board_type.value,
|
||||||
|
"hw_revision": data.board_version,
|
||||||
"mfg_status": "manufactured",
|
"mfg_status": "manufactured",
|
||||||
"mfg_batch_id": batch_id,
|
"mfg_batch_id": batch_id,
|
||||||
"created_at": now,
|
"created_at": now,
|
||||||
@@ -170,8 +172,8 @@ def create_batch(data: BatchCreate) -> BatchResponse:
|
|||||||
|
|
||||||
def list_devices(
|
def list_devices(
|
||||||
status: str | None = None,
|
status: str | None = None,
|
||||||
hw_type: str | None = None,
|
hw_family: str | None = None,
|
||||||
hw_types: list[str] | None = None,
|
hw_families: list[str] | None = None,
|
||||||
has_users: bool | None = None,
|
has_users: bool | None = None,
|
||||||
search: str | None = None,
|
search: str | None = None,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
@@ -182,15 +184,15 @@ def list_devices(
|
|||||||
|
|
||||||
if status:
|
if status:
|
||||||
query = query.where("mfg_status", "==", status)
|
query = query.where("mfg_status", "==", status)
|
||||||
if hw_type:
|
if hw_family:
|
||||||
query = query.where("hw_type", "==", hw_type)
|
query = query.where("hw_family", "==", hw_family)
|
||||||
|
|
||||||
docs = list(query.stream())
|
docs = list(query.stream())
|
||||||
docs_data = [doc.to_dict() or {} for doc in docs]
|
docs_data = [doc.to_dict() or {} for doc in docs]
|
||||||
|
|
||||||
if hw_types:
|
if hw_families:
|
||||||
hw_type_set = set(hw_types)
|
family_set = set(hw_families)
|
||||||
keep = [i for i, d in enumerate(docs_data) if d.get("hw_type") in hw_type_set]
|
keep = [i for i, d in enumerate(docs_data) if d.get("hw_family") in family_set]
|
||||||
docs = [docs[i] for i in keep]
|
docs = [docs[i] for i in keep]
|
||||||
docs_data = [docs_data[i] for i in keep]
|
docs_data = [docs_data[i] for i in keep]
|
||||||
|
|
||||||
@@ -274,8 +276,8 @@ def get_nvs_binary(sn: str, hw_type_override: str | None = None, hw_revision_ove
|
|||||||
item = get_device_by_sn(sn)
|
item = get_device_by_sn(sn)
|
||||||
return generate_nvs_binary(
|
return generate_nvs_binary(
|
||||||
serial_number=item.serial_number,
|
serial_number=item.serial_number,
|
||||||
hw_family=hw_type_override if hw_type_override else item.hw_type,
|
hw_family=hw_type_override if hw_type_override else item.hw_family,
|
||||||
hw_revision=hw_revision_override if hw_revision_override else item.hw_version,
|
hw_revision=hw_revision_override if hw_revision_override else item.hw_revision,
|
||||||
legacy=legacy,
|
legacy=legacy,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -333,7 +335,7 @@ def assign_device(sn: str, data: DeviceAssign) -> DeviceInventoryItem:
|
|||||||
for item in owned_items
|
for item in owned_items
|
||||||
)
|
)
|
||||||
if not already_assigned:
|
if not already_assigned:
|
||||||
device_name = doc_data.get("device_name") or BOARD_TYPE_LABELS.get(doc_data.get("hw_type", ""), sn)
|
device_name = doc_data.get("device_name") or BOARD_TYPE_LABELS.get(doc_data.get("hw_family") or doc_data.get("hw_type", ""), sn)
|
||||||
owned_items.append({
|
owned_items.append({
|
||||||
"type": "console_device",
|
"type": "console_device",
|
||||||
"console_device": {
|
"console_device": {
|
||||||
@@ -403,7 +405,7 @@ def get_stats() -> ManufacturingStats:
|
|||||||
|
|
||||||
activity_candidates.append(RecentActivityItem(
|
activity_candidates.append(RecentActivityItem(
|
||||||
serial_number=data.get("serial_number", ""),
|
serial_number=data.get("serial_number", ""),
|
||||||
hw_type=data.get("hw_type", ""),
|
hw_family=data.get("hw_family") or data.get("hw_type", ""),
|
||||||
mfg_status=status,
|
mfg_status=status,
|
||||||
owner=data.get("owner"),
|
owner=data.get("owner"),
|
||||||
updated_at=ts_str,
|
updated_at=ts_str,
|
||||||
@@ -563,7 +565,6 @@ def get_firmware_url(sn: str) -> str:
|
|||||||
"""Return the FastAPI download URL for the latest stable firmware for this device's hw_type."""
|
"""Return the FastAPI download URL for the latest stable firmware for this device's hw_type."""
|
||||||
from firmware.service import get_latest
|
from firmware.service import get_latest
|
||||||
item = get_device_by_sn(sn)
|
item = get_device_by_sn(sn)
|
||||||
hw_type = item.hw_type.lower()
|
latest = get_latest(item.hw_family.lower(), "stable")
|
||||||
latest = get_latest(hw_type, "stable")
|
|
||||||
# download_url is a relative path like /api/firmware/vs/stable/1.4.2/firmware.bin
|
# download_url is a relative path like /api/firmware/vs/stable/1.4.2/firmware.bin
|
||||||
return latest.download_url
|
return latest.download_url
|
||||||
|
|||||||
@@ -109,9 +109,9 @@ async def validate_serial(serial_number: str):
|
|||||||
device = get_device_by_sn(sn)
|
device = get_device_by_sn(sn)
|
||||||
return SerialValidationResult(
|
return SerialValidationResult(
|
||||||
valid=True,
|
valid=True,
|
||||||
hw_type=device.hw_type,
|
hw_type=device.hw_family,
|
||||||
hw_type_label=HW_TYPE_LABELS.get(device.hw_type, device.hw_type.replace("_", " ").title()),
|
hw_type_label=HW_TYPE_LABELS.get(device.hw_family, device.hw_family.replace("_", " ").title()),
|
||||||
hw_version=device.hw_version,
|
hw_version=device.hw_revision,
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
return SerialValidationResult(valid=False)
|
return SerialValidationResult(valid=False)
|
||||||
|
|||||||
@@ -104,6 +104,18 @@ def test_v1_key_wins_over_legacy_duplicate():
|
|||||||
assert attrs["networkSettings"] == {"usesStaticIP": True}
|
assert attrs["networkSettings"] == {"usesStaticIP": True}
|
||||||
|
|
||||||
|
|
||||||
|
def test_legacy_hw_names_become_firmware_names():
|
||||||
|
out = v1.to_firestore({"hw_type": "vesper_plus", "hw_version": "1.0"})
|
||||||
|
assert out == {"hw_family": "vesper_plus", "hw_revision": "1.0"}
|
||||||
|
assert v1.to_api({"hw_type": "agnus", "hw_version": "1.0"}) == {"hw_family": "agnus", "hw_revision": "1.0"}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("label", ["Bell Plus", "Bell Core", "vesper plus"])
|
||||||
|
def test_hw_family_display_labels_are_rejected(label):
|
||||||
|
with pytest.raises(ValidationError):
|
||||||
|
v1.to_firestore({"hw_family": label})
|
||||||
|
|
||||||
|
|
||||||
def test_retired_users_list_is_dropped():
|
def test_retired_users_list_is_dropped():
|
||||||
assert "users_list" not in v1.to_firestore({"users_list": [], "device_name": "x"})
|
assert "users_list" not in v1.to_firestore({"users_list": [], "device_name": "x"})
|
||||||
|
|
||||||
|
|||||||
@@ -250,8 +250,8 @@ const TABLE_COLUMNS = [
|
|||||||
render: (d) => friendlyName(d) || <span style={{ color: 'var(--color-text-muted)' }}>—</span>,
|
render: (d) => friendlyName(d) || <span style={{ color: 'var(--color-text-muted)' }}>—</span>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'hw_type', label: 'Board Type', sortable: true,
|
key: 'hw_family', label: 'Board Type', sortable: true,
|
||||||
render: (d) => d.hw_type || <span style={{ color: 'var(--color-text-muted)' }}>—</span>,
|
render: (d) => d.hw_family || <span style={{ color: 'var(--color-text-muted)' }}>—</span>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'mfg_status', label: 'Status',
|
key: 'mfg_status', label: 'Status',
|
||||||
@@ -301,14 +301,14 @@ function DevicePicker({ onSelect }) {
|
|||||||
}
|
}
|
||||||
if (boardTypes.length > 0) {
|
if (boardTypes.length > 0) {
|
||||||
const boardTypeSet = new Set(boardTypes)
|
const boardTypeSet = new Set(boardTypes)
|
||||||
list = list.filter((d) => boardTypeSet.has(d.hw_type))
|
list = list.filter((d) => boardTypeSet.has(d.hw_family))
|
||||||
}
|
}
|
||||||
const q = search.trim().toLowerCase()
|
const q = search.trim().toLowerCase()
|
||||||
if (q) {
|
if (q) {
|
||||||
list = list.filter((d) => {
|
list = list.filter((d) => {
|
||||||
if ((d.serial_number || '').toLowerCase().includes(q)) return true
|
if ((d.serial_number || '').toLowerCase().includes(q)) return true
|
||||||
if ((friendlyName(d) || '').toLowerCase().includes(q)) return true
|
if ((friendlyName(d) || '').toLowerCase().includes(q)) return true
|
||||||
if ((d.hw_type || '').toLowerCase().includes(q)) return true
|
if ((d.hw_family || '').toLowerCase().includes(q)) return true
|
||||||
if ((d.customer_name || '').toLowerCase().includes(q)) return true
|
if ((d.customer_name || '').toLowerCase().includes(q)) return true
|
||||||
if ((d.users || []).some((u) => (u.display_name || '').toLowerCase().includes(q) || (u.email || '').toLowerCase().includes(q))) return true
|
if ((d.users || []).some((u) => (u.display_name || '').toLowerCase().includes(q) || (u.email || '').toLowerCase().includes(q))) return true
|
||||||
return false
|
return false
|
||||||
@@ -640,7 +640,7 @@ const PlanStep = forwardRef(function PlanStep({ device, onDeviceUpdated }, ref)
|
|||||||
const startIso = startDateStr ? `${startDateStr}T00:00:00Z` : new Date().toISOString()
|
const startIso = startDateStr ? `${startDateStr}T00:00:00Z` : new Date().toISOString()
|
||||||
// PUT /devices/{id} returns the DeviceInDB shape, which doesn't line up
|
// PUT /devices/{id} returns the DeviceInDB shape, which doesn't line up
|
||||||
// field-for-field with the DeviceInventoryItem shape the rest of the wizard
|
// field-for-field with the DeviceInventoryItem shape the rest of the wizard
|
||||||
// uses (e.g. hw_type vs hw_family) — merge in just the two fields Configure
|
// uses — merge in just the two fields Configure
|
||||||
// actually needs rather than replacing the whole device object.
|
// actually needs rather than replacing the whole device object.
|
||||||
const updated = await api.put(`/devices/${device.id}`, {
|
const updated = await api.put(`/devices/${device.id}`, {
|
||||||
device_subscription: {
|
device_subscription: {
|
||||||
@@ -1975,7 +1975,7 @@ function DeviceWorkspace({ device, onDeviceUpdated, onDone, onChangeDevice }) {
|
|||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
title={device.serial_number}
|
title={device.serial_number}
|
||||||
subtitle={`${friendlyName(device) || device.hw_type || '—'} · ${device.mfg_status}`}
|
subtitle={`${friendlyName(device) || device.hw_family || '—'} · ${device.mfg_status}`}
|
||||||
action={<Button variant="ghost" size="sm" onClick={onChangeDevice}>Change Device</Button>}
|
action={<Button variant="ghost" size="sm" onClick={onChangeDevice}>Change Device</Button>}
|
||||||
>
|
>
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--space-6)' }}>
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--space-6)' }}>
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ export default function OverviewTab({
|
|||||||
api.get('/crm/products').catch(() => null),
|
api.get('/crm/products').catch(() => null),
|
||||||
]).then(([mfgItem, productsRes]) => {
|
]).then(([mfgItem, productsRes]) => {
|
||||||
if (mfgItem?.revision) setHwRevision(mfgItem.revision)
|
if (mfgItem?.revision) setHwRevision(mfgItem.revision)
|
||||||
const hwType = mfgItem?.hw_type || ''
|
const hwType = mfgItem?.hw_family || ''
|
||||||
if (!hwType) return
|
if (!hwType) return
|
||||||
const products = productsRes?.products || []
|
const products = productsRes?.products || []
|
||||||
const norm = s => (s || '').toLowerCase().replace(/[^a-z0-9]/g, '')
|
const norm = s => (s || '').toLowerCase().replace(/[^a-z0-9]/g, '')
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ export default function DeviceInventory() {
|
|||||||
const params = new URLSearchParams()
|
const params = new URLSearchParams()
|
||||||
if (search) params.set('search', search)
|
if (search) params.set('search', search)
|
||||||
if (statusFilter) params.set('status', statusFilter)
|
if (statusFilter) params.set('status', statusFilter)
|
||||||
if (typeFilter) params.set('hw_type', typeFilter)
|
if (typeFilter) params.set('hw_family', typeFilter)
|
||||||
params.set('limit', '500')
|
params.set('limit', '500')
|
||||||
const data = await api.get(`/manufacturing/devices${params.toString() ? `?${params}` : ''}`)
|
const data = await api.get(`/manufacturing/devices${params.toString() ? `?${params}` : ''}`)
|
||||||
const devs = data.devices || []
|
const devs = data.devices || []
|
||||||
@@ -198,8 +198,8 @@ export default function DeviceInventory() {
|
|||||||
if (!sortKey) return devices
|
if (!sortKey) return devices
|
||||||
return [...devices].sort((a, b) => {
|
return [...devices].sort((a, b) => {
|
||||||
let av, bv
|
let av, bv
|
||||||
if (sortKey === 'type') { av = BOARD_TYPE_LABELS[a.hw_type] || a.hw_type || ''; bv = BOARD_TYPE_LABELS[b.hw_type] || b.hw_type || '' }
|
if (sortKey === 'type') { av = BOARD_TYPE_LABELS[a.hw_family] || a.hw_family || ''; bv = BOARD_TYPE_LABELS[b.hw_family] || b.hw_family || '' }
|
||||||
else if (sortKey === 'version') { av = a.hw_version || ''; bv = b.hw_version || '' }
|
else if (sortKey === 'version') { av = a.hw_revision || ''; bv = b.hw_revision || '' }
|
||||||
else if (sortKey === 'created') { av = a.created_at || ''; bv = b.created_at || '' }
|
else if (sortKey === 'created') { av = a.created_at || ''; bv = b.created_at || '' }
|
||||||
else if (sortKey === 'customer') {
|
else if (sortKey === 'customer') {
|
||||||
const ca = customerMap[a.customer_id]; const cb = customerMap[b.customer_id]
|
const ca = customerMap[a.customer_id]; const cb = customerMap[b.customer_id]
|
||||||
@@ -268,7 +268,7 @@ export default function DeviceInventory() {
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
render: (d) => (
|
render: (d) => (
|
||||||
<span style={{ fontSize: 'var(--font-size-sm)', color: 'var(--color-text-secondary)' }}>
|
<span style={{ fontSize: 'var(--font-size-sm)', color: 'var(--color-text-secondary)' }}>
|
||||||
{BOARD_TYPE_LABELS[d.hw_type] || d.hw_type}
|
{BOARD_TYPE_LABELS[d.hw_family] || d.hw_family}
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -278,7 +278,7 @@ export default function DeviceInventory() {
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
render: (d) => (
|
render: (d) => (
|
||||||
<span style={{ fontSize: 'var(--font-size-sm)', fontFamily: 'var(--font-family-mono)', color: 'var(--color-text-muted)' }}>
|
<span style={{ fontSize: 'var(--font-size-sm)', fontFamily: 'var(--font-family-mono)', color: 'var(--color-text-muted)' }}>
|
||||||
{formatHwVersion(d.hw_version)}
|
{formatHwVersion(d.hw_revision)}
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -645,7 +645,7 @@ export default function DeviceInventoryDetail() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const boardLabel = BOARD_TYPE_LABELS[device.hw_type] || device.hw_type
|
const boardLabel = BOARD_TYPE_LABELS[device.hw_family] || device.hw_family
|
||||||
const existingUserIds = deviceUsers.map((u) => u.user_id).filter(Boolean)
|
const existingUserIds = deviceUsers.map((u) => u.user_id).filter(Boolean)
|
||||||
|
|
||||||
const editStepMeta = editModalData ? LIFECYCLE[editModalData.stepIndex] : null
|
const editStepMeta = editModalData ? LIFECYCLE[editModalData.stepIndex] : null
|
||||||
@@ -662,7 +662,7 @@ export default function DeviceInventoryDetail() {
|
|||||||
</StatusBadge>
|
</StatusBadge>
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
subtitle={`${device.name || device.device_name || '—'} · ${boardLabel} · ${formatHwVersion(device.hw_version)}`}
|
subtitle={`${device.name || device.device_name || '—'} · ${boardLabel} · ${formatHwVersion(device.hw_revision)}`}
|
||||||
>
|
>
|
||||||
{canEdit && (
|
{canEdit && (
|
||||||
<Button variant="secondary" size="md" onClick={() => navigate(`/manufacturing/provision?sn=${sn}`)}>
|
<Button variant="secondary" size="md" onClick={() => navigate(`/manufacturing/provision?sn=${sn}`)}>
|
||||||
@@ -687,7 +687,7 @@ export default function DeviceInventoryDetail() {
|
|||||||
<Field label="Serial Number" value={device.serial_number} mono />
|
<Field label="Serial Number" value={device.serial_number} mono />
|
||||||
<Field label="Batch ID" value={device.batch_id || device.mfg_batch_id} mono />
|
<Field label="Batch ID" value={device.batch_id || device.mfg_batch_id} mono />
|
||||||
<Field label="Hardware Family" value={boardLabel} />
|
<Field label="Hardware Family" value={boardLabel} />
|
||||||
<Field label="HW Version" value={formatHwVersion(device.hw_version)} mono />
|
<Field label="HW Version" value={formatHwVersion(device.hw_revision)} mono />
|
||||||
<Field label="Created At" value={formatDate(device.created_at)} />
|
<Field label="Created At" value={formatDate(device.created_at)} />
|
||||||
<Field label="Device Name" value={device.name || device.device_name} />
|
<Field label="Device Name" value={device.name || device.device_name} />
|
||||||
<div style={{ gridColumn: '1 / -1' }}>
|
<div style={{ gridColumn: '1 / -1' }}>
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ function BespokePickerModal({ open, onConfirm, onClose }) {
|
|||||||
Hardware Family for NVS
|
Hardware Family for NVS
|
||||||
</label>
|
</label>
|
||||||
<p style={{ fontSize: 'var(--font-size-xs)', color: 'var(--color-text-muted)', marginBottom: 'var(--space-2)' }}>
|
<p style={{ fontSize: 'var(--font-size-xs)', color: 'var(--color-text-muted)', marginBottom: 'var(--space-2)' }}>
|
||||||
Written to NVS as <span style={{ fontFamily: 'var(--font-family-mono)' }}>hw_type</span>.
|
Written to NVS as <span style={{ fontFamily: 'var(--font-family-mono)' }}>hw_family</span>.
|
||||||
</p>
|
</p>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
@@ -508,7 +508,7 @@ function StepSelectDevice({ mode, preloadSn, onSelected, onCreatedSn }) {
|
|||||||
|
|
||||||
// ── Selected confirmation panel ──
|
// ── Selected confirmation panel ──
|
||||||
if (picked) {
|
if (picked) {
|
||||||
const boardInfo = BOARD_TYPE_MAP[picked.hw_type]
|
const boardInfo = BOARD_TYPE_MAP[picked.hw_family]
|
||||||
const pal = BOARD_FAMILY_COLORS[boardInfo?.family || 'vesper']
|
const pal = BOARD_FAMILY_COLORS[boardInfo?.family || 'vesper']
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--space-4)' }}>
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--space-4)' }}>
|
||||||
@@ -516,8 +516,8 @@ function StepSelectDevice({ mode, preloadSn, onSelected, onCreatedSn }) {
|
|||||||
<p style={{ fontSize: 'var(--font-size-xs)', fontWeight: 'var(--font-weight-semibold)', color: pal.selectedText, textTransform: 'uppercase', letterSpacing: 'var(--tracking-wide)', marginBottom: 'var(--space-3)' }}>Device Selected</p>
|
<p style={{ fontSize: 'var(--font-size-xs)', fontWeight: 'var(--font-weight-semibold)', color: pal.selectedText, textTransform: 'uppercase', letterSpacing: 'var(--tracking-wide)', marginBottom: 'var(--space-3)' }}>Device Selected</p>
|
||||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 'var(--space-3)' }}>
|
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 'var(--space-3)' }}>
|
||||||
<InfoCell label="Serial Number" value={picked.serial_number} mono />
|
<InfoCell label="Serial Number" value={picked.serial_number} mono />
|
||||||
<InfoCell label="Board Type" value={BOARD_TYPE_LABELS[picked.hw_type] || picked.hw_type} />
|
<InfoCell label="Board Type" value={BOARD_TYPE_LABELS[picked.hw_family] || picked.hw_family} />
|
||||||
<InfoCell label="HW Revision" value={formatHwVersion(picked.hw_version)} />
|
<InfoCell label="HW Revision" value={formatHwVersion(picked.hw_revision)} />
|
||||||
<InfoCell label="Status" value={<StatusBadge variant={STATUS_VARIANT[picked.mfg_status] || 'neutral'}>{picked.mfg_status}</StatusBadge>} />
|
<InfoCell label="Status" value={<StatusBadge variant={STATUS_VARIANT[picked.mfg_status] || 'neutral'}>{picked.mfg_status}</StatusBadge>} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -660,8 +660,8 @@ function StepSelectDevice({ mode, preloadSn, onSelected, onCreatedSn }) {
|
|||||||
onMouseLeave={(e) => { e.currentTarget.style.backgroundColor = '' }}
|
onMouseLeave={(e) => { e.currentTarget.style.backgroundColor = '' }}
|
||||||
>
|
>
|
||||||
<td style={{ padding: 'var(--space-3)', fontFamily: 'var(--font-family-mono)', fontSize: 'var(--font-size-sm)', color: 'var(--color-text-primary)' }}>{d.serial_number}</td>
|
<td style={{ padding: 'var(--space-3)', fontFamily: 'var(--font-family-mono)', fontSize: 'var(--font-size-sm)', color: 'var(--color-text-primary)' }}>{d.serial_number}</td>
|
||||||
<td style={{ padding: 'var(--space-3)', fontSize: 'var(--font-size-sm)', color: 'var(--color-text-secondary)' }}>{BOARD_TYPE_LABELS[d.hw_type] || d.hw_type}</td>
|
<td style={{ padding: 'var(--space-3)', fontSize: 'var(--font-size-sm)', color: 'var(--color-text-secondary)' }}>{BOARD_TYPE_LABELS[d.hw_family] || d.hw_family}</td>
|
||||||
<td style={{ padding: 'var(--space-3)', fontFamily: 'var(--font-family-mono)', fontSize: 'var(--font-size-sm)', color: 'var(--color-text-muted)' }}>{formatHwVersion(d.hw_version)}</td>
|
<td style={{ padding: 'var(--space-3)', fontFamily: 'var(--font-family-mono)', fontSize: 'var(--font-size-sm)', color: 'var(--color-text-muted)' }}>{formatHwVersion(d.hw_revision)}</td>
|
||||||
<td style={{ padding: 'var(--space-3)' }}>
|
<td style={{ padding: 'var(--space-3)' }}>
|
||||||
<StatusBadge variant={STATUS_VARIANT[d.mfg_status] || 'neutral'}>{d.mfg_status}</StatusBadge>
|
<StatusBadge variant={STATUS_VARIANT[d.mfg_status] || 'neutral'}>{d.mfg_status}</StatusBadge>
|
||||||
</td>
|
</td>
|
||||||
@@ -888,7 +888,7 @@ function StepFlash({ device, bespokeOverride, onFlashed, serialConn }) {
|
|||||||
|
|
||||||
const webSerialAvailable = typeof navigator !== 'undefined' && 'serial' in navigator
|
const webSerialAvailable = typeof navigator !== 'undefined' && 'serial' in navigator
|
||||||
const busy = connecting || flashing
|
const busy = connecting || flashing
|
||||||
const boardInfo = BOARD_TYPE_MAP[device.hw_type]
|
const boardInfo = BOARD_TYPE_MAP[device.hw_family]
|
||||||
|
|
||||||
const familyPal = BOARD_FAMILY_COLORS[boardInfo?.family || 'vesper']
|
const familyPal = BOARD_FAMILY_COLORS[boardInfo?.family || 'vesper']
|
||||||
const readyToFlash = portConnected && !flashing && !done && log.length === 0
|
const readyToFlash = portConnected && !flashing && !done && log.length === 0
|
||||||
@@ -934,7 +934,7 @@ function StepFlash({ device, bespokeOverride, onFlashed, serialConn }) {
|
|||||||
{bespokeOverride ? (
|
{bespokeOverride ? (
|
||||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 'var(--space-3)' }}>
|
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 'var(--space-3)' }}>
|
||||||
<InfoCell label="Serial Number" value={device.serial_number} mono />
|
<InfoCell label="Serial Number" value={device.serial_number} mono />
|
||||||
<InfoCell label="NVS hw_type" value={bespokeOverride.hwFamily} />
|
<InfoCell label="NVS hw_family" value={bespokeOverride.hwFamily} />
|
||||||
<InfoCell label="NVS hw_revision" value="1.0" />
|
<InfoCell label="NVS hw_revision" value="1.0" />
|
||||||
<div>
|
<div>
|
||||||
<p style={{ fontSize: 'var(--font-size-xs)', color: 'var(--color-text-muted)', textTransform: 'uppercase', letterSpacing: 'var(--tracking-wide)', fontWeight: 'var(--font-weight-semibold)', marginBottom: 'var(--space-1)' }}>Firmware</p>
|
<p style={{ fontSize: 'var(--font-size-xs)', color: 'var(--color-text-muted)', textTransform: 'uppercase', letterSpacing: 'var(--tracking-wide)', fontWeight: 'var(--font-weight-semibold)', marginBottom: 'var(--space-1)' }}>Firmware</p>
|
||||||
@@ -956,7 +956,7 @@ function StepFlash({ device, bespokeOverride, onFlashed, serialConn }) {
|
|||||||
Board Type:
|
Board Type:
|
||||||
<span style={{ display: 'inline-block', width: 'var(--space-3)' }} />
|
<span style={{ display: 'inline-block', width: 'var(--space-3)' }} />
|
||||||
<span style={{ fontFamily: 'var(--font-family-mono)', fontSize: 'var(--font-size-md)', fontWeight: 'var(--font-weight-semibold)', color: 'var(--color-primary)' }}>
|
<span style={{ fontFamily: 'var(--font-family-mono)', fontSize: 'var(--font-size-md)', fontWeight: 'var(--font-weight-semibold)', color: 'var(--color-primary)' }}>
|
||||||
{boardInfo?.uiName || boardInfo?.name || device.hw_type}
|
{boardInfo?.uiName || boardInfo?.name || device.hw_family}
|
||||||
</span>
|
</span>
|
||||||
{boardInfo?.codename && (
|
{boardInfo?.codename && (
|
||||||
<span style={{ fontFamily: 'var(--font-family-mono)', color: 'var(--color-text-muted)', fontSize: 'var(--font-size-xs)', marginLeft: 'var(--space-2)' }}>| {boardInfo.codename}</span>
|
<span style={{ fontFamily: 'var(--font-family-mono)', color: 'var(--color-text-muted)', fontSize: 'var(--font-size-xs)', marginLeft: 'var(--space-2)' }}>| {boardInfo.codename}</span>
|
||||||
@@ -967,7 +967,7 @@ function StepFlash({ device, bespokeOverride, onFlashed, serialConn }) {
|
|||||||
Revision:
|
Revision:
|
||||||
<span style={{ display: 'inline-block', width: 'var(--space-3)' }} />
|
<span style={{ display: 'inline-block', width: 'var(--space-3)' }} />
|
||||||
<span style={{ fontFamily: 'var(--font-family-mono)', fontSize: 'var(--font-size-md)', fontWeight: 'var(--font-weight-semibold)', color: 'var(--color-primary)' }}>
|
<span style={{ fontFamily: 'var(--font-family-mono)', fontSize: 'var(--font-size-md)', fontWeight: 'var(--font-weight-semibold)', color: 'var(--color-primary)' }}>
|
||||||
{formatHwVersion(device.hw_version)}
|
{formatHwVersion(device.hw_revision)}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
</>
|
</>
|
||||||
@@ -1453,11 +1453,11 @@ function StepDone({ device, onProvisionNext, serialConn }) {
|
|||||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr' }}>
|
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr' }}>
|
||||||
<div style={{ padding: 'var(--space-4)', borderRight: '1px solid var(--color-border)' }}>
|
<div style={{ padding: 'var(--space-4)', borderRight: '1px solid var(--color-border)' }}>
|
||||||
<p style={{ fontSize: 'var(--font-size-xs)', color: 'var(--color-text-muted)', textTransform: 'uppercase', letterSpacing: 'var(--tracking-wide)', marginBottom: 'var(--space-1)' }}>Board Type</p>
|
<p style={{ fontSize: 'var(--font-size-xs)', color: 'var(--color-text-muted)', textTransform: 'uppercase', letterSpacing: 'var(--tracking-wide)', marginBottom: 'var(--space-1)' }}>Board Type</p>
|
||||||
<p style={{ fontSize: 'var(--font-size-sm)', color: 'var(--color-text-primary)' }}>{BOARD_TYPE_LABELS[device?.hw_type] || device?.hw_type}</p>
|
<p style={{ fontSize: 'var(--font-size-sm)', color: 'var(--color-text-primary)' }}>{BOARD_TYPE_LABELS[device?.hw_family] || device?.hw_family}</p>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ padding: 'var(--space-4)', display: 'flex', flexDirection: 'column', alignItems: 'flex-end' }}>
|
<div style={{ padding: 'var(--space-4)', display: 'flex', flexDirection: 'column', alignItems: 'flex-end' }}>
|
||||||
<p style={{ fontSize: 'var(--font-size-xs)', color: 'var(--color-text-muted)', textTransform: 'uppercase', letterSpacing: 'var(--tracking-wide)', marginBottom: 'var(--space-1)' }}>HW Version</p>
|
<p style={{ fontSize: 'var(--font-size-xs)', color: 'var(--color-text-muted)', textTransform: 'uppercase', letterSpacing: 'var(--tracking-wide)', marginBottom: 'var(--space-1)' }}>HW Version</p>
|
||||||
<p style={{ fontSize: 'var(--font-size-sm)', color: 'var(--color-text-primary)' }}>{formatHwVersion(device?.hw_version)}</p>
|
<p style={{ fontSize: 'var(--font-size-sm)', color: 'var(--color-text-primary)' }}>{formatHwVersion(device?.hw_revision)}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user