18 | {props.success ? (
19 |
20 |
21 | SUCCESS: {props.success}
22 |
23 | {props.query}
24 |
25 | {props.response}
26 |
27 |
28 | ) : errorResponseBox ? (
29 |
30 |
31 |
32 | ERROR: {props.success}
33 |
34 | {props.query}
35 |
36 |
37 |
38 |
39 | {errorResponseBox && }
40 |
41 |
42 | ) : (
43 |
44 |
45 |
46 | ERROR: {props.success}
47 |
48 | {props.query}
49 |
50 |
51 |
52 | )}
53 |
54 | );
55 | }
56 |
57 | export default Log;
58 |
--------------------------------------------------------------------------------
/grapherrql-package/src/components/LiveMode/LoggerBox.js:
--------------------------------------------------------------------------------
1 | import { useContext } from 'react';
2 |
3 | import { LiveContext } from '../LiveMode/LiveContext';
4 | import {
5 | DataContainer,
6 | IncomingDataContainer,
7 | TextContainer,
8 | ErrorTextContainer,
9 | CurrentLog,
10 | LogContainer,
11 | } from './styles/LoggerResponse.styled';
12 |
13 | function LoggerBox() {
14 | const { liveQuery, liveResponse, dataLog } = useContext(LiveContext);
15 |
16 | const regexRemove = /"/g;
17 | const regexColon = /:/g;
18 |
19 | const liveQueryParsed = liveQuery
20 | .slice(13)
21 | .replace(regexRemove, ``)
22 | .replace(regexColon, ` `);
23 | const liveResponseParsed = liveResponse
24 | .slice(13)
25 | .replace(regexRemove, ``)
26 | .replace(regexColon, ` `);
27 |
28 | let logQueue = [];
29 | const displayDataLog = dataLog
30 | .slice(0, -2)
31 | .reverse()
32 | .map((qR) => {
33 | logQueue.push(qR);
34 | console.log(`LOGQUEUE UPDATE: ${JSON.stringify(logQueue)}`);
35 | if (logQueue.length === 2) {
36 | const items = logQueue;
37 | logQueue = [];
38 | const timestamp = new Date(
39 | parseInt(String(items[0]).slice(0, 13))
40 | ).toString();
41 | return (
42 |