Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36,769 changes: 1 addition & 36,768 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
"file-loader": "^6.2.0",
"sass": "^1.51.0"
},
"engines": {
"node": "22.x"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ const FoldTestContainer = ({ dataToAnalyze }: Props) => {
const [isRunning, setIsRunning] = useState(false);

useEffect(() => {
if (dataToAnalyze && isRunning) foldTestBootstrap(dataToAnalyze, 1000, setDataToShow, setIsRunning);
if (!dataToAnalyze || !isRunning) return;

const cancelBootstrap = foldTestBootstrap(dataToAnalyze, 1000, setDataToShow, setIsRunning);

return () => {
cancelBootstrap?.();
};
}, [dataToAnalyze, isRunning]);

const [wv, wh] = useWindowSize();
Expand Down
30 changes: 14 additions & 16 deletions src/components/AppLogic/ToolsDIR/ReversePolarityButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ const ReversePolarityButtons = ({ data }: Props) => {
const [reverseDirs, setReverseDirs] = useState<boolean>(false);
const [showIndexesInput, setShowIndexesInput] = useState<boolean>(false);

const onUnreverseClick = () => {
const onUnreverseClick = useCallback(() => {
dispatch(setReversedDirectionsIDs([]));
};
}, [dispatch]);

const onReverseClick = () => {
const onReverseClick = useCallback(() => {
setReverseDirs(true);
};
}, []);

// const [showHotkey, setShowHotkey] = useState<{key: string, code: string}>({key: 'S', code: 'KeyS'});
// const [hideHotkey, setHideHotkey] = useState<{key: string, code: string}>({key: 'H', code: 'KeyH'});
Expand All @@ -61,24 +61,14 @@ const ReversePolarityButtons = ({ data }: Props) => {
setShowIndexesInput(true);
}
if (reverseDirs && selectedDirectionsIDs && selectedDirectionsIDs.length) {
console.log(selectedDirectionsIDs)
dispatch(addReversedDirectionsIDs(selectedDirectionsIDs));
setReverseDirs(false);
dispatch(setSelectedDirectionsIDs(null));
dispatch(setStatisticsMode(null));
};
}, [reverseDirs, selectedDirectionsIDs]);

useEffect(() => {
console.log('what', hotkeysActive)
if (hotkeysActive) window.addEventListener("keydown", handleHotkeys);
else window.removeEventListener("keydown", handleHotkeys);
return () => {
window.removeEventListener("keydown", handleHotkeys);
};
}, [hotkeysActive, hotkeys]);

const handleHotkeys = (event: KeyboardEvent) => {
const handleHotkeys = useCallback((event: KeyboardEvent) => {
const keyCode = event.code;

if (keyCode === reverseHotkey.code) {
Expand All @@ -89,7 +79,15 @@ const ReversePolarityButtons = ({ data }: Props) => {
event.preventDefault();
onUnreverseClick();
};
};
}, [reverseHotkey, unreverseHotkey, onReverseClick, onUnreverseClick]);

useEffect(() => {
if (!hotkeysActive) return;
window.addEventListener("keydown", handleHotkeys);
return () => {
window.removeEventListener("keydown", handleHotkeys);
};
}, [hotkeysActive, handleHotkeys]);

const handleEnteredDotsIndexesApply = (indexes: string) => {
const maxIndex = data?.interpretations.length;
Expand Down
28 changes: 14 additions & 14 deletions src/components/AppLogic/ToolsDIR/ShowHideDotsButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ const ShowHideDotsButtons = ({ data }: Props) => {
const [hideDirs, setHideDirs] = useState<boolean>(false);
const [showIndexesInput, setShowIndexesInput] = useState<boolean>(false);

const onShowClick = () => {
const onShowClick = useCallback(() => {
dispatch(setHiddenDirectionsIDs([]));
};
}, [dispatch]);

const onHideClick = () => {
const onHideClick = useCallback(() => {
setHideDirs(true);
};
}, []);

const [showHotkey, setShowHotkey] = useState<{key: string, code: string}>({key: 'S', code: 'KeyS'});
const [hideHotkey, setHideHotkey] = useState<{key: string, code: string}>({key: 'H', code: 'KeyH'});
Expand All @@ -64,15 +64,7 @@ const ShowHideDotsButtons = ({ data }: Props) => {
};
}, [hideDirs, selectedDirectionsIDs]);

useEffect(() => {
if (hotkeysActive) window.addEventListener("keydown", handleHotkeys);
else window.removeEventListener("keydown", handleHotkeys);
return () => {
window.removeEventListener("keydown", handleHotkeys);
};
}, [hotkeysActive, hotkeys]);

const handleHotkeys = (event: KeyboardEvent) => {
const handleHotkeys = useCallback((event: KeyboardEvent) => {
const keyCode = event.code;

if (keyCode === showHotkey.code) {
Expand All @@ -83,7 +75,15 @@ const ShowHideDotsButtons = ({ data }: Props) => {
event.preventDefault();
onHideClick();
};
};
}, [showHotkey, hideHotkey, onShowClick, onHideClick]);

useEffect(() => {
if (!hotkeysActive) return;
window.addEventListener("keydown", handleHotkeys);
return () => {
window.removeEventListener("keydown", handleHotkeys);
};
}, [hotkeysActive, handleHotkeys]);

const handleEnteredDotsIndexesApply = (steps: string) => {
const maxIndex = data?.interpretations.length || 0;
Expand Down
35 changes: 17 additions & 18 deletions src/components/AppLogic/ToolsDIR/ToolsDIR.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useEffect, useState } from 'react';
import React, { FC, useCallback, useEffect, useState } from 'react';
import ButtonGroupWithLabel from '../../Common/Buttons/ButtonGroupWithLabel/ButtonGroupWithLabel';
import { Button, Tooltip, Typography } from '@mui/material';
import { useAppDispatch, useAppSelector } from '../../../services/store/hooks';
Expand Down Expand Up @@ -30,6 +30,8 @@ interface IToolsDIR {
data: IDirData | null;
};

const AVAILABLE_REFERENCES: Array<Reference> = ['geographic', 'stratigraphic'];

const ToolsDIR: FC<IToolsDIR> = ({ data }) => {

const dispatch = useAppDispatch();
Expand All @@ -43,8 +45,6 @@ const ToolsDIR: FC<IToolsDIR> = ({ data }) => {
const [showVGP, setShowVGP] = useState<boolean>(false);
const [showPMTests, setShowPMTests] = useState<boolean>(false);

const availableReferences: Array<Reference> = ['geographic', 'stratigraphic'];

const [coordinateSystemHotkey, setCoordinateSystemHotkey] = useState<{key: string, code: string}>({key: 'Q', code: 'KeyQ'});
const [fisherHotkey, setFisherHotkey] = useState<{key: string, code: string}>({key: 'F', code: 'KeyF'});
const [mcFaddenHotkey, setMcFaddenHotkey] = useState<{key: string, code: string}>({key: 'M', code: 'KeyM'});
Expand Down Expand Up @@ -77,23 +77,14 @@ const ToolsDIR: FC<IToolsDIR> = ({ data }) => {
}, [selectedDirectionsIDs, statisticsMode]);

// добавляет слушатель нажатий на клавиатуру (для использования сочетаний клавиш)
useEffect(() => {
if (hotkeysActive) window.addEventListener("keydown", handleHotkeys);
else window.removeEventListener("keydown", handleHotkeys);
return () => {
window.removeEventListener("keydown", handleHotkeys);
};
}, [hotkeysActive, hotkeys, reference]);

// обработчик нажатий на клавиатуру
const handleHotkeys = (event: KeyboardEvent) => {
const handleHotkeys = useCallback((event: KeyboardEvent) => {
const keyCode = event.code;

if (keyCode === coordinateSystemHotkey.code) {
event.preventDefault();
const currReferenceIndex = availableReferences.findIndex(coordRef => coordRef === reference);
const nextReferenceIndex = (currReferenceIndex + 1) % 2;
dispatch(setReference(availableReferences[nextReferenceIndex]));
const currReferenceIndex = AVAILABLE_REFERENCES.findIndex(coordRef => coordRef === reference);
const nextReferenceIndex = (currReferenceIndex + 1) % AVAILABLE_REFERENCES.length;
dispatch(setReference(AVAILABLE_REFERENCES[nextReferenceIndex]));
};
if (keyCode === fisherHotkey.code) {
event.preventDefault();
Expand All @@ -115,7 +106,15 @@ const ToolsDIR: FC<IToolsDIR> = ({ data }) => {
event.preventDefault();
dispatch(setSelectedDirectionsIDs([]));
};
};
}, [coordinateSystemHotkey, fisherHotkey, mcFaddenHotkey, gcHotkey, gcnHotkey, unselectHotkey, reference, dispatch]);

useEffect(() => {
if (!hotkeysActive) return;
window.addEventListener("keydown", handleHotkeys);
return () => {
window.removeEventListener("keydown", handleHotkeys);
};
}, [hotkeysActive, handleHotkeys]);

// обработчик выбранной системы координат
const handleReferenceSelect = (selectedReference: Reference) => {
Expand All @@ -137,7 +136,7 @@ const ToolsDIR: FC<IToolsDIR> = ({ data }) => {
<ToolsPMDSkeleton>
<ButtonGroupWithLabel label={t('dirPage.tools.coordinateSystem.title')}>
{
availableReferences.map(availRef => (
AVAILABLE_REFERENCES.map(availRef => (
<Tooltip
title={<Typography variant='body1'>{coordinateSystemHotkey.key}</Typography>}
enterDelay={250}
Expand Down
28 changes: 14 additions & 14 deletions src/components/AppLogic/ToolsPMD/ShowHideDotsButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ const ShowHideDotsButtons = ({ data }: Props) => {
const [hideSteps, setHideSteps] = useState<boolean>(false);
const [showStepsInput, setShowStepsInput] = useState<boolean>(false);

const onShowClick = () => {
const onShowClick = useCallback(() => {
dispatch(setHiddenStepsIDs([]));
};
}, [dispatch]);

const onHideClick = () => {
const onHideClick = useCallback(() => {
setHideSteps(true);
};
}, []);

const [showHotkey, setShowHotkey] = useState<{key: string, code: string}>({key: 'S', code: 'KeyS'});
const [hideHotkey, setHideHotkey] = useState<{key: string, code: string}>({key: 'H', code: 'KeyH'});
Expand All @@ -59,15 +59,7 @@ const ShowHideDotsButtons = ({ data }: Props) => {
};
}, [hideSteps, selectedStepsIDs]);

useEffect(() => {
if (hotkeysActive) window.addEventListener("keydown", handleHotkeys);
else window.removeEventListener("keydown", handleHotkeys);
return () => {
window.removeEventListener("keydown", handleHotkeys);
};
}, [hotkeysActive, hotkeys]);

const handleHotkeys = (event: KeyboardEvent) => {
const handleHotkeys = useCallback((event: KeyboardEvent) => {
const keyCode = event.code;

if (keyCode === showHotkey.code) {
Expand All @@ -78,7 +70,15 @@ const ShowHideDotsButtons = ({ data }: Props) => {
event.preventDefault();
onHideClick();
};
};
}, [showHotkey, hideHotkey, onShowClick, onHideClick]);

useEffect(() => {
if (!hotkeysActive) return;
window.addEventListener("keydown", handleHotkeys);
return () => {
window.removeEventListener("keydown", handleHotkeys);
};
}, [hotkeysActive, handleHotkeys]);

const handleEnteredStepsApply = (steps: string) => {
const maxIndex = data.steps.length;
Expand Down
38 changes: 19 additions & 19 deletions src/components/AppLogic/ToolsPMD/ToolsPMD.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useEffect, useState } from 'react';
import React, { FC, useCallback, useEffect, useState } from 'react';
import { ButtonGroupWithLabel } from '../../Common/Buttons';
import { Button, Tooltip, Typography } from '@mui/material';
import { Reference } from '../../../utils/graphs/types';
Expand All @@ -24,6 +24,8 @@ interface IToolsPMD {
data: IPmdData | null;
};

const AVAILABLE_REFERENCES: Array<Reference> = ['specimen', 'geographic', 'stratigraphic'];

const ToolsPMD: FC<IToolsPMD> = ({ data }) => {

const dispatch = useAppDispatch();
Expand All @@ -37,8 +39,6 @@ const ToolsPMD: FC<IToolsPMD> = ({ data }) => {
const [coordinateSystem, setCoordinateSystem] = useState<Reference>('geographic');
const [showStepsInput, setShowStepsInput] = useState<boolean>(false);

const availableReferences: Array<Reference> = ['specimen', 'geographic', 'stratigraphic'];

const [coordinateSystemHotkey, setCoordinateSystemHotkey] = useState<{key: string, code: string}>({key: 'Q', code: 'KeyQ'});
const [pcaHotkey, setPcaHotkey] = useState<{key: string, code: string}>({key: 'D', code: 'KeyD'});
const [pca0Hotkey, setPca0Hotkey] = useState<{key: string, code: string}>({key: 'O', code: 'KeyO'});
Expand Down Expand Up @@ -69,30 +69,22 @@ const ToolsPMD: FC<IToolsPMD> = ({ data }) => {
}
}, [selectedStepsIDs, statisticsMode]);

useEffect(() => {
if (hotkeysActive) window.addEventListener("keydown", handleHotkeys);
else window.removeEventListener("keydown", handleHotkeys);
return () => {
window.removeEventListener("keydown", handleHotkeys);
};
}, [hotkeysActive, hotkeys, reference]);

useEffect(() => {
setCoordinateSystem(reference);
}, [reference]);

const handleReferenceSelect = (selectedReference: Reference) => {
const handleReferenceSelect = useCallback((selectedReference: Reference) => {
dispatch(setReference(selectedReference));
};
}, [dispatch]);

const handleHotkeys = (event: KeyboardEvent) => {
const handleHotkeys = useCallback((event: KeyboardEvent) => {
const keyCode = event.code;

if (keyCode === coordinateSystemHotkey.code) {
event.preventDefault();
const currReferenceIndex = availableReferences.findIndex(coordRef => coordRef === reference);
const nextReferenceIndex = (currReferenceIndex + 1) % 3;
dispatch(setReference(availableReferences[nextReferenceIndex]));
const currReferenceIndex = AVAILABLE_REFERENCES.findIndex(coordRef => coordRef === reference);
const nextReferenceIndex = (currReferenceIndex + 1) % AVAILABLE_REFERENCES.length;
dispatch(setReference(AVAILABLE_REFERENCES[nextReferenceIndex]));
}
if (keyCode === pcaHotkey.code) {
event.preventDefault();
Expand All @@ -114,7 +106,15 @@ const ToolsPMD: FC<IToolsPMD> = ({ data }) => {
event.preventDefault();
dispatch(setSelectedStepsIDs(null));
};
};
}, [coordinateSystemHotkey, pcaHotkey, pca0Hotkey, gcHotkey, gcnHotkey, unselectHotkey, reference, dispatch]);

useEffect(() => {
if (!hotkeysActive) return;
window.addEventListener("keydown", handleHotkeys);
return () => {
window.removeEventListener("keydown", handleHotkeys);
};
}, [hotkeysActive, handleHotkeys]);

if (!data) return <ToolsPMDSkeleton />;

Expand All @@ -130,7 +130,7 @@ const ToolsPMD: FC<IToolsPMD> = ({ data }) => {
<ToolsPMDSkeleton>
<ButtonGroupWithLabel label={t('pcaPage.tools.coordinateSystem.title')}>
{
availableReferences.map(availRef => (
AVAILABLE_REFERENCES.map(availRef => (
<Tooltip
title={<Typography variant='body1'>{coordinateSystemHotkey.key}</Typography>}
enterDelay={250}
Expand Down
Loading