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

140 lines
3.8 KiB
JavaScript
Raw Normal View History

import React, { Component } from 'react';
2019-11-05 23:07:03 -05:00
import { Link, withRouter } from 'react-router-dom';
import { withTranslation } from 'react-i18next';
import PropTypes from 'prop-types';
2019-08-13 15:36:46 -04:00
import { Dropdown } from '@ohif/ui';
2019-11-05 23:07:03 -05:00
import { AboutContent } from '@ohif/ui';
import { withModal } from '@ohif/ui';
import OHIFLogo from '../OHIFLogo/OHIFLogo.js';
import { hotkeysManager } from './../../App.js';
2019-11-05 23:07:03 -05:00
import './Header.css';
// 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,
2019-11-05 23:07:03 -05:00
user: PropTypes.object,
modalContext: 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-11-05 23:07:03 -05:00
const {
t,
user,
userManager,
modalContext: { show },
} = this.props;
this.options = [
{
title: t('About'),
2019-06-16 22:51:28 -05:00
icon: { name: 'info' },
2019-11-05 23:07:03 -05:00
onClick: () =>
show(AboutContent, {
title: t('OHIF Viewer - About'),
customClassName: 'AboutContent',
}),
2019-05-29 08:39:54 -04:00
},
];
2019-11-05 23:07:03 -05:00
if (user && userManager) {
this.options.push({
title: t('Logout'),
icon: { name: 'power-off' },
2019-11-05 23:07:03 -05:00
onClick: () => 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-11-05 23:07:03 -05:00
const { t, home, location, children } = 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>
2019-11-05 23:07:03 -05:00
<div className={`entry-header ${home ? 'header-big' : ''}`}>
2019-10-28 14:47:57 -04:00
<div className="header-left-box">
2019-11-05 23:07:03 -05:00
{location && location.studyLink && (
2019-10-28 14:47:57 -04:00
<Link
2019-11-05 23:07:03 -05:00
to={location.studyLink}
2019-10-28 14:47:57 -04:00
className="header-btn header-viewerLink"
>
{t('Back to Viewer')}
</Link>
)}
2019-11-05 23:07:03 -05:00
{children}
2019-10-28 14:47:57 -04:00
2019-11-05 23:07:03 -05:00
{showStudyList && !home && (
2019-10-28 14:47:57 -04:00
<Link
className="header-btn header-studyListLinkSection"
to={{
pathname: '/',
2019-11-05 23:07:03 -05:00
state: { studyLink: location.pathname },
2019-10-28 14:47:57 -04: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>
</div>
2019-10-28 14:47:57 -04:00
</>
);
}
}
2019-01-08 10:48:57 +01:00
2019-11-05 23:07:03 -05:00
export default withTranslation(['Header', 'AboutModal'])(
withRouter(withModal(Header))
);