2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
4
import { 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' ;
7
7
import { makeStyles } from '@fluentui/react-components' ;
8
8
import './App.css' ;
9
9
import { ScenarioGroup } from './ScenarioTree' ;
@@ -35,30 +35,6 @@ const useStyles = makeStyles({
35
35
alignItems : 'center' ,
36
36
gap : '12px' ,
37
37
} ,
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
- } ,
62
38
footerText : { fontSize : '0.8rem' , marginTop : '2rem' } ,
63
39
closeButton : {
64
40
position : 'absolute' ,
@@ -90,6 +66,22 @@ function App() {
90
66
const toggleSettings = ( ) => setIsSettingsOpen ( ! isSettingsOpen ) ;
91
67
const closeSettings = ( ) => setIsSettingsOpen ( false ) ;
92
68
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
+
93
85
return (
94
86
< >
95
87
< div className = { classes . header } >
@@ -98,15 +90,14 @@ function App() {
98
90
< div className = { classes . headerActions } >
99
91
{ selectedTags . length > 0 && (
100
92
< 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 } />
104
94
</ Tooltip >
105
95
) }
96
+ < Tooltip content = "Download Data as JSON" relationship = "description" >
97
+ < Button icon = { < ArrowDownloadRegular /> } appearance = "subtle" onClick = { downloadDataset } />
98
+ </ Tooltip >
106
99
< Tooltip content = "Settings" relationship = "description" >
107
- < div className = { classes . iconButton } onClick = { toggleSettings } >
108
- < Settings28Regular />
109
- </ div >
100
+ < Button icon = { < Settings28Regular /> } appearance = "subtle" onClick = { toggleSettings } />
110
101
</ Tooltip >
111
102
</ div >
112
103
</ div >
0 commit comments