1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

add cache text to ui

This commit is contained in:
checktheroads
2020-03-23 01:10:27 -07:00
parent ee55f84373
commit 6034735e23
2 changed files with 42 additions and 19 deletions

View File

@@ -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": ...,

View File

@@ -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 => (
<Text key={match} as="strong">
{match}
</Text>
));
return <Text>{keywords.length !== 0 ? errorFmt : message}</Text>;
let errorFmt;
try {
errorFmt = strReplace(message, pattern, match => (
<Text key={match} as="strong">
{match}
</Text>
));
} catch (err) {
errorFmt = <Text as="span">{message}</Text>;
}
return <Text as="span">{keywords.length !== 0 ? errorFmt : message}</Text>;
};
const AccordionHeaderWrapper = styled(Flex)`
@@ -160,8 +162,8 @@ const Result = React.forwardRef(
css={css({ WebkitOverflowScrolling: "touch" })}
>
<Flex direction="row" flexWrap="wrap">
<Flex direction="column" flex="1 0 auto">
{data && (
<Flex direction="column" flex="1 0 auto" maxW={error ? "100%" : null}>
{data && !error && (
<Box
fontFamily="mono"
mt={5}
@@ -188,10 +190,31 @@ const Result = React.forwardRef(
{error && (
<Alert rounded="lg" my={2} py={4} status={errorLevel}>
<FormattedError keywords={errorKw} message={errorMsg} />
{/* {errorMsg} */}
</Alert>
)}
</Flex>
</Flex>
{config.cache.show_text && (
<Flex direction="row" flexWrap="wrap">
<Flex
px={3}
mt={2}
justifyContent={[
"flex-start",
"flex-start",
"flex-end",
"flex-end"
]}
flex="1 0 auto"
>
<Text fontSize="xs" color="gray.500">
{config.web.text.cache}
</Text>
</Flex>
</Flex>
)}
</AccordionPanel>
</AccordionItem>
);