* start moving ui to redux tlk * remove unused reducer * changes for gdpr and site types * ui: migrating duck/roles to mobx * ui: drop unreferenced types * ui: drop unreferenced types * ui: move player slice reducer to mobx family * ui: move assignments to issueReportingStore.ts * remove issues store * some fixes after issues store * remove errors reducer, drop old components * finish removing errors reducer * start moving integrations state to mobx * change(ui): funnel duck cleanup * change(ui): custom fields * change(ui): customMetrics cleanup * change(ui): customMetrics cleanup * change(ui): duck/filters minor cleanup * change(ui): duck/filters cleanup * change(ui): duck/customMetrics cleanup and upgrades * fix integrations service, fix babel config to >.25 + not ie * refactoring integrations reducers etc WIP * finish removing integrations state * some fixes for integrated check * start of projects refactoring * move api and "few" files to new project store * new batch for site -> projects * fix setid context * move all critical components, drop site duck * remove all duck/site refs, remove old components * fixup for SessionTags.tsx, remove duck/sources (?) * move session store * init sessionstore outside of context * fix userfilter * replace simple actions for session store * sessions sotre * Rtm temp (#2597) * change(ui): duck/search wip * change(ui): duck/search wip * change(ui): duck/search wip * change(ui): duck/searchLive wip * change(ui): duck/searchLive wip * change(ui): duck/searchLive wip * change(ui): duck/searchLive wip * change(ui): search states * change(ui): search states * change(ui): search states * change(ui): fix savedSearch store * change(ui): fix savedSearch store * some fixes for session connector * change(ui): fix savedSearch store * change(ui): fix searchLive * change(ui): fix searchLive * fixes for session replay * change(ui): bookmark fetch * last components for sessions * add fetchautoplaylist * finish session reducer, remove deleted reducers * change(ui): fix the search fetch * change(ui): fix the search fetch * fix integrations call ctx * ensure ctx for sessionstore * fix(ui): checking for latest sessions path * start removing user reducer * removing user reducer pt2... * finish user store * remove rand log * fix crashes * tinkering workflow file for tracker test * making sure prefetched sessions work properly * fix conflict * fix router redirects during loading --------- Co-authored-by: Shekar Siri <sshekarsiri@gmail.com>
119 lines
4.2 KiB
TypeScript
119 lines
4.2 KiB
TypeScript
import React from 'react';
|
|
import { useStore } from 'App/mstore';
|
|
import { BackLink } from 'UI';
|
|
import { observer } from 'mobx-react-lite';
|
|
import { useHistory, useParams } from 'react-router-dom';
|
|
import { liveSession, assist, withSiteId, multiview } from 'App/routes';
|
|
import AssistSessionsModal from 'App/components/Session_/Player/Controls/AssistSessionsModal';
|
|
import { useModal } from 'App/components/Modal';
|
|
import LivePlayer from 'App/components/Session/LivePlayer';
|
|
import EmptyTile from './EmptyTile';
|
|
import SessionTileFooter from './SessionTileFooter';
|
|
|
|
function Multiview({
|
|
assistCredentials
|
|
}: {
|
|
assistCredentials: any;
|
|
list: Record<string, any>[];
|
|
}) {
|
|
const { showModal, hideModal } = useModal();
|
|
const { assistMultiviewStore, projectsStore, searchStoreLive, sessionStore } = useStore();
|
|
const siteId = projectsStore.siteId!;
|
|
const history = useHistory();
|
|
// @ts-ignore
|
|
const { sessionsquery } = useParams();
|
|
const total = sessionStore.totalLiveSessions;
|
|
|
|
const onSessionsChange = (sessions: Array<Record<string, any> | undefined>) => {
|
|
const sessionIdQuery = encodeURIComponent(sessions.map((s) => s && s.sessionId).join(','));
|
|
return history.replace(withSiteId(multiview(sessionIdQuery), siteId));
|
|
};
|
|
|
|
React.useEffect(() => {
|
|
assistMultiviewStore.setOnChange(onSessionsChange);
|
|
|
|
if (sessionsquery) {
|
|
const sessionIds = decodeURIComponent(sessionsquery).split(',');
|
|
// preset
|
|
assistMultiviewStore.presetSessions(sessionIds).then((data) => {
|
|
sessionStore.customSetSessions(data);
|
|
});
|
|
} else {
|
|
searchStoreLive.fetchSessions();
|
|
}
|
|
}, []);
|
|
|
|
const openLiveSession = (e: React.MouseEvent, sessionId: string) => {
|
|
e.stopPropagation();
|
|
assistMultiviewStore.setActiveSession(sessionId);
|
|
history.push(withSiteId(liveSession(sessionId) + '?multi=true', siteId));
|
|
};
|
|
|
|
const returnToList = () => {
|
|
assistMultiviewStore.reset();
|
|
history.push(withSiteId(assist(), siteId));
|
|
};
|
|
|
|
const openListModal = () => {
|
|
showModal(<AssistSessionsModal onAdd={hideModal} />, { right: true, width: 700 });
|
|
};
|
|
|
|
const replaceSession = (e: React.MouseEvent, sessionId: string) => {
|
|
e.stopPropagation();
|
|
showModal(<AssistSessionsModal onAdd={hideModal} replaceTarget={sessionId} />, { right: true, width: 700 });
|
|
};
|
|
|
|
const deleteSession = (e: React.MouseEvent, sessionId: string) => {
|
|
e.stopPropagation();
|
|
assistMultiviewStore.removeSession(sessionId);
|
|
};
|
|
|
|
const emptySpace = 4 - assistMultiviewStore.sessions.length;
|
|
|
|
const placeholder = emptySpace > 0 ? new Array(emptySpace).fill(0) : [];
|
|
|
|
return (
|
|
<div style={{ height: '95vh' }} className="full flex flex-col">
|
|
<div className="w-full p-4 flex justify-between items-center">
|
|
<div>
|
|
{/* @ts-ignore */}
|
|
<BackLink label="Exit to sessions list" onClick={returnToList} />
|
|
</div>
|
|
<div>{`Watching ${assistMultiviewStore.sessions.length} of ${total} Live Sessions`}</div>
|
|
</div>
|
|
<div className="w-full h-full grid grid-cols-2 grid-rows-2">
|
|
{assistMultiviewStore.sortedSessions.map((session: Record<string, any>) => (
|
|
<div
|
|
key={session.key}
|
|
className="border hover:bg-active-blue hover:border-borderColor-primary relative group cursor-pointer"
|
|
>
|
|
<div onClick={(e) => openLiveSession(e, session.sessionId)} className="w-full h-full">
|
|
{session.agentToken ? (
|
|
<LivePlayer
|
|
isMultiview
|
|
customSession={session}
|
|
customAssistCredentials={assistCredentials}
|
|
/>
|
|
) : (
|
|
<div>Loading session</div>
|
|
)}
|
|
</div>
|
|
<SessionTileFooter
|
|
userDisplayName={session.userDisplayName}
|
|
sessionId={session.sessionId}
|
|
replaceSession={replaceSession}
|
|
deleteSession={deleteSession}
|
|
/>
|
|
</div>
|
|
))}
|
|
{placeholder.map((_, i) => (
|
|
<React.Fragment key={i}>
|
|
<EmptyTile onClick={openListModal} />
|
|
</React.Fragment>
|
|
))}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default observer(Multiview);
|