diff --git a/hyperglass/models/parsing/mikrotik.py b/hyperglass/models/parsing/mikrotik.py index 46d7b0c..cc48dcb 100644 --- a/hyperglass/models/parsing/mikrotik.py +++ b/hyperglass/models/parsing/mikrotik.py @@ -76,9 +76,9 @@ class MikrotikRouteEntry(MikrotikBase): return self.gateway @property - def age(self) -> str: - # MikroTik output does not provide route age, returning 0 as a placeholder. - return "0" + def age(self) -> int: + # MikroTik output does not provide route age, returning -1 to indicate unavailable. + return -1 @property def weight(self) -> int: @@ -102,6 +102,7 @@ class MikrotikRouteEntry(MikrotikBase): @property def source_rid(self) -> str: + # MikroTik output does not provide source RID, returning empty string. return "" @property diff --git a/hyperglass/ui/components/output/fields.tsx b/hyperglass/ui/components/output/fields.tsx index 58c9102..416c123 100644 --- a/hyperglass/ui/components/output/fields.tsx +++ b/hyperglass/ui/components/output/fields.tsx @@ -50,6 +50,16 @@ dayjs.extend(utcPlugin); export const MonoField = (props: MonoFieldProps): JSX.Element => { const { v, ...rest } = props; + + // Handle empty or undefined values + if (!v || (typeof v === 'string' && v.trim() === '')) { + return ( + + N/A + + ); + } + return ( {v} @@ -74,6 +84,18 @@ export const Active = (props: ActiveProps): JSX.Element => { export const Age = (props: AgeProps): JSX.Element => { const { inSeconds, ...rest } = props; + + // Handle case where age is not available (e.g., MikroTik) + if (inSeconds === -1) { + return ( + + + N/A + + + ); + } + const now = dayjs.utc(); const then = now.subtract(inSeconds, 'second'); return (