2022-02-01 23:11:06 +00:00
|
|
|
import React, { useCallback, useState } from "react";
|
2022-07-30 08:00:51 +00:00
|
|
|
|
2022-02-01 23:11:06 +00:00
|
|
|
import { SequenceDiagramViewer } from "./room/GroupCallInspector";
|
|
|
|
import { FieldRow, InputField } from "./input/Input";
|
2022-02-02 23:02:40 +00:00
|
|
|
import { usePageTitle } from "./usePageTitle";
|
2022-02-01 23:11:06 +00:00
|
|
|
|
2022-07-30 08:00:51 +00:00
|
|
|
interface DebugLog {
|
|
|
|
localUserId: string;
|
|
|
|
eventsByUserId: Record<string, {}>;
|
|
|
|
remoteUserIds: string[];
|
|
|
|
}
|
|
|
|
|
2022-02-01 23:11:06 +00:00
|
|
|
export function SequenceDiagramViewerPage() {
|
2022-02-02 23:02:40 +00:00
|
|
|
usePageTitle("Inspector");
|
|
|
|
|
2022-07-30 08:00:51 +00:00
|
|
|
const [debugLog, setDebugLog] = useState<DebugLog>();
|
|
|
|
const [selectedUserId, setSelectedUserId] = useState<string>();
|
2022-02-01 23:11:06 +00:00
|
|
|
const onChangeDebugLog = useCallback((e) => {
|
|
|
|
if (e.target.files && e.target.files.length > 0) {
|
|
|
|
e.target.files[0].text().then((text) => {
|
|
|
|
setDebugLog(JSON.parse(text));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div style={{ marginTop: 20 }}>
|
|
|
|
<FieldRow>
|
|
|
|
<InputField
|
|
|
|
type="file"
|
|
|
|
id="debugLog"
|
|
|
|
name="debugLog"
|
|
|
|
label="Debug Log"
|
|
|
|
onChange={onChangeDebugLog}
|
|
|
|
/>
|
|
|
|
</FieldRow>
|
|
|
|
{debugLog && (
|
|
|
|
<SequenceDiagramViewer
|
|
|
|
localUserId={debugLog.localUserId}
|
|
|
|
selectedUserId={selectedUserId}
|
|
|
|
onSelectUserId={setSelectedUserId}
|
|
|
|
remoteUserIds={debugLog.remoteUserIds}
|
|
|
|
events={debugLog.eventsByUserId[selectedUserId]}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|