Files
ohif-viewer/platform/viewer/src/components/Header/Header.js
T

143 lines
3.9 KiB
JavaScript
Raw Normal View History

import './Header.css';
2019-01-08 10:48:57 +01:00
import { Link, withRouter } from 'react-router-dom';
import React, { Component } from 'react';
2019-08-13 15:36:46 -04:00
import { Dropdown } from '@ohif/ui';
import OHIFLogo from '../OHIFLogo/OHIFLogo.js';
import PropTypes from 'prop-types';
2019-08-13 15:36:46 -04:00
import { AboutModal } from '@ohif/ui';
import { hotkeysManager } from './../../App.js';
2019-06-18 14:33:39 -04:00
import { withTranslation } from 'react-i18next';
2019-01-08 10:48:57 +01:00
// Context
import AppContext from './../../context/AppContext';
class Header extends Component {
static contextType = AppContext;
static propTypes = {
home: PropTypes.bool.isRequired,
location: PropTypes.object.isRequired,
2019-06-05 17:09:54 -03:00
children: PropTypes.node,
t: PropTypes.func.isRequired,
userManager: PropTypes.object,
};
static defaultProps = {
home: true,
2019-05-29 08:39:54 -04:00
children: OHIFLogo(),
};
// onSave: data => {
2019-06-18 14:33:39 -04:00
// const contextName = store.getState().commandContext.context;
// const preferences = cloneDeep(store.getState().preferences);
// preferences[contextName] = data;
// dispatch(setUserPreferences(preferences));
// dispatch(setUserPreferencesModalOpen(false));
// OHIF.hotkeysUtil.setHotkeys(data.hotKeysData);
// },
// onResetToDefaults: () => {
// dispatch(setUserPreferences());
// dispatch(setUserPreferencesModalOpen(false));
// OHIF.hotkeysUtil.setHotkeys();
// },
constructor(props) {
super(props);
2019-06-16 22:51:28 -05:00
this.state = { isUserPreferencesOpen: false, isOpen: false };
2019-06-03 18:02:01 -03:00
this.loadOptions();
}
loadOptions() {
2019-06-05 17:09:54 -03:00
const { t } = this.props;
this.options = [
{
title: t('About'),
2019-06-16 22:51:28 -05:00
icon: { name: 'info' },
onClick: () => {
this.setState({
isOpen: true,
});
2019-05-28 13:18:40 -04:00
},
2019-05-29 08:39:54 -04:00
},
];
if (this.props.user && this.props.userManager) {
this.options.push({
title: t('Logout'),
icon: { name: 'power-off' },
onClick: () => {
this.props.userManager.signoutRedirect();
},
});
}
this.hotKeysData = hotkeysManager.hotkeyDefinitions;
}
onUserPreferencesSave({ windowLevelData, hotKeysData }) {
// console.log(windowLevelData);
// console.log(hotKeysData);
// TODO: Update hotkeysManager
// TODO: reset `this.hotKeysData`
}
2019-01-01 09:23:17 -02:00
2019-10-28 14:47:57 -04:00
// ANTD -- Hamburger, Drawer, Menu
render() {
2019-06-05 17:09:54 -03:00
const { t } = this.props;
const { appConfig = {} } = this.context;
const showStudyList =
appConfig.showStudyList !== undefined ? appConfig.showStudyList : true;
return (
2019-10-28 14:47:57 -04:00
<>
<div className="notification-bar">{t('INVESTIGATIONAL USE ONLY')}</div>
<div className={`entry-header ${this.props.home ? 'header-big' : ''}`}>
<div className="header-left-box">
{this.props.location && this.props.location.studyLink && (
<Link
to={this.props.location.studyLink}
className="header-btn header-viewerLink"
>
{t('Back to Viewer')}
</Link>
)}
{this.props.children}
{showStudyList && !this.props.home && (
<Link
className="header-btn header-studyListLinkSection"
to={{
pathname: '/',
state: { studyLink: this.props.location.pathname },
}}
>
{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" />
{/* TODO: We need a Modal service */}
<AboutModal
{...this.state}
onCancel={() =>
this.setState({
isOpen: false,
})
}
/>
</div>
</div>
2019-10-28 14:47:57 -04:00
</>
);
}
}
2019-01-08 10:48:57 +01:00
2019-05-30 15:41:15 -03:00
export default withTranslation('Header')(withRouter(Header));