nmrium 0.58.0 → 0.60.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/LinesSeries.js +17 -5
- package/lib/component/1d/Viewer1D.js +10 -4
- package/lib/component/1d/integral/IntegralResizable.js +2 -2
- package/lib/component/1d/matrix/useMatrix.d.ts +1 -1
- package/lib/component/1d/multiAnalysis/AnalysisRange.js +1 -1
- package/lib/component/1d/ranges/Atoms.js +6 -4
- package/lib/component/1d/ranges/Range.js +4 -2
- package/lib/component/1d/tool/PivotIndicator.d.ts +1 -0
- package/lib/component/1d/tool/{VerticalIndicator.js → PivotIndicator.js} +8 -4
- package/lib/component/1d-2d/tools/BrushXY.js +0 -1
- package/lib/component/1d-2d/tools/CrossLinePointer.js +0 -1
- package/lib/component/2d/Viewer2D.js +7 -3
- package/lib/component/2d/tools/PivotIndicator.d.ts +1 -2
- package/lib/component/2d/tools/PivotIndicator.js +2 -3
- package/lib/component/2d/zones/Zone.js +2 -2
- package/lib/component/EventsTrackers/KeysListenerTracker.js +8 -8
- package/lib/component/context/ChartContext.js +12 -1
- package/lib/component/context/ShareDataContext.d.ts +1 -1
- package/lib/component/context/ShareDataContext.js +2 -4
- package/lib/component/context/ToasterContext.d.ts +1 -0
- package/lib/component/context/ToasterContext.js +12 -3
- package/lib/component/elements/ActionsButtonsPopover.js +1 -3
- package/lib/component/elements/Alert.d.ts +20 -0
- package/lib/component/elements/Alert.js +80 -0
- package/lib/component/elements/ContextMenuBluePrint.d.ts +7 -2
- package/lib/component/elements/ContextMenuBluePrint.js +9 -3
- package/lib/component/elements/DialogManager.d.ts +34 -0
- package/lib/component/elements/DialogManager.js +96 -0
- package/lib/component/elements/DraggableDialog.d.ts +13 -0
- package/lib/component/elements/DraggableDialog.js +156 -0
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +1 -1
- package/lib/component/elements/ReactTable/ReactTableFlexLayout.d.ts +0 -3
- package/lib/component/elements/ReactTable/ReactTableFlexLayout.js +1 -1
- package/lib/component/elements/Select2.d.ts +12 -7
- package/lib/component/elements/Select2.js +5 -4
- package/lib/component/elements/Select2Controller.d.ts +2 -2
- package/lib/component/elements/Select2Controller.js +5 -5
- package/lib/component/elements/TabTitle.d.ts +9 -0
- package/lib/component/elements/TabTitle.js +18 -0
- package/lib/component/elements/ToolbarPopoverItem.d.ts +7 -6
- package/lib/component/elements/ToolbarPopoverItem.js +13 -5
- package/lib/component/elements/print/PrintContent.d.ts +17 -0
- package/lib/component/elements/print/PrintContent.js +281 -0
- package/lib/component/elements/print/PrintProvider.d.ts +12 -0
- package/lib/component/elements/print/PrintProvider.js +28 -0
- package/lib/component/elements/print/index.d.ts +2 -0
- package/lib/component/elements/print/index.js +2 -0
- package/lib/component/header/ApodizationOptionsPanel.js +2 -2
- package/lib/component/header/BaseLineCorrectionPanel.js +3 -0
- package/lib/component/hooks/useSaveSettings.d.ts +1 -1
- package/lib/component/hooks/useSaveSettings.js +18 -22
- package/lib/component/hooks/useToggleSpectraVisibility.d.ts +14 -9
- package/lib/component/hooks/useToggleSpectraVisibility.js +45 -16
- package/lib/component/loader/DropZone.js +3 -67
- package/lib/component/loader/useLoadFiles.d.ts +1 -0
- package/lib/component/loader/useLoadFiles.js +78 -0
- package/lib/component/main/InnerNMRium.d.ts +4 -3
- package/lib/component/main/InnerNMRium.js +5 -10
- package/lib/component/main/InnerNMRiumContents.d.ts +3 -2
- package/lib/component/main/InnerNMRiumContents.js +38 -29
- package/lib/component/main/NMRium.d.ts +2 -5
- package/lib/component/main/NMRium.js +1 -1
- package/lib/component/main/NMRiumRefAPI.d.ts +7 -0
- package/lib/component/main/NMRiumRefAPI.js +12 -0
- package/lib/component/main/NMRiumViewer.d.ts +10 -0
- package/lib/component/main/NMRiumViewer.js +35 -0
- package/lib/component/main/index.d.ts +1 -0
- package/lib/component/modal/CopyClipboardModal.d.ts +3 -2
- package/lib/component/modal/CopyClipboardModal.js +18 -32
- package/lib/component/modal/EditPeakShapeModal.d.ts +4 -6
- package/lib/component/modal/EditPeakShapeModal.js +45 -33
- package/lib/component/modal/ExportAsJcampModal.d.ts +6 -3
- package/lib/component/modal/ExportAsJcampModal.js +69 -35
- package/lib/component/modal/ImportPublicationStringModal.js +1 -1
- package/lib/component/modal/editRange/EditRangeModal.d.ts +2 -10
- package/lib/component/modal/editRange/EditRangeModal.js +26 -54
- package/lib/component/modal/editZone/EditZoneModal.d.ts +3 -8
- package/lib/component/modal/editZone/EditZoneModal.js +74 -91
- package/lib/component/modal/editZone/SignalsForm.d.ts +1 -2
- package/lib/component/modal/editZone/SignalsForm.js +33 -50
- package/lib/component/modal/editZone/validation/isDefaultPathLength.d.ts +1 -2
- package/lib/component/modal/editZone/validation/isDefaultPathLength.js +3 -5
- package/lib/component/modal/setting/GeneralSettings.js +4 -2
- package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.d.ts +1 -0
- package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.js +89 -0
- package/lib/component/modal/setting/settingsValidation.js +15 -1
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +8 -5
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +5 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +13 -3
- package/lib/component/panels/Panels.js +2 -2
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +8 -5
- package/lib/component/panels/PeaksPanel/PeaksTable.js +7 -13
- package/lib/component/panels/RangesPanel/RangesHeader.js +52 -15
- package/lib/component/panels/RangesPanel/RangesTable.js +6 -3
- package/lib/component/panels/RangesPanel/TableColumns/ActionsColumn.js +21 -3
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.d.ts +6 -5
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +41 -64
- package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +13 -6
- package/lib/component/panels/SpectraPanel/SpectraTable.js +63 -21
- package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.d.ts +1 -2
- package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.js +33 -41
- package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnHeader.js +68 -53
- package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +70 -58
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.d.ts +13 -8
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +17 -81
- package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts +3 -0
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +8 -1
- package/lib/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
- package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +62 -43
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +16 -8
- package/lib/component/panels/ZonesPanel/ZonesTable.js +4 -1
- package/lib/component/panels/ZonesPanel/hooks/useZoneActions.d.ts +5 -0
- package/lib/component/panels/ZonesPanel/hooks/useZoneActions.js +40 -0
- package/lib/component/panels/databasePanel/DatabasePanel.js +7 -8
- package/lib/component/panels/filtersPanel/FilterPanel.js +9 -6
- package/lib/component/panels/filtersPanel/FiltersTable.js +12 -10
- package/lib/component/panels/header/DefaultPanelHeader.d.ts +1 -0
- package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
- package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +10 -12
- package/lib/component/reducer/IgnoreActions.js +1 -0
- package/lib/component/reducer/Reducer.js +2 -4
- package/lib/component/reducer/actions/DatabaseActions.d.ts +15 -13
- package/lib/component/reducer/actions/DatabaseActions.js +52 -34
- package/lib/component/reducer/actions/DomainActions.d.ts +2 -2
- package/lib/component/reducer/actions/FiltersActions.js +9 -4
- package/lib/component/reducer/actions/RangesActions.d.ts +1 -0
- package/lib/component/reducer/actions/RangesActions.js +9 -4
- package/lib/component/reducer/actions/SpectraActions.d.ts +2 -1
- package/lib/component/reducer/actions/SpectraActions.js +53 -43
- package/lib/component/reducer/actions/ToolsActions.js +0 -17
- package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.d.ts +3 -0
- package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.js +16 -0
- package/lib/component/reducer/preferences/actions/changePrintPageSettings.d.ts +3 -0
- package/lib/component/reducer/preferences/actions/changePrintPageSettings.js +6 -0
- package/lib/component/reducer/preferences/actions/matrixGeneration.d.ts +0 -4
- package/lib/component/reducer/preferences/actions/matrixGeneration.js +1 -2
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -2
- package/lib/component/reducer/preferences/preferencesReducer.js +4 -1
- package/lib/component/toolbar/ToolBar.js +33 -14
- package/lib/component/toolbar/ToolTypes.d.ts +1 -1
- package/lib/component/toolbar/ToolTypes.js +0 -14
- package/lib/component/workspaces/workspaceDefaultProperties.js +2 -0
- package/lib/data/SpectraManager.d.ts +7 -10
- package/lib/data/SpectraManager.js +51 -30
- package/lib/data/data1d/Spectrum1D/SumManager.d.ts +0 -1
- package/lib/data/data1d/Spectrum1D/SumManager.js +2 -10
- package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/index.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/index.js +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +10 -16
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +1 -7
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +2 -1
- package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +10 -16
- package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +10 -16
- package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.d.ts +13 -0
- package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.js +65 -0
- package/lib/data/molecules/MoleculeManager.d.ts +1 -1
- package/lib/data/molecules/MoleculeManager.js +21 -49
- package/lib/data/utilities/getCustomColor.d.ts +1 -1
- package/lib/data/utilities/removeByPaths.d.ts +3 -0
- package/lib/data/utilities/removeByPaths.js +33 -0
- package/lib/versionInfo.js +1 -1
- package/package.json +34 -34
- package/lib/component/1d/tool/VerticalIndicator.d.ts +0 -2
- package/lib/component/elements/ContextMenu.d.ts +0 -9
- package/lib/component/elements/ContextMenu.js +0 -116
- package/lib/component/elements/popup/Modal/ConfirmDialog.d.ts +0 -21
- package/lib/component/elements/popup/Modal/ConfirmDialog.js +0 -68
- package/lib/component/elements/popup/Modal/Context.d.ts +0 -2
- package/lib/component/elements/popup/Modal/Context.js +0 -6
- package/lib/component/elements/popup/Modal/Modal.d.ts +0 -9
- package/lib/component/elements/popup/Modal/Modal.js +0 -42
- package/lib/component/elements/popup/Modal/ModalContent.d.ts +0 -6
- package/lib/component/elements/popup/Modal/ModalContent.js +0 -27
- package/lib/component/elements/popup/Modal/Provider.d.ts +0 -11
- package/lib/component/elements/popup/Modal/Provider.js +0 -172
- package/lib/component/elements/popup/Modal/index.d.ts +0 -4
- package/lib/component/elements/popup/Modal/index.js +0 -4
- package/lib/component/elements/popup/Transition.d.ts +0 -14
- package/lib/component/elements/popup/Transition.js +0 -35
- package/lib/component/elements/popup/Wrapper.d.ts +0 -8
- package/lib/component/elements/popup/Wrapper.js +0 -83
- package/lib/component/elements/popup/options.d.ts +0 -28
- package/lib/component/elements/popup/options.js +0 -25
- package/lib/component/elements/popup/utility.d.ts +0 -2
- package/lib/component/elements/popup/utility.js +0 -13
- package/lib/component/modal/editZone/EditPathLengthFormik.d.ts +0 -5
- package/lib/component/modal/editZone/EditPathLengthFormik.js +0 -67
- package/lib/component/modal/editZone/SignalFormTab.d.ts +0 -5
- package/lib/component/modal/editZone/SignalFormTab.js +0 -6
- package/lib/component/modal/editZone/validation/EditZoneValidation.d.ts +0 -14
- package/lib/component/modal/editZone/validation/EditZoneValidation.js +0 -14
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.d.ts +0 -11
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +0 -29
|
@@ -177,7 +177,7 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
|
|
|
177
177
|
}, [result.data]);
|
|
178
178
|
const resurrectHandler = useCallback((rowData) => {
|
|
179
179
|
const { index, baseURL, jcampURL: jcampRelativeURL } = rowData;
|
|
180
|
-
const
|
|
180
|
+
const databaseEntry = result.data[index];
|
|
181
181
|
if (jcampRelativeURL) {
|
|
182
182
|
const url = new URL(jcampRelativeURL, baseURL);
|
|
183
183
|
setTimeout(async () => {
|
|
@@ -189,11 +189,10 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
|
|
|
189
189
|
entries: [{ baseURL: url.origin, relativePath: url.pathname }],
|
|
190
190
|
});
|
|
191
191
|
const spectrum = data?.spectra?.[0] || null;
|
|
192
|
-
if (spectrum && isSpectrum1D(spectrum)
|
|
193
|
-
spectrum.id = spectrumID;
|
|
192
|
+
if (spectrum && isSpectrum1D(spectrum)) {
|
|
194
193
|
dispatch({
|
|
195
|
-
type: '
|
|
196
|
-
payload: {
|
|
194
|
+
type: 'RESURRECTING_SPECTRUM',
|
|
195
|
+
payload: { source: 'jcamp', databaseEntry, spectrum },
|
|
197
196
|
});
|
|
198
197
|
}
|
|
199
198
|
}
|
|
@@ -207,11 +206,11 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
|
|
|
207
206
|
}
|
|
208
207
|
else {
|
|
209
208
|
dispatch({
|
|
210
|
-
type: '
|
|
211
|
-
payload: {
|
|
209
|
+
type: 'RESURRECTING_SPECTRUM',
|
|
210
|
+
payload: { source: 'rangesOrSignals', databaseEntry },
|
|
212
211
|
});
|
|
213
212
|
}
|
|
214
|
-
}, [dispatch,
|
|
213
|
+
}, [dispatch, result.data, toaster]);
|
|
215
214
|
const saveHandler = useCallback((row) => {
|
|
216
215
|
if (row?.jcampURL) {
|
|
217
216
|
setTimeout(async () => {
|
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useDispatch } from '../../context/DispatchContext';
|
|
3
3
|
import { useToaster } from '../../context/ToasterContext';
|
|
4
|
-
import {
|
|
4
|
+
import { useAlert } from '../../elements/Alert';
|
|
5
|
+
import useSpectrum from '../../hooks/useSpectrum';
|
|
5
6
|
import { tablePanelStyle } from '../extra/BasicPanelStyle';
|
|
6
7
|
import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
7
8
|
import FiltersTable from './FiltersTable';
|
|
8
9
|
export default function FiltersPanel() {
|
|
9
10
|
const dispatch = useDispatch();
|
|
10
|
-
const modal = useModal();
|
|
11
11
|
const toaster = useToaster();
|
|
12
|
+
const { showAlert } = useAlert();
|
|
13
|
+
const { filters } = useSpectrum({ filters: [] });
|
|
12
14
|
function handelDeleteFilter() {
|
|
13
15
|
const buttons = [
|
|
14
16
|
{
|
|
15
17
|
text: 'Yes',
|
|
16
|
-
|
|
17
|
-
const hideLoading = toaster.
|
|
18
|
+
onClick: async () => {
|
|
19
|
+
const hideLoading = await toaster.showAsyncLoading({
|
|
18
20
|
message: 'Delete filters process in progress',
|
|
19
21
|
});
|
|
20
22
|
dispatch({ type: 'DELETE_FILTER', payload: {} });
|
|
21
23
|
hideLoading();
|
|
22
24
|
},
|
|
25
|
+
intent: 'danger',
|
|
23
26
|
},
|
|
24
27
|
{ text: 'No' },
|
|
25
28
|
];
|
|
26
|
-
|
|
29
|
+
showAlert({
|
|
27
30
|
message: 'You are about to delete all processing steps, Are you sure?',
|
|
28
31
|
buttons,
|
|
29
32
|
});
|
|
30
33
|
}
|
|
31
|
-
return (_jsxs("div", { css: tablePanelStyle, children: [_jsx(DefaultPanelHeader, { deleteToolTip: "Delete all filters", onDelete: handelDeleteFilter }), _jsx("div", { className: "inner-container", children: _jsx(FiltersTable, {}) })] }));
|
|
34
|
+
return (_jsxs("div", { css: tablePanelStyle, children: [_jsx(DefaultPanelHeader, { deleteToolTip: "Delete all filters", onDelete: handelDeleteFilter, total: filters?.length, hideCounter: true }), _jsx("div", { className: "inner-container", children: _jsx(FiltersTable, {}) })] }));
|
|
32
35
|
}
|
|
@@ -6,10 +6,10 @@ import { ObjectInspector } from 'react-inspector';
|
|
|
6
6
|
import { useChartData } from '../../context/ChartContext';
|
|
7
7
|
import { useDispatch } from '../../context/DispatchContext';
|
|
8
8
|
import { useToaster } from '../../context/ToasterContext';
|
|
9
|
+
import { useAlert } from '../../elements/Alert';
|
|
9
10
|
import Button from '../../elements/Button';
|
|
10
11
|
import { ColumnWrapper } from '../../elements/ColumnWrapper';
|
|
11
12
|
import ReactTable from '../../elements/ReactTable/ReactTable';
|
|
12
|
-
import { useModal } from '../../elements/popup/Modal';
|
|
13
13
|
import useSpectraByActiveNucleus from '../../hooks/useSpectraPerNucleus';
|
|
14
14
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
15
15
|
const rowColors = {
|
|
@@ -30,7 +30,7 @@ const rowColors = {
|
|
|
30
30
|
};
|
|
31
31
|
function FiltersTableInner({ filters, spectraCounter, activeFilterID, }) {
|
|
32
32
|
const dispatch = useDispatch();
|
|
33
|
-
const
|
|
33
|
+
const alert = useAlert();
|
|
34
34
|
const toaster = useToaster();
|
|
35
35
|
const selectedFilterIndex = useRef();
|
|
36
36
|
const handelFilterCheck = useCallback((id, event) => {
|
|
@@ -47,21 +47,22 @@ function FiltersTableInner({ filters, spectraCounter, activeFilterID, }) {
|
|
|
47
47
|
const buttons = [
|
|
48
48
|
{
|
|
49
49
|
text: 'Yes',
|
|
50
|
-
|
|
51
|
-
const hideLoading = toaster.
|
|
50
|
+
onClick: async () => {
|
|
51
|
+
const hideLoading = await toaster.showAsyncLoading({
|
|
52
52
|
message: 'Delete filter process in progress',
|
|
53
53
|
});
|
|
54
54
|
dispatch({ type: 'DELETE_FILTER', payload: { id } });
|
|
55
55
|
hideLoading();
|
|
56
56
|
},
|
|
57
|
+
intent: 'danger',
|
|
57
58
|
},
|
|
58
59
|
{ text: 'No' },
|
|
59
60
|
];
|
|
60
61
|
if (spectraCounter > 1) {
|
|
61
62
|
buttons.unshift({
|
|
62
63
|
text: 'Yes, for all spectra',
|
|
63
|
-
|
|
64
|
-
const hideLoading = toaster.
|
|
64
|
+
onClick: async () => {
|
|
65
|
+
const hideLoading = await toaster.showAsyncLoading({
|
|
65
66
|
message: 'Delete all spectra filter process in progress',
|
|
66
67
|
});
|
|
67
68
|
dispatch({
|
|
@@ -70,13 +71,14 @@ function FiltersTableInner({ filters, spectraCounter, activeFilterID, }) {
|
|
|
70
71
|
});
|
|
71
72
|
hideLoading();
|
|
72
73
|
},
|
|
74
|
+
intent: spectraCounter ? 'danger' : 'none',
|
|
73
75
|
});
|
|
74
76
|
}
|
|
75
|
-
|
|
77
|
+
alert.showAlert({
|
|
76
78
|
message: (_jsxs("span", { children: ["You are about to delete this processing step", _jsxs("span", { style: { color: 'black' }, children: [" ", label, " "] }), " , Are you sure?"] })),
|
|
77
79
|
buttons,
|
|
78
|
-
}
|
|
79
|
-
}, [
|
|
80
|
+
});
|
|
81
|
+
}, [alert, dispatch, spectraCounter, toaster]);
|
|
80
82
|
const filterSnapShotHandler = useCallback((filter, index) => {
|
|
81
83
|
selectedFilterIndex.current =
|
|
82
84
|
selectedFilterIndex.current && index === selectedFilterIndex.current
|
|
@@ -134,7 +136,7 @@ function FiltersTableInner({ filters, spectraCounter, activeFilterID, }) {
|
|
|
134
136
|
if (activeFilterID === id) {
|
|
135
137
|
return rowColors.active;
|
|
136
138
|
}
|
|
137
|
-
else if (selectedFilterIndex.current &&
|
|
139
|
+
else if (selectedFilterIndex.current != null &&
|
|
138
140
|
index > selectedFilterIndex.current) {
|
|
139
141
|
return rowColors.deActive;
|
|
140
142
|
}
|
|
@@ -18,6 +18,7 @@ interface DefaultPanelHeaderProps {
|
|
|
18
18
|
className?: string;
|
|
19
19
|
leftButtons?: ToolbarItemProps[];
|
|
20
20
|
rightButtons?: ToolbarItemProps[];
|
|
21
|
+
hideCounter?: boolean;
|
|
21
22
|
}
|
|
22
23
|
export declare function formatCounterLabel(counter?: number, total?: number): string;
|
|
23
24
|
declare function DefaultPanelHeader(props: DefaultPanelHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -29,13 +29,13 @@ export function formatCounterLabel(counter, total) {
|
|
|
29
29
|
return '';
|
|
30
30
|
}
|
|
31
31
|
function DefaultPanelHeader(props) {
|
|
32
|
-
const { total, counter, onDelete, deleteToolTip = 'Delete', onFilter, filterToolTip = '', children, onSettingClick, disableDelete = false, style = {}, className = '', rightButtons = [], leftButtons = [], } = props;
|
|
32
|
+
const { total, counter, onDelete, deleteToolTip = 'Delete', onFilter, filterToolTip = '', children, onSettingClick, disableDelete = false, style = {}, className = '', rightButtons = [], leftButtons = [], hideCounter = false, } = props;
|
|
33
33
|
const [isFiltered, setFilterStatus] = useState(false);
|
|
34
34
|
function handleFilter() {
|
|
35
35
|
setFilterStatus((previousValue) => !previousValue);
|
|
36
36
|
onFilter?.();
|
|
37
37
|
}
|
|
38
|
-
return (_jsxs(PanelHeader, { style, className, children: [_jsxs("div", { style: styles.leftContainer, children: [_jsxs(Toolbar, { children: [onDelete && (_jsx(Toolbar.Item, { id: "delete-button", onClick: onDelete, tooltip: deleteToolTip, icon: _jsx(FaRegTrashAlt, {}), intent: "danger", disabled: !total || disableDelete })), onFilter && (_jsx(Toolbar.Item, { id: "filter-button", onClick: handleFilter, tooltip: filterToolTip, active: isFiltered, icon: _jsx(FaFilter, {}) })), mapToolbarButtons(leftButtons)] }), children] }), _jsx(Toolbar, { children: mapToolbarButtons(rightButtons) }), _jsx(CounterLabel, { value: formatCounterLabel(counter, total) }), onSettingClick && (_jsx(PreferencesButton, { tooltip: "Preferences", onClick: onSettingClick }))] }));
|
|
38
|
+
return (_jsxs(PanelHeader, { style, className, children: [_jsxs("div", { style: styles.leftContainer, children: [_jsxs(Toolbar, { children: [onDelete && (_jsx(Toolbar.Item, { id: "delete-button", onClick: onDelete, tooltip: deleteToolTip, icon: _jsx(FaRegTrashAlt, {}), intent: "danger", disabled: !total || disableDelete })), onFilter && (_jsx(Toolbar.Item, { id: "filter-button", onClick: handleFilter, tooltip: filterToolTip, active: isFiltered, icon: _jsx(FaFilter, {}) })), mapToolbarButtons(leftButtons)] }), children] }), _jsx(Toolbar, { children: mapToolbarButtons(rightButtons) }), !hideCounter && (_jsx(CounterLabel, { value: formatCounterLabel(counter, total) })), onSettingClick && (_jsx(PreferencesButton, { tooltip: "Preferences", onClick: onSettingClick }))] }));
|
|
39
39
|
}
|
|
40
40
|
function mapToolbarButtons(buttons) {
|
|
41
41
|
return buttons.map((props, index) => isCustomToolbarItem(props) ? (
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/reac
|
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { Formik } from 'formik';
|
|
5
5
|
import { xFindClosestIndex } from 'ml-spectra-processing';
|
|
6
|
-
import {
|
|
6
|
+
import { useState } from 'react';
|
|
7
7
|
import * as Yup from 'yup';
|
|
8
8
|
import { REFERENCES } from '../../../data/constants/References';
|
|
9
9
|
import { useDispatch } from '../../context/DispatchContext';
|
|
@@ -13,7 +13,7 @@ import Message from '../../elements/Message';
|
|
|
13
13
|
import Select from '../../elements/Select';
|
|
14
14
|
import FormikInput from '../../elements/formik/FormikInput';
|
|
15
15
|
import useSpectraByActiveNucleus from '../../hooks/useSpectraPerNucleus';
|
|
16
|
-
import
|
|
16
|
+
import { useEvent } from '../../utility/Events';
|
|
17
17
|
const labelStyle = {
|
|
18
18
|
label: { flex: 4, fontWeight: '500' },
|
|
19
19
|
wrapper: { flex: 8, display: 'flex', alignItems: 'center' },
|
|
@@ -87,16 +87,14 @@ function AlignSpectra({ onClose = () => null, nucleus }) {
|
|
|
87
87
|
setError(message);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const [from, to] =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
};
|
|
99
|
-
}, []);
|
|
90
|
+
useEvent({
|
|
91
|
+
onBrushEnd: (options) => {
|
|
92
|
+
const { range: [from, to], shiftKey, } = options;
|
|
93
|
+
if (shiftKey) {
|
|
94
|
+
setOptions((prevOptions) => ({ ...prevOptions, from, to }));
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
});
|
|
100
98
|
function optionChangeHandler(key) {
|
|
101
99
|
const { delta: targetX = 0, ...otherOptions } = REFERENCES?.[nucleus]?.[key] || {};
|
|
102
100
|
const value = {
|
|
@@ -412,10 +412,8 @@ function innerSpectrumReducer(draft, action) {
|
|
|
412
412
|
return ZonesActions.handleSetZoneAssignmentLabelCoordination(draft, action);
|
|
413
413
|
case 'ORDER_MULTIPLE_SPECTRA_ANALYSIS':
|
|
414
414
|
return SpectraAnalysisActions.handleOrderSpectra(draft, action);
|
|
415
|
-
case '
|
|
416
|
-
return DatabaseActions.
|
|
417
|
-
case 'RESURRECTING_SPECTRUM_FROM_JCAMP':
|
|
418
|
-
return DatabaseActions.handleResurrectSpectrumFromJcamp(draft, action);
|
|
415
|
+
case 'RESURRECTING_SPECTRUM':
|
|
416
|
+
return DatabaseActions.handleResurrectSpectrum(draft, action);
|
|
419
417
|
case 'TOGGLE_SIMILARITY_TREE':
|
|
420
418
|
return DatabaseActions.handleToggleSimilarityTree(draft);
|
|
421
419
|
case 'SET_AUTOMATIC_ASSIGNMENTS':
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { Draft } from 'immer';
|
|
2
2
|
import { Spectrum1D } from 'nmr-load-save';
|
|
3
|
-
import {
|
|
4
|
-
import { ResurrectSpectrumInfo } from '../../../data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges';
|
|
3
|
+
import { DatabaseNMREntry } from 'nmr-processing';
|
|
5
4
|
import { State } from '../Reducer';
|
|
6
5
|
import { ActionType } from '../types/ActionType';
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
interface BaseResurrectSpectrum {
|
|
7
|
+
databaseEntry: DatabaseNMREntry;
|
|
8
|
+
}
|
|
9
|
+
interface ResurrectSpectrumFromJCAMP extends BaseResurrectSpectrum {
|
|
10
|
+
source: 'jcamp';
|
|
9
11
|
spectrum: Spectrum1D;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
declare function
|
|
12
|
+
}
|
|
13
|
+
interface ResurrectSpectrumFromRangesOrSignals extends BaseResurrectSpectrum {
|
|
14
|
+
source: 'rangesOrSignals';
|
|
15
|
+
}
|
|
16
|
+
type ResurrectSpectrum = ResurrectSpectrumFromJCAMP | ResurrectSpectrumFromRangesOrSignals;
|
|
17
|
+
type ResurrectSpectrumAction = ActionType<'RESURRECTING_SPECTRUM', ResurrectSpectrum>;
|
|
18
|
+
export type DatabaseActions = ActionType<'TOGGLE_SIMILARITY_TREE'> | ResurrectSpectrumAction;
|
|
19
|
+
declare function handleResurrectSpectrum(draft: Draft<State>, action: ResurrectSpectrumAction): void;
|
|
18
20
|
declare function handleToggleSimilarityTree(draft: Draft<State>): void;
|
|
19
|
-
export {
|
|
21
|
+
export { handleResurrectSpectrum, handleToggleSimilarityTree };
|
|
@@ -1,43 +1,61 @@
|
|
|
1
|
-
import { get1DColor, mapRanges } from '../../../data/data1d/Spectrum1D';
|
|
2
|
-
import {
|
|
1
|
+
import { get1DColor, isSpectrum1D, mapRanges, } from '../../../data/data1d/Spectrum1D';
|
|
2
|
+
import { resurrectSpectrumFromRanges, resurrectSpectrumFromSignals, } from '../../../data/data1d/Spectrum1D/ranges/resurrectSpectrum';
|
|
3
3
|
import { setZoom } from '../helper/Zoom1DManager';
|
|
4
4
|
import zoomHistoryManager from '../helper/ZoomHistoryManager';
|
|
5
|
+
import { getSpectrum } from '../helper/getSpectrum';
|
|
5
6
|
import { setDomain } from './DomainActions';
|
|
6
|
-
function
|
|
7
|
-
const {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const zoomHistory = zoomHistoryManager(draft.zoom.history, draft.view.spectra.activeTab);
|
|
26
|
-
const zoomValue = zoomHistory.getLast();
|
|
27
|
-
if (zoomValue) {
|
|
28
|
-
draft.xDomain = zoomValue.xDomain;
|
|
29
|
-
draft.yDomain = zoomValue.yDomain;
|
|
7
|
+
function handleResurrectSpectrum(draft, action) {
|
|
8
|
+
const { spectra: { activeTab: nucleus }, } = draft.view;
|
|
9
|
+
const { databaseEntry, source } = action.payload;
|
|
10
|
+
const { ranges, signals, solvent, names = [], id: spectrumID, } = databaseEntry;
|
|
11
|
+
let resurrectedSpectrum = null;
|
|
12
|
+
if (source === 'jcamp') {
|
|
13
|
+
const { spectrum } = action.payload;
|
|
14
|
+
resurrectedSpectrum = {
|
|
15
|
+
...spectrum,
|
|
16
|
+
id: spectrumID,
|
|
17
|
+
ranges: {
|
|
18
|
+
...spectrum.ranges,
|
|
19
|
+
values: mapRanges(ranges, spectrum),
|
|
20
|
+
},
|
|
21
|
+
display: {
|
|
22
|
+
...spectrum.display,
|
|
23
|
+
...get1DColor(spectrum.display, { usedColors: draft.usedColors }),
|
|
24
|
+
},
|
|
25
|
+
};
|
|
30
26
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
if (source === 'rangesOrSignals') {
|
|
28
|
+
const activeSpectrum = getSpectrum(draft) || draft.data[0];
|
|
29
|
+
let options = {};
|
|
30
|
+
let info = { solvent, name: names[0], nucleus };
|
|
31
|
+
if (activeSpectrum && isSpectrum1D(activeSpectrum)) {
|
|
32
|
+
const { data: { x }, info: spectrumInfo, } = activeSpectrum;
|
|
33
|
+
options = { from: x[0], to: x.at(-1) };
|
|
34
|
+
info = { ...spectrumInfo, ...info };
|
|
35
|
+
}
|
|
36
|
+
if (signals) {
|
|
37
|
+
resurrectedSpectrum = resurrectSpectrumFromSignals(signals, {
|
|
38
|
+
spectrumID,
|
|
39
|
+
info,
|
|
40
|
+
usedColors: draft.usedColors,
|
|
41
|
+
...options,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else if (ranges) {
|
|
45
|
+
resurrectedSpectrum = resurrectSpectrumFromRanges(ranges, {
|
|
46
|
+
spectrumID,
|
|
47
|
+
info,
|
|
48
|
+
usedColors: draft.usedColors,
|
|
49
|
+
...options,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!resurrectedSpectrum)
|
|
36
54
|
return;
|
|
37
|
-
draft.data.push(
|
|
55
|
+
draft.data.push(resurrectedSpectrum);
|
|
38
56
|
setDomain(draft, { isYDomainShared: false });
|
|
39
57
|
//rescale the vertical zoom
|
|
40
|
-
setZoom(draft, { scale: 0.8, spectrumID:
|
|
58
|
+
setZoom(draft, { scale: 0.8, spectrumID: resurrectedSpectrum.id });
|
|
41
59
|
//keep the last horizontal zoom
|
|
42
60
|
const zoomHistory = zoomHistoryManager(draft.zoom.history, draft.view.spectra.activeTab);
|
|
43
61
|
const zoomValue = zoomHistory.getLast();
|
|
@@ -50,4 +68,4 @@ function handleToggleSimilarityTree(draft) {
|
|
|
50
68
|
draft.view.spectra.showSimilarityTree =
|
|
51
69
|
!draft.view.spectra.showSimilarityTree;
|
|
52
70
|
}
|
|
53
|
-
export {
|
|
71
|
+
export { handleResurrectSpectrum, handleToggleSimilarityTree };
|
|
@@ -20,8 +20,8 @@ interface GetDomainOptions {
|
|
|
20
20
|
domainSpectraScope?: 'visible' | 'all';
|
|
21
21
|
}
|
|
22
22
|
declare function getDomain(draft: Draft<State>, options?: GetDomainOptions): {
|
|
23
|
-
xDomain: [
|
|
24
|
-
yDomain: [
|
|
23
|
+
xDomain: never[] | [number, number] | [undefined, undefined];
|
|
24
|
+
yDomain: never[] | [number, number] | [undefined, undefined];
|
|
25
25
|
yDomains: Record<string, number[]>;
|
|
26
26
|
xDomains: Record<string, number[]>;
|
|
27
27
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { v4 } from '@lukeed/uuid';
|
|
2
2
|
import { current } from 'immer';
|
|
3
3
|
import { xFindClosestIndex } from 'ml-spectra-processing';
|
|
4
|
-
import { Filters, FiltersManager,
|
|
4
|
+
import { Filters, FiltersManager, getBaselineZonesByDietrich, } from 'nmr-processing';
|
|
5
5
|
import { defaultApodizationOptions } from '../../../data/constants/DefaultApodizationOptions';
|
|
6
6
|
import { isSpectrum1D } from '../../../data/data1d/Spectrum1D';
|
|
7
7
|
import { isSpectrum2D } from '../../../data/data2d/Spectrum2D';
|
|
@@ -21,7 +21,7 @@ import { getTwoDimensionPhaseCorrectionOptions } from '../helper/getTwoDimension
|
|
|
21
21
|
import { setDomain, setMode } from './DomainActions';
|
|
22
22
|
import { changeSpectrumVerticalAlignment } from './PreferencesActions';
|
|
23
23
|
import { activateTool, resetSelectedTool } from './ToolsActions';
|
|
24
|
-
const { fft, fftDimension1, fftDimension2, apodization, baselineCorrection, phaseCorrection, phaseCorrectionTwoDimensions, zeroFilling, shiftX, shift2DX, shift2DY, exclusionZones, signalProcessing, } = Filters;
|
|
24
|
+
const { fft, fftDimension1, fftDimension2, apodization, baselineCorrection, phaseCorrection, phaseCorrectionTwoDimensions, zeroFilling, shiftX, shift2DX, shift2DY, exclusionZones, signalProcessing, digitalFilter, digitalFilter2D, } = Filters;
|
|
25
25
|
function getFilterUpdateDomainRules(filterName, defaultRule) {
|
|
26
26
|
return (Filters[filterName]?.DOMAIN_UPDATE_RULES ||
|
|
27
27
|
defaultRule || {
|
|
@@ -70,7 +70,7 @@ function rollbackSpectrumByFilter(draft, options) {
|
|
|
70
70
|
//set active filter
|
|
71
71
|
draft.toolOptions.data.activeFilterID =
|
|
72
72
|
datum.filters?.[filterIndex]?.id || null;
|
|
73
|
-
const filters = datum.filters.slice(0, filterIndex
|
|
73
|
+
const filters = datum.filters.slice(0, filterIndex);
|
|
74
74
|
updateDomainOptions = getFilterDomain(datum, {
|
|
75
75
|
startIndex: Math.min(activeFilterIndex, filterIndex),
|
|
76
76
|
lastIndex: Math.max(activeFilterIndex, filterIndex),
|
|
@@ -131,6 +131,8 @@ function rollbackSpectrum(draft, options) {
|
|
|
131
131
|
shift2DX.id,
|
|
132
132
|
shift2DY.id,
|
|
133
133
|
signalProcessing.id,
|
|
134
|
+
digitalFilter.id,
|
|
135
|
+
digitalFilter2D.id,
|
|
134
136
|
].includes(filterKey);
|
|
135
137
|
beforeRollback(draft, filterKey);
|
|
136
138
|
rollbackSpectrumByFilter(draft, {
|
|
@@ -233,7 +235,8 @@ function beforeRollback(draft, filterKey) {
|
|
|
233
235
|
if (!baselineCorrectionFilter ||
|
|
234
236
|
(baselineCorrectionFilter &&
|
|
235
237
|
baselineCorrectionFilter.value.zones?.length === 0)) {
|
|
236
|
-
draft.toolOptions.data.baselineCorrection.zones =
|
|
238
|
+
draft.toolOptions.data.baselineCorrection.zones =
|
|
239
|
+
getBaselineZonesByDietrich(datum.data);
|
|
237
240
|
}
|
|
238
241
|
else {
|
|
239
242
|
draft.toolOptions.data.baselineCorrection.zones =
|
|
@@ -773,6 +776,8 @@ function handleSetFilterSnapshotHandler(draft, action) {
|
|
|
773
776
|
activateTool(draft, { toolId: filterKey, reset });
|
|
774
777
|
}
|
|
775
778
|
else {
|
|
779
|
+
draft.toolOptions.selectedOptionPanel = null;
|
|
780
|
+
draft.toolOptions.selectedTool = 'zoom';
|
|
776
781
|
rollbackSpectrum(draft, { filterKey, reset });
|
|
777
782
|
}
|
|
778
783
|
}
|
|
@@ -65,6 +65,7 @@ type CutRangAction = ActionType<'CUT_RANGE', {
|
|
|
65
65
|
}>;
|
|
66
66
|
type ToggleRangesViewAction = ActionType<'TOGGLE_RANGES_VIEW_PROPERTY', {
|
|
67
67
|
key: keyof FilterType<RangesViewState, boolean>;
|
|
68
|
+
value?: boolean;
|
|
68
69
|
}>;
|
|
69
70
|
type DeleteRangePeakAction = ActionType<'DELETE_RANGE_PEAK', {
|
|
70
71
|
id: string;
|
|
@@ -323,13 +323,18 @@ function handleUpdateRange(draft, action) {
|
|
|
323
323
|
datum.ranges.values[index] = range;
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
-
function toggleRangesViewProperty(draft, key) {
|
|
327
|
-
|
|
326
|
+
function toggleRangesViewProperty(draft, key, value) {
|
|
327
|
+
if (typeof value === 'boolean') {
|
|
328
|
+
setRangesViewProperty(draft, key, value);
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
setRangesViewProperty(draft, key, (flag) => !flag);
|
|
332
|
+
}
|
|
328
333
|
}
|
|
329
334
|
//action
|
|
330
335
|
function handleToggleRangesViewProperty(draft, action) {
|
|
331
|
-
const { key } = action.payload;
|
|
332
|
-
toggleRangesViewProperty(draft, key);
|
|
336
|
+
const { key, value } = action.payload;
|
|
337
|
+
toggleRangesViewProperty(draft, key, value);
|
|
333
338
|
}
|
|
334
339
|
function handleCutRange(draft, action) {
|
|
335
340
|
const { ranges: cutRanges } = action.payload;
|
|
@@ -10,10 +10,11 @@ type ChangeSpectrumVisibilityByIdAction = ActionType<'CHANGE_SPECTRUM_VISIBILITY
|
|
|
10
10
|
id: string;
|
|
11
11
|
key: 'isVisible' | 'isPositiveVisible' | 'isNegativeVisible';
|
|
12
12
|
}>;
|
|
13
|
+
export type SpectraSelectedMode = 'selected' | 'all' | 'selectedOnly';
|
|
13
14
|
type ChangeSpectraVisibilityByNucleusAction = ActionType<'CHANGE_SPECTRA_VISIBILITY_BY_NUCLEUS', {
|
|
14
15
|
nucleus: Nucleus;
|
|
15
16
|
flag: boolean;
|
|
16
|
-
mode?:
|
|
17
|
+
mode?: SpectraSelectedMode;
|
|
17
18
|
}>;
|
|
18
19
|
type ChangeActiveSpectrumAction = ActionType<'CHANGE_ACTIVE_SPECTRUM', {
|
|
19
20
|
modifier?: 'shift[false]_ctrl[true]' | 'shift[true]_ctrl[false]' | 'shift[true]_ctrl[true]' | (string & {});
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { original } from 'immer';
|
|
2
2
|
import lodashGet from 'lodash/get';
|
|
3
|
-
import omitBy from 'lodash/omitBy';
|
|
4
|
-
import lodashSet from 'lodash/set';
|
|
5
3
|
import { Filters, FiltersManager } from 'nmr-processing';
|
|
6
|
-
import { getReferenceShift, isSpectrum1D, get1DColor, initiateDatum1D,
|
|
4
|
+
import { getReferenceShift, isSpectrum1D, get1DColor, initiateDatum1D, resurrectSpectrumFromRanges, } from '../../../data/data1d/Spectrum1D';
|
|
7
5
|
import { simulateSpectrum, } from '../../../data/data1d/spectrumSimulation';
|
|
8
6
|
import { getMissingProjection, isSpectrum2D, get2DColor, } from '../../../data/data2d/Spectrum2D';
|
|
9
7
|
import { contoursManager } from '../../../data/data2d/Spectrum2D/contours';
|
|
@@ -12,8 +10,9 @@ import groupByInfoKey from '../../utility/GroupByInfoKey';
|
|
|
12
10
|
import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
|
|
13
11
|
import { setZoom } from '../helper/Zoom1DManager';
|
|
14
12
|
import { getActiveSpectra } from '../helper/getActiveSpectra';
|
|
15
|
-
import { getActiveSpectraAsObject
|
|
13
|
+
import { getActiveSpectraAsObject } from '../helper/getActiveSpectraAsObject';
|
|
16
14
|
import { getActiveSpectrum } from '../helper/getActiveSpectrum';
|
|
15
|
+
import { removeSpectrumRelatedObjectsById } from '../helper/removeSpectrumRelatedObjectsById';
|
|
17
16
|
import { setDomain, setMode } from './DomainActions';
|
|
18
17
|
import { rollbackSpectrumByFilter } from './FiltersActions';
|
|
19
18
|
import { setTab, setActiveTab, setMargin, resetSelectedTool, } from './ToolsActions';
|
|
@@ -52,23 +51,6 @@ function multipleSelect(spectraIds, options) {
|
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
|
-
function removeActiveSpectra(draft, relatedTargets) {
|
|
56
|
-
const activeSpectra = getActiveSpectraAsObject(draft);
|
|
57
|
-
// remove the active spectra
|
|
58
|
-
relatedTargets.unshift({ jpath: 'data', key: 'id' });
|
|
59
|
-
for (const target of relatedTargets) {
|
|
60
|
-
const { jpath } = target;
|
|
61
|
-
const targetObj = lodashGet(draft, jpath);
|
|
62
|
-
if (Array.isArray(targetObj)) {
|
|
63
|
-
const data = targetObj.filter((datum) => !isActiveSpectrum(activeSpectra, datum[target.key]));
|
|
64
|
-
lodashSet(draft, jpath, data);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
const data = omitBy(draft.view.peaks, (_, id) => isActiveSpectrum(activeSpectra, id));
|
|
68
|
-
lodashSet(draft, jpath, data);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
54
|
function setSpectraMetaInfo(draft, spectraMetaInfo) {
|
|
73
55
|
const { data } = draft;
|
|
74
56
|
for (const spectrum of data) {
|
|
@@ -97,13 +79,22 @@ function handleChangeSpectraVisibilityByNucleus(draft, action) {
|
|
|
97
79
|
const { nucleus, flag, mode = 'all' } = action.payload;
|
|
98
80
|
const activeSpectra = getActiveSpectraAsObject(draft);
|
|
99
81
|
for (const datum of getSpectraByNucleus(nucleus, draft.data)) {
|
|
100
|
-
|
|
101
|
-
|
|
82
|
+
switch (mode) {
|
|
83
|
+
case 'selected':
|
|
84
|
+
if (activeSpectra && datum.id in activeSpectra) {
|
|
85
|
+
setVisible(datum, flag);
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
case 'selectedOnly':
|
|
89
|
+
if (activeSpectra && datum.id in activeSpectra) {
|
|
90
|
+
setVisible(datum, flag);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
setVisible(datum, !flag);
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
default:
|
|
102
97
|
setVisible(datum, flag);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
setVisible(datum, flag);
|
|
107
98
|
}
|
|
108
99
|
}
|
|
109
100
|
}
|
|
@@ -240,23 +231,39 @@ function handleChangeSpectrumSetting(draft, action) {
|
|
|
240
231
|
}
|
|
241
232
|
//action
|
|
242
233
|
function handleDeleteSpectra(draft, action) {
|
|
243
|
-
const
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
draft.data.
|
|
248
|
-
|
|
249
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
250
|
-
delete draft.view.peaks[spectraId];
|
|
234
|
+
const { id: spectrumID, domainOptions } = action?.payload || {};
|
|
235
|
+
const activeSpectra = getActiveSpectra(draft);
|
|
236
|
+
let spectraIDs = [];
|
|
237
|
+
if (spectrumID) {
|
|
238
|
+
const index = draft.data.findIndex((spectrum) => spectrum.id === spectrumID);
|
|
239
|
+
spectraIDs = [{ id: spectrumID, index }];
|
|
251
240
|
}
|
|
252
241
|
else {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
242
|
+
spectraIDs = activeSpectra || [];
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Sort the spectraIDs indices in descending order.
|
|
246
|
+
* This prevents shifting issues when removing elements, ensuring that each deletion doesn't changing the positions of remaining elements to be removed.
|
|
247
|
+
*/
|
|
248
|
+
spectraIDs.sort((a, b) => b.index - a.index);
|
|
249
|
+
for (const { index, id } of spectraIDs) {
|
|
250
|
+
draft.data.splice(index, 1);
|
|
251
|
+
removeSpectrumRelatedObjectsById(draft, id);
|
|
252
|
+
}
|
|
253
|
+
//TODO refactor the view state, https://github.com/cheminfo/nmrium/issues/3169
|
|
254
|
+
//update keys preferences
|
|
255
|
+
const spectraRemovedIDs = {};
|
|
256
|
+
for (const { id } of spectraIDs) {
|
|
257
|
+
spectraRemovedIDs[id] = true;
|
|
258
|
+
}
|
|
259
|
+
for (const key of Object.keys(draft.keysPreferences)) {
|
|
260
|
+
const preferencesState = draft.keysPreferences[key];
|
|
261
|
+
// remove related object from save preferences for deleted spectra
|
|
262
|
+
for (const { id } of preferencesState.data) {
|
|
263
|
+
if (spectraRemovedIDs[id]) {
|
|
264
|
+
removeSpectrumRelatedObjectsById(preferencesState, id);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
260
267
|
}
|
|
261
268
|
setActiveTab(draft, {
|
|
262
269
|
tab: draft.view.spectra.activeTab,
|
|
@@ -307,7 +314,10 @@ function handleAlignSpectraHandler(draft, action) {
|
|
|
307
314
|
//action
|
|
308
315
|
function handleGenerateSpectrumFromPublicationStringHandler(draft, action) {
|
|
309
316
|
const { ranges, info } = action.payload;
|
|
310
|
-
const spectrum =
|
|
317
|
+
const spectrum = resurrectSpectrumFromRanges(ranges, {
|
|
318
|
+
info,
|
|
319
|
+
usedColors: draft.usedColors,
|
|
320
|
+
});
|
|
311
321
|
if (spectrum) {
|
|
312
322
|
draft.data.push(spectrum);
|
|
313
323
|
setActiveTab(draft);
|