Merge pull request #417 from getmaxun/show-run
feat: display currently running robot run
This commit is contained in:
@@ -501,6 +501,7 @@ router.put('/runs/:id', requireSignIn, async (req: AuthenticatedRequest, res) =>
|
|||||||
return res.send({
|
return res.send({
|
||||||
browserId: id,
|
browserId: id,
|
||||||
runId: plainRun.runId,
|
runId: plainRun.runId,
|
||||||
|
robotMetaId: recording.recording_meta.id,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const { message } = e as Error;
|
const { message } = e as Error;
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ export const createRunForStoredRecording = async (id: string, settings: RunSetti
|
|||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
return { browserId: '', runId: '' };
|
return { browserId: '', runId: '', robotMetaId: '' };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ interface CollapsibleRowProps {
|
|||||||
currentLog: string;
|
currentLog: string;
|
||||||
abortRunHandler: () => void;
|
abortRunHandler: () => void;
|
||||||
runningRecordingName: string;
|
runningRecordingName: string;
|
||||||
|
urlRunId: string | null;
|
||||||
}
|
}
|
||||||
export const CollapsibleRow = ({ row, handleDelete, isOpen, currentLog, abortRunHandler, runningRecordingName }: CollapsibleRowProps) => {
|
export const CollapsibleRow = ({ row, handleDelete, isOpen, currentLog, abortRunHandler, runningRecordingName, urlRunId }: CollapsibleRowProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [open, setOpen] = useState(isOpen);
|
const [open, setOpen] = useState(isOpen);
|
||||||
@@ -62,14 +63,18 @@ export const CollapsibleRow = ({ row, handleDelete, isOpen, currentLog, abortRun
|
|||||||
abortRunHandler();
|
abortRunHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setOpen(urlRunId === row.runId || isOpen);
|
||||||
|
}, [urlRunId, row.runId, isOpen]);
|
||||||
|
|
||||||
const handleRowExpand = () => {
|
const handleRowExpand = () => {
|
||||||
const newOpen = !open;
|
const newOpen = !open;
|
||||||
setOpen(newOpen);
|
setOpen(newOpen);
|
||||||
if (newOpen) {
|
navigate(
|
||||||
navigate(`/runs/${row.robotMetaId}/run/${row.runId}`);
|
newOpen
|
||||||
} else {
|
? `/runs/${row.robotMetaId}/run/${row.runId}`
|
||||||
navigate(`/runs/${row.robotMetaId}`);
|
: `/runs/${row.robotMetaId}`
|
||||||
}
|
);
|
||||||
//scrollToLogBottom();
|
//scrollToLogBottom();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import TableRow from '@mui/material/TableRow';
|
|||||||
import { Accordion, AccordionSummary, AccordionDetails, Typography, Box, TextField, CircularProgress, Tooltip } from '@mui/material';
|
import { Accordion, AccordionSummary, AccordionDetails, Typography, Box, TextField, CircularProgress, Tooltip } from '@mui/material';
|
||||||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
||||||
import SearchIcon from '@mui/icons-material/Search';
|
import SearchIcon from '@mui/icons-material/Search';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useLocation, useNavigate } from 'react-router-dom';
|
||||||
import { useGlobalInfoStore } from "../../context/globalInfo";
|
import { useGlobalInfoStore } from "../../context/globalInfo";
|
||||||
import { getStoredRuns } from "../../api/storage";
|
import { getStoredRuns } from "../../api/storage";
|
||||||
import { RunSettings } from "./RunSettings";
|
import { RunSettings } from "./RunSettings";
|
||||||
@@ -85,6 +85,21 @@ export const RunsTable: React.FC<RunsTableProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
|
const getUrlParams = () => {
|
||||||
|
const match = location.pathname.match(/\/runs\/([^\/]+)(?:\/run\/([^\/]+))?/);
|
||||||
|
return {
|
||||||
|
robotMetaId: match?.[1] || null,
|
||||||
|
urlRunId: match?.[2] || null
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const { robotMetaId: urlRobotMetaId, urlRunId } = getUrlParams();
|
||||||
|
|
||||||
|
const isAccordionExpanded = useCallback((currentRobotMetaId: string) => {
|
||||||
|
return currentRobotMetaId === urlRobotMetaId;
|
||||||
|
}, [urlRobotMetaId]);
|
||||||
|
|
||||||
const [accordionPage, setAccordionPage] = useState(0);
|
const [accordionPage, setAccordionPage] = useState(0);
|
||||||
const [accordionsPerPage, setAccordionsPerPage] = useState(10);
|
const [accordionsPerPage, setAccordionsPerPage] = useState(10);
|
||||||
@@ -314,10 +329,11 @@ export const RunsTable: React.FC<RunsTableProps> = ({
|
|||||||
key={`row-${row.id}`}
|
key={`row-${row.id}`}
|
||||||
row={row}
|
row={row}
|
||||||
handleDelete={handleDelete}
|
handleDelete={handleDelete}
|
||||||
isOpen={runId === row.runId && runningRecordingName === row.name}
|
isOpen={urlRunId === row.runId || (runId === row.runId && runningRecordingName === row.name)}
|
||||||
currentLog={currentInterpretationLog}
|
currentLog={currentInterpretationLog}
|
||||||
abortRunHandler={abortRunHandler}
|
abortRunHandler={abortRunHandler}
|
||||||
runningRecordingName={runningRecordingName}
|
runningRecordingName={runningRecordingName}
|
||||||
|
urlRunId={urlRunId}
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
}, [paginationStates, runId, runningRecordingName, currentInterpretationLog, abortRunHandler, handleDelete, accordionSortConfigs]);
|
}, [paginationStates, runId, runningRecordingName, currentInterpretationLog, abortRunHandler, handleDelete, accordionSortConfigs]);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { ScheduleSettings } from "../components/robot/ScheduleSettings";
|
|||||||
import { IntegrationSettings } from "../components/integration/IntegrationSettings";
|
import { IntegrationSettings } from "../components/integration/IntegrationSettings";
|
||||||
import { RobotSettings } from "../components/robot/RobotSettings";
|
import { RobotSettings } from "../components/robot/RobotSettings";
|
||||||
import { apiUrl } from "../apiConfig";
|
import { apiUrl } from "../apiConfig";
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
interface MainPageProps {
|
interface MainPageProps {
|
||||||
handleEditRecording: (id: string, fileName: string) => void;
|
handleEditRecording: (id: string, fileName: string) => void;
|
||||||
@@ -24,6 +25,7 @@ interface MainPageProps {
|
|||||||
export interface CreateRunResponse {
|
export interface CreateRunResponse {
|
||||||
browserId: string;
|
browserId: string;
|
||||||
runId: string;
|
runId: string;
|
||||||
|
robotMetaId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ScheduleRunResponse {
|
export interface ScheduleRunResponse {
|
||||||
@@ -40,12 +42,14 @@ export const MainPage = ({ handleEditRecording, initialContent }: MainPageProps)
|
|||||||
const [currentInterpretationLog, setCurrentInterpretationLog] = React.useState('');
|
const [currentInterpretationLog, setCurrentInterpretationLog] = React.useState('');
|
||||||
const [ids, setIds] = React.useState<CreateRunResponse>({
|
const [ids, setIds] = React.useState<CreateRunResponse>({
|
||||||
browserId: '',
|
browserId: '',
|
||||||
runId: ''
|
runId: '',
|
||||||
|
robotMetaId: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
let aborted = false;
|
let aborted = false;
|
||||||
|
|
||||||
const { notify, setRerenderRuns, setRecordingId } = useGlobalInfoStore();
|
const { notify, setRerenderRuns, setRecordingId } = useGlobalInfoStore();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const abortRunHandler = (runId: string) => {
|
const abortRunHandler = (runId: string) => {
|
||||||
aborted = true;
|
aborted = true;
|
||||||
@@ -88,8 +92,9 @@ export const MainPage = ({ handleEditRecording, initialContent }: MainPageProps)
|
|||||||
}, [currentInterpretationLog])
|
}, [currentInterpretationLog])
|
||||||
|
|
||||||
const handleRunRecording = useCallback((settings: RunSettings) => {
|
const handleRunRecording = useCallback((settings: RunSettings) => {
|
||||||
createRunForStoredRecording(runningRecordingId, settings).then(({ browserId, runId }: CreateRunResponse) => {
|
createRunForStoredRecording(runningRecordingId, settings).then(({ browserId, runId, robotMetaId }: CreateRunResponse) => {
|
||||||
setIds({ browserId, runId });
|
setIds({ browserId, runId, robotMetaId });
|
||||||
|
navigate(`/runs/${robotMetaId}/run/${runId}`);
|
||||||
const socket =
|
const socket =
|
||||||
io(`${apiUrl}/${browserId}`, {
|
io(`${apiUrl}/${browserId}`, {
|
||||||
transports: ["websocket"],
|
transports: ["websocket"],
|
||||||
|
|||||||
Reference in New Issue
Block a user