diff --git a/src/SessionMonitor/index.js b/src/SessionMonitor/index.js index 06b3eada6b..0809a26612 100644 --- a/src/SessionMonitor/index.js +++ b/src/SessionMonitor/index.js @@ -83,6 +83,9 @@ export class SessionMonitor { if (response.type === 'UPDATE_POPUP') { this.popupShown = true; } + }).catch(() => { + // if API failed check if user is still logged in + this.notifyUserIfTheyAreNotLoggedIn(); }); }); } diff --git a/src/Workspace/index.jsx b/src/Workspace/index.jsx index bf3c79ca7d..b788640202 100644 --- a/src/Workspace/index.jsx +++ b/src/Workspace/index.jsx @@ -22,6 +22,7 @@ import galaxyIcon from '../img/icons/galaxy.svg'; import ohifIcon from '../img/icons/ohif-viewer.svg'; import WorkspaceOption from './WorkspaceOption'; import WorkspaceLogin from './WorkspaceLogin'; +import sessionMonitor from '../SessionMonitor'; class Workspace extends React.Component { constructor(props) { @@ -61,22 +62,25 @@ class Workspace extends React.Component { ); } - componentDidUpdate() { - // force workspace iframe acquire focus if it does not have yet - // to fix the noVNC workspace doesn't respond to keyboard event when came up - if (document.getElementsByClassName('workspace') - && document.getElementsByClassName('workspace')[1] - && document.getElementsByClassName('workspace')[1] !== document.activeElement) { - document.getElementsByClassName('workspace')[1].focus(); - } - } - componentWillUnmount() { if (this.state.interval) { clearInterval(this.state.interval); } } + oniframeLoad = (e) => { + // force workspace iframe acquire focus if it does not have yet + // to fix the noVNC workspace doesn't respond to keyboard event when came up + e.target.focus(); + + // add event listeners for sessionMonitor timeout + const iframeContent = e.target.contentDocument; + if (iframeContent) { + iframeContent.addEventListener('mousedown', () => sessionMonitor.updateUserActivity(), false); + iframeContent.addEventListener('keypress', () => sessionMonitor.updateUserActivity(), false); + } + } + getWorkspaceOptions = () => { fetchWithCreds({ path: `${workspaceOptionsUrl}`, @@ -253,6 +257,7 @@ class Workspace extends React.Component { title='Workspace' frameBorder='0' src={`${workspaceUrl}proxy/`} + onLoad={this.oniframeLoad} />
@@ -333,6 +338,7 @@ class Workspace extends React.Component { frameBorder='0' className='workspace__iframe' src={workspaceUrl} + onLoad={this.oniframeLoad} />
);