Skip to content

Commit

Permalink
Fix ES lint issues (#1784)
Browse files Browse the repository at this point in the history
Signed-off-by: Sachidanand Alle <[email protected]>
  • Loading branch information
SachidanandAlle authored Nov 19, 2024
1 parent cae5499 commit d2d7d20
Show file tree
Hide file tree
Showing 25 changed files with 187 additions and 183 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import React, { Component } from 'react';
import PropTypes from 'prop-types';

Expand Down Expand Up @@ -41,9 +40,11 @@ export default class ModelSelector extends Component {
return null;
}

onChangeModel = evt => {
onChangeModel = (evt) => {
this.setState({ currentModel: evt.target.value });
if (this.props.onSelectModel) this.props.onSelectModel(evt.target.value);
if (this.props.onSelectModel) {
this.props.onSelectModel(evt.target.value);
}
};

currentModel = () => {
Expand Down Expand Up @@ -84,7 +85,7 @@ export default class ModelSelector extends Component {
onChange={this.onChangeModel}
value={currentModel}
>
{this.props.models.map(model => (
{this.props.models.map((model) => (
<option key={model} name={model} value={model}>
{`${model} `}
</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,23 @@ export default class MonaiLabelPanel extends Component {
const response = await this.client().info();

// remove the background
const labels = response.data.labels.splice(1)
const labels = response.data.labels.splice(1);

const segmentations = [
{
id: '1',
label: 'Segmentations',
segments: labels.map((label, index) => ({
segmentIndex: index + 1,
label
label,
})),
isActive: true,
activeSegmentIndex: 1,
},
];

this.props.commandsManager.runCommand('loadSegmentationsForViewport', {
segmentations
segmentations,
});

if (response.status !== 200) {
Expand All @@ -163,16 +163,18 @@ export default class MonaiLabelPanel extends Component {
// Leave Event
for (const action of Object.keys(this.actions)) {
if (this.state.action === action) {
if (this.actions[action].current)
if (this.actions[action].current) {
this.actions[action].current.onLeaveActionTab();
}
}
}

// Enter Event
for (const action of Object.keys(this.actions)) {
if (name === action) {
if (this.actions[action].current)
if (this.actions[action].current) {
this.actions[action].current.onEnterActionTab();
}
}
}
this.setState({ action: name });
Expand All @@ -193,11 +195,10 @@ export default class MonaiLabelPanel extends Component {
console.info('These are the predicted labels');
console.info(onInfoLabelNames);

if (onInfoLabelNames.hasOwnProperty('background')){
delete onInfoLabelNames.background;
if (onInfoLabelNames.hasOwnProperty('background')) {
delete onInfoLabelNames.background;
}


const ret = SegmentationReader.parseNrrdData(response.data);

if (!ret) {
Expand Down Expand Up @@ -248,7 +249,7 @@ delete onInfoLabelNames.background;
};

_debug = async () => {
let nrrdFetch = await fetch('http://localhost:3000/pred2.nrrd');
const nrrdFetch = await fetch('http://localhost:3000/pred2.nrrd');

const info = {
spleen: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {

const unsubscriptions = [];

events.forEach(event => {
events.forEach((event) => {
const { unsubscribe } = segmentationService.subscribe(event, () => {
const segmentations = segmentationService.getSegmentations();

const activeSegmentation = segmentations?.find(seg => seg.isActive);
const activeSegmentation = segmentations?.find((seg) => seg.isActive);

setToolsEnabled(activeSegmentation?.segmentCount > 0);
});
Expand All @@ -96,7 +96,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
});

return () => {
unsubscriptions.forEach(unsubscribe => unsubscribe());
unsubscriptions.forEach((unsubscribe) => unsubscribe());
};
}, [activeViewportId, viewports, segmentationService]);

Expand All @@ -117,7 +117,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
}, [toolbarService, updateActiveTool]);

const setToolActive = useCallback(
toolName => {
(toolName) => {
toolbarService.recordInteraction({
groupId: 'SegmentationTools',
itemId: 'Brush',
Expand All @@ -139,8 +139,12 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {

const updateBrushSize = useCallback(
(toolName, brushSize) => {
toolGroupService.getToolGroupIds()?.forEach(toolGroupId => {
segmentationUtils.setBrushSizeForToolGroup(toolGroupId, brushSize, toolName);
toolGroupService.getToolGroupIds()?.forEach((toolGroupId) => {
segmentationUtils.setBrushSizeForToolGroup(
toolGroupId,
brushSize,
toolName
);
});
},
[toolGroupService]
Expand All @@ -150,7 +154,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
(valueAsStringOrNumber, toolCategory) => {
const value = Number(valueAsStringOrNumber);

_getToolNamesFromCategory(toolCategory).forEach(toolName => {
_getToolNamesFromCategory(toolCategory).forEach((toolName) => {
updateBrushSize(toolName, value);
});

Expand All @@ -166,7 +170,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
);

const handleRangeChange = useCallback(
newRange => {
(newRange) => {
if (
newRange[0] === state.ThresholdBrush.thresholdRange[0] &&
newRange[1] === state.ThresholdBrush.thresholdRange[1]
Expand All @@ -176,8 +180,8 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {

const toolNames = _getToolNamesFromCategory('ThresholdBrush');

toolNames.forEach(toolName => {
toolGroupService.getToolGroupIds()?.forEach(toolGroupId => {
toolNames.forEach((toolName) => {
toolGroupService.getToolGroupIds()?.forEach((toolGroupId) => {
const toolGroup = toolGroupService.getToolGroup(toolGroupId);
toolGroup.setToolConfiguration(toolName, {
strategySpecificConfiguration: {
Expand Down Expand Up @@ -208,7 +212,9 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
name: 'Brush',
icon: 'icon-tool-brush',
disabled: !toolsEnabled,
active: state.activeTool === 'CircularBrush' || state.activeTool === 'SphereBrush',
active:
state.activeTool === 'CircularBrush' ||
state.activeTool === 'SphereBrush',
onClick: () => setToolActive('CircularBrush'),
options: [
{
Expand All @@ -219,7 +225,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
max: 100,
value: state.Brush.brushSize,
step: 0.5,
onChange: value => onBrushSizeChange(value, 'Brush'),
onChange: (value) => onBrushSizeChange(value, 'Brush'),
},
{
name: 'Mode',
Expand All @@ -230,15 +236,17 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
{ value: 'CircularBrush', label: 'Circle' },
{ value: 'SphereBrush', label: 'Sphere' },
],
onChange: value => setToolActive(value),
onChange: (value) => setToolActive(value),
},
],
},
{
name: 'Eraser',
icon: 'icon-tool-eraser',
disabled: !toolsEnabled,
active: state.activeTool === 'CircularEraser' || state.activeTool === 'SphereEraser',
active:
state.activeTool === 'CircularEraser' ||
state.activeTool === 'SphereEraser',
onClick: () => setToolActive('CircularEraser'),
options: [
{
Expand All @@ -249,7 +257,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
max: 100,
value: state.Eraser.brushSize,
step: 0.5,
onChange: value => onBrushSizeChange(value, 'Eraser'),
onChange: (value) => onBrushSizeChange(value, 'Eraser'),
},
{
name: 'Mode',
Expand All @@ -260,7 +268,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
{ value: 'CircularEraser', label: 'Circle' },
{ value: 'SphereEraser', label: 'Sphere' },
],
onChange: value => setToolActive(value),
onChange: (value) => setToolActive(value),
},
],
},
Expand All @@ -284,7 +292,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
{ value: 'RectangleScissor', label: 'Rectangle' },
{ value: 'SphereScissor', label: 'Sphere' },
],
onChange: value => setToolActive(value),
onChange: (value) => setToolActive(value),
},
],
},
Expand All @@ -305,7 +313,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
max: 100,
value: state.ThresholdBrush.brushSize,
step: 0.5,
onChange: value => onBrushSizeChange(value, 'ThresholdBrush'),
onChange: (value) => onBrushSizeChange(value, 'ThresholdBrush'),
},
{
name: 'Mode',
Expand All @@ -316,7 +324,7 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
{ value: 'ThresholdCircularBrush', label: 'Circle' },
{ value: 'ThresholdSphereBrush', label: 'Sphere' },
],
onChange: value => setToolActive(value),
onChange: (value) => setToolActive(value),
},
{
type: 'custom',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default class SettingsTable extends Component {
constructor(props) {
super(props);

const onInfo = props.onInfo
this.onInfo = onInfo
const onInfo = props.onInfo;
this.onInfo = onInfo;

this.state = this.getSettings();
}
Expand All @@ -35,8 +35,8 @@ export default class SettingsTable extends Component {
};
};

onBlurSeverURL = evt => {
let url = evt.target.value;
onBlurSeverURL = (evt) => {
const url = evt.target.value;
this.setState({ url: url });
CookieUtils.setCookie('MONAILABEL_SERVER_URL', url);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,19 @@ function ThresholdSettings({ onRangeChange }) {
const [options, setOptions] = useState(defaultOptions);
const [selectedPreset, setSelectedPreset] = useState(defaultOptions[0].value);

const handleRangeChange = newRange => {
const selectedOption = options.find(o => o.value === selectedPreset);
const handleRangeChange = (newRange) => {
const selectedOption = options.find((o) => o.value === selectedPreset);

if (newRange[0] === selectedOption.range[0] && newRange[1] === selectedOption.range[1]) {
if (
newRange[0] === selectedOption.range[0] &&
newRange[1] === selectedOption.range[1]
) {
return;
}

onRangeChange(newRange);

const updatedOptions = options.map(o => {
const updatedOptions = options.map((o) => {
if (o.value === selectedPreset) {
return {
...o,
Expand All @@ -55,7 +58,9 @@ function ThresholdSettings({ onRangeChange }) {
setOptions(updatedOptions);
};

const selectedPresetRange = options.find(ds => ds.value === selectedPreset).range;
const selectedPresetRange = options.find(
(ds) => ds.value === selectedPreset
).range;

return (
<div>
Expand All @@ -66,7 +71,7 @@ function ThresholdSettings({ onRangeChange }) {
isClearable={false}
onChange={handlePresetChange}
options={options}
value={options.find(ds => ds.value === selectedPreset)}
value={options.find((ds) => ds.value === selectedPreset)}
className="text-white"
isSearchable={false}
/>
Expand Down
Loading

0 comments on commit d2d7d20

Please sign in to comment.