Skip to content

Commit e1aa489

Browse files
committed
add demo file
1 parent 833eec0 commit e1aa489

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

frontend/packages/insights/public/files/tpch-22-sf10.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

frontend/packages/insights/src/App.js

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
11
import './App.css';
22
import React, {useState} from "react";
33
import 'bootstrap/dist/css/bootstrap.min.css';
4-
import {Col, Container, Form, Modal, Navbar, Row} from 'react-bootstrap';
4+
import {Button, Col, Container, Form, Modal, Navbar, Row} from 'react-bootstrap';
55
import {TraceOnlyView} from "./TraceOnlyView";
66
import {ProfilingView} from "./ProfilingView";
77
import {DebuggingView} from "./DebuggingView";
8-
const version="0.0.3";
8+
9+
const version = "0.0.3";
910
const App = () => {
1011
const [data, setData] = useState(null);
1112
const [error, setError] = useState(null);
1213

13-
14+
const handleDemoFile = async (file) => {
15+
try {
16+
const response = await fetch(`/files/${file}.json`);
17+
if (!response.ok) {
18+
setError("Failed to load JSON");
19+
}
20+
const jsonData = await response.json();
21+
setData(jsonData);
22+
} catch (error) {
23+
setError("Error loading JSON");
24+
}
25+
};
1426
const handleFileUpload = (event) => {
1527
const file = event.target.files[0];
1628
const reader = new FileReader();
1729
reader.onload = (e) => {
1830
try {
1931
const json = JSON.parse(e.target.result);
20-
if(!json.version){
32+
if (!json.version) {
2133
setError("File does not contain version information.");
22-
}else if(json.version===version){
34+
} else if (json.version === version) {
2335
setData(json);
24-
}else{
36+
} else {
2537
setError(`Unsupported file version. Supported version is ${version}`);
2638
}
2739

@@ -62,9 +74,12 @@ const App = () => {
6274
</Row>
6375
<Row className="flex-grow-1">
6476
<Col
65-
className="d-flex justify-content-center align-items-center bg-dark text-white"
66-
>
67-
<h2>Demo Files: Coming Soon</h2>
77+
className="d-flex flex-column justify-content-center align-items-center bg-dark text-white">
78+
<h2>Demo Files</h2>
79+
<p style={{marginTop:"40px"}}>
80+
81+
<Button variant="outline-light" onClick={()=>handleDemoFile("tpch-22-sf10")}> TPC-H Q22, SF=10</Button>
82+
</p>
6883
</Col>
6984
</Row>
7085
</Container>
@@ -83,9 +98,9 @@ const App = () => {
8398
</Modal.Header>
8499
<Modal.Body>{error}</Modal.Body>
85100
</Modal>
86-
{data&&data.fileType==="debugging"&&<DebuggingView data={data} onClose={()=>setData(null)}/> }
87-
{data&&data.fileType==="traceOnly"&&<TraceOnlyView data={data} onClose={()=>setData(null)}/>}
88-
{data&&data.fileType==="profiling"&&<ProfilingView data={data} onClose={()=>setData(null)}/>}
101+
{data && data.fileType === "debugging" && <DebuggingView data={data} onClose={() => setData(null)}/>}
102+
{data && data.fileType === "traceOnly" && <TraceOnlyView data={data} onClose={() => setData(null)}/>}
103+
{data && data.fileType === "profiling" && <ProfilingView data={data} onClose={() => setData(null)}/>}
89104

90105
</div>
91106
);

0 commit comments

Comments
 (0)