lint(curly): consistent use of curly brackets in codebase (#3584)

This commit is contained in:
Alireza 2023-08-09 10:07:33 -04:00 committed by GitHub
parent 9ae3d9f769
commit 5d435424e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
113 changed files with 1501 additions and 1056 deletions

View File

@ -21,6 +21,10 @@
"version": "detect"
}
},
"rules": {
// Enforce consistent brace style for all control statements for readability
"curly": "error"
},
"globals": {
"cy": true,
"before": true,

View File

@ -2,13 +2,12 @@ import React from 'react';
import { useTranslation } from 'react-i18next';
import { Icon, Tooltip } from '@ohif/ui';
export default function _getStatusComponent({ isHydrated, onStatusClick }) {
let ToolTipMessage = null;
let StatusIcon = null;
const {t} = useTranslation("Common");
const loadStr = t("LOAD");
const { t } = useTranslation('Common');
const loadStr = t('LOAD');
switch (isHydrated) {
case true:
@ -18,7 +17,7 @@ export default function _getStatusComponent({ isHydrated, onStatusClick }) {
<div>This Segmentation is loaded in the segmentation panel</div>
);
break;
case false:
case false:
StatusIcon = () => <Icon name="status-untracked" />;
ToolTipMessage = () => <div>Click LOAD to load segmentation.</div>;
@ -42,7 +41,6 @@ export default function _getStatusComponent({ isHydrated, onStatusClick }) {
</div>
);
return (
<>
{ToolTipMessage && (

View File

@ -308,8 +308,9 @@ function _measurementReferencesSOPInstanceUID(
measurement.coords[0].ReferencedSOPSequence[0]?.ReferencedFrameNumber) ||
1;
if (frameNumber && Number(frameNumber) !== Number(ReferencedFrameNumber))
if (frameNumber && Number(frameNumber) !== Number(ReferencedFrameNumber)) {
return false;
}
for (let j = 0; j < coords.length; j++) {
const coord = coords[j];
@ -670,7 +671,9 @@ function _getReferencedImagesList(ImagingMeasurementReportContentSequence) {
_getSequenceAsArray(ImageLibraryGroup.ContentSequence).forEach(item => {
const { ReferencedSOPSequence } = item;
if (!ReferencedSOPSequence) return;
if (!ReferencedSOPSequence) {
return;
}
for (const ref of _getSequenceAsArray(ReferencedSOPSequence)) {
if (ref.ReferencedSOPClassUID) {
const { ReferencedSOPClassUID, ReferencedSOPInstanceUID } = ref;
@ -687,7 +690,9 @@ function _getReferencedImagesList(ImagingMeasurementReportContentSequence) {
}
function _getSequenceAsArray(sequence) {
if (!sequence) return [];
if (!sequence) {
return [];
}
return Array.isArray(sequence) ? sequence : [sequence];
}

View File

@ -314,18 +314,16 @@ export default class DICOMSRDisplayTool extends AnnotationTool {
);
let canvasCorners;
if (rotation == 90 || rotation == 270) {
canvasCorners = <Array<Types.Point2>>(
utilities.math.ellipse.getCanvasEllipseCorners([
canvasCoordinates[2],
canvasCoordinates[3],
canvasCoordinates[0],
canvasCoordinates[1],
])
);
canvasCorners = utilities.math.ellipse.getCanvasEllipseCorners([
canvasCoordinates[2],
canvasCoordinates[3],
canvasCoordinates[0],
canvasCoordinates[1],
]) as Array<Types.Point2>;
} else {
canvasCorners = <Array<Types.Point2>>(
utilities.math.ellipse.getCanvasEllipseCorners(canvasCoordinates)
);
canvasCorners = utilities.math.ellipse.getCanvasEllipseCorners(
canvasCoordinates
) as Array<Types.Point2>;
}
const lineUID = `${index}`;

View File

@ -3,12 +3,16 @@ import { DisplaySetService, classes } from '@ohif/core';
const ImageSet = classes.ImageSet;
const findInstance = (measurement, displaySetService: DisplaySetService) => {
const { displaySetInstanceUID, ReferencedSOPInstanceUID: sopUid } =
measurement;
const {
displaySetInstanceUID,
ReferencedSOPInstanceUID: sopUid,
} = measurement;
const referencedDisplaySet = displaySetService.getDisplaySetByUID(
displaySetInstanceUID
);
if (!referencedDisplaySet.images) return;
if (!referencedDisplaySet.images) {
return;
}
return referencedDisplaySet.images.find(it => it.SOPInstanceUID === sopUid);
};
@ -24,8 +28,12 @@ const findReferencedInstances = (
const instanceById = {};
for (const measurement of displaySet.measurements) {
const { imageId } = measurement;
if (!imageId) continue;
if (instanceById[imageId]) continue;
if (!imageId) {
continue;
}
if (instanceById[imageId]) {
continue;
}
const instance = findInstance(measurement, displaySetService);
if (!instance) {

View File

@ -9,7 +9,9 @@ const findInstanceMetadataBySopInstanceUID = (displaySets, SOPInstanceUID) => {
let instanceFound;
displaySets.find(displaySet => {
if (!displaySet.images) return false;
if (!displaySet.images) {
return false;
}
instanceFound = displaySet.images.find(
instanceMetadata =>

View File

@ -12,20 +12,26 @@ const CORNERSTONE_3D_TOOLS_SOURCE_VERSION = '0.1';
const supportedLegacyCornerstoneTags = ['cornerstoneTools@^4.0.0'];
const convertCode = (codingValues, code) => {
if (!code || code.CodingSchemeDesignator === 'CORNERSTONEJS') return;
if (!code || code.CodingSchemeDesignator === 'CORNERSTONEJS') {
return;
}
const ref = `${code.CodingSchemeDesignator}:${code.CodeValue}`;
const ret = { ...codingValues[ref], ref, ...code, text: code.CodeMeaning };
return ret;
};
const convertSites = (codingValues, sites) => {
if (!sites || !sites.length) return;
if (!sites || !sites.length) {
return;
}
const ret = [];
// Do as a loop to convert away from Proxy instances
for (let i = 0; i < sites.length; i++) {
// Deal with irregular conversion from dcmjs
const site = convertCode(codingValues, sites[i][0] || sites[i]);
if (site) ret.push(site);
if (site) {
ret.push(site);
}
}
return (ret.length && ret) || undefined;
};
@ -287,7 +293,7 @@ function _mapLegacyDataSet(dataset) {
return dataset;
}
const toArray = function (x) {
const toArray = function(x) {
return Array.isArray(x) ? x : [x];
};

View File

@ -445,7 +445,9 @@ function _subscribeToJumpToMeasurementEvents(
props => {
cacheJumpToMeasurementEvent = props;
const { viewportIndex: jumpIndex, measurement, isConsumed } = props;
if (!measurement || isConsumed) return;
if (!measurement || isConsumed) {
return;
}
if (cacheJumpToMeasurementEvent.cornerstoneViewport === undefined) {
// Decide on which viewport should handle this
cacheJumpToMeasurementEvent.cornerstoneViewport = cornerstoneViewportService.getViewportIndexToJump(
@ -482,7 +484,9 @@ function _checkForCachedJumpToMeasurementEvents(
viewportGridService,
cornerstoneViewportService
) {
if (!cacheJumpToMeasurementEvent) return;
if (!cacheJumpToMeasurementEvent) {
return;
}
if (cacheJumpToMeasurementEvent.isConsumed) {
cacheJumpToMeasurementEvent = null;
return;
@ -490,7 +494,9 @@ function _checkForCachedJumpToMeasurementEvents(
const displaysUIDs = displaySets.map(
displaySet => displaySet.displaySetInstanceUID
);
if (!displaysUIDs?.length) return;
if (!displaysUIDs?.length) {
return;
}
// Jump to measurement if the measurement exists
const { measurement } = cacheJumpToMeasurementEvent;

View File

@ -36,8 +36,9 @@ function CornerstoneOverlays(props) {
}
if (viewportData) {
const viewportInfo =
cornerstoneViewportService.getViewportInfoByIndex(viewportIndex);
const viewportInfo = cornerstoneViewportService.getViewportInfoByIndex(
viewportIndex
);
if (viewportInfo?.viewportOptions?.customViewportProps?.hideOverlays) {
return null;

View File

@ -35,9 +35,15 @@ const DEFAULT_CONTEXT_MENU_CLICKS = {
function getEventName(evt) {
const button = evt.detail.event.which;
const nameArr = [];
if (evt.detail.event.altKey) nameArr.push('alt');
if (evt.detail.event.ctrlKey) nameArr.push('ctrl');
if (evt.detail.event.shiftKey) nameArr.push('shift');
if (evt.detail.event.altKey) {
nameArr.push('alt');
}
if (evt.detail.event.ctrlKey) {
nameArr.push('ctrl');
}
if (evt.detail.event.shiftKey) {
nameArr.push('shift');
}
nameArr.push('button');
nameArr.push(button);
return nameArr.join('');
@ -73,7 +79,9 @@ function initContextMenu({
function elementEnabledHandler(evt) {
const { viewportId, element } = evt.detail;
const viewportInfo = cornerstoneViewportService.getViewportInfo(viewportId);
if (!viewportInfo) return;
if (!viewportInfo) {
return;
}
const viewportIndex = viewportInfo.getViewportIndex();
// TODO check update upstream
setEnabledElement(viewportIndex, element);

View File

@ -21,9 +21,15 @@ const DEFAULT_DOUBLE_CLICK = {
*/
function getDoubleClickEventName(evt: CustomEvent) {
const nameArr = [];
if (evt.detail.event.altKey) nameArr.push('alt');
if (evt.detail.event.ctrlKey) nameArr.push('ctrl');
if (evt.detail.event.shiftKey) nameArr.push('shift');
if (evt.detail.event.altKey) {
nameArr.push('alt');
}
if (evt.detail.event.ctrlKey) {
nameArr.push('ctrl');
}
if (evt.detail.event.shiftKey) {
nameArr.push('shift');
}
nameArr.push('doubleClick');
return nameArr.join('');
}

View File

@ -190,18 +190,26 @@ class CornerstoneViewportService extends PubSubService
public setPresentations(viewport, presentations?: Presentations): void {
const properties = presentations?.lutPresentation?.properties;
if (properties) viewport.setProperties(properties);
if (properties) {
viewport.setProperties(properties);
}
const camera = presentations?.positionPresentation?.camera;
if (camera) viewport.setCamera(camera);
if (camera) {
viewport.setCamera(camera);
}
}
public getPresentation(viewportIndex: number): Presentation {
const viewportInfo = this.viewportsInfo.get(viewportIndex);
if (!viewportInfo) return;
if (!viewportInfo) {
return;
}
const { viewportType, presentationIds } = viewportInfo.getViewportOptions();
const csViewport = this.getCornerstoneViewportByIndex(viewportIndex);
if (!csViewport) return;
if (!csViewport) {
return;
}
const properties = csViewport.getProperties();
if (properties.isComputedVOI) {
@ -408,7 +416,9 @@ class CornerstoneViewportService extends PubSubService
viewport.setStack(imageIds, initialImageIndexToUse).then(() => {
viewport.setProperties(properties);
const camera = presentations.positionPresentation?.camera;
if (camera) viewport.setCamera(camera);
if (camera) {
viewport.setCamera(camera);
}
});
}
@ -745,7 +755,10 @@ class CornerstoneViewportService extends PubSubService
const viewport = this.getCornerstoneViewport(viewportId);
const viewportCamera = viewport.getCamera();
if (viewport instanceof VolumeViewport || viewport instanceof VolumeViewport3D) {
if (
viewport instanceof VolumeViewport ||
viewport instanceof VolumeViewport3D
) {
this._setVolumeViewport(viewport, viewportData, viewportInfo).then(() => {
if (keepCamera) {
viewport.setCamera(viewportCamera);

View File

@ -95,7 +95,9 @@ const dataContains = (
displaySetUID: string,
imageId?: string
): boolean => {
if (data.displaySetInstanceUID === displaySetUID) return true;
if (data.displaySetInstanceUID === displaySetUID) {
return true;
}
if (imageId && data.isCompositeStack && data.imageIds) {
return !!data.imageIds.find(dataId => dataId === imageId);
}
@ -123,7 +125,9 @@ class ViewportInfo {
* OR if it is a composite stack and contains the given imageId
*/
public contains(displaySetUID: string, imageId: string): boolean {
if (!this.viewportData?.data) return false;
if (!this.viewportData?.data) {
return false;
}
if (this.viewportData.data.length) {
return !!this.viewportData.data.find(data =>

View File

@ -212,7 +212,9 @@ export default class DicomFileUploader extends PubSubService {
}
private _checkDicomFile(arrayBuffer: ArrayBuffer) {
if (arrayBuffer.length <= 132) return false;
if (arrayBuffer.length <= 132) {
return false;
}
const arr = new Uint8Array(arrayBuffer.slice(128, 132));
// bytes from 128 to 132 must be "DICM"
return Array.from('DICM').every((char, i) => char.charCodeAt(0) === arr[i]);

View File

@ -35,8 +35,9 @@ function callInputDialog(
const onSubmitHandler = ({ action, value }) => {
switch (action.id) {
case 'save':
if (typeof validateFunc === 'function' && !validateFunc(value.label))
if (typeof validateFunc === 'function' && !validateFunc(value.label)) {
return;
}
callback(value.label, action.id);
break;

View File

@ -7,8 +7,12 @@
* @returns [] reordered to be breadth first traversal of lists
*/
export default function interleave(lists) {
if (!lists || !lists.length) return [];
if (lists.length === 1) return lists[0];
if (!lists || !lists.length) {
return [];
}
if (lists.length === 1) {
return lists[0];
}
console.time('interleave');
const useLists = [...lists];
const ret = [];

View File

@ -3,7 +3,7 @@ import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
import { utils } from '@ohif/core';
const Angle = {
toAnnotation: measurement => { },
toAnnotation: measurement => {},
/**
* Maps cornerstone annotation event data to measurement service format.
@ -198,7 +198,9 @@ function getDisplayText(mappedAnnotations, displaySet) {
const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
if (angle === undefined) return displayText;
if (angle === undefined) {
return displayText;
}
const roundedAngle = utils.roundNumber(angle, 2);
displayText.push(
`${roundedAngle} ${unit} (S: ${SeriesNumber}${instanceText}${frameText})`

View File

@ -3,7 +3,7 @@ import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
import { utils } from '@ohif/core';
const CobbAngle = {
toAnnotation: measurement => { },
toAnnotation: measurement => {},
/**
* Maps cornerstone annotation event data to measurement service format.
@ -198,7 +198,9 @@ function getDisplayText(mappedAnnotations, displaySet) {
const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
if (angle === undefined) return displayText;
if (angle === undefined) {
return displayText;
}
const roundedAngle = utils.roundNumber(angle, 2);
displayText.push(
`${roundedAngle} ${unit} (S: ${SeriesNumber}${instanceText}${frameText})`

View File

@ -32,12 +32,15 @@ const Length = {
throw new Error('Tool not supported');
}
const { SOPInstanceUID, SeriesInstanceUID, StudyInstanceUID } =
getSOPInstanceAttributes(
referencedImageId,
cornerstoneViewportService,
viewportId
);
const {
SOPInstanceUID,
SeriesInstanceUID,
StudyInstanceUID,
} = getSOPInstanceAttributes(
referencedImageId,
cornerstoneViewportService,
viewportId
);
let displaySet;
@ -101,8 +104,11 @@ function getMappedAnnotations(annotation, displaySetService) {
);
}
const { SOPInstanceUID, SeriesInstanceUID, frameNumber } =
getSOPInstanceAttributes(referencedImageId);
const {
SOPInstanceUID,
SeriesInstanceUID,
frameNumber,
} = getSOPInstanceAttributes(referencedImageId);
const displaySet = displaySetService.getDisplaySetForSOPInstanceUID(
SOPInstanceUID,
@ -173,8 +179,12 @@ function getDisplayText(mappedAnnotations, displaySet) {
const displayText = [];
// Area is the same for all series
const { length, SeriesNumber, SOPInstanceUID, frameNumber } =
mappedAnnotations[0];
const {
length,
SeriesNumber,
SOPInstanceUID,
frameNumber,
} = mappedAnnotations[0];
const instance = displaySet.images.find(
image => image.SOPInstanceUID === SOPInstanceUID
@ -188,7 +198,9 @@ function getDisplayText(mappedAnnotations, displaySet) {
const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
if (length === null || length === undefined) return displayText;
if (length === null || length === undefined) {
return displayText;
}
const roundedLength = utils.roundNumber(length, 2);
displayText.push(
`${roundedLength} mm (S: ${SeriesNumber}${instanceText}${frameText})`

View File

@ -2,7 +2,7 @@ import SUPPORTED_TOOLS from './constants/supportedTools';
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
const PlanarFreehandROI = {
toAnnotation: measurement => { },
toAnnotation: measurement => {},
/**
* Maps cornerstone annotation event data to measurement service format.

View File

@ -25,12 +25,15 @@ const RectangleROI = {
throw new Error('Tool not supported');
}
const { SOPInstanceUID, SeriesInstanceUID, StudyInstanceUID } =
getSOPInstanceAttributes(
referencedImageId,
CornerstoneViewportService,
viewportId
);
const {
SOPInstanceUID,
SeriesInstanceUID,
StudyInstanceUID,
} = getSOPInstanceAttributes(
referencedImageId,
CornerstoneViewportService,
viewportId
);
let displaySet;
@ -95,8 +98,11 @@ function getMappedAnnotations(annotation, DisplaySetService) {
);
}
const { SOPInstanceUID, SeriesInstanceUID, frameNumber } =
getSOPInstanceAttributes(referencedImageId);
const {
SOPInstanceUID,
SeriesInstanceUID,
frameNumber,
} = getSOPInstanceAttributes(referencedImageId);
const displaySet = DisplaySetService.getDisplaySetForSOPInstanceUID(
SOPInstanceUID,

View File

@ -46,7 +46,9 @@ function createDicomJSONApi(dicomJsonConfig) {
const implementation = {
initialize: async ({ query, url }) => {
if (!url) url = query.get('url');
if (!url) {
url = query.get('url');
}
let metaData = getMetaDataByURL(url);
// if we have already cached the data from this specific url
@ -212,7 +214,9 @@ function createDicomJSONApi(dicomJsonConfig) {
return obj;
});
storeInstances(instances);
if (index === numberOfSeries - 1) setSuccessFlag();
if (index === numberOfSeries - 1) {
setSuccessFlag();
}
});
},
},

View File

@ -12,8 +12,12 @@ const END_MODALITIES = {
};
const compareValue = (v1, v2, def = 0) => {
if (v1 === v2) return def;
if (v1 < v2) return -1;
if (v1 === v2) {
return def;
}
if (v1 < v2) {
return -1;
}
return 1;
};

View File

@ -1,4 +1,4 @@
export default function (wadoRoot) {
export default function(wadoRoot) {
return {
series: (StudyInstanceUID, SeriesInstanceUID) => {
return new Promise((resolve, reject) => {
@ -15,7 +15,7 @@ export default function (wadoRoot) {
console.log(xhr);
xhr.onreadystatechange = function () {
xhr.onreadystatechange = function() {
//Call a function when the state changes.
if (xhr.readyState == 4) {
switch (xhr.status) {

View File

@ -36,12 +36,16 @@ export default class StaticWadoClient extends api.DICOMwebClient {
* @returns
*/
async searchForStudies(options) {
if (!this.staticWado) return super.searchForStudies(options);
if (!this.staticWado) {
return super.searchForStudies(options);
}
const searchResult = await super.searchForStudies(options);
const { queryParams } = options;
if (!queryParams) return searchResult;
if (!queryParams) {
return searchResult;
}
const lowerParams = this.toLowerParams(queryParams);
const filtered = searchResult.filter(study => {
@ -63,11 +67,15 @@ export default class StaticWadoClient extends api.DICOMwebClient {
}
async searchForSeries(options) {
if (!this.staticWado) return super.searchForSeries(options);
if (!this.staticWado) {
return super.searchForSeries(options);
}
const searchResult = await super.searchForSeries(options);
const { queryParams } = options;
if (!queryParams) return searchResult;
if (!queryParams) {
return searchResult;
}
const lowerParams = this.toLowerParams(queryParams);
const filtered = searchResult.filter(series => {
@ -112,8 +120,12 @@ export default class StaticWadoClient extends api.DICOMwebClient {
actual = actual.Alphabetic;
}
if (typeof actual == 'string') {
if (actual.length === 0) return true;
if (desired.length === 0 || desired === '*') return true;
if (actual.length === 0) {
return true;
}
if (desired.length === 0 || desired === '*') {
return true;
}
if (desired[0] === '*' && desired[desired.length - 1] === '*') {
// console.log(`Comparing ${actual} to ${desired.substring(1, desired.length - 1)}`)
return actual.indexOf(desired.substring(1, desired.length - 1)) != -1;
@ -131,9 +143,13 @@ export default class StaticWadoClient extends api.DICOMwebClient {
/** Compares a pair of dates to see if the value is within the range */
compareDateRange(range, value) {
if (!value) return true;
if (!value) {
return true;
}
const dash = range.indexOf('-');
if (dash === -1) return this.compareValues(range, value);
if (dash === -1) {
return this.compareValues(range, value);
}
const start = range.substring(0, dash);
const end = range.substring(dash + 1);
return (!start || value >= start) && (!end || value <= end);
@ -150,11 +166,17 @@ export default class StaticWadoClient extends api.DICOMwebClient {
*/
filterItem(key: string, queryParams, study, sourceFilterMap) {
const altKey = sourceFilterMap[key] || key;
if (!queryParams) return true;
if (!queryParams) {
return true;
}
const testValue = queryParams[key] || queryParams[altKey];
if (!testValue) return true;
if (!testValue) {
return true;
}
const valueElem = study[key] || study[altKey];
if (!valueElem) return false;
if (!valueElem) {
return false;
}
if (valueElem.vr == 'DA') {
return this.compareDateRange(testValue, valueElem.Value[0]);
}

View File

@ -276,7 +276,9 @@ function _mapMeasurementToDisplay(measurement, index, types) {
if (findingSites) {
const siteText = [];
findingSites.forEach(site => {
if (site?.text !== label) siteText.push(site.text);
if (site?.text !== label) {
siteText.push(site.text);
}
});
displayText = [...siteText, ...displayText];
}

View File

@ -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);
}
};
}

View File

@ -40,8 +40,8 @@ NestedMenu.propTypes = {
};
NestedMenu.defaultProps = {
icon: "tool-more-menu",
label: "More",
icon: 'tool-more-menu',
label: 'More',
};
export default NestedMenu;

View File

@ -50,7 +50,7 @@ function ViewerLayout({
// dataSourceIdx === -1
// ? undefined
// : `datasources=${pathname.substring(dataSourceIdx + 1)}`;
// Todo: Handle parameters in a better way.
const query = new URLSearchParams(window.location.search);
const configUrl = query.get('configUrl');
@ -69,7 +69,7 @@ function ViewerLayout({
navigate({
pathname: '/',
search: decodeURIComponent(searchQuery.toString())
search: decodeURIComponent(searchQuery.toString()),
});
};

View File

@ -129,13 +129,17 @@ const commandsModule = ({
stage,
} = hangingProtocolService.getActiveProtocol();
const enableListener = button => {
if (!button.id) return;
if (!button.id) {
return;
}
const { commands, items } = button.props || button;
if (items) {
items.forEach(enableListener);
}
const hpCommand = commands?.find?.(isHangingProtocolCommand);
if (!hpCommand) return;
if (!hpCommand) {
return;
}
const { protocolId, stageIndex, stageId } = hpCommand.commandOptions;
const isActive =
(!protocolId || protocolId === protocol.id) &&

View File

@ -22,7 +22,9 @@ export const findOrCreateViewport = (
options: Record<string, unknown>
) => {
const byPositionViewport = viewportsByPosition?.[positionId];
if (byPositionViewport) return { ...byPositionViewport };
if (byPositionViewport) {
return { ...byPositionViewport };
}
const { protocolId, stageIndex } = hangingProtocolService.getState();
// Setup the initial in display correctly for initial view/select

View File

@ -83,17 +83,21 @@ export default function getCustomizationModule() {
*/
{
id: 'ohif.overlayItem',
content: function (props) {
if (this.condition && !this.condition(props)) return null;
content: function(props) {
if (this.condition && !this.condition(props)) {
return null;
}
const { instance } = props;
const value =
instance && this.attribute
? instance[this.attribute]
: this.contentF && typeof this.contentF === 'function'
? this.contentF(props)
: null;
if (!value) return null;
? this.contentF(props)
: null;
if (!value) {
return null;
}
return (
<span
@ -117,7 +121,7 @@ export default function getCustomizationModule() {
* This function clones the object and child objects to prevent
* changes to the original customization object.
*/
transform: function (customizationService: CustomizationService) {
transform: function(customizationService: CustomizationService) {
// Don't modify the children, as those are copied by reference
const clonedObject = { ...this };
clonedObject.menus = this.menus.map(menu => ({ ...menu }));

View File

@ -23,9 +23,13 @@ const getDirectURL = (config, params) => {
singlepart: fetchPart = 'video',
} = params;
const value = instance[tag];
if (!value) return undefined;
if (!value) {
return undefined;
}
if (value.DirectRetrieveURL) return value.DirectRetrieveURL;
if (value.DirectRetrieveURL) {
return value.DirectRetrieveURL;
}
if (value.InlineBinary) {
const blob = utils.b64toBlob(value.InlineBinary, defaultType);
value.DirectRetrieveURL = URL.createObjectURL(blob);

View File

@ -47,10 +47,14 @@ const reuseCachedLayout = (
for (let idx = 0; idx < state.viewports.length; idx++) {
const viewport = state.viewports[idx];
const { displaySetOptions, displaySetInstanceUIDs } = viewport;
if (!displaySetOptions) continue;
if (!displaySetOptions) {
continue;
}
for (let i = 0; i < displaySetOptions.length; i++) {
const displaySetUID = displaySetInstanceUIDs[i];
if (!displaySetUID) continue;
if (!displaySetUID) {
continue;
}
if (idx === activeViewportIndex && i === 0) {
displaySetSelectorMap[
`${activeStudyUID}:activeDisplaySet:0`

View File

@ -41,7 +41,9 @@ class DicomMicroscopyViewport extends Component {
const { microscopyService } = this.props.servicesManager.services;
this.microscopyService = microscopyService;
this.debouncedResize = debounce(() => {
if (this.viewer) this.viewer.resize();
if (this.viewer) {
this.viewer.resize();
}
}, 100);
}

View File

@ -107,8 +107,12 @@ const itemGenerator = (props: any) => {
props.formatTime = formatDICOMTime;
props.formatPN = formatPN;
props.formatNumberPrecision = formatNumberPrecision;
if (condition && !condition(props)) return null;
if (!contents && !valueFunc) return null;
if (condition && !condition(props)) {
return null;
}
if (!contents && !valueFunc) {
return null;
}
const value = valueFunc && valueFunc(props);
const contentsValue = (contents && contents(props)) || [
{ className: 'mr-1', value: title },

View File

@ -1,10 +1,16 @@
const listComponentGenerator = props => {
const { list, itemGenerator } = props;
if (!list) return;
if (!list) {
return;
}
return list.map(item => {
if (!item) return;
if (!item) {
return;
}
const generator = item.generator || itemGenerator;
if (!generator) throw new Error(`No generator for ${item}`);
if (!generator) {
throw new Error(`No generator for ${item}`);
}
return generator({ ...props, item });
});
};

View File

@ -22,7 +22,9 @@ export default function getCommandsModule({
deleteMeasurement: ({ uid }) => {
if (uid) {
const roiAnnotation = microscopyService.getAnnotation(uid);
if (roiAnnotation) microscopyService.removeAnnotation(roiAnnotation);
if (roiAnnotation) {
microscopyService.removeAnnotation(roiAnnotation);
}
}
},
@ -72,7 +74,7 @@ export default function getCommandsModule({
].indexOf(toolName) >= 0
) {
// TODO: read from configuration
let options = {
const options = {
geometryType: toolName,
vertexEnabled: true,
styleOptions: styles.default,
@ -140,7 +142,9 @@ export default function getCommandsModule({
);
let onoff = false; // true if this will toggle on
for (let i = 0; i < overlays.length; i++) {
if (i === 0) onoff = overlays.item(0).classList.contains('hidden');
if (i === 0) {
onoff = overlays.item(0).classList.contains('hidden');
}
overlays.item(i).classList.toggle('hidden');
}

View File

@ -5,7 +5,9 @@
* @returns {string} formatted name
*/
export default function formatDICOMPatientName(name) {
if (typeof name !== 'string') return;
if (typeof name !== 'string') {
return;
}
/**
* Convert the first ^ to a ', '. String.replace() only affects

View File

@ -56,7 +56,7 @@ export default class MicroscopyService extends PubSubService {
clear() {
this.managedViewers.forEach(managedViewer => managedViewer.destroy());
this.managedViewers.clear();
for (var key in this.annotations) {
for (const key in this.annotations) {
delete this.annotations[key];
}
@ -124,7 +124,9 @@ export default class MicroscopyService extends PubSubService {
_onRoiModified(data) {
const { roiGraphic, managedViewer } = data;
const roiAnnotation = this.getAnnotation(roiGraphic.uid);
if (!roiAnnotation) return;
if (!roiAnnotation) {
return;
}
roiAnnotation.setRoiGraphic(roiGraphic);
roiAnnotation.setViewState(managedViewer.getViewState());
}
@ -156,7 +158,10 @@ export default class MicroscopyService extends PubSubService {
_onRoiUpdated(data) {
const { roiGraphic, managedViewer } = data;
this.synchronizeViewers(managedViewer);
this._broadcastEvent(EVENTS.ANNOTATION_UPDATED, this.getAnnotation(roiGraphic.uid));
this._broadcastEvent(
EVENTS.ANNOTATION_UPDATED,
this.getAnnotation(roiGraphic.uid)
);
}
/**
@ -170,8 +175,13 @@ export default class MicroscopyService extends PubSubService {
_onRoiSelected(data) {
const { roiGraphic } = data;
const selectedAnnotation = this.getAnnotation(roiGraphic.uid);
if (selectedAnnotation && selectedAnnotation !== this.getSelectedAnnotation()) {
if (this.selectedAnnotation) this.clearSelection();
if (
selectedAnnotation &&
selectedAnnotation !== this.getSelectedAnnotation()
) {
if (this.selectedAnnotation) {
this.clearSelection();
}
this.selectedAnnotation = selectedAnnotation;
this._broadcastEvent(EVENTS.ANNOTATION_SELECTED, selectedAnnotation);
}
@ -183,11 +193,26 @@ export default class MicroscopyService extends PubSubService {
* @param {ViewerManager} managedViewer The viewer being added
*/
_addManagedViewerSubscriptions(managedViewer) {
managedViewer._roiAddedSubscription = managedViewer.subscribe(ViewerEvents.ADDED, this._onRoiAdded);
managedViewer._roiModifiedSubscription = managedViewer.subscribe(ViewerEvents.MODIFIED, this._onRoiModified);
managedViewer._roiRemovedSubscription = managedViewer.subscribe(ViewerEvents.REMOVED, this._onRoiRemoved);
managedViewer._roiUpdatedSubscription = managedViewer.subscribe(ViewerEvents.UPDATED, this._onRoiUpdated);
managedViewer._roiSelectedSubscription = managedViewer.subscribe(ViewerEvents.UPDATED, this._onRoiSelected);
managedViewer._roiAddedSubscription = managedViewer.subscribe(
ViewerEvents.ADDED,
this._onRoiAdded
);
managedViewer._roiModifiedSubscription = managedViewer.subscribe(
ViewerEvents.MODIFIED,
this._onRoiModified
);
managedViewer._roiRemovedSubscription = managedViewer.subscribe(
ViewerEvents.REMOVED,
this._onRoiRemoved
);
managedViewer._roiUpdatedSubscription = managedViewer.subscribe(
ViewerEvents.UPDATED,
this._onRoiUpdated
);
managedViewer._roiSelectedSubscription = managedViewer.subscribe(
ViewerEvents.UPDATED,
this._onRoiSelected
);
}
/**
@ -196,11 +221,16 @@ export default class MicroscopyService extends PubSubService {
* @param {ViewerManager} managedViewer The viewer being removed
*/
_removeManagedViewerSubscriptions(managedViewer) {
managedViewer._roiAddedSubscription && managedViewer._roiAddedSubscription.unsubscribe();
managedViewer._roiModifiedSubscription && managedViewer._roiModifiedSubscription.unsubscribe();
managedViewer._roiRemovedSubscription && managedViewer._roiRemovedSubscription.unsubscribe();
managedViewer._roiUpdatedSubscription && managedViewer._roiUpdatedSubscription.unsubscribe();
managedViewer._roiSelectedSubscription && managedViewer._roiSelectedSubscription.unsubscribe();
managedViewer._roiAddedSubscription &&
managedViewer._roiAddedSubscription.unsubscribe();
managedViewer._roiModifiedSubscription &&
managedViewer._roiModifiedSubscription.unsubscribe();
managedViewer._roiRemovedSubscription &&
managedViewer._roiRemovedSubscription.unsubscribe();
managedViewer._roiUpdatedSubscription &&
managedViewer._roiUpdatedSubscription.unsubscribe();
managedViewer._roiSelectedSubscription &&
managedViewer._roiSelectedSubscription.unsubscribe();
managedViewer._roiAddedSubscription = null;
managedViewer._roiModifiedSubscription = null;
@ -460,7 +490,9 @@ export default class MicroscopyService extends PubSubService {
* @param {RoiAnnotation} roiAnnotation The instance to be selected
*/
selectAnnotation(roiAnnotation) {
if (this.selectedAnnotation) this.clearSelection();
if (this.selectedAnnotation) {
this.clearSelection();
}
this.selectedAnnotation = roiAnnotation;
this._broadcastEvent(EVENTS.ANNOTATION_SELECTED, roiAnnotation);

View File

@ -83,7 +83,9 @@ export default function constructSR(
console.debug('[SR] storing evaluations...', evaluations);
console.debug('[SR] storing presentation state...', presentationState);
if (presentationState) presentationState.marker = marker;
if (presentationState) {
presentationState.marker = marker;
}
/** Avoid incompatibility with dcmjs */
measurements = measurements.map((measurement: any) => {

View File

@ -38,7 +38,9 @@ export default function coordinateFormatScoord3d2Geometry(
}
function _getPixelSpacing(metadata) {
if (metadata.PixelSpacing) return metadata.PixelSpacing;
if (metadata.PixelSpacing) {
return metadata.PixelSpacing;
}
const functionalGroup = metadata.SharedFunctionalGroupsSequence[0];
const pixelMeasures = functionalGroup.PixelMeasuresSequence[0];
return pixelMeasures.PixelSpacing;

View File

@ -4,8 +4,8 @@
* @param filename
*/
export function saveByteArray(buffer: ArrayBuffer, filename: string) {
var blob = new Blob([buffer], { type: 'application/dicom' });
var link = document.createElement('a');
const blob = new Blob([buffer], { type: 'application/dicom' });
const link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = filename;
link.click();

View File

@ -344,7 +344,9 @@ function _mapMeasurementToDisplay(measurement, types, displaySetService) {
if (findingSites) {
const siteText = [];
findingSites.forEach(site => {
if (site?.text !== label) siteText.push(site.text);
if (site?.text !== label) {
siteText.push(site.text);
}
});
displayText = [...siteText, ...displayText];
}

View File

@ -1 +1,4 @@
export default (study, extraData) => Math.max(...(extraData?.displaySets?.map?.(ds => (ds.numImageFrames ?? 0))) || [0]);
export default (study, extraData) =>
Math.max(
...(extraData?.displaySets?.map?.(ds => ds.numImageFrames ?? 0) || [0])
);

View File

@ -1 +1 @@
export default (study, extraData) => extraData?.displaySets?.length;
export default (study, extraData) => extraData?.displaySets?.length;

View File

@ -4,30 +4,37 @@
* From 'this', it uses:
* `sameAttribute` as the attribute name to look for
* `sameDisplaySetId` as the display set id to look for
* From `options`, it looks for
* From `options`, it looks for
*/
export default function (displaySet, options) {
export default function(displaySet, options) {
const { sameAttribute, sameDisplaySetId } = this;
if( !sameAttribute ) {
console.log("sameAttribute not defined in", this);
if (!sameAttribute) {
console.log('sameAttribute not defined in', this);
return `sameAttribute not defined in ${this.id}`;
}
if( !sameDisplaySetId ) {
console.log("sameDisplaySetId not defined in", this);
if (!sameDisplaySetId) {
console.log('sameDisplaySetId not defined in', this);
return `sameDisplaySetId not defined in ${this.id}`;
}
const { displaySetMatchDetails, displaySets } = options;
const match = displaySetMatchDetails.get(sameDisplaySetId);
if( !match ) {
console.log("No match for display set", sameDisplaySetId);
if (!match) {
console.log('No match for display set', sameDisplaySetId);
return false;
}
const { displaySetInstanceUID } = match;
const altDisplaySet = displaySets.find(it => it.displaySetInstanceUID==displaySetInstanceUID);
if( !altDisplaySet ) {
console.log("No display set found with", displaySetInstanceUID, "in", displaySets);
const altDisplaySet = displaySets.find(
it => it.displaySetInstanceUID == displaySetInstanceUID
);
if (!altDisplaySet) {
console.log(
'No display set found with',
displaySetInstanceUID,
'in',
displaySets
);
return false;
}
const testValue = altDisplaySet[sameAttribute];
return testValue===displaySet[sameAttribute];
}
return testValue === displaySet[sameAttribute];
}

View File

@ -2,9 +2,11 @@ const codeMenuItem = {
id: '@ohif/contextMenuAnnotationCode',
/** Applies the code value setup for this item */
transform: function (customizationService) {
transform: function(customizationService) {
const { code: codeRef } = this;
if (!codeRef) throw new Error(`item ${this} has no code ref`);
if (!codeRef) {
throw new Error(`item ${this} has no code ref`);
}
const codingValues = customizationService.get('codingValues');
const code = codingValues[codeRef];
return {

View File

@ -117,7 +117,7 @@ function calculateSuvPeak(
const secondaryCircleWorld = vec3.create();
const bottomWorld = vec3.create();
const topWorld = vec3.create();
referenceVolumeImageData.indexToWorld(<vec3>maxIJK, secondaryCircleWorld);
referenceVolumeImageData.indexToWorld(maxIJK as vec3, secondaryCircleWorld);
vec3.scaleAndAdd(bottomWorld, secondaryCircleWorld, direction, -diameter / 2);
vec3.scaleAndAdd(topWorld, secondaryCircleWorld, direction, diameter / 2);
const suvPeakCirclePoints = [bottomWorld, topWorld] as [

View File

@ -78,8 +78,8 @@
"@babel/preset-react": "^7.16.7",
"@babel/preset-typescript": "^7.13.0",
"@types/jest": "^27.5.0",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"autoprefixer": "^10.4.4",
"babel-eslint": "9.x",
"babel-loader": "^8.2.4",

View File

@ -71,6 +71,7 @@ describe('OHIF Cornerstone Toolbar', () => {
it('checks if Levels tool will change the window width and center of an image', () => {
//Click on button and verify if icon is active on toolbar
cy.waitDicomImage();
cy.get('@wwwcBtnPrimary')
.click()
.then($wwwcBtn => {

View File

@ -60,7 +60,7 @@ Cypress.Commands.add(
cy.location('pathname').then($url => {
cy.log($url);
if (
$url == 'blank' ||
$url === 'blank' ||
!$url.includes(`/basic-test/${StudyInstanceUID}${otherParams}`)
) {
cy.openStudyInViewer(StudyInstanceUID, otherParams);
@ -158,10 +158,10 @@ Cypress.Commands.add('addLine', (viewport, firstClick, secondClick) => {
// TODO: Added a wait which appears necessary in Cornerstone Tools >4?
cy.wrap($viewport)
.click(x1, y1)
.click(x1, y1, { force: true })
.wait(100)
.trigger('mousemove', { clientX: x2, clientY: y2 })
.click(x2, y2)
.click(x2, y2, { force: true })
.wait(100);
});
});

View File

@ -4,6 +4,8 @@ const originalConsoleError = console.error;
// JSDom's CSS Parser has limited support for certain features
// This supresses error warnings caused by it
console.error = function(msg) {
if (_.startsWith(msg, 'Error: Could not parse CSS stylesheet')) return;
if (_.startsWith(msg, 'Error: Could not parse CSS stylesheet')) {
return;
}
originalConsoleError(msg);
};

View File

@ -103,7 +103,9 @@ async function appInit(appConfigOrFunc, defaultExtensions, defaultModes) {
const modesById = new Set();
for (let i = 0; i < loadedModes.length; i++) {
let mode = loadedModes[i];
if (!mode) continue;
if (!mode) {
continue;
}
const { id } = mode;
if (mode.modeFactory) {
@ -116,10 +118,14 @@ async function appInit(appConfigOrFunc, defaultExtensions, defaultModes) {
mode = mode.modeFactory({ modeConfiguration });
}
if (modesById.has(id)) continue;
if (modesById.has(id)) {
continue;
}
// Prevent duplication
modesById.add(id);
if (!mode || typeof mode !== 'object') continue;
if (!mode || typeof mode !== 'object') {
continue;
}
appConfig.loadedModes.push(mode);
}
// Hack alert - don't touch the original modes definition,

View File

@ -145,7 +145,9 @@ function ViewerViewportGrid(props) {
const { unsubscribe } = measurementService.subscribe(
MeasurementService.EVENTS.JUMP_TO_MEASUREMENT_LAYOUT,
({ viewportIndex, measurement, isConsumed }) => {
if (isConsumed) return;
if (isConsumed) {
return;
}
// This occurs when no viewport has elected to consume the event
// so we need to change layouts into a layout which can consume
// the event.
@ -292,7 +294,9 @@ function ViewerViewportGrid(props) {
});
const onInteractionHandler = event => {
if (isActive) return;
if (isActive) {
return;
}
if (event) {
event.preventDefault();

View File

@ -1,6 +1,6 @@
export default class FileLoader {
fileType;
loadFile(file, imageId) { }
getDataset(image, imageId) { }
getStudies(dataset, imageId) { }
loadFile(file, imageId) {}
getDataset(image, imageId) {}
getStudies(dataset, imageId) {}
}

View File

@ -11,8 +11,12 @@ type StudyMetadata = Types.StudyMetadata;
* @returns - compare a and b, returning 1 if a<b -1 if a>b and defaultCompare otherwise
*/
const compare = (a, b, defaultCompare = 0): number => {
if (a === b) return defaultCompare;
if (a < b) return 1;
if (a === b) {
return defaultCompare;
}
if (a < b) {
return 1;
}
return -1;
};
@ -49,7 +53,9 @@ const getStudiesfromDisplaySets = (displaysets): StudyMetadata[] => {
* in the original order, as specified.
*/
const getStudiesFromUIDs = (studyUids: string[]): StudyMetadata[] => {
if (!studyUids?.length) return;
if (!studyUids?.length) {
return;
}
return studyUids.map(uid => DicomMetadataStore.getStudy(uid));
};

View File

@ -361,32 +361,35 @@ function WorkList({
query.append('configUrl', filterValues.configUrl);
}
query.append('StudyInstanceUIDs', studyInstanceUid);
return mode.displayName && (
<Link
className={isValidMode ? '' : 'cursor-not-allowed'}
key={i}
to={`${dataPath ? '../../' : ''}${mode.routeName}${dataPath ||
''}?${query.toString()}`}
onClick={event => {
// In case any event bubbles up for an invalid mode, prevent the navigation.
// For example, the event bubbles up when the icon embedded in the disabled button is clicked.
if (!isValidMode) {
event.preventDefault();
}
}}
// to={`${mode.routeName}/dicomweb?StudyInstanceUIDs=${studyInstanceUid}`}
>
{/* TODO revisit the completely rounded style of buttons used for launching a mode from the worklist later - for now use LegacyButton*/}
<LegacyButton
rounded="full"
variant={isValidMode ? 'contained' : 'disabled'}
disabled={!isValidMode}
endIcon={<Icon name="launch-arrow" />} // launch-arrow | launch-info
onClick={() => {}}
return (
mode.displayName && (
<Link
className={isValidMode ? '' : 'cursor-not-allowed'}
key={i}
to={`${dataPath ? '../../' : ''}${
mode.routeName
}${dataPath || ''}?${query.toString()}`}
onClick={event => {
// In case any event bubbles up for an invalid mode, prevent the navigation.
// For example, the event bubbles up when the icon embedded in the disabled button is clicked.
if (!isValidMode) {
event.preventDefault();
}
}}
// to={`${mode.routeName}/dicomweb?StudyInstanceUIDs=${studyInstanceUid}`}
>
{t(`Modes:${mode.displayName}`)}
</LegacyButton>
</Link>
{/* TODO revisit the completely rounded style of buttons used for launching a mode from the worklist later - for now use LegacyButton*/}
<LegacyButton
rounded="full"
variant={isValidMode ? 'contained' : 'disabled'}
disabled={!isValidMode}
endIcon={<Icon name="launch-arrow" />} // launch-arrow | launch-info
onClick={() => {}}
>
{t(`Modes:${mode.displayName}`)}
</LegacyButton>
</Link>
)
);
})}
</div>

View File

@ -10,7 +10,7 @@ import {
initGit,
} from './utils/index.js';
const createPackage = async (options) => {
const createPackage = async options => {
const { packageType } = options; // extension or mode
if (fs.existsSync(options.targetDir)) {

View File

@ -22,7 +22,9 @@ const createDirectoryContents = (
const contents = fs.readFileSync(origFilePath, 'utf8');
// Rename
if (file === '.npmignore') file = '.gitignore';
if (file === '.npmignore') {
file = '.gitignore';
}
const writePath = `${targetDirPath}/${file}`;
fs.writeFileSync(writePath, contents, 'utf8');

View File

@ -11,7 +11,7 @@ export default async function findRequiredOhifExtensionsForMode(yarnInfo) {
const dependencies = [];
const ohifExtensions = [];
Object.keys(peerDependencies).forEach((packageName) => {
Object.keys(peerDependencies).forEach(packageName => {
dependencies.push({
packageName,
version: peerDependencies[packageName],

View File

@ -77,14 +77,14 @@ function getVersion(json, version) {
const [majorVersion] = version
.split('^')[1]
.split('.')
.map((v) => parseInt(v));
.map(v => parseInt(v));
// Find the version that matches the major version, but is the latest minor version
versions
.filter((version) => parseInt(version.split('.')[0]) === majorVersion)
.filter(version => parseInt(version.split('.')[0]) === majorVersion)
.sort((a, b) => {
const [majorA, minorA, patchA] = a.split('.').map((v) => parseInt(v));
const [majorB, minorB, patchB] = b.split('.').map((v) => parseInt(v));
const [majorA, minorA, patchA] = a.split('.').map(v => parseInt(v));
const [majorB, minorB, patchB] = b.split('.').map(v => parseInt(v));
if (majorA === majorB) {
if (minorA === minorB) {
@ -110,13 +110,16 @@ function validate(packageName, version, keyword) {
// Gets the registry of the package. Scoped packages may not be using the global default.
const registryUrlOfPackage = registryUrl(scope);
let options = {}
if (process.env.NPM_TOKEN){
let options = {};
if (process.env.NPM_TOKEN) {
options['headers'] = {
'Authorization': `Bearer ${process.env.NPM_TOKEN}`,
}
Authorization: `Bearer ${process.env.NPM_TOKEN}`,
};
}
const response = await fetch(`${registryUrlOfPackage}${packageName}`, options);
const response = await fetch(
`${registryUrlOfPackage}${packageName}`,
options
);
const json = await response.json();
if (json.error && json.error === NOT_FOUND) {

View File

@ -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;
}

View File

@ -1,4 +1,4 @@
import 'isomorphic-base64'
import 'isomorphic-base64';
import user from '../user';
/**

View File

@ -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]) ||

View File

@ -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,

View File

@ -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') {

View File

@ -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],

View File

@ -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);

View File

@ -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 => {

View File

@ -134,7 +134,7 @@ function checkHpsBestMatch(hps) {
displaySetOptions: {
id: 'displaySetSelector',
options: {},
},
},
},
],
});
@ -192,6 +192,6 @@ describe('HangingProtocolService', () => {
it('matches best image match', () => {
checkHpsBestMatch(hangingProtocolService);
});
});
});
});
});

View File

@ -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

View File

@ -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)

View File

@ -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;
};
};

View File

@ -1 +1,2 @@
export default (study, extraData) => extraData?.displaySets?.map(ds => ds.SeriesDescription);
export default (study, extraData) =>
extraData?.displaySets?.map(ds => ds.SeriesDescription);

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);
}
};
}

View File

@ -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;
};

View File

@ -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);

View File

@ -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;
}
);

View File

@ -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 = [];

View File

@ -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;
}

View File

@ -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);
}
};
/**

View File

@ -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));
};

View File

@ -11,7 +11,7 @@
module.exports = {
// By default, Docusaurus generates a sidebar from the docs folder structure
tutorialSidebar: [{type: 'autogenerated', dirName: '.'}],
tutorialSidebar: [{ type: 'autogenerated', dirName: '.' }],
// But you can create a sidebar manually
/*

View File

@ -4,7 +4,15 @@ const debugMode = !!(
const detectionOptions = {
// order and from where user language should be detected
order: ['querystring', 'cookie', 'localStorage', 'navigator', 'htmlTag', 'path', 'subdomain'],
order: [
'querystring',
'cookie',
'localStorage',
'navigator',
'htmlTag',
'path',
'subdomain',
],
// keys or params to lookup language from
lookupQuerystring: 'lng',
@ -18,7 +26,7 @@ const detectionOptions = {
excludeCacheFor: ['cimode'], // languages to not persist (cookie, localStorage)
// optional htmlTag with lang attribute, the default is:
htmlTag: document.documentElement
htmlTag: document.documentElement,
};
export { debugMode, detectionOptions };

View File

@ -128,7 +128,7 @@ function initI18n(
});
}
return initialized.then(function (t) {
return initialized.then(function(t) {
i18n.T = t;
customDebug(`T function available.`, 'info');
});
@ -140,7 +140,13 @@ i18n.initializing = initI18n();
i18n.initI18n = initI18n;
i18n.addLocales = addLocales;
i18n.availableLanguages = getAvailableLanguagesInfo(locales);
i18n.defaultLanguage = { label: getLanguageLabel(DEFAULT_LANGUAGE), value: DEFAULT_LANGUAGE };
i18n.currentLanguage = () => ({ label: getLanguageLabel(i18n.language), value: i18n.language });
i18n.defaultLanguage = {
label: getLanguageLabel(DEFAULT_LANGUAGE),
value: DEFAULT_LANGUAGE,
};
i18n.currentLanguage = () => ({
label: getLanguageLabel(i18n.language),
value: i18n.language,
});
export default i18n;

View File

@ -19,5 +19,5 @@ export default {
...pt_BR,
...vi,
...zh,
...test_lng
...test_lng,
};

View File

@ -32,6 +32,6 @@ export default {
PatientInfo,
Modes,
SidePanel,
Modals
Modals,
},
};

View File

@ -57,7 +57,7 @@ const languagesMap = {
'test-LNG': 'Test Language',
};
const getLanguageLabel = (language) => {
const getLanguageLabel = language => {
return languagesMap[language];
};

View File

@ -21,7 +21,9 @@ const directories = getDirectories(directoryPath);
function writeFile(filepath, name, content) {
fs.writeFile(path.join(filepath, name), content, err => {
if (err) throw err;
if (err) {
throw err;
}
});
}

View File

@ -45,7 +45,7 @@ const renderYearsOptions = () => {
return options;
};
const DateRange = (props) => {
const DateRange = props => {
const { id, onChange, startDate, endDate } = props;
const [focusedInput, setFocusedInput] = useState(null);
const renderYearsOptionsCallback = useCallback(renderYearsOptions, []);
@ -81,15 +81,15 @@ const DateRange = (props) => {
onYearSelect: PropTypes.func,
};
const handleMonthChange = (event) => {
const handleMonthChange = event => {
onMonthSelect(month, event.target.value);
};
const handleYearChange = (event) => {
const handleYearChange = event => {
onYearSelect(month, event.target.value);
};
const handleOnBlur = () => { };
const handleOnBlur = () => {};
return (
<div className="flex justify-center">
@ -136,10 +136,10 @@ const DateRange = (props) => {
onChange({
startDate: newStartDate ? newStartDate.format('YYYYMMDD') : undefined,
endDate: newEndDate ? newEndDate.format('YYYYMMDD') : undefined,
})
});
}}
focusedInput={focusedInput}
onFocusChange={(updatedVal) => setFocusedInput(updatedVal)}
onFocusChange={updatedVal => setFocusedInput(updatedVal)}
/** OPTIONAL */
renderCalendarInfo={renderDatePresets}
renderMonthElement={renderMonthElement}
@ -149,7 +149,7 @@ const DateRange = (props) => {
closeDatePicker: 'Close',
clearDates: 'Clear dates',
}}
isOutsideRange={(day) => !isInclusivelyBeforeDay(day, moment())}
isOutsideRange={day => !isInclusivelyBeforeDay(day, moment())}
hideKeyboardShortcutsPanel={true}
numberOfMonths={1}
showClearDates={false}

View File

@ -15,7 +15,14 @@ import { getKeys, formatKeysForInput } from './utils';
* @param {string} props.className input classes
* @param {Array[]} props.modifierKeys
*/
const HotkeyField = ({ disabled, keys, onChange, className, modifierKeys, hotkeys }) => {
const HotkeyField = ({
disabled,
keys,
onChange,
className,
modifierKeys,
hotkeys,
}) => {
const inputValue = formatKeysForInput(keys);
const onInputKeyDown = event => {
@ -55,11 +62,11 @@ HotkeyField.propTypes = {
unpause: PropTypes.func.isRequired,
startRecording: PropTypes.func.isRequired,
record: PropTypes.func.isRequired,
}).isRequired
}).isRequired,
};
HotkeyField.defaultProps = {
disabled: false
disabled: false,
};
export default HotkeyField;

View File

@ -25,7 +25,4 @@ const getKeys = ({ sequence, modifierKeys }) => {
return [...modifiers, ...keys];
};
export {
getKeys,
formatKeysForInput
};
export { getKeys, formatKeysForInput };

View File

@ -72,7 +72,9 @@ const disallowedValidator = ({ pressedKeys = [] }) => {
if (hasDisallowedCombinations) {
return {
error: `"${formatPressedKeys(pressedKeys)}" shortcut combination is not allowed`,
error: `"${formatPressedKeys(
pressedKeys
)}" shortcut combination is not allowed`,
};
}
};

Some files were not shown because too many files have changed in this diff Show More