Removing trailing 'frame' query string and allowing usage of first series' instance as thumbnail

This commit is contained in:
Bruno Alves de Faria 2017-08-29 11:46:22 -03:00
parent 335c3526cc
commit ae39f1841d
2 changed files with 10 additions and 2 deletions

View File

@ -180,6 +180,11 @@ export const UISettings = new SimpleSchema({
type: Boolean, type: Boolean,
label: 'Define if the series\' images shall be sorted by incoming order. Sort by Instance Number by default.', label: 'Define if the series\' images shall be sorted by incoming order. Sort by Instance Number by default.',
defaultValue: false defaultValue: false
},
useMiddleSeriesInstanceAsThumbnail: {
type: Boolean,
label: 'Define if the middle instance of a series will be used as thumbnail. If not, the first instance will be used.',
defaultValue: true
} }
}); });

View File

@ -1,3 +1,4 @@
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating'; import { Template } from 'meteor/templating';
import { Tracker } from 'meteor/tracker'; import { Tracker } from 'meteor/tracker';
import { Session } from 'meteor/session'; import { Session } from 'meteor/session';
@ -8,16 +9,18 @@ Template.imageThumbnail.onCreated(() => {
// Get the image ID for current thumbnail // Get the image ID for current thumbnail
instance.getThumbnailImageId = () => { instance.getThumbnailImageId = () => {
const settingPath = 'public.ui.useMiddleSeriesInstanceAsThumbnail';
const useMiddleFrame = OHIF.utils.ObjectPath.get(Meteor.settings, settingPath);
const stack = instance.data.thumbnail.stack; const stack = instance.data.thumbnail.stack;
const lastIndex = (stack.numImageFrames || stack.images.length || 1) - 1; const lastIndex = (stack.numImageFrames || stack.images.length || 1) - 1;
let imageIndex = Math.floor(lastIndex / 2); let imageIndex = useMiddleFrame ? Math.floor(lastIndex / 2) : 0;
let imageInstance; let imageInstance;
if (stack.isMultiFrame) { if (stack.isMultiFrame) {
imageInstance = stack.images[0]; imageInstance = stack.images[0];
} else { } else {
imageInstance = stack.images[imageIndex]; imageInstance = stack.images[imageIndex];
imageIndex = 0; imageIndex = undefined;
} }
return imageInstance.getImageId(imageIndex, true); return imageInstance.getImageId(imageIndex, true);