Adjustments on hotkeys and presets

This commit is contained in:
Bruno Alves de Faria 2017-05-02 13:06:45 -03:00 committed by Erik Ziegler
parent e6b5a21ae2
commit 2f7722d569
10 changed files with 23 additions and 42 deletions

View File

@ -1,7 +0,0 @@
<template name="hotkeysDialog">
{{#dialogSimple (extend this dialogClass='dialog-hotkeys' title='Keyboard Shortcuts')}}
{{! >hotkeysForm this}}
<hr>
{{>windowLevelPresetsForm this}}
{{/dialogSimple}}
</template>

View File

@ -1,3 +0,0 @@
.dialog-hotkeys .modal-body
max-height: 80vh
overflow-y: auto

View File

@ -3,8 +3,7 @@
{{#each hotkeyInputInformation in getHotkeyInputInformationList}} {{#each hotkeyInputInformation in getHotkeyInputInformationList}}
{{>inputText (extend hotkeyInputInformation class='hotkey')}} {{>inputText (extend hotkeyInputInformation class='hotkey')}}
{{/each}} {{/each}}
<hr> <div class="clearfix form-buttons">
<div class="clearfix">
{{#button class='btn btn-primary pull-right' action='save'}}Save{{/button}} {{#button class='btn btn-primary pull-right' action='save'}}Save{{/button}}
{{#button class='btn btn-secondary pull-right m-r-1' action='resetDefaults'}}Reset to Defaults{{/button}} {{#button class='btn btn-secondary pull-right m-r-1' action='resetDefaults'}}Reset to Defaults{{/button}}
</div> </div>

View File

@ -71,11 +71,6 @@ Template.hotkeysForm.onCreated(() => {
}; };
}); });
// >>>> REMOVE ME
Meteor.startup(() => {
OHIF.ui.showDialog('hotkeysDialog', { contextName: 'viewer' });
});
Template.hotkeysForm.events({ Template.hotkeysForm.events({
'keydown .hotkey'(event, instance) { 'keydown .hotkey'(event, instance) {
if (instance.allowedKeys.indexOf(event.keyCode) > -1) { if (instance.allowedKeys.indexOf(event.keyCode) > -1) {

View File

@ -1,5 +1,2 @@
import './dialog.html';
import './dialog.styl';
import './form.html'; import './form.html';
import './form.js'; import './form.js';

View File

@ -13,8 +13,11 @@ OHIF.user.getData = key => {
// Check if there is an user logged in // Check if there is an user logged in
OHIF.user.validate(); OHIF.user.validate();
// Get the user object
const user = Meteor.user();
// Get user profile data // Get user profile data
const profile = Meteor.user().profile; const profile = user && user.profile;
// Get the user persistent data // Get the user persistent data
const data = profile && profile.persistent; const data = profile && profile.persistent;

View File

@ -47,9 +47,6 @@ Template.viewerMain.onRendered(() => {
OHIF.viewerbase.layoutManager = new LayoutManager(parentElement, studies); OHIF.viewerbase.layoutManager = new LayoutManager(parentElement, studies);
studyPrefetcher.setStudies(studies); studyPrefetcher.setStudies(studies);
// Enable hotkeys
hotkeyUtils.enableHotkeys();
Session.set('OHIFViewerMainRendered', Random.id()); Session.set('OHIFViewerMainRendered', Random.id());
}); });

View File

@ -4,7 +4,7 @@
<thead> <thead>
<tr> <tr>
<th>Preset</th> <th>Preset</th>
<th>Name</th> <th>Description</th>
<th>Window Level (WL)</th> <th>Window Level (WL)</th>
<th>Window Width (WW)</th> <th>Window Width (WW)</th>
</tr> </tr>
@ -20,8 +20,7 @@
{{/each}} {{/each}}
</tbody> </tbody>
</table> </table>
<hr> <div class="clearfix form-buttons">
<div class="clearfix">
{{#button class='btn btn-primary pull-right' action='save'}}Save{{/button}} {{#button class='btn btn-primary pull-right' action='save'}}Save{{/button}}
{{#button class='btn btn-secondary pull-right m-r-1' action='resetDefaults'}}Reset to Defaults{{/button}} {{#button class='btn btn-secondary pull-right m-r-1' action='resetDefaults'}}Reset to Defaults{{/button}}
</div> </div>

View File

@ -121,22 +121,24 @@ class WindowLevelPresetsManager {
} }
store(wlPresets) { store(wlPresets) {
const self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.storeFunction) { if (self.storeFunction) {
this.storeFunction(wlPresets).then(resolve).catch(reject); self.storeFunction(wlPresets).then(resolve).catch(reject);
} else if (Meteor.userId()) { } else if (Meteor.userId()) {
OHIF.user.setData(WL_STORAGE_KEY, wlPresets).then(resolve).catch(reject); OHIF.user.setData(WL_STORAGE_KEY, wlPresets).then(resolve).catch(reject);
} else { } else {
Session.setPersistent(WL_STORAGE_KEY, wlPresets); Session.setPersistent(WL_STORAGE_KEY, wlPresets);
resolve(); resolve();
} }
}).then(() => this.setOHIFWLPresets(wlPresets)); }).then(() => self.setOHIFWLPresets(wlPresets));
} }
retrieve() { retrieve() {
const self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.retrieveFunction) { if (self.retrieveFunction) {
this.retrieveFunction().then(resolve).catch(reject); self.retrieveFunction().then(resolve).catch(reject);
} else if (Meteor.userId()) { } else if (Meteor.userId()) {
try { try {
resolve(OHIF.user.getData(WL_STORAGE_KEY)); resolve(OHIF.user.getData(WL_STORAGE_KEY));
@ -150,14 +152,15 @@ class WindowLevelPresetsManager {
} }
load() { load() {
const self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.retrieve().then(wlPresets => { self.retrieve().then(wlPresets => {
if (wlPresets) { if (wlPresets) {
this.setOHIFWLPresets(wlPresets); self.setOHIFWLPresets(wlPresets);
} else { } else {
this.loadDefauls(); self.loadDefaults();
} }
}).catch(this.loadDefauls); }).catch(self.loadDefaults);
}); });
} }
@ -187,7 +190,7 @@ class WindowLevelPresetsManager {
this.changeObserver.changed(); this.changeObserver.changed();
} }
loadDefauls() { loadDefaults() {
this.setOHIFWLPresets(OHIF.viewer.defaultWLPresets); this.setOHIFWLPresets(OHIF.viewer.defaultWLPresets);
} }
@ -196,11 +199,6 @@ class WindowLevelPresetsManager {
} }
} }
// TODO: add this to a namespace definition
Meteor.startup(function() {
});
/** /**
* Export functions inside WLPresets namespace. * Export functions inside WLPresets namespace.
*/ */

View File

@ -217,6 +217,9 @@ Meteor.startup(function() {
OHIF.viewer.hotkeyFunctions = {}; OHIF.viewer.hotkeyFunctions = {};
OHIF.viewer.loadedSeriesData = {}; OHIF.viewer.loadedSeriesData = {};
// Enable hotkeys
hotkeyUtils.enableHotkeys();
}); });
// Define a jQuery reverse function // Define a jQuery reverse function