nmrium 0.50.0 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/lib/component/1d/Chart1D.js +1 -1
- package/lib/component/1d/LinesSeries.js +2 -2
- package/lib/component/1d/Viewer1D.js +6 -11
- package/lib/component/1d/database/DatabaseSpectrum.js +3 -3
- package/lib/component/2d/1d-tracer/HorizontalSliceChart.js +6 -2
- package/lib/component/2d/1d-tracer/VerticalSliceChart.js +8 -1
- package/lib/component/2d/1d-tracer/phase-correction-traces/PhaseTraceWithMouse.js +2 -21
- package/lib/component/2d/1d-tracer/phase-correction-traces/PhaseTraces.js +1 -1
- package/lib/component/2d/1d-tracer/phase-correction-traces/SpectraPhaseTraces.d.ts +1 -1
- package/lib/component/2d/1d-tracer/phase-correction-traces/SpectraPhaseTraces.js +6 -17
- package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.d.ts +6 -10
- package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.js +62 -13
- package/lib/component/2d/1d-tracer/phase-correction-traces/useActivePhaseTraces.d.ts +1 -0
- package/lib/component/2d/1d-tracer/phase-correction-traces/useActivePhaseTraces.js +2 -1
- package/lib/component/2d/Viewer2D.js +16 -15
- package/lib/component/2d/ft/Contours.js +6 -3
- package/lib/component/2d/utilities/scale.d.ts +2 -1
- package/lib/component/2d/utilities/scale.js +12 -2
- package/lib/component/EventsTrackers/BrushTracker.d.ts +5 -3
- package/lib/component/EventsTrackers/BrushTracker.js +2 -2
- package/lib/component/EventsTrackers/KeysListenerTracker.d.ts +1 -1
- package/lib/component/EventsTrackers/KeysListenerTracker.js +29 -15
- package/lib/component/context/ToasterContext.d.ts +13 -0
- package/lib/component/context/ToasterContext.js +34 -0
- package/lib/component/elements/CloseButton.d.ts +2 -2
- package/lib/component/elements/CloseButton.js +1 -1
- package/lib/component/elements/CounterLabel.d.ts +3 -3
- package/lib/component/elements/CounterLabel.js +3 -3
- package/lib/component/elements/PreferencesButton.d.ts +2 -2
- package/lib/component/elements/PreferencesButton.js +2 -4
- package/lib/component/elements/SaveButton.d.ts +2 -2
- package/lib/component/elements/SaveButton.js +1 -1
- package/lib/component/elements/Select.js +2 -2
- package/lib/component/elements/ToolBarButton.d.ts +1 -8
- package/lib/component/elements/ToolBarButton.js +2 -11
- package/lib/component/elements/ToolbarPopoverItem.d.ts +11 -0
- package/lib/component/elements/ToolbarPopoverItem.js +10 -0
- package/lib/component/header/AutoPeakPickingOptionPanel.js +6 -3
- package/lib/component/header/Header.d.ts +1 -11
- package/lib/component/header/Header.js +5 -6
- package/lib/component/header/PhaseCorrectionPanel.js +24 -33
- package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.d.ts +1 -1
- package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.js +96 -42
- package/lib/component/header/RangesPickingOptionPanel.js +6 -3
- package/lib/component/hooks/useDialogToggle.d.ts +5 -0
- package/lib/component/hooks/useDialogToggle.js +16 -0
- package/lib/component/hooks/useExport.d.ts +9 -1
- package/lib/component/hooks/useExport.js +34 -36
- package/lib/component/hooks/useSaveSettings.js +6 -3
- package/lib/component/hooks/useToolsFunctions.js +6 -4
- package/lib/component/loader/DropZone.js +14 -14
- package/lib/component/main/InnerNMRium.js +5 -9
- package/lib/component/main/InnerNMRiumContents.d.ts +0 -2
- package/lib/component/main/InnerNMRiumContents.js +5 -3
- package/lib/component/main/NMRium.js +2 -2
- package/lib/component/modal/AboutPredictionModal.js +1 -1
- package/lib/component/modal/CopyClipboardModal.js +1 -1
- package/lib/component/modal/EditPeakShapeModal.js +1 -1
- package/lib/component/modal/ExportAsJcampModal.js +15 -15
- package/lib/component/modal/ImportPublicationStringModal.js +5 -3
- package/lib/component/modal/LoadJCAMPModal.js +6 -4
- package/lib/component/modal/PredictSpectraModal.js +11 -9
- package/lib/component/modal/SaveAsModal.d.ts +3 -4
- package/lib/component/modal/SaveAsModal.js +27 -27
- package/lib/component/modal/aboutUs/AboutUsModal.js +1 -1
- package/lib/component/modal/editRange/EditRangeModal.js +2 -2
- package/lib/component/modal/editRange/forms/components/DeltaInput.d.ts +2 -3
- package/lib/component/modal/editRange/forms/components/DeltaInput.js +2 -3
- package/lib/component/modal/editRange/forms/components/InfoBlock.d.ts +1 -0
- package/lib/component/modal/editRange/forms/components/{SignalFormInfo.js → InfoBlock.js} +2 -2
- package/lib/component/modal/editRange/forms/components/NewSignalTab.d.ts +5 -0
- package/lib/component/modal/editRange/forms/components/NewSignalTab.js +85 -0
- package/lib/component/modal/editRange/forms/components/SignalTab.d.ts +7 -0
- package/lib/component/modal/editRange/forms/components/SignalTab.js +24 -0
- package/lib/component/modal/editRange/forms/components/SignalsContent.d.ts +8 -0
- package/lib/component/modal/editRange/forms/components/SignalsContent.js +57 -0
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.d.ts +5 -0
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +133 -0
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.d.ts +5 -0
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +141 -0
- package/lib/component/modal/editZone/EditZoneModal.js +1 -1
- package/lib/component/modal/metaImportation/MetaImportationModal.d.ts +7 -4
- package/lib/component/modal/metaImportation/MetaImportationModal.js +23 -13
- package/lib/component/modal/metaImportation/utils/mapColumnToSelectItems.js +1 -1
- package/lib/component/modal/setting/GeneralSettings.js +7 -4
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +16 -2
- package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js +7 -4
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +20 -6
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +16 -3
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +14 -10
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +6 -4
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +48 -14
- package/lib/component/panels/RangesPanel/RangesHeader.js +73 -13
- package/lib/component/panels/RangesPanel/RangesPanel.js +4 -4
- package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +49 -8
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +11 -5
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +1 -1
- package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.js +1 -1
- package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.js +1 -1
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +28 -18
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +28 -4
- package/lib/component/panels/databasePanel/DatabasePanel.js +37 -19
- package/lib/component/panels/databasePanel/DatabaseSearchOptions.d.ts +3 -3
- package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +4 -4
- package/lib/component/panels/filtersPanel/FilterPanel.js +6 -4
- package/lib/component/panels/filtersPanel/FiltersTable.js +27 -23
- package/lib/component/panels/header/DefaultPanelHeader.d.ts +10 -6
- package/lib/component/panels/header/DefaultPanelHeader.js +26 -10
- package/lib/component/panels/header/SpectraAutomaticPickingButton.js +6 -4
- package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +2 -2
- package/lib/component/panels/multipleAnalysisPanel/AnalysisChart.js +3 -3
- package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +36 -7
- package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +4 -2
- package/lib/component/panels/predictionPanel/PredictionPanel.js +7 -5
- package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +1 -0
- package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +5 -1
- package/lib/component/reducer/Reducer.d.ts +2 -2
- package/lib/component/reducer/Reducer.js +23 -16
- package/lib/component/reducer/actions/FiltersActions.d.ts +11 -4
- package/lib/component/reducer/actions/FiltersActions.js +243 -91
- package/lib/component/reducer/actions/IntegralsActions.d.ts +1 -1
- package/lib/component/reducer/actions/IntegralsActions.js +2 -2
- package/lib/component/reducer/actions/MoleculeActions.js +0 -1
- package/lib/component/reducer/actions/RangesActions.js +16 -6
- package/lib/component/reducer/actions/ToolsActions.d.ts +3 -3
- package/lib/component/reducer/actions/ToolsActions.js +75 -14
- package/lib/component/reducer/helper/Zoom1DManager.d.ts +4 -3
- package/lib/component/reducer/helper/Zoom1DManager.js +4 -4
- package/lib/component/reducer/helper/ZoomHistoryManager.js +1 -5
- package/lib/component/reducer/helper/findStrongestPeak.d.ts +6 -0
- package/lib/component/reducer/helper/findStrongestPeak.js +13 -0
- package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.d.ts +2 -1
- package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.js +7 -1
- package/lib/component/toolbar/ToolBar.js +241 -8
- package/lib/component/toolbar/toolbarMenu.d.ts +4 -0
- package/lib/component/toolbar/toolbarMenu.js +77 -0
- package/lib/component/utility/Events.d.ts +11 -0
- package/lib/component/utility/Events.js +22 -0
- package/lib/component/utility/booleanToString.d.ts +6 -0
- package/lib/component/utility/booleanToString.js +4 -0
- package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +0 -33
- package/lib/data/data1d/Spectrum1D/ranges/addRange.js +5 -15
- package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -4
- package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectRanges.d.ts +6 -4
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +13 -3
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +6 -0
- package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.d.ts +13 -3
- package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js +78 -18
- package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +2 -2
- package/lib/data/data1d/spectrumSimulation.d.ts +1 -1
- package/lib/data/data2d/Spectrum2D/contours.js +3 -3
- package/lib/data/data2d/Spectrum2D/getMissingProjection.js +2 -2
- package/lib/data/data2d/Spectrum2D/getSlice.js +3 -3
- package/lib/data/getDefaultMatrixFilters.js +2 -2
- package/lib/data/matrixGeneration.js +1 -1
- package/lib/data/utilities/calculateSanPlot.d.ts +1 -6
- package/lib/versionInfo.js +1 -1
- package/package.json +31 -30
- package/lib/component/elements/DeleteButton.d.ts +0 -6
- package/lib/component/elements/DeleteButton.js +0 -8
- package/lib/component/elements/DropdownMenu.d.ts +0 -9
- package/lib/component/elements/DropdownMenu.js +0 -7
- package/lib/component/elements/FilterButton.d.ts +0 -6
- package/lib/component/elements/FilterButton.js +0 -8
- package/lib/component/elements/popup/Alert/AlertBlock.d.ts +0 -8
- package/lib/component/elements/popup/Alert/AlertBlock.js +0 -30
- package/lib/component/elements/popup/Alert/Context.d.ts +0 -27
- package/lib/component/elements/popup/Alert/Context.js +0 -10
- package/lib/component/elements/popup/Alert/ProgressIndicator.d.ts +0 -1
- package/lib/component/elements/popup/Alert/ProgressIndicator.js +0 -33
- package/lib/component/elements/popup/Alert/Provider.d.ts +0 -19
- package/lib/component/elements/popup/Alert/Provider.js +0 -127
- package/lib/component/elements/popup/Alert/index.d.ts +0 -3
- package/lib/component/elements/popup/Alert/index.js +0 -3
- package/lib/component/modal/editRange/forms/components/AddSignalFormTab.d.ts +0 -10
- package/lib/component/modal/editRange/forms/components/AddSignalFormTab.js +0 -81
- package/lib/component/modal/editRange/forms/components/CouplingsTable.d.ts +0 -13
- package/lib/component/modal/editRange/forms/components/CouplingsTable.js +0 -63
- package/lib/component/modal/editRange/forms/components/SignalFormInfo.d.ts +0 -1
- package/lib/component/modal/editRange/forms/components/SignalFormTab.d.ts +0 -8
- package/lib/component/modal/editRange/forms/components/SignalFormTab.js +0 -18
- package/lib/component/modal/editRange/forms/components/SignalsForm.d.ts +0 -10
- package/lib/component/modal/editRange/forms/components/SignalsForm.js +0 -114
- package/lib/component/modal/metaImportation/index.d.ts +0 -2
- package/lib/component/modal/metaImportation/index.js +0 -17
- package/lib/component/panels/PeaksPanel/PeaksToggleActions.d.ts +0 -12
- package/lib/component/panels/PeaksPanel/PeaksToggleActions.js +0 -7
- package/lib/component/reducer/helper/getStrongestPeak.d.ts +0 -7
- package/lib/component/reducer/helper/getStrongestPeak.js +0 -15
- package/lib/component/toolbar/BasicToolBar.d.ts +0 -1
- package/lib/component/toolbar/BasicToolBar.js +0 -165
- package/lib/component/toolbar/FunctionToolBar.d.ts +0 -3
- package/lib/component/toolbar/FunctionToolBar.js +0 -148
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { css } from '@emotion/react';
|
|
4
|
+
import { useFormikContext } from 'formik';
|
|
5
|
+
import { useCallback, useMemo, memo, useEffect } from 'react';
|
|
6
|
+
import { FaPlus } from 'react-icons/fa';
|
|
7
|
+
import Tab from '../../../../elements/Tab/Tab';
|
|
8
|
+
import Tabs from '../../../../elements/Tab/Tabs';
|
|
9
|
+
import { DeltaInput } from './DeltaInput';
|
|
10
|
+
import { InfoBlock } from './InfoBlock';
|
|
11
|
+
import { NewSignalTab } from './NewSignalTab';
|
|
12
|
+
import SignalTab from './SignalTab';
|
|
13
|
+
const tabStylesAddition = css `
|
|
14
|
+
color: red;
|
|
15
|
+
`;
|
|
16
|
+
const tabStyles = css `
|
|
17
|
+
padding: 0 1.5rem !important;
|
|
18
|
+
height: 40px;
|
|
19
|
+
`;
|
|
20
|
+
const newTabStyles = css `
|
|
21
|
+
padding: 0 !important;
|
|
22
|
+
height: 40px;
|
|
23
|
+
`;
|
|
24
|
+
function SignalsContent({ range }) {
|
|
25
|
+
const { values, setFieldValue, errors, } = useFormikContext();
|
|
26
|
+
const tapClickHandler = useCallback(({ tabid }) => {
|
|
27
|
+
setFieldValue('signalIndex', tabid);
|
|
28
|
+
}, [setFieldValue]);
|
|
29
|
+
const handleDeleteSignal = useCallback(({ tabid }) => {
|
|
30
|
+
const _signals = values.signals.filter((_signal, i) => i !== Number(tabid));
|
|
31
|
+
setFieldValue('signals', _signals);
|
|
32
|
+
}, [setFieldValue, values.signals]);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
setFieldValue('signalIndex', values.signals.length > 0 ? (values.signals.length - 1).toString() : '-1');
|
|
35
|
+
}, [setFieldValue, values.signals.length]);
|
|
36
|
+
const tabContainsErrors = useCallback((i) => {
|
|
37
|
+
return !!errors?.signals?.[i];
|
|
38
|
+
}, [errors]);
|
|
39
|
+
const signalFormTabs = useMemo(() => {
|
|
40
|
+
const signalTabs = values.signals.length > 0
|
|
41
|
+
? values.signals.map((signal, i) => (_jsx(Tab
|
|
42
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
43
|
+
, { tabid: `${i}`, tabstyles: tabContainsErrors(i) ? tabStylesAddition : tabStyles, canDelete: true, render: () => _jsx(DeltaInput, { signal: signal, index: i }), children: _jsx(SignalTab, { index: i }) }, `signalForm${i}`)))
|
|
44
|
+
: [];
|
|
45
|
+
const addSignalTab = (_jsx(Tab, { tabid: "-1", canDelete: false, tabstyles: newTabStyles, render: () => (_jsxs("div", { style: {
|
|
46
|
+
display: 'flex',
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
padding: '0 1.5rem',
|
|
49
|
+
fontSize: '12px',
|
|
50
|
+
color: '#28ba62',
|
|
51
|
+
textWrap: 'nowrap',
|
|
52
|
+
}, children: [_jsx(FaPlus, { style: { display: 'inline-block' } }), _jsx("span", { style: { display: 'inline-block' }, children: "New Signal" })] })), children: _jsx(NewSignalTab, { range: range }) }, "addSignalTab"));
|
|
53
|
+
return [...signalTabs, addSignalTab];
|
|
54
|
+
}, [range, tabContainsErrors, values.signals]);
|
|
55
|
+
return (_jsxs("div", { children: [_jsx(InfoBlock, {}), _jsx(Tabs, { activeTab: values.signalIndex, onClick: tapClickHandler, onDelete: handleDeleteSignal, children: signalFormTabs })] }));
|
|
56
|
+
}
|
|
57
|
+
export default memo(SignalsContent);
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useFormikContext } from 'formik';
|
|
3
|
+
import { translateMultiplet } from 'nmr-processing';
|
|
4
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
5
|
+
import { FaPlus, FaRegTrashAlt } from 'react-icons/fa';
|
|
6
|
+
import { Toolbar } from 'react-science/ui';
|
|
7
|
+
import { Multiplets } from '../../../../../../data/constants/Multiplets';
|
|
8
|
+
import { isSpectrum1D } from '../../../../../../data/data1d/Spectrum1D';
|
|
9
|
+
import { useChartData } from '../../../../../context/ChartContext';
|
|
10
|
+
import Button from '../../../../../elements/Button';
|
|
11
|
+
import ReactTable from '../../../../../elements/ReactTable/ReactTable';
|
|
12
|
+
import FormikInput from '../../../../../elements/formik/FormikInput';
|
|
13
|
+
import FormikSelect from '../../../../../elements/formik/FormikSelect';
|
|
14
|
+
import { usePanelPreferences } from '../../../../../hooks/usePanelPreferences';
|
|
15
|
+
import useSpectrum from '../../../../../hooks/useSpectrum';
|
|
16
|
+
import { hasCouplingConstant } from '../../../../../panels/extra/utilities/MultiplicityUtilities';
|
|
17
|
+
import { useEvent } from '../../../../../utility/Events';
|
|
18
|
+
import { formatNumber } from '../../../../../utility/formatNumber';
|
|
19
|
+
const styles = {
|
|
20
|
+
input: {
|
|
21
|
+
width: '100%',
|
|
22
|
+
padding: '0.25rem 0.5rem',
|
|
23
|
+
},
|
|
24
|
+
select: {
|
|
25
|
+
height: '26px',
|
|
26
|
+
width: '100%',
|
|
27
|
+
},
|
|
28
|
+
column: {
|
|
29
|
+
padding: '2px',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
function getJCouplingKey(signalIndex, jIndex, jCouplingKey) {
|
|
33
|
+
return `signals[${signalIndex}].js.${jIndex}.${jCouplingKey}`;
|
|
34
|
+
}
|
|
35
|
+
export function SignalJCouplingsTable(props) {
|
|
36
|
+
const { values, setFieldValue } = useFormikContext();
|
|
37
|
+
const signal = values?.signals?.[values?.signalIndex] || {};
|
|
38
|
+
const jCouplings = signal?.js || [];
|
|
39
|
+
const [lastSelectedCouplingIndex, setLastSelectedCouplingIndex] = useState(null);
|
|
40
|
+
const spectrum = useSpectrum();
|
|
41
|
+
const { view: { spectra: { activeTab }, }, } = useChartData();
|
|
42
|
+
const rangesPreferences = usePanelPreferences('ranges', activeTab);
|
|
43
|
+
useEvent({
|
|
44
|
+
onClick: (options) => {
|
|
45
|
+
if (`${props.index}` === values.signalIndex &&
|
|
46
|
+
typeof lastSelectedCouplingIndex === 'number') {
|
|
47
|
+
const x = formatNumber(options.xPPM, rangesPreferences.deltaHz.format);
|
|
48
|
+
void setFieldValue(getJCouplingKey(values.signalIndex, lastSelectedCouplingIndex, 'coupling'), x);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
onBrushEnd: (options) => {
|
|
52
|
+
const { range: [from, to], } = options;
|
|
53
|
+
if (`${props.index}` === values.signalIndex &&
|
|
54
|
+
typeof lastSelectedCouplingIndex === 'number' &&
|
|
55
|
+
isSpectrum1D(spectrum)) {
|
|
56
|
+
const value = Number(formatNumber(Math.abs(to - from) * spectrum.info.originFrequency, rangesPreferences.deltaHz.format));
|
|
57
|
+
void setFieldValue(getJCouplingKey(values.signalIndex, lastSelectedCouplingIndex, 'coupling'), value);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
const addHandler = useCallback((data) => {
|
|
62
|
+
const coupling = {
|
|
63
|
+
multiplicity: translateMultiplet('m'),
|
|
64
|
+
coupling: '',
|
|
65
|
+
};
|
|
66
|
+
void setFieldValue(`signals[${values?.signalIndex}].js`, [
|
|
67
|
+
...data,
|
|
68
|
+
coupling,
|
|
69
|
+
]);
|
|
70
|
+
setLastSelectedCouplingIndex(data.length);
|
|
71
|
+
}, [setFieldValue, values?.signalIndex]);
|
|
72
|
+
const deleteHandler = useCallback((data, index) => {
|
|
73
|
+
const jCouplings = data.filter((_, columnIndex) => columnIndex !== index);
|
|
74
|
+
void setFieldValue(`signals[${values?.signalIndex}].js`, jCouplings);
|
|
75
|
+
if (lastSelectedCouplingIndex === index) {
|
|
76
|
+
setLastSelectedCouplingIndex(null);
|
|
77
|
+
}
|
|
78
|
+
}, [lastSelectedCouplingIndex, setFieldValue, values?.signalIndex]);
|
|
79
|
+
function deleteAllHandler() {
|
|
80
|
+
void setFieldValue(`signals[${values?.signalIndex}].js`, []);
|
|
81
|
+
setLastSelectedCouplingIndex(null);
|
|
82
|
+
}
|
|
83
|
+
const multiplicityChangeHandler = useCallback((value, name) => {
|
|
84
|
+
if (!hasCouplingConstant(value)) {
|
|
85
|
+
void setFieldValue(name, '');
|
|
86
|
+
}
|
|
87
|
+
}, [setFieldValue]);
|
|
88
|
+
const COLUMNS = useMemo(() => [
|
|
89
|
+
{
|
|
90
|
+
Header: '#',
|
|
91
|
+
style: { width: '25px', ...styles.column },
|
|
92
|
+
accessor: (_, index) => index + 1,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
Header: 'Multiplicity',
|
|
96
|
+
style: { padding: 0, ...styles.column },
|
|
97
|
+
Cell: ({ row }) => {
|
|
98
|
+
return (_jsx(FormikSelect, { className: "select-box", name: getJCouplingKey(values.signalIndex, row.index, 'multiplicity'), items: Multiplets, itemValueField: "label", onChange: (value) => {
|
|
99
|
+
multiplicityChangeHandler(value, getJCouplingKey(values.signalIndex, row.index, 'coupling'));
|
|
100
|
+
}, style: styles.select, onClick: (e) => e.stopPropagation() }));
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
Header: 'J (Hz)',
|
|
105
|
+
style: { padding: 0, ...styles.column },
|
|
106
|
+
Cell: ({ row }) => {
|
|
107
|
+
return (_jsx(FormikInput, { name: getJCouplingKey(values.signalIndex, row.index, 'coupling'), type: "number", placeholder: 'J (Hz)', style: { input: styles.input }, disabled: !hasCouplingConstant(row.original?.multiplicity), onClick: (e) => e.stopPropagation() }));
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
Header: '',
|
|
112
|
+
style: { width: '70px', ...styles.column },
|
|
113
|
+
id: 'action-button',
|
|
114
|
+
Cell: ({ data, row }) => {
|
|
115
|
+
const record = row.original;
|
|
116
|
+
return (_jsx("div", { style: { display: 'flex', justifyContent: 'space-around' }, children: !record?.name && (_jsx(Button.Danger, { fill: "outline", onClick: (e) => {
|
|
117
|
+
e.stopPropagation();
|
|
118
|
+
deleteHandler(data, row.index);
|
|
119
|
+
}, children: _jsx(FaRegTrashAlt, {}) })) }));
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
], [deleteHandler, multiplicityChangeHandler, values.signalIndex]);
|
|
123
|
+
function selectRowHandler(index) {
|
|
124
|
+
setLastSelectedCouplingIndex((prevIndex) => prevIndex === index ? null : index);
|
|
125
|
+
}
|
|
126
|
+
function handleActiveRow(row) {
|
|
127
|
+
return row?.index === lastSelectedCouplingIndex;
|
|
128
|
+
}
|
|
129
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("div", { style: { padding: '5px 0', display: 'flex' }, children: _jsxs(Toolbar, { children: [_jsx(Toolbar.Item, { icon: _jsx(FaPlus, {}), title: "Add a new J coupling", intent: "success", onClick: () => addHandler(jCouplings) }), _jsx(Toolbar.Item, { icon: _jsx(FaRegTrashAlt, {}), title: "Delete all J couplings", intent: "danger", onClick: deleteAllHandler })] }) }), _jsx("div", { style: {
|
|
130
|
+
maxHeight: '300px',
|
|
131
|
+
overflow: 'auto',
|
|
132
|
+
}, children: _jsx(ReactTable, { data: jCouplings, columns: COLUMNS, onClick: (e, rowData) => selectRowHandler(rowData.index), activeRow: handleActiveRow, emptyDataRowText: "No J Couplings" }) })] }));
|
|
133
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { v4 } from '@lukeed/uuid';
|
|
3
|
+
import { useFormikContext } from 'formik';
|
|
4
|
+
import { xFindClosestIndex } from 'ml-spectra-processing';
|
|
5
|
+
import { getShiftX } from 'nmr-processing';
|
|
6
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
7
|
+
import { FaPlus, FaRegTrashAlt } from 'react-icons/fa';
|
|
8
|
+
import { Toolbar } from 'react-science/ui';
|
|
9
|
+
import { useChartData } from '../../../../../context/ChartContext';
|
|
10
|
+
import Button from '../../../../../elements/Button';
|
|
11
|
+
import ReactTable from '../../../../../elements/ReactTable/ReactTable';
|
|
12
|
+
import FormikInput from '../../../../../elements/formik/FormikInput';
|
|
13
|
+
import { usePanelPreferences } from '../../../../../hooks/usePanelPreferences';
|
|
14
|
+
import useSpectrum from '../../../../../hooks/useSpectrum';
|
|
15
|
+
import { useEvent } from '../../../../../utility/Events';
|
|
16
|
+
import { formatNumber } from '../../../../../utility/formatNumber';
|
|
17
|
+
const styles = {
|
|
18
|
+
input: {
|
|
19
|
+
width: '100%',
|
|
20
|
+
padding: '0.25rem 0.5rem',
|
|
21
|
+
},
|
|
22
|
+
column: {
|
|
23
|
+
padding: '2px',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
function getPeakKey(signalIndex, peakIndex, key) {
|
|
27
|
+
const path = `signals[${signalIndex}].peaks.${peakIndex}`;
|
|
28
|
+
if (!key) {
|
|
29
|
+
return path;
|
|
30
|
+
}
|
|
31
|
+
return `${path}.${key}`;
|
|
32
|
+
}
|
|
33
|
+
export function SignalPeaksTable(props) {
|
|
34
|
+
const { values, setFieldValue } = useFormikContext();
|
|
35
|
+
const signal = values?.signals?.[values?.signalIndex] || {};
|
|
36
|
+
const peaks = signal?.peaks || [];
|
|
37
|
+
const delta = signal?.delta || 0;
|
|
38
|
+
const spectrum = useSpectrum();
|
|
39
|
+
const { data: { x: xArray, re }, } = spectrum;
|
|
40
|
+
const shiftX = getShiftX(spectrum);
|
|
41
|
+
const [lastSelectedPeakIndex, setLastSelectedPeakIndex] = useState(null);
|
|
42
|
+
const { view: { spectra: { activeTab }, }, } = useChartData();
|
|
43
|
+
const rangesPreferences = usePanelPreferences('ranges', activeTab);
|
|
44
|
+
useEvent({
|
|
45
|
+
onClick: (options) => {
|
|
46
|
+
if (`${props.index}` === values.signalIndex &&
|
|
47
|
+
typeof lastSelectedPeakIndex === 'number') {
|
|
48
|
+
const delta = formatNumber(options.xPPM, rangesPreferences.deltaPPM.format);
|
|
49
|
+
const xIndex = xFindClosestIndex(xArray, delta, { sorted: false });
|
|
50
|
+
const intensity = formatNumber(re[xIndex], rangesPreferences.deltaPPM.format);
|
|
51
|
+
void setFieldValue(getPeakKey(values?.signalIndex, lastSelectedPeakIndex), {
|
|
52
|
+
...peaks[lastSelectedPeakIndex],
|
|
53
|
+
x: delta,
|
|
54
|
+
y: intensity,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
onBrushEnd: (options) => {
|
|
59
|
+
const { range: [from, to], } = options;
|
|
60
|
+
if (`${props.index}` === values.signalIndex &&
|
|
61
|
+
typeof lastSelectedPeakIndex === 'number') {
|
|
62
|
+
const value = Number(formatNumber((to - from) / 2 + from, rangesPreferences.deltaPPM.format));
|
|
63
|
+
void setFieldValue(getPeakKey(values.signalIndex, lastSelectedPeakIndex, 'x'), value);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
const addHandler = useCallback((data) => {
|
|
68
|
+
const xIndex = xFindClosestIndex(xArray, delta, { sorted: false });
|
|
69
|
+
const peak = {
|
|
70
|
+
id: v4(),
|
|
71
|
+
x: delta,
|
|
72
|
+
y: xIndex !== -1 ? re[xIndex] : 0,
|
|
73
|
+
originalX: delta - shiftX,
|
|
74
|
+
width: 1,
|
|
75
|
+
};
|
|
76
|
+
void setFieldValue(`signals[${values?.signalIndex}].peaks`, [
|
|
77
|
+
...data,
|
|
78
|
+
peak,
|
|
79
|
+
]);
|
|
80
|
+
setLastSelectedPeakIndex(data?.length || 0);
|
|
81
|
+
}, [delta, re, setFieldValue, shiftX, values?.signalIndex, xArray]);
|
|
82
|
+
const deleteHandler = useCallback((data, index) => {
|
|
83
|
+
const peaks = data.filter((_, columnIndex) => columnIndex !== index);
|
|
84
|
+
void setFieldValue(`signals[${values?.signalIndex}].peaks`, peaks);
|
|
85
|
+
if (lastSelectedPeakIndex === index) {
|
|
86
|
+
setLastSelectedPeakIndex(null);
|
|
87
|
+
}
|
|
88
|
+
}, [lastSelectedPeakIndex, setFieldValue, values?.signalIndex]);
|
|
89
|
+
function deleteAllHandler() {
|
|
90
|
+
void setFieldValue(`signals[${values?.signalIndex}].peaks`, []);
|
|
91
|
+
setLastSelectedPeakIndex(null);
|
|
92
|
+
}
|
|
93
|
+
const changeDeltaHandler = useCallback((event, index) => {
|
|
94
|
+
const delta = Number(event.target.value);
|
|
95
|
+
const xIndex = xFindClosestIndex(xArray, delta, { sorted: false });
|
|
96
|
+
void setFieldValue(`signals[${values?.signalIndex}].peaks.${index}.y`, re[xIndex]);
|
|
97
|
+
}, [re, setFieldValue, values?.signalIndex, xArray]);
|
|
98
|
+
const COLUMNS = useMemo(() => [
|
|
99
|
+
{
|
|
100
|
+
Header: '#',
|
|
101
|
+
style: { width: '25px', ...styles.column },
|
|
102
|
+
accessor: (_, index) => index + 1,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
Header: 'delta',
|
|
106
|
+
style: { padding: 0, ...styles.column },
|
|
107
|
+
Cell: ({ row }) => {
|
|
108
|
+
return (_jsx(FormikInput, { name: `signals.${values?.signalIndex}.peaks.${row.index}.x`, style: { input: styles.input }, onChange: (event) => changeDeltaHandler(event, row.index), type: "number", onClick: (e) => e.stopPropagation() }));
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
Header: 'Intensity',
|
|
113
|
+
style: { padding: 0, ...styles.column },
|
|
114
|
+
Cell: ({ row }) => {
|
|
115
|
+
return (_jsx(FormikInput, { name: `signals.${values?.signalIndex}.peaks.${row.index}.y`, style: { input: styles.input }, readOnly: true }));
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
Header: '',
|
|
120
|
+
style: { width: '70px', ...styles.column },
|
|
121
|
+
id: 'action-button',
|
|
122
|
+
Cell: ({ data, row }) => {
|
|
123
|
+
const record = row.original;
|
|
124
|
+
return (_jsx("div", { style: { display: 'flex', justifyContent: 'space-around' }, children: !record?.name && (_jsx(Button.Danger, { fill: "outline", onClick: (e) => {
|
|
125
|
+
e.stopPropagation();
|
|
126
|
+
deleteHandler(data, row.index);
|
|
127
|
+
}, children: _jsx(FaRegTrashAlt, {}) })) }));
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
], [changeDeltaHandler, deleteHandler, values?.signalIndex]);
|
|
131
|
+
function selectRowHandler(index) {
|
|
132
|
+
setLastSelectedPeakIndex((prevIndex) => prevIndex === index ? null : index);
|
|
133
|
+
}
|
|
134
|
+
function handleActiveRow(row) {
|
|
135
|
+
return row?.index === lastSelectedPeakIndex;
|
|
136
|
+
}
|
|
137
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("div", { style: { padding: '5px 0', display: 'flex' }, children: _jsxs(Toolbar, { children: [_jsx(Toolbar.Item, { icon: _jsx(FaPlus, {}), title: "Add a new peak", intent: "success", onClick: () => addHandler(peaks) }), _jsx(Toolbar.Item, { icon: _jsx(FaRegTrashAlt, {}), title: "Delete all peaks", intent: "danger", onClick: deleteAllHandler })] }) }), _jsx("div", { style: {
|
|
138
|
+
maxHeight: '300px',
|
|
139
|
+
overflow: 'auto',
|
|
140
|
+
}, children: _jsx(ReactTable, { data: peaks, columns: COLUMNS, onClick: (e, rowData) => selectRowHandler(rowData.index), activeRow: handleActiveRow, emptyDataRowText: "No peaks" }) })] }));
|
|
141
|
+
}
|
|
@@ -96,6 +96,6 @@ function EditZoneModal({ onSaveEditZoneModal = () => null, onCloseEditZoneModal
|
|
|
96
96
|
}),
|
|
97
97
|
};
|
|
98
98
|
}, [rowData.signals, rowData.tableMetaInfo.experiment]);
|
|
99
|
-
return (_jsx("div", { css: styles, children: _jsx(Formik, { innerRef: formRef, initialValues: data, validationSchema: zoneFormValidation, onSubmit: handleOnSave, children: _jsxs(_Fragment, { children: [_jsxs("div", { className: "header handle", children: [_jsx(Button, { onClick: handleOnZoom, className: "zoom-button", children: _jsx(FaSearchPlus, { title: "Set to default view on range in spectrum" }) }), _jsx("span", { children: `Zone and Signal edition` }), _jsx(SaveButton, { onClick: () => formRef.current.submitForm(), title: "Save and Exit" }), _jsx(CloseButton, { onClick: handleOnClose })] }), _jsx(SignalsForm, {})] }) }) }));
|
|
99
|
+
return (_jsx("div", { css: styles, children: _jsx(Formik, { innerRef: formRef, initialValues: data, validationSchema: zoneFormValidation, onSubmit: handleOnSave, children: _jsxs(_Fragment, { children: [_jsxs("div", { className: "header handle", children: [_jsx(Button, { onClick: handleOnZoom, className: "zoom-button", children: _jsx(FaSearchPlus, { title: "Set to default view on range in spectrum" }) }), _jsx("span", { children: `Zone and Signal edition` }), _jsx(SaveButton, { onClick: () => formRef.current.submitForm(), title: "Save and Exit" }), _jsx(CloseButton, { title: "Close", onClick: handleOnClose })] }), _jsx(SignalsForm, {})] }) }) }));
|
|
100
100
|
}
|
|
101
101
|
export default EditZoneModal;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
interface
|
|
2
|
-
onClose?: () => void;
|
|
1
|
+
interface InnerMetaImportationModalPropsProps {
|
|
3
2
|
file?: File;
|
|
3
|
+
onCloseDialog: () => void;
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
interface MetaImportationModalPropsProps extends InnerMetaImportationModalPropsProps {
|
|
6
|
+
isOpen: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function MetaImportationModal(props: MetaImportationModalPropsProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { Dialog, DialogBody, DialogFooter } from '@blueprintjs/core';
|
|
3
4
|
import { Formik } from 'formik';
|
|
4
5
|
import { useState, useMemo, useRef, useEffect } from 'react';
|
|
5
6
|
import { DropZone } from 'react-science/ui';
|
|
@@ -7,16 +8,14 @@ import * as Yup from 'yup';
|
|
|
7
8
|
import { isMetaFile, linkMetaWithSpectra, parseMetaFile, TargetPathError, mapErrors, } from '../../../data/parseMeta';
|
|
8
9
|
import { useChartData } from '../../context/ChartContext';
|
|
9
10
|
import { useDispatch } from '../../context/DispatchContext';
|
|
11
|
+
import { useToaster } from '../../context/ToasterContext';
|
|
10
12
|
import Button from '../../elements/Button';
|
|
11
|
-
import { CloseButton } from '../../elements/CloseButton';
|
|
12
13
|
import Label from '../../elements/Label';
|
|
13
14
|
import ReactTable from '../../elements/ReactTable/ReactTable';
|
|
14
15
|
import FormikInput from '../../elements/formik/FormikInput';
|
|
15
16
|
import FormikSelect from '../../elements/formik/FormikSelect';
|
|
16
|
-
import { useAlert } from '../../elements/popup/Alert/Context';
|
|
17
17
|
import { convertPathArrayToString } from '../../utility/convertPathArrayToString';
|
|
18
18
|
import { getSpectraObjectPaths } from '../../utility/getSpectraObjectPaths';
|
|
19
|
-
import { ModalStyles } from '../ModalStyle';
|
|
20
19
|
import { mapColumnToSelectItems } from './utils/mapColumnToSelectItems';
|
|
21
20
|
const styles = {
|
|
22
21
|
container: {
|
|
@@ -63,8 +62,14 @@ const validationSchema = Yup.object({
|
|
|
63
62
|
source: Yup.string().required(),
|
|
64
63
|
target: Yup.array(Yup.string()).min(1).required(),
|
|
65
64
|
});
|
|
66
|
-
function MetaImportationModal(
|
|
67
|
-
const
|
|
65
|
+
export function MetaImportationModal(props) {
|
|
66
|
+
const { isOpen, onCloseDialog, file } = props;
|
|
67
|
+
if (!isOpen)
|
|
68
|
+
return null;
|
|
69
|
+
return (_jsx(Dialog, { isOpen: true, title: "Import Meta Information", style: { width: 900, height: 600 }, onClose: onCloseDialog, children: _jsx(InnerMetaImportationModal, { onCloseDialog, file }) }));
|
|
70
|
+
}
|
|
71
|
+
function InnerMetaImportationModal({ file, onCloseDialog, }) {
|
|
72
|
+
const toaster = useToaster();
|
|
68
73
|
const dispatch = useDispatch();
|
|
69
74
|
const formRef = useRef(null);
|
|
70
75
|
const [parseResult, setParseResult] = useState();
|
|
@@ -129,7 +134,10 @@ function MetaImportationModal({ onClose, file }) {
|
|
|
129
134
|
setCompareResults(compareResult);
|
|
130
135
|
}
|
|
131
136
|
else {
|
|
132
|
-
|
|
137
|
+
toaster.show({
|
|
138
|
+
message: `No matches found: Source field [${source}] => Target field [${target}]`,
|
|
139
|
+
intent: 'danger',
|
|
140
|
+
});
|
|
133
141
|
}
|
|
134
142
|
}
|
|
135
143
|
catch (error) {
|
|
@@ -137,7 +145,10 @@ function MetaImportationModal({ onClose, file }) {
|
|
|
137
145
|
void formRef.current?.setFieldValue('target', null);
|
|
138
146
|
formRef.current?.setFieldError('target', '');
|
|
139
147
|
}
|
|
140
|
-
|
|
148
|
+
toaster.show({
|
|
149
|
+
message: error.message,
|
|
150
|
+
intent: 'danger',
|
|
151
|
+
});
|
|
141
152
|
}
|
|
142
153
|
}
|
|
143
154
|
}
|
|
@@ -166,11 +177,11 @@ function MetaImportationModal({ onClose, file }) {
|
|
|
166
177
|
type: 'IMPORT_SPECTRA_META_INFO',
|
|
167
178
|
payload: { spectraMeta: matches },
|
|
168
179
|
});
|
|
169
|
-
|
|
180
|
+
onCloseDialog?.();
|
|
170
181
|
}
|
|
171
|
-
return (_jsxs(
|
|
182
|
+
return (_jsxs(_Fragment, { children: [_jsx(DialogBody, { children: _jsx("div", { style: { width: '100%', height: '100%' }, onDrop: (e) => e.preventDefault(), children: !parseResult ? (_jsx(DropZone, { validator: fileValidator, emptyDescription: "Drag and Drop CSV or tab-delimited file (.csv, .txt or .tsv)", onDrop: handleDrop, noDragEventsBubbling: true })) : (_jsxs(_Fragment, { children: [_jsxs("div", { style: { height: '130px' }, children: [_jsx(Formik, { innerRef: formRef, initialValues: {
|
|
172
183
|
source: null,
|
|
173
|
-
target:
|
|
184
|
+
target: [],
|
|
174
185
|
}, onSubmit: handleLinkSpectra, validationSchema: validationSchema, children: _jsxs(_Fragment, { children: [_jsx(Label, { title: "Source field", style: { label: { width: '100px' } }, children: _jsx(FormikSelect, { name: "source", items: mapColumnToSelectItems(parseResult?.meta.fields || []), style: {
|
|
175
186
|
width: '300px',
|
|
176
187
|
padding: '5px',
|
|
@@ -184,7 +195,7 @@ function MetaImportationModal({ onClose, file }) {
|
|
|
184
195
|
padding: '5px',
|
|
185
196
|
fontSize: '14px',
|
|
186
197
|
},
|
|
187
|
-
}, placeholder: "Example: info.plus", datalist: datalist, mapOnChangeValue: (key) => paths?.[key] ||
|
|
198
|
+
}, placeholder: "Example: info.plus", datalist: datalist, mapOnChangeValue: (key) => paths?.[key] || key, mapValue: (paths) => convertPathArrayToString(paths) }) })] }) }), _jsx(Button.Done, { onClick: () => formRef.current?.submitForm(), children: "Link Spectra" })] }), _jsx("div", { style: { height: 'calc(100% - 160px)' }, children: _jsx(ReactTable, { columns: columns, data: metaData, approxItemHeight: 25, approxColumnWidth: 100, enableVirtualScroll: true, enableColumnsVirtualScroll: true, activeRow: handleActiveRow, rowStyle: handleRowStyle }) })] })) }) }), _jsx(DialogFooter, { children: _jsx(Button.Done, { onClick: handleImport, disabled: Object.keys(matches).length === 0, children: "Import" }) })] }));
|
|
188
199
|
}
|
|
189
200
|
function fileValidator(file) {
|
|
190
201
|
if (!isMetaFile(file)) {
|
|
@@ -195,4 +206,3 @@ function fileValidator(file) {
|
|
|
195
206
|
}
|
|
196
207
|
return null;
|
|
197
208
|
}
|
|
198
|
-
export default MetaImportationModal;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function mapColumnToSelectItems(fields) {
|
|
2
|
-
const items = [{ value:
|
|
2
|
+
const items = [{ value: '', label: 'Select source field' }];
|
|
3
3
|
for (const fieldName of fields) {
|
|
4
4
|
if (fieldName) {
|
|
5
5
|
items.push({ value: fieldName, label: fieldName });
|
|
@@ -9,13 +9,13 @@ import { Toolbar, useOnOff } from 'react-science/ui';
|
|
|
9
9
|
import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
|
|
10
10
|
import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
|
|
11
11
|
import { usePreferences, useWorkspacesList, } from '../../context/PreferencesContext';
|
|
12
|
+
import { useToaster } from '../../context/ToasterContext';
|
|
12
13
|
import ActionButtons from '../../elements/ActionButtons';
|
|
13
14
|
import Button from '../../elements/Button';
|
|
14
15
|
import Label from '../../elements/Label';
|
|
15
16
|
import Tab from '../../elements/Tab/Tab';
|
|
16
17
|
import Tabs, { PositionsEnum } from '../../elements/Tab/Tabs';
|
|
17
18
|
import DropDownButton from '../../elements/dropDownButton/DropDownButton';
|
|
18
|
-
import { useAlert } from '../../elements/popup/Alert';
|
|
19
19
|
import { useSaveSettings } from '../../hooks/useSaveSettings';
|
|
20
20
|
import { getPreferencesByWorkspace } from '../../reducer/preferences/utilities/getPreferencesByWorkspace';
|
|
21
21
|
import PredefinedWorkspaces from '../../workspaces';
|
|
@@ -86,7 +86,7 @@ function GeneralSettingsModal({ height }) {
|
|
|
86
86
|
const [activeTab, setActiveTab] = useState('general');
|
|
87
87
|
const { dispatch, current: currentWorkspace, originalWorkspaces, ...preferences } = usePreferences();
|
|
88
88
|
const { saveSettings, SaveSettingsModal } = useSaveSettings();
|
|
89
|
-
const
|
|
89
|
+
const toaster = useToaster();
|
|
90
90
|
const refForm = useRef(null);
|
|
91
91
|
const workspaces = useWorkspacesList();
|
|
92
92
|
const workspaceName = preferences.workspace.current;
|
|
@@ -161,7 +161,10 @@ function GeneralSettingsModal({ height }) {
|
|
|
161
161
|
function handleCopyWorkspace() {
|
|
162
162
|
const data = { [workspaceName]: refForm.current?.values };
|
|
163
163
|
void rawWriteWithType(JSON.stringify(data)).then(() => {
|
|
164
|
-
|
|
164
|
+
toaster.show({
|
|
165
|
+
message: 'Workspace copied to clipboard',
|
|
166
|
+
intent: 'success',
|
|
167
|
+
});
|
|
165
168
|
});
|
|
166
169
|
}
|
|
167
170
|
const setWorkspaceSetting = useCallback((inputWorkspace) => {
|
|
@@ -194,7 +197,7 @@ function GeneralSettingsModal({ height }) {
|
|
|
194
197
|
setWorkspaceSetting(parseWorkspaces);
|
|
195
198
|
}
|
|
196
199
|
catch {
|
|
197
|
-
|
|
200
|
+
toaster.show({ message: 'object parse error', intent: 'danger' });
|
|
198
201
|
}
|
|
199
202
|
cleanShouldFallback();
|
|
200
203
|
}
|
|
@@ -2,7 +2,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { SvgNmrAssignment2 } from 'cheminfo-font';
|
|
4
4
|
import { FaBolt } from 'react-icons/fa';
|
|
5
|
-
import { Toolbar } from 'react-science/ui';
|
|
6
5
|
import { isSpectrum1D } from '../../../data/data1d/Spectrum1D/isSpectrum1D';
|
|
7
6
|
import { useChartData } from '../../context/ChartContext';
|
|
8
7
|
import { tablePanelStyle } from '../extra/BasicPanelStyle';
|
|
@@ -22,6 +21,21 @@ function useCheckEnableAutomaticAssignments() {
|
|
|
22
21
|
function AutomaticAssignment() {
|
|
23
22
|
const { getAssignments, assignments, restAssignments } = useAutoAssignments();
|
|
24
23
|
const enabled = useCheckEnableAutomaticAssignments();
|
|
25
|
-
return (_jsxs("div", { css: tablePanelStyle, children: [_jsx(DefaultPanelHeader, {
|
|
24
|
+
return (_jsxs("div", { css: tablePanelStyle, children: [_jsx(DefaultPanelHeader, { leftButtons: [
|
|
25
|
+
{
|
|
26
|
+
component: _jsx(SpectraAutomaticPickingButton, {}),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
icon: _jsx(SvgNmrAssignment2, {}),
|
|
30
|
+
title: 'Automatic assignment',
|
|
31
|
+
onClick: getAssignments,
|
|
32
|
+
disabled: !enabled,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
icon: _jsx(FaBolt, {}),
|
|
36
|
+
title: 'Reset assignment',
|
|
37
|
+
onClick: restAssignments,
|
|
38
|
+
},
|
|
39
|
+
] }), _jsx("div", { className: "inner-container", children: _jsx(AutomaticAssignmentTable, { data: assignments }) })] }));
|
|
26
40
|
}
|
|
27
41
|
export default AutomaticAssignment;
|
|
@@ -3,7 +3,7 @@ import OCL from 'openchemlib/full';
|
|
|
3
3
|
import { useRef, useState } from 'react';
|
|
4
4
|
import { useChartData } from '../../context/ChartContext';
|
|
5
5
|
import { useDispatch } from '../../context/DispatchContext';
|
|
6
|
-
import {
|
|
6
|
+
import { useToaster } from '../../context/ToasterContext';
|
|
7
7
|
import { assert } from '../../utility/assert';
|
|
8
8
|
function mapSpectra(data) {
|
|
9
9
|
return data.map((spectrum) => {
|
|
@@ -24,7 +24,7 @@ export function useAutoAssignments() {
|
|
|
24
24
|
const dispatch = useDispatch();
|
|
25
25
|
const { data, molecules } = useChartData();
|
|
26
26
|
const originData = useRef();
|
|
27
|
-
const
|
|
27
|
+
const toaster = useToaster();
|
|
28
28
|
const [assignments, setAssignments] = useState([]);
|
|
29
29
|
function restAssignments() {
|
|
30
30
|
if (originData.current) {
|
|
@@ -36,7 +36,7 @@ export function useAutoAssignments() {
|
|
|
36
36
|
}
|
|
37
37
|
function getAssignments() {
|
|
38
38
|
void (async () => {
|
|
39
|
-
const hideLoading =
|
|
39
|
+
const hideLoading = toaster.showLoading({ message: 'Auto Assignments' });
|
|
40
40
|
const molecule = OCL.Molecule.fromMolfile(molecules[0]?.molfile || '');
|
|
41
41
|
const spectra = mapSpectra(data);
|
|
42
42
|
if (!originData.current) {
|
|
@@ -53,7 +53,10 @@ export function useAutoAssignments() {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
|
-
|
|
56
|
+
toaster.show({
|
|
57
|
+
message: 'Could not assign molecule, please check that all the ranges are defined correctly',
|
|
58
|
+
intent: 'danger',
|
|
59
|
+
});
|
|
57
60
|
}
|
|
58
61
|
setAssignments(result);
|
|
59
62
|
hideLoading();
|