forked from mirrors/thatmattlove-hyperglass
fix text output empty bug
This commit is contained in:
parent
0c0bdc7f9b
commit
f0028a3df6
6 changed files with 48 additions and 39 deletions
|
|
@ -69,6 +69,8 @@ async def execute(query: "Query") -> Union["OutputDataModel", str]:
|
|||
|
||||
output = await driver.response(response)
|
||||
|
||||
log.debug("Response for {!r}\n{response}", query, response=response)
|
||||
|
||||
if is_series(output):
|
||||
if len(output) == 0:
|
||||
raise ResponseEmpty(query=query)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React, { memo } from 'react';
|
||||
import { Badge, Tooltip, useStyleConfig } from '@chakra-ui/react';
|
||||
import React, { memo } from 'react';
|
||||
import isEqual from 'react-fast-compare';
|
||||
import replace from 'react-string-replace';
|
||||
|
||||
|
|
@ -29,20 +29,24 @@ const Highlight = (props: HighlightProps): JSX.Element => {
|
|||
|
||||
const _Highlighted = (props: HighlightedProps): JSX.Element => {
|
||||
const { patterns, children } = props;
|
||||
let result: React.ReactNodeArray = [];
|
||||
let result: React.ReactNode[] = [];
|
||||
let times: number = 0;
|
||||
|
||||
for (const config of patterns) {
|
||||
let toReplace: string | React.ReactNodeArray = children;
|
||||
if (times !== 0) {
|
||||
toReplace = result;
|
||||
if (patterns.length === 0) {
|
||||
result = [children];
|
||||
} else {
|
||||
for (const config of patterns) {
|
||||
let toReplace: string | React.ReactNode[] = children;
|
||||
if (times !== 0) {
|
||||
toReplace = result;
|
||||
}
|
||||
result = replace(toReplace, new RegExp(`(${config.pattern})`, 'gm'), (m, i) => (
|
||||
<Highlight key={`${m + i}`} label={config.label} colorScheme={config.color}>
|
||||
{m}
|
||||
</Highlight>
|
||||
));
|
||||
times++;
|
||||
}
|
||||
result = replace(toReplace, new RegExp(`(${config.pattern})`, 'gm'), (m, i) => (
|
||||
<Highlight key={`${m + i}`} label={config.label} colorScheme={config.color}>
|
||||
{m}
|
||||
</Highlight>
|
||||
));
|
||||
times++;
|
||||
}
|
||||
|
||||
return <>{result}</>;
|
||||
|
|
|
|||
|
|
@ -1,39 +1,39 @@
|
|||
import { forwardRef, memo, useEffect, useMemo } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Flex,
|
||||
Alert,
|
||||
chakra,
|
||||
HStack,
|
||||
Tooltip,
|
||||
useToast,
|
||||
AccordionButton,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
AccordionButton,
|
||||
Alert,
|
||||
Box,
|
||||
Flex,
|
||||
HStack,
|
||||
Tooltip,
|
||||
chakra,
|
||||
useAccordionContext,
|
||||
useToast,
|
||||
} from '@chakra-ui/react';
|
||||
import { motion } from 'framer-motion';
|
||||
import startCase from 'lodash/startCase';
|
||||
import { forwardRef, memo, useEffect, useMemo } from 'react';
|
||||
import isEqual from 'react-fast-compare';
|
||||
import { If, Then, Else } from 'react-if';
|
||||
import { Else, If, Then } from 'react-if';
|
||||
import { BGPTable, Path, TextOutput } from '~/components';
|
||||
import { useConfig } from '~/context';
|
||||
import { Countdown, DynamicIcon } from '~/elements';
|
||||
import {
|
||||
useStrf,
|
||||
useDevice,
|
||||
useMobile,
|
||||
useLGQuery,
|
||||
useFormState,
|
||||
useColorValue,
|
||||
useDevice,
|
||||
useFormState,
|
||||
useLGQuery,
|
||||
useMobile,
|
||||
useStrf,
|
||||
useTableToString,
|
||||
} from '~/hooks';
|
||||
import { isStructuredOutput, isStringOutput } from '~/types';
|
||||
import { isStackError, isFetchError, isLGError, isLGOutputOrError } from './guards';
|
||||
import { RequeryButton } from './requery-button';
|
||||
import { isStringOutput, isStructuredOutput } from '~/types';
|
||||
import { CopyButton } from './copy-button';
|
||||
import { FormattedError } from './formatted-error';
|
||||
import { isFetchError, isLGError, isLGOutputOrError, isStackError } from './guards';
|
||||
import { ResultHeader } from './header';
|
||||
import { RequeryButton } from './requery-button';
|
||||
|
||||
import type { ErrorLevels } from '~/types';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import { useEffect, useMemo } from 'react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import { useConfig } from '~/context';
|
||||
import { fetchWithTimeout } from '~/util';
|
||||
|
||||
import type {
|
||||
QueryFunction,
|
||||
UseQueryOptions,
|
||||
QueryObserverResult,
|
||||
QueryFunctionContext,
|
||||
QueryObserverResult,
|
||||
UseQueryOptions,
|
||||
} from '@tanstack/react-query';
|
||||
import type { FormQuery } from '~/types';
|
||||
|
||||
|
|
@ -54,7 +54,10 @@ export function useLGQuery(
|
|||
controller,
|
||||
);
|
||||
try {
|
||||
return await res.json();
|
||||
const data = await res.json();
|
||||
console.dir(data, { depth: null });
|
||||
return data;
|
||||
// return await res.json();
|
||||
} catch (err) {
|
||||
throw new Error(res.statusText);
|
||||
}
|
||||
|
|
|
|||
2
hyperglass/ui/package.json
vendored
2
hyperglass/ui/package.json
vendored
|
|
@ -44,7 +44,7 @@
|
|||
"react-if": "^4.1.4",
|
||||
"react-markdown": "^5.0.3",
|
||||
"react-select": "^5.7.0",
|
||||
"react-string-replace": "^0.5.0",
|
||||
"react-string-replace": "^1.1.1",
|
||||
"react-table": "^7.7.0",
|
||||
"reactflow": "^11.10.4",
|
||||
"remark-gfm": "^1.0.0",
|
||||
|
|
|
|||
8
hyperglass/ui/pnpm-lock.yaml
generated
8
hyperglass/ui/pnpm-lock.yaml
generated
|
|
@ -87,8 +87,8 @@ dependencies:
|
|||
specifier: ^5.7.0
|
||||
version: 5.7.0(@types/react@18.2.60)(react-dom@18.2.0)(react@18.2.0)
|
||||
react-string-replace:
|
||||
specifier: ^0.5.0
|
||||
version: 0.5.0
|
||||
specifier: ^1.1.1
|
||||
version: 1.1.1
|
||||
react-table:
|
||||
specifier: ^7.7.0
|
||||
version: 7.7.0(react@18.2.0)
|
||||
|
|
@ -6325,8 +6325,8 @@ packages:
|
|||
react-dom: 18.2.0(react@18.2.0)
|
||||
dev: false
|
||||
|
||||
/react-string-replace@0.5.0:
|
||||
resolution: {integrity: sha512-xtfotmm+Gby5LjfYg3s5+eT6bnwgOIdZRAdHTouLY/7SicDtX4JXjG7CAGaGDcS0ax4nsaaEVNRxArSa8BgQKw==}
|
||||
/react-string-replace@1.1.1:
|
||||
resolution: {integrity: sha512-26TUbLzLfHQ5jO5N7y3Mx88eeKo0Ml0UjCQuX4BMfOd/JX+enQqlKpL1CZnmjeBRvQE8TR+ds9j1rqx9CxhKHQ==}
|
||||
engines: {node: '>=0.12.0'}
|
||||
dev: false
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue