You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dispatch(setCurrentTabInApp('performance'));// dispatch sent at initial page load allowing changing "immer's" draft.currentTabInApp to 'performance' to facilitate render.
168
-
},[dispatch]);
169
-
170
-
// Creates the actions array used to populate the compare actions dropdown
171
-
constgetActions=()=>{
153
+
constgetActions=()=>{// Creates the actions array used to populate the compare actions dropdown (WORK IN PROGRESS)
dispatch(setCurrentTabInApp('performance'));// dispatch sent at initial page load allowing changing "immer's" draft.currentTabInApp to 'performance' to facilitate render.
constcheckData=[data.barStack.find((comp)=>comp.snapshotId===snapshot)];// filter barStack to make it equal to an array of length 1 with object matching snapshot ID to mirror the data.barStack object's shape
241
243
constholdData=[];
242
-
// looping through checkData which is composed of a single snapshot while pushing key/values to a new object and setting maxHeight
243
-
for(constkeyincheckData[0]){
244
+
245
+
for(constkeyincheckData[0]){// looping through checkData which is composed of a single snapshot while pushing key/values to a new object and setting maxHeight
// maxTotalRender height of bar is aligned to y-axis
254
-
// 1.15 adjusts the numbers on the y-axis so the max bar's true height never reaches the max of the y-axis
255
-
data.maxTotalRender=maxHeight*1.15;
256
-
// assign holdData to data.barStack to be used later to create graph
257
-
if(holdData)data.barStack=holdData;
255
+
256
+
data.maxTotalRender=maxHeight*1.15;// maxTotalRender height of bar is aligned to y-axis. 1.15 adjusts the numbers on the y-axis so the max bar's true height never reaches the max of the y-axis
257
+
if(holdData)data.barStack=holdData;// assign holdData to data.barStack to be used later to create graph
Copy file name to clipboardExpand all lines: src/app/components/StateRoute/PerformanceVisx/RenderingFrequency.tsx
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,11 @@ import { useStoreContext } from '../../../store';
12
12
constRenderingFrequency=(props)=>{
13
13
constperfData=props.data;
14
14
const[store,dispatch]=useStoreContext();
15
+
15
16
useEffect(()=>{
16
17
dispatch(setCurrentTabInApp('performance-comparison'));// dispatch sent at initial page load allowing changing "immer's" draft.currentTabInApp to 'performance-comparison' to facilitate render.
functionexportHandler(snapshots: []): void{// function that takes in our tabs[currentTab] object to be exported as a JSON file. NOTE: TypeScript needs to be updated
13
+
constfileDownload: HTMLAnchorElement=document.createElement('a');// invisible HTML element that will hold our tabs[currentTab] object
12
14
13
-
// function exportHandler takes in a parameter snapshots which is typed as an array
14
-
// the function does not return anything so the type is void
fileDownload.href=URL.createObjectURL(// href is the reference to the URL object created from the Blob
16
+
newBlob([JSON.stringify(snapshots)],{type: 'application/json'}),// Blob obj is raw data. The tabs[currentTab] object is stringified so the Blob can access the raw data
26
17
);
27
18
28
-
// set anchor as file download and click it
29
-
// anchor element has a download attribute
30
-
// snapshot.json is what the file name will be once the file is downloaded locally
// simulates a mouse click, triggering the element's click event
34
-
fileDownload.click();
19
+
fileDownload.setAttribute('download','snapshot.json');// We set a download attribute with snapshots.json as the file name. This allows us to download the file when the element is 'clicked.' The file will be named snapshots.json once the file is downloaded locally
20
+
fileDownload.click();// click is a method on all HTML elements that simulates a mouse click, triggering the element's click event
35
21
36
-
// remove file url
37
-
// after file is downloaded, remove the href
38
-
URL.revokeObjectURL(fileDownload.href);
22
+
URL.revokeObjectURL(fileDownload.href);// after file is downloaded, remove the href
// fileUpload is HTMLInputElement, which is an interface for HTML input elements
44
-
// accepts data from user
45
-
constfileUpload=document.createElement('input');
46
-
// file is a type attribute on the input element, allows users to select a file
47
-
console.log('fileUpload element:',fileUpload)
48
-
fileUpload.setAttribute('type','file');
49
-
50
-
// onChange is when value of HTML element is changed
51
-
// parameter for onChange is an event
52
-
fileUpload.onchange=(e: Event)=>{
53
-
// FileReader is an object
54
-
// reads contents of local files in async
55
-
// can use file or blob objects
56
-
constreader=newFileReader();
57
-
console.log('on change triggered')
58
-
//console.log('reader :', reader);
25
+
functionimportHandler(dispatch: (a: unknown)=>void): void{// function handles the importing of a tabs[currentTab] object when the upload button is selected
26
+
constfileUpload=document.createElement('input');// invisible HTML element that will hold our uploaded tabs[currentTab] object
27
+
fileUpload.setAttribute('type','file');// Attributes added to HTML element
consttest=reader.result.toString();// once the local file has been loaded, result property on FileReader object returns the file's contents and then converts the file contents to a string
39
+
returndispatch(importSnapshots(JSON.parse(test)));// dispatch sends the result of of converting our tabs[currentTab] object => string => JSON Object. This updates the current tab
78
40
};
79
-
// const eventFiles = e.target as HTMLInputElement;
80
-
// if (eventFiles?.hasOwnProperty('files')) {
81
-
// // const eventFiles = target as HTMLInputElement;
0 commit comments