mirror of
https://github.com/thatmattlove/hyperglass.git
synced 2026-05-07 12:43:05 +00:00
fix: Improve handling of missing data fields in MikroTik BGP parser
- Update MikroTik parser to return -1 for unavailable age data instead of "0" - Change age property return type from string to int for consistency - Enhance frontend Age component to display "N/A" when age is -1 - Improve MonoField component to handle empty/undefined values gracefully - Add appropriate tooltips and styling for missing data indicators This addresses the issue where MikroTik devices don't provide route age and source RID information, ensuring the UI displays user-friendly indicators instead of potentially misleading placeholder values.
This commit is contained in:
parent
b2a05994aa
commit
7a6388bd39
2 changed files with 26 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<Text as="span" fontSize="sm" fontFamily="mono" color="gray.500" {...rest}>
|
||||
N/A
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Text as="span" fontSize="sm" fontFamily="mono" {...rest}>
|
||||
{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 (
|
||||
<Tooltip hasArrow label="Age information not available" placement="right">
|
||||
<Text fontSize="sm" color="gray.500" {...rest}>
|
||||
N/A
|
||||
</Text>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
const now = dayjs.utc();
|
||||
const then = now.subtract(inSeconds, 'second');
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue