{props.warningMessage && (
{props.warningMessage}
diff --git a/src/common/components/layouts/pages/inspect/structure/Structure.js b/src/common/components/layouts/pages/inspect/structure/Structure.js
index f82f383b..981d4308 100644
--- a/src/common/components/layouts/pages/inspect/structure/Structure.js
+++ b/src/common/components/layouts/pages/inspect/structure/Structure.js
@@ -1,8 +1,8 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
+import useResizeObserver from 'use-resize-observer';
import _ from 'lodash';
-import useResizeObserver from 'use-resize-observer';
import { makeStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
diff --git a/src/common/components/layouts/pages/inspect/toolbar/Toolbar.js b/src/common/components/layouts/pages/inspect/toolbar/Toolbar.js
index ca0bcd4a..457e20f2 100644
--- a/src/common/components/layouts/pages/inspect/toolbar/Toolbar.js
+++ b/src/common/components/layouts/pages/inspect/toolbar/Toolbar.js
@@ -2,12 +2,13 @@ import React, { useCallback, useMemo } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { useHistory } from 'react-router-dom';
+import _ from 'lodash';
+
import ArrowBack from '@material-ui/icons/ArrowBack';
import AddIcon from '@material-ui/icons/Add';
import RemoveIcon from '@material-ui/icons/Remove';
import IconButton from '@material-ui/core/IconButton';
import Typography from '@material-ui/core/Typography';
-import _ from 'lodash';
import AppPages from '../../../../AppPages';
import { getJobId } from '../../../../../store/job/selectors';
@@ -16,23 +17,26 @@ import Select from '../../../../shared/select/Select';
import Pagination from '../../../../shared/pagination/Pagination';
import { getNumPages, getPage } from '../../../../../store/application/selectors';
import { setPage } from '../../../../../store/application/actions';
+import { scaleAdvancedValues } from '../constants';
import './Toolbar.scss';
const BACK = 'Back to summary';
-function Toolbar({ jobId, name, scale, scaleOptions, page, numPages, onScaleChanged, setPage }) {
+function Toolbar({ jobId, name, scale, mode, scaleOptions, page, numPages, onScaleChanged, onModeChanged, setPage }) {
const history = useHistory();
+ const isAutozoom = useMemo(() => scaleAdvancedValues.includes(mode), [mode]);
const onBackClick = useMemo(() => () => history.push(AppPages.RESULTS.url(jobId)), [history, jobId]);
- const currentScaleIndex = useMemo(() => _.findIndex(scaleOptions, { value: scale }), [scaleOptions, scale]);
+ const currentScaleIndex = useMemo(() => _.findIndex(scaleOptions.basic, { value: scale }), [scaleOptions, scale]);
+
const onZoomIn = useCallback(() => {
- if (currentScaleIndex < scaleOptions.length - 1) {
- onScaleChanged(scaleOptions[currentScaleIndex + 1].value);
+ if (currentScaleIndex < scaleOptions.basic.length - 1) {
+ onScaleChanged(scaleOptions.basic[currentScaleIndex + 1].value);
}
}, [scaleOptions, currentScaleIndex, onScaleChanged]);
const onZoomOut = useCallback(() => {
if (currentScaleIndex > 0) {
- onScaleChanged(scaleOptions[currentScaleIndex - 1].value);
+ onScaleChanged(scaleOptions.basic[currentScaleIndex - 1].value);
}
}, [scaleOptions, currentScaleIndex, onScaleChanged]);
@@ -51,19 +55,25 @@ function Toolbar({ jobId, name, scale, scaleOptions, page, numPages, onScaleChan
@@ -74,10 +84,12 @@ Toolbar.propTypes = {
name: PropTypes.string,
jobId: PropTypes.string,
scale: PropTypes.string.isRequired,
- scaleOptions: PropTypes.arrayOf(PropTypes.object).isRequired,
+ mode: PropTypes.string.isRequired,
+ scaleOptions: PropTypes.object.isRequired,
page: PropTypes.number.isRequired,
numPages: PropTypes.number.isRequired,
onScaleChanged: PropTypes.func.isRequired,
+ onModeChanged: PropTypes.func.isRequired,
};
function mapStateToProps(state) {
diff --git a/src/common/components/shared/select/Select.js b/src/common/components/shared/select/Select.js
index ebf23b67..48639617 100644
--- a/src/common/components/shared/select/Select.js
+++ b/src/common/components/shared/select/Select.js
@@ -1,19 +1,41 @@
-import React, { useCallback } from 'react';
+import React, { useState, useEffect, useCallback } from 'react';
import PropTypes from 'prop-types';
+
import MaterialSelect from '@material-ui/core/Select';
import FormControl from '@material-ui/core/FormControl';
import MenuItem from '@material-ui/core/MenuItem';
+import { scaleAdvancedValues } from '../../layouts/pages/inspect/constants';
+
import './Select.scss';
-function Select({ id, options, value, labelId, disabled, onChange }) {
- const handleChange = useCallback(e => onChange(e.target.value), [onChange]);
+function Select({ id, options, value, mode, labelId, disabled, onChange, onMode }) {
+ const [selectValue, setSelectValue] = useState(value);
+
+ const handleChange = useCallback(
+ ({ target: { value: newValue } }) => {
+ if (scaleAdvancedValues.includes(newValue)) {
+ onMode?.(newValue);
+ setSelectValue(newValue);
+ } else {
+ onMode?.('');
+ onChange(newValue);
+ }
+ },
+ [onMode, onChange]
+ );
+
+ useEffect(() => {
+ if (!scaleAdvancedValues.includes(mode)) {
+ setSelectValue(value);
+ }
+ }, [mode, value]);
return (
{
+ const [size, setSize] = React.useState({});
+ const onResize = React.useMemo(() => _.debounce(setSize, delay, { leading: true }), [delay]);
+ const { ref } = useResizeObserver({ onResize });
+ return { ref, ...size };
+};
diff --git a/src/common/services/treeService.js b/src/common/services/treeService.js
index 873189c7..e51c16f7 100644
--- a/src/common/services/treeService.js
+++ b/src/common/services/treeService.js
@@ -47,6 +47,19 @@ const findIdByObjNumbers = (node, pathArray) => {
return findIdByObjNumbers(nextNode, pathArray);
};
+export const getRange = (start, stop, step, digits = 1) =>
+ Array.from({ length: (stop - start) / step + 1 }, (_, i) => (start + i * step).toFixed(digits));
+
+export const findNearToOneIndexInSortArray = arr => {
+ if (!Array.isArray(arr)) return null;
+ for (let i = 0; i < arr.length; i++) {
+ if (arr[i] < 1 && (arr[i + 1] > 1 || _.isNil(arr[i + 1]))) {
+ return i;
+ }
+ }
+ return null;
+};
+
export const getTreeIds = (node, ids = []) => {
if (_.isNil(node)) return ids;
if (!node.hasOwnProperty('final')) ids.push(node.id);