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

126 lines
3.4 KiB
JavaScript
Raw Normal View History

import './Header.css';
2019-05-30 06:46:45 +02:00
import { Link, withRouter } from 'react-router-dom';
import React, { Component } from 'react';
2019-05-30 06:46:45 +02:00
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-01-08 10:48:57 +01:00
class Header extends Component {
static propTypes = {
home: PropTypes.bool.isRequired,
location: PropTypes.object.isRequired,
2019-05-28 19:19:06 +02:00
children: PropTypes.node,
2019-05-30 06:46:45 +02:00
};
static defaultProps = {
home: true,
2019-05-28 19:19:06 +02:00
children: OHIFLogo(),
2019-05-30 06:46:45 +02:00
};
// onSave: data => {
// const contextName = window.store.getState().commandContext.context;
// const preferences = cloneDeep(window.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) {
2019-05-30 06:46:45 +02:00
super(props);
this.state = { isUserPreferencesOpen: false };
const onClick = this.toggleUserPreferences.bind(this);
this.options = [
// {
// title: 'Preferences ',
// icon: {
// name: 'user',
// },
// onClick: onClick,
// },
{
title: 'About',
2019-05-28 19:18:40 +02:00
icon: {
name: 'info',
},
link: 'http://ohif.org',
},
2019-05-30 06:46:45 +02:00
];
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() {
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"
>
Back to Viewer
</Link>
)}
{this.props.children}
{!this.props.home && (
<Link
className="header-btn header-studyListLinkSection"
to={{
pathname: '/',
2019-05-28 19:19:06 +02:00
state: { studyLink: this.props.location.pathname },
}}
>
Study list
</Link>
)}
</div>
2019-01-08 10:48:57 +01:00
<div className="header-menu">
<span className="research-use">INVESTIGATIONAL USE ONLY</span>
<Dropdown title="Options" list={this.options} align="right" />
{/* <UserPreferencesModal
isOpen={this.state.isUserPreferencesOpen}
onCancel={this.toggleUserPreferences.bind(this)}
onSave={this.toggleUserPreferences.bind(this)}
onResetToDefaults={this.toggleUserPreferences.bind(this)}
windowLevelData={{}}
hotKeysData={this.hotKeysData}
/> */}
</div>
</div>
2019-05-30 06:46:45 +02:00
);
}
}
2019-01-08 10:48:57 +01:00
2019-05-30 06:46:45 +02:00
export default withRouter(Header);