ohif-viewer/OHIFViewer/client/components/ohifViewer/ohifViewer.js
Egor Lezhnin 9486522552 feat(google-cloud): Add support for Google Cloud Healthcare API DICOM Store Switch (#325)
* NOTASK: PoC for loading data from Healthcare API

* NOTASK: PoC for loading data from Healthcare API fix

* Add sample dialog for loading test dicom-picker

* Fix incorrect promise resolving

* NOTASK: PoC for loading dicom store

* Add web-components as git submodules. (Probably will be changed later)

* Add rough dicomStore picker

* Add dataset selector

* NOTASK: QIDO metadata first draft

* NOTASK: Not Implemented error for color images

* NOTASK: clean-up

* Dicom files uploader intermediate version

* NOTASK: Accept header

* NOTASK: docker configs

* NOTASK: fix

* NOTASK: howTo

* Add draft of DICOM uploader

* Add missing files

* Fix error with missing clientId

* Update submodule

* NOTASK: HowTo

* NOTASK: config for dev

* NOTASK: new docker file

* clean-up

* Update GCP web-components

* Add integration with async web components

* Fix errors in nginx.conf

* Structured reports views basic implementation

* NOTASK: qido -> wado

* NOTASK: config fix

* NOTASK: dirty copy-paste implementation

* Add "Change dicom store" button.
Add an ability to clear date.
Fix bug, when OAuth dosn't work if URL is not /

* Fix studylist filtering

* Fix dockerfile

* NOTASK: meteor update

* NOTASK: fix of package structure

* NOTASK: merge fix

* improvements

Move check for now SR into SR modal
Use simple button to open SR modal
Remove button styling
cleanup

* copy SR data retrieval to wado

* make search of SR simpler

* Codestyle fix

* NOTASK: palette color error message

* Fix date filter.
Fix server settings on first loading.
Add SR and PS buttons

* NOTASK: PS is now hidden by default

* NOTASK: dirty solution

* NOTASK:  new wadoimage lib version

* Fix PS and SR buttons

* Make modal dialogs vertically centered

* Update web components. Quick UI fixes

* Add missing files to the previous commit

* NOTASK:  show-hide for PS

* NOTASK:  show-hide for PS

* NOTASK:  fix of min-max PixelValue bug

* Add "sign out" functionality for Google OAuth. Update web-components.

* intermediate commit

* Add demo signin page

* Beautifying demo sign in page

* NOTASK:  merge

* NOTASK:  clean-up

* Use npm for getting healthcare-api-adapter instead of git submodule.

* NOTASK:  clean-up

* meteor update

* clean-up

* clean-up

* Clean up code

* Update healthcare-api-adapter version. Add location to dicom store path. Fix buttons style.

* Downgrade meteor and packages to master version. Use meteor-build-client-fixed2
2019-03-22 16:42:26 +01:00

116 lines
3.8 KiB
JavaScript

import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { Session } from 'meteor/session';
import { Router } from 'meteor/clinical:router';
import { ReactiveVar } from 'meteor/reactive-var';
import { OHIF } from 'meteor/ohif:core';
Template.ohifViewer.onCreated(() => {
const instance = Template.instance();
instance.headerClasses = new ReactiveVar('');
Session.set("IsStudyListReady", true);;
const headerItems = [{
action: () => OHIF.ui.showDialog('serverInformationModal'),
text: 'Server Information',
icon: 'fa fa-server fa-lg',
separatorAfter: true
}, {
action: () => OHIF.ui.showDialog('themeSelectorModal'),
text: 'Themes',
iconClasses: 'theme',
iconSvgUse: 'packages/ohif_viewerbase/assets/icons.svg#theme',
separatorAfter: false
}, {
action: () => OHIF.ui.showDialog('userPreferencesDialog'),
text: 'Preferences',
icon: 'fa fa-user',
separatorAfter: true
}, {
action: () => OHIF.ui.showDialog('aboutModal'),
text: 'About',
icon: 'fa fa-info'
}];
const isUserLoggedIn = OHIF.user.userLoggedIn();
const isDemoUserLoggedIn = OHIF.demoMode && OHIF.demoMode.userLoggedIn();
if (isUserLoggedIn || isDemoUserLoggedIn) {
headerItems.push({
action: isDemoUserLoggedIn ? OHIF.demoMode.logout : OHIF.user.logout,
text: 'Logout',
iconClasses: 'logout',
iconSvgUse: 'packages/ohif_viewerbase/assets/user-menu-icons.svg#logout'
});
}
OHIF.header.dropdown.setItems(headerItems);
instance.autorun(() => {
const currentRoute = Router.current();
if (!currentRoute) return;
const routeName = currentRoute.route.getName();
const isViewer = routeName.indexOf('viewer') === 0;
// Add or remove the strech class from body
$(document.body)[isViewer ? 'addClass' : 'removeClass']('stretch');
// Set the header on its bigger version if the viewer is not opened
instance.headerClasses.set(isViewer ? '' : 'header-big');
// Set the viewer open state on session
Session.set('ViewerOpened', isViewer);
});
if (OHIF.demoMode && OHIF.demoMode.userLoggedIn())
OHIF.demoMode.setDemoServerConfig();
else if (OHIF.gcloud && OHIF.gcloud.isEnabled()) {
const server = OHIF.servers.getCurrentServer();
if (!server || !server.isCloud) {
Session.set("IsStudyListReady", false);
OHIF.gcloud.showDicomStorePicker({canClose: OHIF.demoMode}).then(config => {
if (!config) {
if (OHIF.demoMode)
Router.go('/demo-signin');
return;
}
OHIF.servers.applyCloudServerConfig(config);
Session.set("IsStudyListReady", true);
});
}
}
});
Template.ohifViewer.events({
'click .js-toggle-studyList'(event, instance) {
event.preventDefault();
const isViewer = Session.get('ViewerOpened');
if (isViewer) {
Router.go('studylist');
} else {
const { studyInstanceUids } = OHIF.viewer.data;
if (studyInstanceUids) {
Router.go('viewerStudies', { studyInstanceUids });
}
}
},
});
Template.ohifViewer.helpers({
studyListToggleText() {
const instance = Template.instance();
const isViewer = Session.get('ViewerOpened');
if (isViewer) {
instance.hasViewerData = true;
return 'Study list';
}
return instance.hasViewerData ? 'Back to viewer' : '';
},
isStudyListReady() {
return !!Session.get('IsStudyListReady');
}
});