lint(curly): consistent use of curly brackets in codebase (#3584)
This commit is contained in:
1 parent
9ae3d9f769
commit
5d435424e2
113 files changed
+1501
-1056
No files matched your search
@@ -25,10 +25,18 @@ function convertToInt(input) {
|
||||
function padFour(input) {
|
||||
const l = input.length;
|
||||
|
||||
if (l == 0) return '0000';
|
||||
if (l == 1) return '000' + input;
|
||||
if (l == 2) return '00' + input;
|
||||
if (l == 3) return '0' + input;
|
||||
if (l === 0) {
|
||||
return '0000';
|
||||
}
|
||||
if (l === 1) {
|
||||
return '000' + input;
|
||||
}
|
||||
if (l === 2) {
|
||||
return '00' + input;
|
||||
}
|
||||
if (l === 3) {
|
||||
return '0' + input;
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'isomorphic-base64'
|
||||
import 'isomorphic-base64';
|
||||
import user from '../user';
|
||||
|
||||
/**
|
||||
|
||||
@@ -175,7 +175,9 @@ export class CommandsManager {
|
||||
toRun: Command | Commands | Command[] | undefined,
|
||||
options?: Record<string, unknown>
|
||||
): unknown {
|
||||
if (!toRun) return;
|
||||
if (!toRun) {
|
||||
return;
|
||||
}
|
||||
const commands =
|
||||
(Array.isArray(toRun) && toRun) ||
|
||||
((toRun as Command).commandName && [toRun]) ||
|
||||
|
||||
@@ -454,7 +454,9 @@ class MetadataProvider {
|
||||
}
|
||||
|
||||
getUIDsFromImageID(imageId) {
|
||||
if (!imageId) throw new Error('MetadataProvider::Empty imageId');
|
||||
if (!imageId) {
|
||||
throw new Error('MetadataProvider::Empty imageId');
|
||||
}
|
||||
// TODO: adding csiv here is not really correct. Probably need to use
|
||||
// metadataProvider.addImageIdToUIDs(imageId, {
|
||||
// StudyInstanceUID,
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
function getNestedObject(shallowObject) {
|
||||
const nestedObject = {};
|
||||
for (let key in shallowObject) {
|
||||
if (!shallowObject.hasOwnProperty(key)) continue;
|
||||
if (!shallowObject.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
const value = shallowObject[key];
|
||||
const propertyArray = key.split('.');
|
||||
let currentObject = nestedObject;
|
||||
@@ -28,7 +30,9 @@ function getShallowObject(nestedObject) {
|
||||
const shallowObject = {};
|
||||
const putValues = (baseKey, nestedObject, resultObject) => {
|
||||
for (let key in nestedObject) {
|
||||
if (!nestedObject.hasOwnProperty(key)) continue;
|
||||
if (!nestedObject.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
let currentKey = baseKey ? `${baseKey}.${key}` : key;
|
||||
const currentValue = nestedObject[key];
|
||||
if (typeof currentValue === 'object') {
|
||||
|
||||
@@ -11,7 +11,7 @@ const extensionManager = {
|
||||
registeredExtensionIds: [],
|
||||
moduleEntries: {},
|
||||
|
||||
getModuleEntry: function (id) {
|
||||
getModuleEntry: function(id) {
|
||||
return this.moduleEntries[id];
|
||||
},
|
||||
};
|
||||
@@ -20,7 +20,7 @@ const commandsManager = {};
|
||||
|
||||
const ohifOverlayItem = {
|
||||
id: 'ohif.overlayItem',
|
||||
content: function (props) {
|
||||
content: function(props) {
|
||||
return {
|
||||
label: this.label,
|
||||
value: props[this.attribute],
|
||||
|
||||
@@ -12,8 +12,12 @@ const flattenNestedStrings = (
|
||||
strs: NestedStrings | string,
|
||||
ret?: Record<string, string>
|
||||
): Record<string, string> => {
|
||||
if (!ret) ret = {};
|
||||
if (!strs) return ret;
|
||||
if (!ret) {
|
||||
ret = {};
|
||||
}
|
||||
if (!strs) {
|
||||
return ret;
|
||||
}
|
||||
if (Array.isArray(strs)) {
|
||||
for (const val of strs) {
|
||||
flattenNestedStrings(val, ret);
|
||||
@@ -81,7 +85,9 @@ export default class CustomizationService extends PubSubService {
|
||||
this.extensionManager.registeredExtensionIds.forEach(extensionId => {
|
||||
const key = `${extensionId}.customizationModule.default`;
|
||||
const defaultCustomizations = this.findExtensionValue(key);
|
||||
if (!defaultCustomizations) return;
|
||||
if (!defaultCustomizations) {
|
||||
return;
|
||||
}
|
||||
const { value } = defaultCustomizations;
|
||||
this.addReference(value, true);
|
||||
});
|
||||
@@ -172,9 +178,13 @@ export default class CustomizationService extends PubSubService {
|
||||
* type into the new type, allowing default behaviour to be configured.
|
||||
*/
|
||||
public transform(customization: Customization): Customization {
|
||||
if (!customization) return customization;
|
||||
if (!customization) {
|
||||
return customization;
|
||||
}
|
||||
const { customizationType } = customization;
|
||||
if (!customizationType) return customization;
|
||||
if (!customizationType) {
|
||||
return customization;
|
||||
}
|
||||
const parent = this.getCustomization(customizationType);
|
||||
const result = parent
|
||||
? Object.assign(Object.create(parent), customization)
|
||||
@@ -242,7 +252,9 @@ export default class CustomizationService extends PubSubService {
|
||||
* or a customization itself.
|
||||
*/
|
||||
addReference(value?: Obj | string, isGlobal = true, id?: string): void {
|
||||
if (!value) return;
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
if (typeof value === 'string') {
|
||||
const extensionValue = this.findExtensionValue(value);
|
||||
// The child of a reference is only a set of references when an array,
|
||||
@@ -265,7 +277,9 @@ export default class CustomizationService extends PubSubService {
|
||||
* or customization.
|
||||
*/
|
||||
addReferences(references?: Obj | Obj[], isGlobal = true): void {
|
||||
if (!references) return;
|
||||
if (!references) {
|
||||
return;
|
||||
}
|
||||
if (Array.isArray(references)) {
|
||||
references.forEach(item => {
|
||||
this.addReference(item, isGlobal);
|
||||
|
||||
@@ -157,7 +157,9 @@ export default class DisplaySetService extends PubSubService {
|
||||
}
|
||||
|
||||
public deleteDisplaySet(displaySetInstanceUID) {
|
||||
if (!displaySetInstanceUID) return;
|
||||
if (!displaySetInstanceUID) {
|
||||
return;
|
||||
}
|
||||
const { activeDisplaySets, activeDisplaySetsMap } = this;
|
||||
|
||||
const activeDisplaySetsIndex = activeDisplaySets.findIndex(
|
||||
@@ -314,7 +316,9 @@ export default class DisplaySetService extends PubSubService {
|
||||
}
|
||||
// This means that all instances already existed or got added to
|
||||
// existing display sets, and had an invalidated event fired
|
||||
if (!instances.length) return allDisplaySets;
|
||||
if (!instances.length) {
|
||||
return allDisplaySets;
|
||||
}
|
||||
}
|
||||
|
||||
if (!instances.length) {
|
||||
@@ -329,7 +333,9 @@ export default class DisplaySetService extends PubSubService {
|
||||
// creating additional display sets using the sop class handler
|
||||
displaySets = handler.getDisplaySetsFromSeries(instances);
|
||||
|
||||
if (!displaySets || !displaySets.length) continue;
|
||||
if (!displaySets || !displaySets.length) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// applying hp-defined viewport settings to the displaysets
|
||||
displaySets.forEach(ds => {
|
||||
|
||||
@@ -134,7 +134,7 @@ function checkHpsBestMatch(hps) {
|
||||
displaySetOptions: {
|
||||
id: 'displaySetSelector',
|
||||
options: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -192,6 +192,6 @@ describe('HangingProtocolService', () => {
|
||||
it('matches best image match', () => {
|
||||
checkHpsBestMatch(hangingProtocolService);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -86,7 +86,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
metadata.ModalitiesInStudy ??
|
||||
(metadata.series || []).reduce((prev, curr) => {
|
||||
const { Modality } = curr;
|
||||
if (Modality && prev.indexOf(Modality) == -1) prev.push(Modality);
|
||||
if (Modality && prev.indexOf(Modality) == -1) {
|
||||
prev.push(Modality);
|
||||
}
|
||||
return prev;
|
||||
}, []),
|
||||
},
|
||||
@@ -200,7 +202,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
* protocolId, stageIndex, stageId and activeStudyUID
|
||||
*/
|
||||
public getState(): HangingProtocol.HPInfo {
|
||||
if (!this.protocol) return;
|
||||
if (!this.protocol) {
|
||||
return;
|
||||
}
|
||||
return {
|
||||
protocolId: this.protocol.id,
|
||||
stageIndex: this.stageIndex,
|
||||
@@ -257,8 +261,12 @@ export default class HangingProtocolService extends PubSubService {
|
||||
* @returns protocol - the protocol with the given id
|
||||
*/
|
||||
public getProtocolById(protocolId: string): HangingProtocol.Protocol {
|
||||
if (!protocolId) return;
|
||||
if (protocolId === this.protocol?.id) return this.protocol;
|
||||
if (!protocolId) {
|
||||
return;
|
||||
}
|
||||
if (protocolId === this.protocol?.id) {
|
||||
return this.protocol;
|
||||
}
|
||||
const protocol = this.protocols.get(protocolId);
|
||||
if (!protocol) {
|
||||
throw new Error(`No protocol ${protocolId} found`);
|
||||
@@ -697,7 +705,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
const { id } = displaySet;
|
||||
const displaySetMatchDetail = displaySetMatchDetails.get(id);
|
||||
|
||||
const { displaySetInstanceUID: oldDisplaySetInstanceUID } = displaySetMatchDetail;
|
||||
const {
|
||||
displaySetInstanceUID: oldDisplaySetInstanceUID,
|
||||
} = displaySetMatchDetail;
|
||||
|
||||
const displaySetInstanceUID =
|
||||
displaySet.id === displaySetSelectorId
|
||||
@@ -730,8 +740,12 @@ export default class HangingProtocolService extends PubSubService {
|
||||
);
|
||||
}
|
||||
|
||||
if (options === null) return options;
|
||||
if (typeof options !== 'object') return options;
|
||||
if (options === null) {
|
||||
return options;
|
||||
}
|
||||
if (typeof options !== 'object') {
|
||||
return options;
|
||||
}
|
||||
|
||||
// If options is an object with a custom attribute, compute a new options object
|
||||
if (options.custom) {
|
||||
@@ -892,7 +906,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
if (stageId) {
|
||||
for (let i = 0; i < stages.length; i++) {
|
||||
const stage = stages[i];
|
||||
if (stage.id === stageId && stage.status !== 'disabled') return i;
|
||||
if (stage.id === stageId && stage.status !== 'disabled') {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -905,7 +921,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
let firstNotDisabled: number;
|
||||
|
||||
for (let i = 0; i < stages.length; i++) {
|
||||
if (stages[i].status === 'enabled') return i;
|
||||
if (stages[i].status === 'enabled') {
|
||||
return i;
|
||||
}
|
||||
if (firstNotDisabled === undefined && stages[i].status !== 'disabled') {
|
||||
firstNotDisabled = i;
|
||||
}
|
||||
@@ -979,7 +997,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
if (stageId !== undefined) {
|
||||
return protocol.stages.findIndex(it => it.id === stageId);
|
||||
}
|
||||
if (stageIndex !== undefined) return stageIndex;
|
||||
if (stageIndex !== undefined) {
|
||||
return stageIndex;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1030,7 +1050,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
const protocol = this.protocol;
|
||||
const stage = protocol.stages[stageIdx];
|
||||
const defaultViewport = stage.defaultViewport || protocol.defaultViewport;
|
||||
if (!defaultViewport) return;
|
||||
if (!defaultViewport) {
|
||||
return;
|
||||
}
|
||||
|
||||
const useViewport = { ...defaultViewport };
|
||||
return this._matchViewport(useViewport, options);
|
||||
@@ -1152,12 +1174,18 @@ export default class HangingProtocolService extends PubSubService {
|
||||
offset: number,
|
||||
options: HangingProtocol.SetProtocolOptions = {}
|
||||
): HangingProtocol.DisplaySetMatchDetails {
|
||||
if (!matchDetails) return;
|
||||
if (offset === 0) return matchDetails;
|
||||
if (!matchDetails) {
|
||||
return;
|
||||
}
|
||||
if (offset === 0) {
|
||||
return matchDetails;
|
||||
}
|
||||
const { matchingScores = [] } = matchDetails;
|
||||
if (offset === -1) {
|
||||
const { inDisplay } = options;
|
||||
if (!inDisplay) return matchDetails;
|
||||
if (!inDisplay) {
|
||||
return matchDetails;
|
||||
}
|
||||
for (let i = 0; i < matchDetails.matchingScores.length; i++) {
|
||||
if (
|
||||
inDisplay.indexOf(
|
||||
@@ -1184,12 +1212,16 @@ export default class HangingProtocolService extends PubSubService {
|
||||
id: string,
|
||||
displaySetUID: string
|
||||
): void {
|
||||
if (match.displaySetInstanceUID === displaySetUID) return;
|
||||
if (match.displaySetInstanceUID === displaySetUID) {
|
||||
return;
|
||||
}
|
||||
if (!match.matchingScores) {
|
||||
throw new Error('No matchingScores found in ' + match);
|
||||
}
|
||||
for (const subMatch of match.matchingScores) {
|
||||
if (subMatch.displaySetInstanceUID === displaySetUID) return;
|
||||
if (subMatch.displaySetInstanceUID === displaySetUID) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new Error(
|
||||
`Reused viewport details ${id} with ds ${displaySetUID} not valid`
|
||||
@@ -1391,21 +1423,23 @@ export default class HangingProtocolService extends PubSubService {
|
||||
const matchActiveOnly = this.protocol.numberOfPriorsReferenced === -1;
|
||||
this.studies.forEach(study => {
|
||||
// Skip non-active if active only
|
||||
if (matchActiveOnly && this.activeStudy !== study) return;
|
||||
if (matchActiveOnly && this.activeStudy !== study) {
|
||||
return;
|
||||
}
|
||||
|
||||
const studyDisplaySets = this.displaySets.filter(
|
||||
it => it.StudyInstanceUID === study.StudyInstanceUID
|
||||
it => it.StudyInstanceUID === study.StudyInstanceUID
|
||||
);
|
||||
|
||||
const studyMatchDetails = this.protocolEngine.findMatch(
|
||||
study,
|
||||
studyMatchingRules,
|
||||
{
|
||||
studies: this.studies,
|
||||
displaySets: studyDisplaySets,
|
||||
allDisplaySets: this.displaySets,
|
||||
displaySetMatchDetails: this.displaySetMatchDetails,
|
||||
}
|
||||
study,
|
||||
studyMatchingRules,
|
||||
{
|
||||
studies: this.studies,
|
||||
displaySets: studyDisplaySets,
|
||||
allDisplaySets: this.displaySets,
|
||||
displaySetMatchDetails: this.displaySetMatchDetails,
|
||||
}
|
||||
);
|
||||
|
||||
// Prevent bestMatch from being updated if the matchDetails' required attribute check has failed
|
||||
@@ -1414,10 +1448,10 @@ export default class HangingProtocolService extends PubSubService {
|
||||
}
|
||||
|
||||
this.debug(
|
||||
'study',
|
||||
study.StudyInstanceUID,
|
||||
'display sets #',
|
||||
studyDisplaySets.length
|
||||
'study',
|
||||
study.StudyInstanceUID,
|
||||
'display sets #',
|
||||
studyDisplaySets.length
|
||||
);
|
||||
studyDisplaySets.forEach(displaySet => {
|
||||
const {
|
||||
@@ -1426,15 +1460,15 @@ export default class HangingProtocolService extends PubSubService {
|
||||
displaySetInstanceUID,
|
||||
} = displaySet;
|
||||
const seriesMatchDetails = this.protocolEngine.findMatch(
|
||||
displaySet,
|
||||
seriesMatchingRules,
|
||||
// Todo: why we have images here since the matching type does not have it
|
||||
{
|
||||
studies: this.studies,
|
||||
instance: displaySet.images?.[0],
|
||||
displaySetMatchDetails: this.displaySetMatchDetails,
|
||||
displaySets: studyDisplaySets,
|
||||
}
|
||||
displaySet,
|
||||
seriesMatchingRules,
|
||||
// Todo: why we have images here since the matching type does not have it
|
||||
{
|
||||
studies: this.studies,
|
||||
instance: displaySet.images?.[0],
|
||||
displaySetMatchDetails: this.displaySetMatchDetails,
|
||||
displaySets: studyDisplaySets,
|
||||
}
|
||||
);
|
||||
|
||||
// Prevent bestMatch from being updated if the matchDetails' required attribute check has failed
|
||||
|
||||
+9
-3
@@ -13,7 +13,9 @@ const isDisplaySetFromUrl = (displaySet): boolean => {
|
||||
params
|
||||
);
|
||||
const initialSOPInstanceUID = getSplitParam('initialsopinstanceuid', params);
|
||||
if (!initialSeriesInstanceUID && !initialSOPInstanceUID) return false;
|
||||
if (!initialSeriesInstanceUID && !initialSOPInstanceUID) {
|
||||
return false;
|
||||
}
|
||||
const isSeriesMatch =
|
||||
!initialSeriesInstanceUID ||
|
||||
initialSeriesInstanceUID.some(
|
||||
@@ -32,9 +34,13 @@ const isDisplaySetFromUrl = (displaySet): boolean => {
|
||||
*/
|
||||
function sopInstanceLocation(displaySets) {
|
||||
const displaySet = displaySets?.[0];
|
||||
if (!displaySet) return;
|
||||
if (!displaySet) {
|
||||
return;
|
||||
}
|
||||
const initialSOPInstanceUID = getSplitParam('initialsopinstanceuid');
|
||||
if (!initialSOPInstanceUID) return;
|
||||
if (!initialSOPInstanceUID) {
|
||||
return;
|
||||
}
|
||||
|
||||
const index = displaySet.instances.findIndex(instance =>
|
||||
initialSOPInstanceUID.includes(instance.SOPInstanceUID)
|
||||
|
||||
+4
-3
@@ -1,5 +1,6 @@
|
||||
export default (study, extraData) => {
|
||||
const ret = extraData?.displaySets?.filter(ds => ds.numImageFrames>0)?.length;
|
||||
console.log("number of display sets with images", ret);
|
||||
const ret = extraData?.displaySets?.filter(ds => ds.numImageFrames > 0)
|
||||
?.length;
|
||||
console.log('number of display sets with images', ret);
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
export default (study, extraData) => extraData?.displaySets?.map(ds => ds.SeriesDescription);
|
||||
export default (study, extraData) =>
|
||||
extraData?.displaySets?.map(ds => ds.SeriesDescription);
|
||||
@@ -111,10 +111,12 @@ validate.validators.includes = function(value, options, key) {
|
||||
const includedValues = testValue.filter(el => dicomArrayValue.includes(el));
|
||||
if (includedValues.length === 0) {
|
||||
return `${key} must include at least one of the following values: ${testValue.join(
|
||||
', '
|
||||
', '
|
||||
)}`;
|
||||
}
|
||||
} else return `${key} ${testValue} must be an array`;
|
||||
} else {
|
||||
return `${key} ${testValue} must be an array`;
|
||||
}
|
||||
// else if (!value.includes(testValue)) {
|
||||
// return `${key} ${value} must include ${testValue}`;
|
||||
// }
|
||||
@@ -151,7 +153,9 @@ validate.validators.doesNotInclude = function(value, options, key) {
|
||||
if (includedValues.length > 0) {
|
||||
return `${key} must not include the following value: ${includedValues}`;
|
||||
}
|
||||
} else return `${key} ${testValue} must be an array`;
|
||||
} else {
|
||||
return `${key} ${testValue} must be an array`;
|
||||
}
|
||||
};
|
||||
// Ignore case contains.
|
||||
// options testValue MUST be in lower case already, otherwise it won't match
|
||||
@@ -175,31 +179,31 @@ validate.validators.containsI = function(value, options, key) {
|
||||
const testValue = getTestValue(options);
|
||||
if (Array.isArray(value)) {
|
||||
if (
|
||||
value.some(
|
||||
item => !validate.validators.containsI(item.toLowerCase(), options, key)
|
||||
)
|
||||
value.some(
|
||||
item => !validate.validators.containsI(item.toLowerCase(), options, key)
|
||||
)
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
return `No item of ${value.join(',')} contains ${JSON.stringify(
|
||||
testValue
|
||||
testValue
|
||||
)}`;
|
||||
}
|
||||
if (Array.isArray(testValue)) {
|
||||
if (
|
||||
testValue.some(
|
||||
subTest =>
|
||||
!validate.validators.containsI(value, subTest.toLowerCase(), key)
|
||||
)
|
||||
testValue.some(
|
||||
subTest =>
|
||||
!validate.validators.containsI(value, subTest.toLowerCase(), key)
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
return `${key} must contain at least one of ${testValue.join(',')}`;
|
||||
}
|
||||
if (
|
||||
testValue &&
|
||||
value.indexOf &&
|
||||
value.toLowerCase().indexOf(testValue.toLowerCase()) === -1
|
||||
testValue &&
|
||||
value.indexOf &&
|
||||
value.toLowerCase().indexOf(testValue.toLowerCase()) === -1
|
||||
) {
|
||||
return key + 'must contain any case of' + testValue;
|
||||
}
|
||||
@@ -227,14 +231,14 @@ validate.validators.contains = function(value, options, key) {
|
||||
return undefined;
|
||||
}
|
||||
return `No item of ${value.join(',')} contains ${JSON.stringify(
|
||||
testValue
|
||||
testValue
|
||||
)}`;
|
||||
}
|
||||
if (Array.isArray(testValue)) {
|
||||
if (
|
||||
testValue.some(
|
||||
subTest => !validate.validators.contains(value, subTest, key)
|
||||
)
|
||||
testValue.some(
|
||||
subTest => !validate.validators.contains(value, subTest, key)
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -454,11 +458,13 @@ validate.validators.range = function(value, options, key) {
|
||||
if (value === undefined || value < min || value > max) {
|
||||
return `${key} with value ${value} must be between ${min} and ${max}`;
|
||||
}
|
||||
} else return `${key} must be an array of length 2`;
|
||||
} else {
|
||||
return `${key} must be an array of length 2`;
|
||||
}
|
||||
};
|
||||
|
||||
validate.validators.notNull = value =>
|
||||
value === null || value === undefined ? 'Value is null' : undefined;
|
||||
value === null || value === undefined ? 'Value is null' : undefined;
|
||||
const getTestValue = options => {
|
||||
if (Array.isArray(options)) {
|
||||
return options.map(option => option?.value ?? option);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -40,7 +40,7 @@ export default class StateSyncService extends PubSubService {
|
||||
this.configuration = configuration || {};
|
||||
}
|
||||
|
||||
public init(extensionManager: ExtensionManager): void { }
|
||||
public init(extensionManager: ExtensionManager): void {}
|
||||
|
||||
/** Registers a new sync store called `id`. The state
|
||||
* defines how the state is stored, and any default clearing of the
|
||||
|
||||
@@ -66,7 +66,9 @@ export default class ToolbarService extends PubSubService {
|
||||
* called with {...commandOptions,...options}
|
||||
*/
|
||||
recordInteraction(interaction, options?: Record<string, unknown>) {
|
||||
if (!interaction) return;
|
||||
if (!interaction) {
|
||||
return;
|
||||
}
|
||||
const commandsManager = this._commandsManager;
|
||||
const { groupId, itemId, interactionType, commands } = interaction;
|
||||
|
||||
|
||||
@@ -35,10 +35,16 @@ const addUniqueIndex = (arr, key, viewports, isUpdatingSameViewport) => {
|
||||
};
|
||||
|
||||
const getLutId = (ds): string => {
|
||||
if (!ds || !ds.options) return DEFAULT;
|
||||
if (ds.options.id) return ds.options.id;
|
||||
if (!ds || !ds.options) {
|
||||
return DEFAULT;
|
||||
}
|
||||
if (ds.options.id) {
|
||||
return ds.options.id;
|
||||
}
|
||||
const arr = Object.entries(ds.options).map(([key, val]) => `${key}=${val}`);
|
||||
if (!arr.length) return DEFAULT;
|
||||
if (!arr.length) {
|
||||
return DEFAULT;
|
||||
}
|
||||
return arr.join(JOIN_STR);
|
||||
};
|
||||
|
||||
@@ -93,7 +99,9 @@ export type PresentationIds = {
|
||||
* @returns PresentationIds
|
||||
*/
|
||||
const getPresentationIds = (viewport, viewports): PresentationIds => {
|
||||
if (!viewport) return;
|
||||
if (!viewport) {
|
||||
return;
|
||||
}
|
||||
const {
|
||||
viewportOptions,
|
||||
displaySetInstanceUIDs,
|
||||
@@ -108,7 +116,9 @@ const getPresentationIds = (viewport, viewports): PresentationIds => {
|
||||
const lutPresentationArr = [lutId];
|
||||
|
||||
const positionPresentationArr = [orientation || 'acquisition'];
|
||||
if (id) positionPresentationArr.push(id);
|
||||
if (id) {
|
||||
positionPresentationArr.push(id);
|
||||
}
|
||||
|
||||
for (const uid of displaySetInstanceUIDs) {
|
||||
positionPresentationArr.push(uid);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
const absoluteUrl = path => {
|
||||
let absolutePath = '/';
|
||||
|
||||
if (!path) return absolutePath;
|
||||
if (!path) {
|
||||
return absolutePath;
|
||||
}
|
||||
|
||||
// TODO: Find another way to get root url
|
||||
const absoluteUrl = window.location.origin;
|
||||
|
||||
@@ -9,12 +9,16 @@ function debounce(func, wait, immediate) {
|
||||
args = arguments;
|
||||
var later = function() {
|
||||
timeout = null;
|
||||
if (!immediate) func.apply(context, args);
|
||||
if (!immediate) {
|
||||
func.apply(context, args);
|
||||
}
|
||||
};
|
||||
var callNow = immediate && !timeout;
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(later, wait);
|
||||
if (callNow) func.apply(context, args);
|
||||
if (callNow) {
|
||||
func.apply(context, args);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,8 @@ const imagesTypes = [
|
||||
* @returns {boolean} - true if it has image data
|
||||
*/
|
||||
export const isImage = SOPClassUID => {
|
||||
if (!SOPClassUID) return false;
|
||||
if (!SOPClassUID) {
|
||||
return false;
|
||||
}
|
||||
return imagesTypes.indexOf(SOPClassUID) !== -1;
|
||||
};
|
||||
@@ -1,4 +1,10 @@
|
||||
const LOW_PRIORITY_MODALITIES = Object.freeze(['SEG', 'KO', 'PR', 'SR', 'RTSTRUCT']);
|
||||
const LOW_PRIORITY_MODALITIES = Object.freeze([
|
||||
'SEG',
|
||||
'KO',
|
||||
'PR',
|
||||
'SR',
|
||||
'RTSTRUCT',
|
||||
]);
|
||||
|
||||
export default function isLowPriorityModality(Modality) {
|
||||
return LOW_PRIORITY_MODALITIES.includes(Modality);
|
||||
|
||||
@@ -2,11 +2,15 @@ export default function makeCancelable(thenable) {
|
||||
let isCanceled = false;
|
||||
const promise = Promise.resolve(thenable).then(
|
||||
function(result) {
|
||||
if (isCanceled) throw Object.freeze({ isCanceled });
|
||||
if (isCanceled) {
|
||||
throw Object.freeze({ isCanceled });
|
||||
}
|
||||
return result;
|
||||
},
|
||||
function(error) {
|
||||
if (isCanceled) throw Object.freeze({ isCanceled, error });
|
||||
if (isCanceled) {
|
||||
throw Object.freeze({ isCanceled, error });
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -18,8 +18,9 @@ export default function fetchPaletteColorLookupTableData(
|
||||
) {
|
||||
const { PaletteColorLookupTableUID } = item;
|
||||
const paletteData = item[tag];
|
||||
if (paletteData === undefined && PaletteColorLookupTableUID === undefined)
|
||||
if (paletteData === undefined && PaletteColorLookupTableUID === undefined) {
|
||||
return;
|
||||
}
|
||||
// performance optimization - read UID and cache by UID
|
||||
return _getPaletteColor(item[tag], item[descriptorTag]);
|
||||
}
|
||||
@@ -28,7 +29,9 @@ function _getPaletteColor(paletteColorLookupTableData, lutDescriptor) {
|
||||
const numLutEntries = lutDescriptor[0];
|
||||
const bits = lutDescriptor[2];
|
||||
|
||||
if (!paletteColorLookupTableData) return undefined;
|
||||
if (!paletteColorLookupTableData) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const arrayBufferToPaletteColorLUT = arraybuffer => {
|
||||
const lut = [];
|
||||
|
||||
@@ -124,7 +124,9 @@ function getOverallProgress(list) {
|
||||
status.total++;
|
||||
if (isValidProgress(task.progress)) {
|
||||
status.partial += task.progress;
|
||||
if (task.progress === 1.0 && task.failed) status.failures++;
|
||||
if (task.progress === 1.0 && task.failed) {
|
||||
status.failures++;
|
||||
}
|
||||
}
|
||||
task = task.next;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ const compareSeriesDateTime = (a, b) => {
|
||||
const defaultSeriesSort = (a, b) => {
|
||||
const seriesNumberA = a.SeriesNumber ?? a.seriesNumber;
|
||||
const seriesNumberB = b.SeriesNumber ?? b.seriesNumber;
|
||||
if (seriesNumberA === seriesNumberB) return compareSeriesDateTime(a, b);
|
||||
if (seriesNumberA === seriesNumberB) {
|
||||
return compareSeriesDateTime(a, b);
|
||||
}
|
||||
return seriesNumberA - seriesNumberB;
|
||||
};
|
||||
|
||||
@@ -67,8 +69,11 @@ const sortStudySeries = (
|
||||
seriesSortingCriteria = seriesSortCriteria.default,
|
||||
sortFunction = null
|
||||
) => {
|
||||
if (typeof sortFunction === 'function') return sortFunction(series);
|
||||
else return series.sort(seriesSortingCriteria);
|
||||
if (typeof sortFunction === 'function') {
|
||||
return sortFunction(series);
|
||||
} else {
|
||||
return series.sort(seriesSortingCriteria);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/** Splits a list of stirngs by commas within the strings */
|
||||
const splitComma = (strings: string[]): string[] => {
|
||||
if (!strings) return null;
|
||||
if (!strings) {
|
||||
return null;
|
||||
}
|
||||
for (let i = 0; i < strings.length; i++) {
|
||||
const comma = strings[i].indexOf(',');
|
||||
if (comma !== -1) {
|
||||
@@ -24,7 +26,9 @@ const getSplitParam = (
|
||||
const sourceKey = [...params.keys()].find(
|
||||
it => it.toLowerCase() === lowerCaseKey
|
||||
);
|
||||
if (!sourceKey) return;
|
||||
if (!sourceKey) {
|
||||
return;
|
||||
}
|
||||
return splitComma(params.getAll(sourceKey));
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user