22// The .NET Foundation licenses this file to you under the MIT license.
33
44import { useState } from 'react' ;
5- import { Settings28Regular , FilterDismissRegular , Dismiss20Regular } from '@fluentui/react-icons' ;
6- import { Drawer , DrawerBody , DrawerHeader , DrawerHeaderTitle , Switch , Tooltip } from '@fluentui/react-components' ;
5+ import { Settings28Regular , FilterDismissRegular , Dismiss20Regular , ArrowDownloadRegular } from '@fluentui/react-icons' ;
6+ import { Button , Drawer , DrawerBody , DrawerHeader , DrawerHeaderTitle , Switch , Tooltip } from '@fluentui/react-components' ;
77import { makeStyles } from '@fluentui/react-components' ;
88import './App.css' ;
99import { ScenarioGroup } from './ScenarioTree' ;
@@ -35,30 +35,6 @@ const useStyles = makeStyles({
3535 alignItems : 'center' ,
3636 gap : '12px' ,
3737 } ,
38- iconButton : {
39- cursor : 'pointer' ,
40- display : 'flex' ,
41- alignItems : 'center' ,
42- justifyContent : 'center' ,
43- width : '40px' ,
44- height : '40px' ,
45- borderRadius : '6px' ,
46- transition : 'all 0.2s ease-in-out' ,
47- '&:hover' : {
48- backgroundColor : tokens . colorNeutralBackground4 ,
49- } ,
50- } ,
51- filterButton : {
52- backgroundColor : tokens . colorBrandBackground2 ,
53- border : `1px solid ${ tokens . colorBrandStroke1 } ` ,
54- fontSize : '20px' ,
55- width : '40px' ,
56- height : '40px' ,
57- borderRadius : '6px' ,
58- '&:hover' : {
59- backgroundColor : tokens . colorNeutralBackground4 ,
60- } ,
61- } ,
6238 footerText : { fontSize : '0.8rem' , marginTop : '2rem' } ,
6339 closeButton : {
6440 position : 'absolute' ,
@@ -90,6 +66,22 @@ function App() {
9066 const toggleSettings = ( ) => setIsSettingsOpen ( ! isSettingsOpen ) ;
9167 const closeSettings = ( ) => setIsSettingsOpen ( false ) ;
9268
69+ const downloadDataset = ( ) => {
70+ // create a stringified JSON of the dataset
71+ const dataStr = JSON . stringify ( dataset , null , 2 ) ;
72+
73+ // create a link to download the JSON file in the page and click it
74+ const blob = new Blob ( [ dataStr ] , { type : 'application/json' } ) ;
75+ const url = URL . createObjectURL ( blob ) ;
76+ const a = document . createElement ( 'a' ) ;
77+ a . href = url ;
78+ a . download = `${ scoreSummary . primaryResult . executionName } .json` ;
79+ document . body . appendChild ( a ) ;
80+ a . click ( ) ;
81+ document . body . removeChild ( a ) ;
82+ URL . revokeObjectURL ( url ) ;
83+ } ;
84+
9385 return (
9486 < >
9587 < div className = { classes . header } >
@@ -98,15 +90,14 @@ function App() {
9890 < div className = { classes . headerActions } >
9991 { selectedTags . length > 0 && (
10092 < Tooltip content = "Clear Filters" relationship = "description" >
101- < div className = { `${ classes . iconButton } ${ classes . filterButton } ` } onClick = { clearFilters } >
102- < FilterDismissRegular />
103- </ div >
93+ < Button icon = { < FilterDismissRegular /> } appearance = "subtle" onClick = { clearFilters } />
10494 </ Tooltip >
10595 ) }
96+ < Tooltip content = "Download Data as JSON" relationship = "description" >
97+ < Button icon = { < ArrowDownloadRegular /> } appearance = "subtle" onClick = { downloadDataset } />
98+ </ Tooltip >
10699 < Tooltip content = "Settings" relationship = "description" >
107- < div className = { classes . iconButton } onClick = { toggleSettings } >
108- < Settings28Regular />
109- </ div >
100+ < Button icon = { < Settings28Regular /> } appearance = "subtle" onClick = { toggleSettings } />
110101 </ Tooltip >
111102 </ div >
112103 </ div >
0 commit comments