nmrium 0.50.1 → 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/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/Select.js +2 -2
- package/lib/component/elements/ToolbarPopoverItem.js +1 -1
- 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/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/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/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/useAutoAssignments.js +7 -4
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +13 -7
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +6 -4
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +6 -3
- package/lib/component/panels/RangesPanel/RangesHeader.js +3 -3
- package/lib/component/panels/RangesPanel/RangesPanel.js +4 -4
- package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -3
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +11 -5
- package/lib/component/panels/databasePanel/DatabasePanel.js +37 -19
- package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +1 -1
- package/lib/component/panels/filtersPanel/FilterPanel.js +5 -3
- package/lib/component/panels/filtersPanel/FiltersTable.js +27 -23
- 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 +5 -5
- 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/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.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 +17 -12
- package/lib/component/utility/Events.d.ts +11 -0
- package/lib/component/utility/Events.js +22 -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/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/reducer/helper/getStrongestPeak.d.ts +0 -7
- package/lib/component/reducer/helper/getStrongestPeak.js +0 -15
|
@@ -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
|
+
}
|
|
@@ -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
|
}
|
|
@@ -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();
|
|
@@ -10,9 +10,9 @@ import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
|
|
|
10
10
|
import { useAssignmentData } from '../../assignment/AssignmentsContext';
|
|
11
11
|
import { useDispatch } from '../../context/DispatchContext';
|
|
12
12
|
import { useGlobal } from '../../context/GlobalContext';
|
|
13
|
+
import { useToaster } from '../../context/ToasterContext';
|
|
13
14
|
import { PreferencesButton } from '../../elements/PreferencesButton';
|
|
14
15
|
import { ToolbarPopoverItem, } from '../../elements/ToolbarPopoverItem';
|
|
15
|
-
import { useAlert } from '../../elements/popup/Alert';
|
|
16
16
|
import AboutPredictionModal from '../../modal/AboutPredictionModal';
|
|
17
17
|
import PredictSpectraModal from '../../modal/PredictSpectraModal';
|
|
18
18
|
import { copyPNGToClipboard, exportAsSVG } from '../../utility/export';
|
|
@@ -66,7 +66,7 @@ const MOL_EXPORT_MENU = [
|
|
|
66
66
|
];
|
|
67
67
|
export default function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMoleculeIndexChange, onOpenMoleculeEditor, renderSource = 'moleculePanel', onClickPreferences, onClickPastMolecule, children, }) {
|
|
68
68
|
const { rootRef } = useGlobal();
|
|
69
|
-
const
|
|
69
|
+
const toaster = useToaster();
|
|
70
70
|
const dispatch = useDispatch();
|
|
71
71
|
const assignmentData = useAssignmentData();
|
|
72
72
|
const moleculeKey = molecules?.[currentIndex]?.id;
|
|
@@ -79,14 +79,20 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
|
|
|
79
79
|
if (!rootRef)
|
|
80
80
|
return;
|
|
81
81
|
await copyPNGToClipboard(rootRef, `molSVG${currentIndex} `);
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
toaster.show({
|
|
83
|
+
message: 'MOL copied as PNG to clipboard',
|
|
84
|
+
intent: 'success',
|
|
85
|
+
});
|
|
86
|
+
}, [rootRef, currentIndex, toaster]);
|
|
84
87
|
const { rawWriteWithType, readText, shouldFallback, cleanShouldFallback, text, } = useClipboard();
|
|
85
88
|
const saveAsMolHandler = useCallback((molfile) => {
|
|
86
89
|
void rawWriteWithType(molfile).then(() => {
|
|
87
|
-
|
|
90
|
+
toaster.show({
|
|
91
|
+
message: 'MOLFile copied to clipboard',
|
|
92
|
+
intent: 'success',
|
|
93
|
+
});
|
|
88
94
|
});
|
|
89
|
-
}, [
|
|
95
|
+
}, [rawWriteWithType, toaster]);
|
|
90
96
|
const exportHandler = useCallback((selected) => {
|
|
91
97
|
const molecule = molecules?.[currentIndex];
|
|
92
98
|
if (molecule) {
|
|
@@ -154,5 +160,5 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
|
|
|
154
160
|
});
|
|
155
161
|
}
|
|
156
162
|
const hasMolecules = molecules && molecules.length > 0;
|
|
157
|
-
return (_jsxs(PanelHeader, { children: [renderSource === 'predictionPanel' && _jsx(AboutPredictionModal, {}),
|
|
163
|
+
return (_jsxs(PanelHeader, { children: [_jsxs(Toolbar, { children: [renderSource === 'predictionPanel' && _jsx(AboutPredictionModal, {}), renderSource === 'moleculePanel' && (_jsxs(_Fragment, { children: [_jsx(ToolbarPopoverItem, { options: MOL_EXPORT_MENU, onClick: exportHandler, disabled: !hasMolecules, title: "Export As", icon: _jsx(FaFileExport, {}) }), _jsx(Toolbar.Item, { title: "Paste molfile", icon: _jsx(FaPaste, {}), onClick: handlePasteMolfileAction }), _jsx(Toolbar.Item, { title: "Add molecule", icon: _jsx(FaPlus, {}), onClick: onOpenMoleculeEditor })] })), renderSource === 'moleculePanel' && (_jsxs(_Fragment, { children: [_jsx(Toolbar.Item, { title: "Delete molecule", icon: _jsx(FaRegTrashAlt, {}), onClick: handleDelete, disabled: !hasMolecules }), hasMolecules && (_jsx(PredictSpectraModal, { molecule: molecules[currentIndex] }))] })), _jsx(Toolbar.Item, { title: "Float molecule", icon: _jsx(IoOpenOutline, {}), onClick: floatMoleculeHandler, active: moleculesView?.[moleculeKey]?.floating.visible || false, disabled: !hasMolecules }), _jsx(Toolbar.Item, { title: "Show atom number", icon: _jsx("p", { style: styles.atomLabel, children: "#" }), onClick: showAtomNumbersHandler, active: moleculesView?.[moleculeKey]?.showAtomNumber || false, disabled: !hasMolecules })] }), _jsx("div", { style: { flex: 1 }, children: children }), molecules && molecules.length > 0 && (_jsx("p", { style: styles.counter, children: `${+(currentIndex + 1)} / ${molecules.length}` })), onClickPreferences && (_jsx(PreferencesButton, { title: "Preferences", onClick: onClickPreferences })), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePasteMolfile, text: text, label: "Molfile" })] }));
|
|
158
164
|
}
|
|
@@ -4,11 +4,11 @@ import checkModifierKeyActivated from '../../../data/utilities/checkModifierKeyA
|
|
|
4
4
|
import { useAssignment, useAssignmentData, } from '../../assignment/AssignmentsContext';
|
|
5
5
|
import { filterForIDsWithAssignment } from '../../assignment/utilities/filterForIDsWithAssignment';
|
|
6
6
|
import { useDispatch } from '../../context/DispatchContext';
|
|
7
|
-
import {
|
|
7
|
+
import { useToaster } from '../../context/ToasterContext';
|
|
8
8
|
import { HighlightEventSource, useHighlightData } from '../../highlight';
|
|
9
9
|
import { extractFromAtom, findDatumAndSignalIndex, getCurrentDiaIDsToHighlight, getHighlightsOnHover, toggleDiaIDs, } from './Utilities';
|
|
10
10
|
export default function useAtomAssignment({ displayerMode, activeTab: nucleus, zones, ranges, }) {
|
|
11
|
-
const
|
|
11
|
+
const toaster = useToaster();
|
|
12
12
|
const dispatch = useDispatch();
|
|
13
13
|
const highlightData = useHighlightData();
|
|
14
14
|
const assignments = useAssignmentData();
|
|
@@ -159,17 +159,19 @@ export default function useAtomAssignment({ displayerMode, activeTab: nucleus, z
|
|
|
159
159
|
activeAssignment.setActive(axis);
|
|
160
160
|
}
|
|
161
161
|
else {
|
|
162
|
-
|
|
162
|
+
toaster.show({
|
|
163
|
+
message: 'Not assigned! Different atom type or no attached hydrogens found!',
|
|
164
|
+
});
|
|
163
165
|
}
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
168
|
}, [
|
|
167
169
|
activeAssignment,
|
|
168
|
-
alert,
|
|
169
170
|
data,
|
|
170
171
|
dispatch,
|
|
171
172
|
displayerMode,
|
|
172
173
|
nucleus,
|
|
174
|
+
toaster,
|
|
173
175
|
toggleAssignment,
|
|
174
176
|
]);
|
|
175
177
|
const handleOnAtomHover = useCallback((diaIDAndInfo) => {
|
|
@@ -9,7 +9,7 @@ import isInRange from '../../../data/utilities/isInRange';
|
|
|
9
9
|
import { useChartData } from '../../context/ChartContext';
|
|
10
10
|
import { useDispatch } from '../../context/DispatchContext';
|
|
11
11
|
import { usePreferences } from '../../context/PreferencesContext';
|
|
12
|
-
import {
|
|
12
|
+
import { useToaster } from '../../context/ToasterContext';
|
|
13
13
|
import { useModal } from '../../elements/popup/Modal';
|
|
14
14
|
import { useActiveSpectrumPeaksViewState } from '../../hooks/useActiveSpectrumPeaksViewState';
|
|
15
15
|
import useCheckExperimentalFeature from '../../hooks/useCheckExperimentalFeature';
|
|
@@ -27,7 +27,7 @@ function PeaksPanelInner({ peaks, info, xDomain, activeTab, peaksViewState, }) {
|
|
|
27
27
|
const format = useFormatNumberByNucleus(info.nucleus);
|
|
28
28
|
const dispatch = useDispatch();
|
|
29
29
|
const modal = useModal();
|
|
30
|
-
const
|
|
30
|
+
const toaster = useToaster();
|
|
31
31
|
const isExperimental = useCheckExperimentalFeature();
|
|
32
32
|
const settingRef = useRef();
|
|
33
33
|
const yesHandler = useCallback(() => {
|
|
@@ -79,7 +79,10 @@ function PeaksPanelInner({ peaks, info, xDomain, activeTab, peaksViewState, }) {
|
|
|
79
79
|
dispatch({ type: 'OPTIMIZE_PEAKS', payload: { peaks: filterPeaks } });
|
|
80
80
|
}
|
|
81
81
|
else {
|
|
82
|
-
|
|
82
|
+
toaster.show({
|
|
83
|
+
message: 'optimization can be done on no more than 4 peaks',
|
|
84
|
+
intent: 'danger',
|
|
85
|
+
});
|
|
83
86
|
}
|
|
84
87
|
};
|
|
85
88
|
function toggleViewProperty(key) {
|
|
@@ -8,7 +8,7 @@ import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardCompon
|
|
|
8
8
|
import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
|
|
9
9
|
import { useAssignmentData } from '../../assignment/AssignmentsContext';
|
|
10
10
|
import { useDispatch } from '../../context/DispatchContext';
|
|
11
|
-
import {
|
|
11
|
+
import { useToaster } from '../../context/ToasterContext';
|
|
12
12
|
import { useModal } from '../../elements/popup/Modal';
|
|
13
13
|
import { useActiveSpectrumRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
|
|
14
14
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
@@ -19,7 +19,7 @@ import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
|
19
19
|
function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClick, isFilterActive, filterCounter, activeTab, }) {
|
|
20
20
|
const dispatch = useDispatch();
|
|
21
21
|
const modal = useModal();
|
|
22
|
-
const
|
|
22
|
+
const toaster = useToaster();
|
|
23
23
|
const assignmentData = useAssignmentData();
|
|
24
24
|
const currentSum = lodashGet(ranges, 'options.sum', null);
|
|
25
25
|
const rangesPreferences = usePanelPreferences('ranges', activeTab);
|
|
@@ -80,7 +80,7 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
|
|
|
80
80
|
}
|
|
81
81
|
const { rawWriteWithType, shouldFallback, cleanShouldFallback, text } = useClipboard();
|
|
82
82
|
function saveToClipboardHandler(value) {
|
|
83
|
-
void rawWriteWithType(value, 'text/html').then(() =>
|
|
83
|
+
void rawWriteWithType(value, 'text/html').then(() => toaster.show({ message: 'Data copied to clipboard', intent: 'success' }));
|
|
84
84
|
}
|
|
85
85
|
function saveAsHTMLHandler() {
|
|
86
86
|
if (Array.isArray(ranges?.values) && ranges.values.length > 0) {
|
|
@@ -9,7 +9,7 @@ import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
|
|
|
9
9
|
import { useAssignmentData } from '../../assignment/AssignmentsContext';
|
|
10
10
|
import { useChartData } from '../../context/ChartContext';
|
|
11
11
|
import { useDispatch } from '../../context/DispatchContext';
|
|
12
|
-
import {
|
|
12
|
+
import { useToaster } from '../../context/ToasterContext';
|
|
13
13
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
14
14
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
15
15
|
import { tablePanelStyle } from '../extra/BasicPanelStyle';
|
|
@@ -27,7 +27,7 @@ function RangesTablePanelInner({ id, ranges, data, info, xDomain, preferences, a
|
|
|
27
27
|
const [isFilterActive, setFilterIsActive] = useState(false);
|
|
28
28
|
const assignmentData = useAssignmentData();
|
|
29
29
|
const dispatch = useDispatch();
|
|
30
|
-
const
|
|
30
|
+
const toaster = useToaster();
|
|
31
31
|
const [isFlipped, setFlipStatus] = useState(false);
|
|
32
32
|
const settingRef = useRef();
|
|
33
33
|
const rangesData = useMemo(() => {
|
|
@@ -81,9 +81,9 @@ function RangesTablePanelInner({ id, ranges, data, info, xDomain, preferences, a
|
|
|
81
81
|
...value,
|
|
82
82
|
};
|
|
83
83
|
await rawWriteWithType(JSON.stringify(dataToClipboard, undefined, 2));
|
|
84
|
-
|
|
84
|
+
toaster.show({ message: 'Data copied to clipboard' });
|
|
85
85
|
}
|
|
86
|
-
}, [data, rawWriteWithType,
|
|
86
|
+
}, [data, rawWriteWithType, toaster]);
|
|
87
87
|
const contextMenuSelectHandler = useCallback((option, data) => {
|
|
88
88
|
void saveJSONToClipboardHandler(data);
|
|
89
89
|
}, [saveJSONToClipboardHandler]);
|
|
@@ -5,7 +5,7 @@ import { FaCreativeCommonsSamplingPlus, FaEye, FaEyeSlash, } from 'react-icons/f
|
|
|
5
5
|
import { IoColorPaletteOutline } from 'react-icons/io5';
|
|
6
6
|
import { useChartData } from '../../context/ChartContext';
|
|
7
7
|
import { useDispatch } from '../../context/DispatchContext';
|
|
8
|
-
import {
|
|
8
|
+
import { useToaster } from '../../context/ToasterContext';
|
|
9
9
|
import { useModal } from '../../elements/popup/Modal';
|
|
10
10
|
import { useActiveSpectra } from '../../hooks/useActiveSpectra';
|
|
11
11
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
@@ -26,7 +26,7 @@ function getMissingProjection(SpectrumsData, activeTab) {
|
|
|
26
26
|
}
|
|
27
27
|
function SpectraPanelHeaderInner({ data, activeSpectrum, activeSpectra, activeTab, displayerMode, onSettingClick, }) {
|
|
28
28
|
const modal = useModal();
|
|
29
|
-
const
|
|
29
|
+
const toaster = useToaster();
|
|
30
30
|
const dispatch = useDispatch();
|
|
31
31
|
const handleDelete = useCallback(() => {
|
|
32
32
|
modal.showConfirmDialog({
|
|
@@ -63,7 +63,7 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeSpectra, activeTa
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
|
-
|
|
66
|
+
toaster.show({ message: 'Nothing to calculate', intent: 'danger' });
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
function setSameTopHandler() {
|
|
@@ -8,9 +8,9 @@ import { isSpectrum1D } from '../../../data/data1d/Spectrum1D';
|
|
|
8
8
|
import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
|
|
9
9
|
import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
|
|
10
10
|
import { useDispatch } from '../../context/DispatchContext';
|
|
11
|
+
import { useToaster } from '../../context/ToasterContext';
|
|
11
12
|
import { ContextMenu, } from '../../elements/ContextMenuBluePrint';
|
|
12
13
|
import ReactTable from '../../elements/ReactTable/ReactTable';
|
|
13
|
-
import { useAlert } from '../../elements/popup/Alert';
|
|
14
14
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
15
15
|
import ExportAsJcampModal from '../../modal/ExportAsJcampModal';
|
|
16
16
|
import ColorIndicator from './base/ColorIndicator';
|
|
@@ -79,7 +79,7 @@ const Spectra1DContextMenuOptions = [
|
|
|
79
79
|
];
|
|
80
80
|
export function SpectraTable(props) {
|
|
81
81
|
const { data, activeSpectra, onChangeVisibility, onOpenSettingModal, onChangeActiveSpectrum, nucleus, } = props;
|
|
82
|
-
const
|
|
82
|
+
const toaster = useToaster();
|
|
83
83
|
const dispatch = useDispatch();
|
|
84
84
|
const spectraPreferences = usePanelPreferences('spectra', nucleus);
|
|
85
85
|
const activeSpectraObj = getActiveSpectraAsObject(activeSpectra);
|
|
@@ -121,7 +121,10 @@ export function SpectraTable(props) {
|
|
|
121
121
|
void (async () => {
|
|
122
122
|
const { data, info } = spectrum;
|
|
123
123
|
await rawWriteWithType(JSON.stringify({ data, info }, (_, value) => ArrayBuffer.isView(value) ? Array.from(value) : value, 2));
|
|
124
|
-
|
|
124
|
+
toaster.show({
|
|
125
|
+
message: 'Data copied to clipboard',
|
|
126
|
+
intent: 'success',
|
|
127
|
+
});
|
|
125
128
|
})();
|
|
126
129
|
break;
|
|
127
130
|
}
|
|
@@ -143,14 +146,17 @@ export function SpectraTable(props) {
|
|
|
143
146
|
}
|
|
144
147
|
case SpectraContextMenuOptionsKeys.CopyAsText: {
|
|
145
148
|
const data = convertSpectrumToText(spectrum);
|
|
146
|
-
void rawWriteWithType(data, 'text/plain').then(() =>
|
|
149
|
+
void rawWriteWithType(data, 'text/plain').then(() => toaster.show({
|
|
150
|
+
message: 'Spectrum copied to clipboard',
|
|
151
|
+
intent: 'success',
|
|
152
|
+
}));
|
|
147
153
|
break;
|
|
148
154
|
}
|
|
149
155
|
default: {
|
|
150
156
|
break;
|
|
151
157
|
}
|
|
152
158
|
}
|
|
153
|
-
}, [
|
|
159
|
+
}, [dispatch, rawWriteWithType, toaster]);
|
|
154
160
|
function handleActiveRow(row) {
|
|
155
161
|
return activeSpectraObj?.[row?.original.id] || false;
|
|
156
162
|
}
|