-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- make fat html containing all assets itself - add support for inline added base64 data to html input with id=embedded-file-input. If it exists, atson displays this data. Co-authored-by: Vladislav Baluk <[email protected]>
- Loading branch information
1 parent
ffef759
commit 0cb5f3f
Showing
6 changed files
with
1,948 additions
and
1,277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React from 'react'; | ||
import { Navigate } from 'react-router-dom'; | ||
import JSZip from 'jszip'; | ||
import { setParsedData } from '../../common/threadDumpsStorageService'; | ||
import Parser from '../../parser/Parser'; | ||
import ThreadDump from '../../types/ThreadDump'; | ||
|
||
type State = { | ||
parsedDataKey: string | undefined; | ||
hasCpuUsageInfo: boolean; | ||
loadingEmbeddedData: boolean; | ||
b64zip: string; | ||
}; | ||
|
||
type Props = { | ||
b64zip: string; | ||
}; | ||
|
||
export default class EmbeddedDataIndex extends React.PureComponent<Props, State> { | ||
constructor(props: Props) { | ||
super(props); | ||
this.state = { | ||
parsedDataKey: undefined, | ||
hasCpuUsageInfo: false, | ||
loadingEmbeddedData: true, | ||
b64zip: props.b64zip, | ||
}; | ||
} | ||
|
||
async componentDidMount(): Promise<void> { | ||
const { b64zip } = this.state; | ||
const zipBytes = atob(b64zip); | ||
const zipFile = new File([new Uint8Array(zipBytes.split('').map((c) => c.charCodeAt(0)))], 'embedded.zip'); | ||
const zip = await new JSZip().loadAsync(zipFile); | ||
const files = await Promise.all(zip.file(/.*\.txt/) | ||
.map(async (zipEntry) => { | ||
const blob = await zipEntry.async('blob'); | ||
return new File([blob], zipEntry.name); | ||
})); | ||
|
||
const parser = new Parser(this.onParsed); | ||
parser.parseFiles(files); | ||
} | ||
|
||
private onParsed = (threadDumps: ThreadDump[]): void => { | ||
const key = setParsedData(threadDumps); | ||
this.setState((state) => ({ | ||
...state, | ||
parsedDataKey: key, | ||
hasCpuUsageInfo: threadDumps.some((dump) => dump.threads.some((thread) => thread.cpuUsage !== '0.00')), | ||
loadingEmbeddedData: false, | ||
})); | ||
}; | ||
|
||
public render(): JSX.Element { | ||
const { parsedDataKey, hasCpuUsageInfo, loadingEmbeddedData } = this.state; | ||
if (loadingEmbeddedData) { | ||
return <h1>Loading...</h1>; | ||
} | ||
|
||
if (parsedDataKey) { | ||
if (hasCpuUsageInfo) { | ||
return ( | ||
<Navigate to={`/${parsedDataKey}/summary`} /> | ||
); | ||
} | ||
return ( | ||
<Navigate to={`/${parsedDataKey}/similar-stacks`} /> | ||
); | ||
} | ||
|
||
return ( | ||
<h1>Loading...</h1> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
|
||
import EmbeddedDataIndex from '../EmbeddedDataIndex/EmbeddedDataIndex'; | ||
import FullPageDropzone from '../FullPageDropzone/FullPageDropzone'; | ||
|
||
export default class Index extends React.PureComponent<unknown, { b64zip: string | undefined }> { | ||
constructor(props: unknown) { | ||
super(props); | ||
this.state = { | ||
b64zip: undefined, | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
let b64zip:string; | ||
const embeddedFileInput = document.getElementById('embedded-file-input'); | ||
if (embeddedFileInput) { | ||
b64zip = embeddedFileInput.getAttribute('value')!; | ||
if (b64zip) this.setState((state) => ({ ...state, b64zip })); | ||
} | ||
} | ||
|
||
public render(): JSX.Element { | ||
const { b64zip } = this.state; | ||
if (b64zip) { | ||
return <EmbeddedDataIndex b64zip={b64zip} />; | ||
} | ||
|
||
return <FullPageDropzone />; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.