ohif-viewer/src/components/Header/Header.js

125 lines
3.3 KiB
JavaScript
Raw Normal View History

import './Header.css';
2019-06-18 20:33:39 +02:00
import './Header.css';
2019-01-08 10:48:57 +01:00
import { Link, withRouter } from 'react-router-dom';
import React, { Component } from 'react';
import { Dropdown } from 'react-viewerbase';
import OHIFLogo from '../OHIFLogo/OHIFLogo.js';
import PropTypes from 'prop-types';
// import { UserPreferencesModal } from 'react-viewerbase';
import { hotkeysManager } from './../../App.js';
2019-06-18 20:33:39 +02:00
import { withTranslation } from 'react-i18next';
2019-01-08 10:48:57 +01:00
class Header extends Component {
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,
};
static defaultProps = {
home: true,
2019-05-29 14:39:54 +02:00
children: OHIFLogo(),
};
// onSave: data => {
2019-06-18 20:33:39 +02: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);
this.state = { isUserPreferencesOpen: false };
// const onClick = this.toggleUserPreferences.bind(this);
2019-06-03 23:02:01 +02:00
this.loadOptions();
}
loadOptions() {
2019-06-05 22:09:54 +02:00
const { t } = this.props;
this.options = [
// {
2019-06-12 18:22:46 +02:00
// title: t('Preferences'),
// icon: { name: 'user' },
// onClick: onClick,
// },
{
title: t('About'),
2019-05-28 19:18:40 +02:00
icon: {
2019-06-08 00:54:35 +02:00
name: 'info',
2019-05-28 19:18:40 +02:00
},
2019-05-29 14:39:54 +02:00
link: 'http://ohif.org',
},
];
this.hotKeysData = hotkeysManager.hotkeyDefinitions;
}
toggleUserPreferences() {
const isOpen = this.state.isUserPreferencesOpen;
this.setState({
isUserPreferencesOpen: !isOpen,
});
}
onUserPreferencesSave({ windowLevelData, hotKeysData }) {
// console.log(windowLevelData);
// console.log(hotKeysData);
// TODO: Update hotkeysManager
// TODO: reset `this.hotKeysData`
}
render() {
2019-06-05 22:09:54 +02:00
const { t } = this.props;
return (
<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}
{!this.props.home && (
<Link
className="header-btn header-studyListLinkSection"
to={{
pathname: '/',
2019-05-29 14:39:54 +02:00
state: { studyLink: this.props.location.pathname },
}}
>
{t('Study list')}
</Link>
)}
</div>
2019-01-08 10:48:57 +01:00
<div className="header-menu">
<span className="research-use">{t('INVESTIGATIONAL USE ONLY')}</span>
<Dropdown title={t('Options')} list={this.options} align="right" />
2019-06-12 18:22:46 +02:00
{/* <ConnectedUserPreferencesModal /> */}
</div>
</div>
);
}
}
2019-01-08 10:48:57 +01:00
2019-05-30 20:41:15 +02:00
export default withTranslation('Header')(withRouter(Header));