chore(prettier): full repo linting and code reformatting once and for all (#3627)
This commit is contained in:
1 parent
01500a2d4c
commit
9045ddaedc
656 files changed
+21737
-20628
No files matched your search
@@ -1,11 +1,6 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {
|
||||
ServicesManager,
|
||||
ExtensionManager,
|
||||
CommandsManager,
|
||||
DicomMetadataStore,
|
||||
} from '@ohif/core';
|
||||
import { ServicesManager, ExtensionManager, CommandsManager, DicomMetadataStore } from '@ohif/core';
|
||||
import { MeasurementTable, Icon, ButtonGroup, Button } from '@ohif/ui';
|
||||
import { withTranslation, WithTranslation } from 'react-i18next';
|
||||
import { EVENTS as MicroscopyEvents } from '../../services/MicroscopyService';
|
||||
@@ -73,9 +68,7 @@ interface IMicroscopyPanelProps extends WithTranslation {
|
||||
function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
const { microscopyService } = props.servicesManager.services;
|
||||
|
||||
const [studyInstanceUID, setStudyInstanceUID] = useState(
|
||||
null as string | null
|
||||
);
|
||||
const [studyInstanceUID, setStudyInstanceUID] = useState(null as string | null);
|
||||
const [roiAnnotations, setRoiAnnotations] = useState([] as any[]);
|
||||
const [selectedAnnotation, setSelectedAnnotation] = useState(null as any);
|
||||
const { servicesManager, extensionManager } = props;
|
||||
@@ -85,9 +78,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
useEffect(() => {
|
||||
const viewport = props.viewports[props.activeViewportId];
|
||||
if (viewport.displaySetInstanceUIDs[0]) {
|
||||
const displaySet = displaySetService.getDisplaySetByUID(
|
||||
viewport.displaySetInstanceUIDs[0]
|
||||
);
|
||||
const displaySet = displaySetService.getDisplaySetByUID(viewport.displaySetInstanceUIDs[0]);
|
||||
if (displaySet) {
|
||||
setStudyInstanceUID(displaySet.StudyInstanceUID);
|
||||
}
|
||||
@@ -96,9 +87,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
|
||||
useEffect(() => {
|
||||
const onAnnotationUpdated = () => {
|
||||
const roiAnnotations = microscopyService.getAnnotationsForStudy(
|
||||
studyInstanceUID
|
||||
);
|
||||
const roiAnnotations = microscopyService.getAnnotationsForStudy(studyInstanceUID);
|
||||
setRoiAnnotations(roiAnnotations);
|
||||
};
|
||||
|
||||
@@ -111,21 +100,15 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
onAnnotationUpdated();
|
||||
};
|
||||
|
||||
const {
|
||||
unsubscribe: unsubscribeAnnotationUpdated,
|
||||
} = microscopyService.subscribe(
|
||||
const { unsubscribe: unsubscribeAnnotationUpdated } = microscopyService.subscribe(
|
||||
MicroscopyEvents.ANNOTATION_UPDATED,
|
||||
onAnnotationUpdated
|
||||
);
|
||||
const {
|
||||
unsubscribe: unsubscribeAnnotationSelected,
|
||||
} = microscopyService.subscribe(
|
||||
const { unsubscribe: unsubscribeAnnotationSelected } = microscopyService.subscribe(
|
||||
MicroscopyEvents.ANNOTATION_SELECTED,
|
||||
onAnnotationSelected
|
||||
);
|
||||
const {
|
||||
unsubscribe: unsubscribeAnnotationRemoved,
|
||||
} = microscopyService.subscribe(
|
||||
const { unsubscribe: unsubscribeAnnotationRemoved } = microscopyService.subscribe(
|
||||
MicroscopyEvents.ANNOTATION_REMOVED,
|
||||
onAnnotationRemoved
|
||||
);
|
||||
@@ -147,9 +130,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
* @returns
|
||||
*/
|
||||
const promptSave = () => {
|
||||
const annotations = microscopyService.getAnnotationsForStudy(
|
||||
studyInstanceUID
|
||||
);
|
||||
const annotations = microscopyService.getAnnotationsForStudy(studyInstanceUID);
|
||||
|
||||
if (!annotations || saving) {
|
||||
return;
|
||||
@@ -172,9 +153,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
const getAllDisplaySets = (studyMetadata: any) => {
|
||||
let allDisplaySets = [] as any[];
|
||||
studyMetadata.series.forEach((series: any) => {
|
||||
const displaySets = displaySetService.getDisplaySetsForSeries(
|
||||
series.SeriesInstanceUID
|
||||
);
|
||||
const displaySets = displaySetService.getDisplaySetsForSeries(series.SeriesInstanceUID);
|
||||
allDisplaySets = allDisplaySets.concat(displaySets);
|
||||
});
|
||||
return allDisplaySets;
|
||||
@@ -189,9 +168,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
const saveFunction = async (SeriesDescription: string) => {
|
||||
const dataSource = extensionManager.getActiveDataSource()[0];
|
||||
const { onSaveComplete } = props;
|
||||
const annotations = microscopyService.getAnnotationsForStudy(
|
||||
studyInstanceUID
|
||||
);
|
||||
const annotations = microscopyService.getAnnotationsForStudy(studyInstanceUID);
|
||||
|
||||
saving = true;
|
||||
|
||||
@@ -206,10 +183,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
// Get the next available series number after 4700.
|
||||
|
||||
const dsWithMetadata = displaySets.filter(
|
||||
ds =>
|
||||
ds.metadata &&
|
||||
ds.metadata.SeriesNumber &&
|
||||
typeof ds.metadata.SeriesNumber === 'number'
|
||||
ds => ds.metadata && ds.metadata.SeriesNumber && typeof ds.metadata.SeriesNumber === 'number'
|
||||
);
|
||||
|
||||
// Generate next series number
|
||||
@@ -220,11 +194,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
const { instance: metadata } = smDisplaySet;
|
||||
|
||||
// construct SR dataset
|
||||
const dataset = constructSR(
|
||||
metadata,
|
||||
{ SeriesDescription, SeriesNumber },
|
||||
annotations
|
||||
);
|
||||
const dataset = constructSR(metadata, { SeriesDescription, SeriesNumber }, annotations);
|
||||
|
||||
// Save in DICOM format
|
||||
try {
|
||||
@@ -271,13 +241,11 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
// TODO: studies?
|
||||
const study = DicomMetadataStore.getStudy(StudyInstanceUID);
|
||||
|
||||
const lastDerivedDisplaySet = study.derivedDisplaySets.sort(
|
||||
(ds1: any, ds2: any) => {
|
||||
const dateTime1 = Number(`${ds1.SeriesDate}${ds1.SeriesTime}`);
|
||||
const dateTime2 = Number(`${ds2.SeriesDate}${ds2.SeriesTime}`);
|
||||
return dateTime1 > dateTime2;
|
||||
}
|
||||
)[study.derivedDisplaySets.length - 1];
|
||||
const lastDerivedDisplaySet = study.derivedDisplaySets.sort((ds1: any, ds2: any) => {
|
||||
const dateTime1 = Number(`${ds1.SeriesDate}${ds1.SeriesTime}`);
|
||||
const dateTime2 = Number(`${ds2.SeriesDate}${ds2.SeriesTime}`);
|
||||
return dateTime1 > dateTime2;
|
||||
})[study.derivedDisplaySets.length - 1];
|
||||
|
||||
// TODO: use dataSource.reject.dicom()
|
||||
// await DICOMSR.rejectMeasurements(
|
||||
@@ -314,13 +282,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
* Handler for "Edit" action of an annotation item
|
||||
* @param param0
|
||||
*/
|
||||
const onMeasurementItemEditHandler = ({
|
||||
uid,
|
||||
isActive,
|
||||
}: {
|
||||
uid: string;
|
||||
isActive: boolean;
|
||||
}) => {
|
||||
const onMeasurementItemEditHandler = ({ uid, isActive }: { uid: string; isActive: boolean }) => {
|
||||
props.commandsManager.runCommand('setLabel', { uid }, 'MICROSCOPY');
|
||||
};
|
||||
|
||||
@@ -344,10 +306,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
} else if (length !== undefined) {
|
||||
displayText.push(
|
||||
shortAxisLength
|
||||
? `${formatLength(length, 'μm')} x ${formatLength(
|
||||
shortAxisLength,
|
||||
'μm'
|
||||
)}`
|
||||
? `${formatLength(length, 'μm')} x ${formatLength(shortAxisLength, 'μm')}`
|
||||
: `${formatLength(length, 'μm')}`
|
||||
);
|
||||
}
|
||||
@@ -368,7 +327,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className="overflow-x-hidden overflow-y-auto ohif-scrollbar"
|
||||
className="ohif-scrollbar overflow-y-auto overflow-x-hidden"
|
||||
data-cy={'measurements-panel'}
|
||||
>
|
||||
<MeasurementTable
|
||||
@@ -406,8 +365,6 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
|
||||
);
|
||||
}
|
||||
|
||||
const connectedMicroscopyPanel = withTranslation(['MicroscopyTable', 'Common'])(
|
||||
MicroscopyPanel
|
||||
);
|
||||
const connectedMicroscopyPanel = withTranslation(['MicroscopyTable', 'Common'])(MicroscopyPanel);
|
||||
|
||||
export default connectedMicroscopyPanel;
|
||||
@@ -84,4 +84,4 @@
|
||||
|
||||
.DicomMicroscopyViewer .top-viewport .flex span:not(.font-light) {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,7 @@ import classnames from 'classnames';
|
||||
|
||||
import listComponentGenerator from './listComponentGenerator';
|
||||
import './ViewportOverlay.css';
|
||||
import {
|
||||
formatDICOMDate,
|
||||
formatDICOMTime,
|
||||
formatNumberPrecision,
|
||||
formatPN,
|
||||
} from './utils';
|
||||
import { formatDICOMDate, formatDICOMTime, formatNumberPrecision, formatPN } from './utils';
|
||||
|
||||
interface OverlayItem {
|
||||
id: string;
|
||||
@@ -41,20 +36,15 @@ export const generateFromConfig = ({
|
||||
}) => {
|
||||
return (props: any) => {
|
||||
const topLeftClass = 'top-viewport left-viewport text-primary-light';
|
||||
const topRightClass =
|
||||
'top-viewport right-viewport-scrollbar text-primary-light';
|
||||
const bottomRightClass =
|
||||
'bottom-viewport right-viewport-scrollbar text-primary-light';
|
||||
const topRightClass = 'top-viewport right-viewport-scrollbar text-primary-light';
|
||||
const bottomRightClass = 'bottom-viewport right-viewport-scrollbar text-primary-light';
|
||||
const bottomLeftClass = 'bottom-viewport left-viewport text-primary-light';
|
||||
const overlay = 'absolute pointer-events-none microscopy-viewport-overlay';
|
||||
|
||||
return (
|
||||
<>
|
||||
{topLeft && topLeft.length > 0 && (
|
||||
<div
|
||||
data-cy={'viewport-overlay-top-left'}
|
||||
className={classnames(overlay, topLeftClass)}
|
||||
>
|
||||
<div data-cy={'viewport-overlay-top-left'} className={classnames(overlay, topLeftClass)}>
|
||||
{listComponentGenerator({ ...props, list: topLeft, itemGenerator })}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -81,20 +81,13 @@ export function formatPN(name) {
|
||||
* @returns {string} comrpession type.
|
||||
*/
|
||||
export function getCompression(imageId) {
|
||||
const generalImageModule =
|
||||
cornerstone.metaData.get('generalImageModule', imageId) || {};
|
||||
const {
|
||||
lossyImageCompression,
|
||||
lossyImageCompressionRatio,
|
||||
lossyImageCompressionMethod,
|
||||
} = generalImageModule;
|
||||
const generalImageModule = cornerstone.metaData.get('generalImageModule', imageId) || {};
|
||||
const { lossyImageCompression, lossyImageCompressionRatio, lossyImageCompressionMethod } =
|
||||
generalImageModule;
|
||||
|
||||
if (lossyImageCompression === '01' && lossyImageCompressionRatio !== '') {
|
||||
const compressionMethod = lossyImageCompressionMethod || 'Lossy: ';
|
||||
const compressionRatio = formatNumberPrecision(
|
||||
lossyImageCompressionRatio,
|
||||
2
|
||||
);
|
||||
const compressionRatio = formatNumberPrecision(lossyImageCompressionRatio, 2);
|
||||
return compressionMethod + compressionRatio + ' : 1';
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user