File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
apps/browser-example/src/components Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -36,9 +36,21 @@ export function EventList({ events }: { events: any[] }) {
3636 }
3737 } , [ events ] )
3838
39+ function saveEvents ( ) {
40+ const blob = new Blob ( [ JSON . stringify ( events , null , 2 ) ] , {
41+ type : "application/json" ,
42+ } )
43+ const url = URL . createObjectURL ( blob )
44+ const a = document . createElement ( "a" )
45+ a . href = url
46+ const timestamp = new Date ( ) . toISOString ( ) . replace ( / [: .] / g, "-" )
47+ a . download = `events-${ timestamp } .json`
48+ a . click ( )
49+ }
50+
3951 return (
4052 < div className = "card my-2" >
41- < div className = "card-header" >
53+ < div className = "card-header d-flex gap-2 " >
4254 < div className = "dropdown" >
4355 < button
4456 type = "button"
@@ -49,6 +61,13 @@ export function EventList({ events }: { events: any[] }) {
4961 >
5062 Filter
5163 </ button >
64+ < button
65+ type = "button"
66+ className = "btn btn-secondary"
67+ onClick = { ( ) => saveEvents ( ) }
68+ >
69+ Save Events to File
70+ </ button >
5271 < span className = "mx-2" > Event Count: { events . length } </ span >
5372
5473 < form
You can’t perform that action at this time.
0 commit comments