11import './App.css' ;
22import React , { useState } from "react" ;
33import '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' ;
55import { TraceOnlyView } from "./TraceOnlyView" ;
66import { ProfilingView } from "./ProfilingView" ;
77import { DebuggingView } from "./DebuggingView" ;
8- const version = "0.0.3" ;
8+
9+ const version = "0.0.3" ;
910const 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