diff --git a/hyperglass/configuration/__init__.py b/hyperglass/configuration/__init__.py index 03ec32b..b606801 100644 --- a/hyperglass/configuration/__init__.py +++ b/hyperglass/configuration/__init__.py @@ -193,12 +193,11 @@ except ValidationError as validation_errors: error_msg=error["msg"], ) -""" -Perform post-config initialization string formatting or other -functions that require access to other config levels. E.g., -something in 'params.web.text' needs to be formatted with a value -from params. -""" + +# Perform post-config initialization string formatting or other +# functions that require access to other config levels. E.g., +# something in 'params.web.text' needs to be formatted with a value +# from params. try: params.web.text.subtitle = params.web.text.subtitle.format( **params.dict(exclude={"web", "queries", "messages"}) @@ -418,13 +417,14 @@ content_terms = aiorun( config_path=params.web.terms, default=DEFAULT_TERMS, params=content_terms_params ) ) -content_credit = CREDIT +content_credit = CREDIT.format(version=__version__) vrfs = _build_vrfs() networks = _build_networks() frontend_networks = _build_frontend_networks() frontend_devices = _build_frontend_devices() _frontend_fields = { + "cache": {"show_text"}, "debug": ..., "developer_mode": ..., "primary_asn": ..., diff --git a/hyperglass/ui/components/Result.js b/hyperglass/ui/components/Result.js index 4985909..1e5f2c7 100644 --- a/hyperglass/ui/components/Result.js +++ b/hyperglass/ui/components/Result.js @@ -22,17 +22,19 @@ import ResultHeader from "~/components/ResultHeader"; import { startCase } from "lodash"; const FormattedError = ({ keywords, message }) => { - if (keywords === null || keywords === undefined) { - keywords = []; - } - const patternStr = `(${keywords.join("|")})`; + const patternStr = keywords.map(kw => `(${kw})`).join("|"); const pattern = new RegExp(patternStr, "gi"); - const errorFmt = strReplace(message, pattern, match => ( - - {match} - - )); - return {keywords.length !== 0 ? errorFmt : message}; + let errorFmt; + try { + errorFmt = strReplace(message, pattern, match => ( + + {match} + + )); + } catch (err) { + errorFmt = {message}; + } + return {keywords.length !== 0 ? errorFmt : message}; }; const AccordionHeaderWrapper = styled(Flex)` @@ -160,8 +162,8 @@ const Result = React.forwardRef( css={css({ WebkitOverflowScrolling: "touch" })} > - - {data && ( + + {data && !error && ( + {/* {errorMsg} */} )} + + {config.cache.show_text && ( + + + + {config.web.text.cache} + + + + )} );