2019-06-06 20:41:31 +02:00
|
|
|
import React, { Component } from 'react';
|
2019-11-06 05:07:03 +01:00
|
|
|
import { Link, withRouter } from 'react-router-dom';
|
|
|
|
|
import { withTranslation } from 'react-i18next';
|
|
|
|
|
import PropTypes from 'prop-types';
|
2019-06-06 20:41:31 +02:00
|
|
|
|
2019-11-12 03:03:36 +01:00
|
|
|
import ConnectedUserPreferencesForm from '../../connectedComponents/ConnectedUserPreferencesForm';
|
|
|
|
|
import { Dropdown, AboutContent, withModal } from '@ohif/ui';
|
2019-01-24 14:00:01 +01:00
|
|
|
import OHIFLogo from '../OHIFLogo/OHIFLogo.js';
|
2019-11-06 05:07:03 +01:00
|
|
|
import './Header.css';
|
2019-11-12 03:03:36 +01:00
|
|
|
|
2019-09-06 20:31:26 +02:00
|
|
|
// Context
|
|
|
|
|
import AppContext from './../../context/AppContext';
|
|
|
|
|
|
2019-01-31 08:55:05 +01:00
|
|
|
class Header extends Component {
|
2019-09-06 20:31:26 +02:00
|
|
|
static contextType = AppContext;
|
2019-01-31 08:55:05 +01:00
|
|
|
static propTypes = {
|
|
|
|
|
home: PropTypes.bool.isRequired,
|
|
|
|
|
location: PropTypes.object.isRequired,
|
2019-06-05 22:09:54 +02:00
|
|
|
children: PropTypes.node,
|
|
|
|
|
t: PropTypes.func.isRequired,
|
2019-09-06 20:31:26 +02:00
|
|
|
userManager: PropTypes.object,
|
2019-11-06 05:07:03 +01:00
|
|
|
user: PropTypes.object,
|
|
|
|
|
modalContext: PropTypes.object,
|
2019-01-31 08:55:05 +01:00
|
|
|
};
|
2019-01-24 14:00:01 +01:00
|
|
|
|
2019-01-31 08:55:05 +01:00
|
|
|
static defaultProps = {
|
|
|
|
|
home: true,
|
2019-05-29 14:39:54 +02:00
|
|
|
children: OHIFLogo(),
|
2019-01-31 08:55:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
2019-11-12 03:03:36 +01:00
|
|
|
this.state = { isOpen: false };
|
2019-01-31 08:55:05 +01:00
|
|
|
|
2019-06-03 23:02:01 +02:00
|
|
|
this.loadOptions();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadOptions() {
|
2019-11-06 05:07:03 +01:00
|
|
|
const {
|
|
|
|
|
t,
|
|
|
|
|
user,
|
|
|
|
|
userManager,
|
|
|
|
|
modalContext: { show },
|
|
|
|
|
} = this.props;
|
2019-01-31 08:55:05 +01:00
|
|
|
this.options = [
|
|
|
|
|
{
|
2019-06-07 22:55:53 +02:00
|
|
|
title: t('About'),
|
2019-06-17 05:51:28 +02:00
|
|
|
icon: { name: 'info' },
|
2019-11-06 05:07:03 +01:00
|
|
|
onClick: () =>
|
|
|
|
|
show(AboutContent, {
|
|
|
|
|
title: t('OHIF Viewer - About'),
|
|
|
|
|
customClassName: 'AboutContent',
|
|
|
|
|
}),
|
2019-05-29 14:39:54 +02:00
|
|
|
},
|
2019-11-12 03:03:36 +01:00
|
|
|
{
|
|
|
|
|
title: 'Preferences ',
|
|
|
|
|
icon: {
|
|
|
|
|
name: 'user',
|
|
|
|
|
},
|
|
|
|
|
onClick: () =>
|
|
|
|
|
show(ConnectedUserPreferencesForm, {
|
|
|
|
|
title: t('User Preferences'),
|
|
|
|
|
}),
|
|
|
|
|
},
|
2019-01-31 08:55:05 +01:00
|
|
|
];
|
2019-06-06 20:41:31 +02:00
|
|
|
|
2019-11-06 05:07:03 +01:00
|
|
|
if (user && userManager) {
|
2019-07-21 16:43:42 +02:00
|
|
|
this.options.push({
|
|
|
|
|
title: t('Logout'),
|
2019-09-06 20:31:26 +02:00
|
|
|
icon: { name: 'power-off' },
|
2019-11-06 05:07:03 +01:00
|
|
|
onClick: () => userManager.signoutRedirect(),
|
2019-07-21 16:43:42 +02:00
|
|
|
});
|
|
|
|
|
}
|
2019-01-24 14:00:01 +01:00
|
|
|
}
|
2019-01-01 12:23:17 +01:00
|
|
|
|
2019-10-28 19:47:57 +01:00
|
|
|
// ANTD -- Hamburger, Drawer, Menu
|
2019-01-31 08:55:05 +01:00
|
|
|
render() {
|
2019-11-06 05:07:03 +01:00
|
|
|
const { t, home, location, children } = this.props;
|
2019-09-06 20:31:26 +02:00
|
|
|
const { appConfig = {} } = this.context;
|
2019-07-08 21:29:59 +02:00
|
|
|
const showStudyList =
|
2019-09-06 20:31:26 +02:00
|
|
|
appConfig.showStudyList !== undefined ? appConfig.showStudyList : true;
|
2019-01-31 08:55:05 +01:00
|
|
|
return (
|
2019-10-28 19:47:57 +01:00
|
|
|
<>
|
|
|
|
|
<div className="notification-bar">{t('INVESTIGATIONAL USE ONLY')}</div>
|
2019-11-06 05:07:03 +01:00
|
|
|
<div className={`entry-header ${home ? 'header-big' : ''}`}>
|
2019-10-28 19:47:57 +01:00
|
|
|
<div className="header-left-box">
|
2019-11-06 05:07:03 +01:00
|
|
|
{location && location.studyLink && (
|
2019-10-28 19:47:57 +01:00
|
|
|
<Link
|
2019-11-06 05:07:03 +01:00
|
|
|
to={location.studyLink}
|
2019-10-28 19:47:57 +01:00
|
|
|
className="header-btn header-viewerLink"
|
|
|
|
|
>
|
|
|
|
|
{t('Back to Viewer')}
|
|
|
|
|
</Link>
|
|
|
|
|
)}
|
|
|
|
|
|
2019-11-06 05:07:03 +01:00
|
|
|
{children}
|
2019-10-28 19:47:57 +01:00
|
|
|
|
2019-11-06 05:07:03 +01:00
|
|
|
{showStudyList && !home && (
|
2019-10-28 19:47:57 +01:00
|
|
|
<Link
|
|
|
|
|
className="header-btn header-studyListLinkSection"
|
|
|
|
|
to={{
|
|
|
|
|
pathname: '/',
|
2019-11-06 05:07:03 +01:00
|
|
|
state: { studyLink: location.pathname },
|
2019-10-28 19:47:57 +01:00
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{t('Study list')}
|
|
|
|
|
</Link>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="header-menu">
|
|
|
|
|
<span className="research-use">
|
|
|
|
|
{t('INVESTIGATIONAL USE ONLY')}
|
|
|
|
|
</span>
|
|
|
|
|
<Dropdown title={t('Options')} list={this.options} align="right" />
|
|
|
|
|
</div>
|
2019-01-31 08:55:05 +01:00
|
|
|
</div>
|
2019-10-28 19:47:57 +01:00
|
|
|
</>
|
2019-01-31 08:55:05 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-08 10:48:57 +01:00
|
|
|
|
2019-11-06 05:07:03 +01:00
|
|
|
export default withTranslation(['Header', 'AboutModal'])(
|
|
|
|
|
withRouter(withModal(Header))
|
|
|
|
|
);
|