2022-08-01 04:11:46 +08:00
|
|
|
/*
|
|
|
|
Copyright 2022 New Vector Ltd
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-02-02 07:11:06 +08:00
|
|
|
import React, { useCallback, useState } from "react";
|
2022-10-10 21:19:10 +08:00
|
|
|
import { useTranslation } from "react-i18next";
|
2022-07-30 16:00:51 +08:00
|
|
|
|
2022-08-02 06:46:16 +08:00
|
|
|
import {
|
|
|
|
SequenceDiagramViewer,
|
|
|
|
SequenceDiagramMatrixEvent,
|
|
|
|
} from "./room/GroupCallInspector";
|
2022-02-02 07:11:06 +08:00
|
|
|
import { FieldRow, InputField } from "./input/Input";
|
2022-02-03 07:02:40 +08:00
|
|
|
import { usePageTitle } from "./usePageTitle";
|
2022-02-02 07:11:06 +08:00
|
|
|
|
2022-07-30 16:00:51 +08:00
|
|
|
interface DebugLog {
|
|
|
|
localUserId: string;
|
2022-08-02 06:46:16 +08:00
|
|
|
eventsByUserId: { [userId: string]: SequenceDiagramMatrixEvent[] };
|
2022-07-30 16:00:51 +08:00
|
|
|
remoteUserIds: string[];
|
|
|
|
}
|
|
|
|
|
2022-02-02 07:11:06 +08:00
|
|
|
export function SequenceDiagramViewerPage() {
|
2022-10-10 21:19:10 +08:00
|
|
|
const { t } = useTranslation();
|
|
|
|
usePageTitle(t("Inspector"));
|
2022-02-03 07:02:40 +08:00
|
|
|
|
2022-07-30 16:00:51 +08:00
|
|
|
const [debugLog, setDebugLog] = useState<DebugLog>();
|
|
|
|
const [selectedUserId, setSelectedUserId] = useState<string>();
|
2022-02-02 07:11:06 +08:00
|
|
|
const onChangeDebugLog = useCallback((e) => {
|
|
|
|
if (e.target.files && e.target.files.length > 0) {
|
2022-08-02 06:46:16 +08:00
|
|
|
e.target.files[0].text().then((text: string) => {
|
2022-02-02 07:11:06 +08:00
|
|
|
setDebugLog(JSON.parse(text));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div style={{ marginTop: 20 }}>
|
|
|
|
<FieldRow>
|
|
|
|
<InputField
|
|
|
|
type="file"
|
|
|
|
id="debugLog"
|
|
|
|
name="debugLog"
|
2022-10-10 21:19:10 +08:00
|
|
|
label={t("Debug log")}
|
2022-02-02 07:11:06 +08:00
|
|
|
onChange={onChangeDebugLog}
|
|
|
|
/>
|
|
|
|
</FieldRow>
|
|
|
|
{debugLog && (
|
|
|
|
<SequenceDiagramViewer
|
|
|
|
localUserId={debugLog.localUserId}
|
|
|
|
selectedUserId={selectedUserId}
|
|
|
|
onSelectUserId={setSelectedUserId}
|
|
|
|
remoteUserIds={debugLog.remoteUserIds}
|
|
|
|
events={debugLog.eventsByUserId[selectedUserId]}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|