nmrium 0.20.2 → 0.23.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/ExclusionZonesAnnotations.js +1 -2
- package/lib/component/1d/FooterBanner.js +1 -1
- package/lib/component/1d/Integral.js +1 -6
- package/lib/component/1d/Viewer1D.js +4 -4
- package/lib/component/1d/ranges/RangeIntegral.js +2 -6
- package/lib/component/1d/utilities/scale.d.ts +1 -1
- package/lib/component/1d/utilities/scale.js +7 -6
- package/lib/component/2d/Viewer2D.js +5 -5
- package/lib/component/EventsTrackers/KeysListenerTracker.js +98 -81
- package/lib/component/NMRium.d.ts +10 -6
- package/lib/component/NMRium.js +3 -9
- package/lib/component/elements/EditableColumn.d.ts +1 -1
- package/lib/component/header/Header.js +13 -10
- package/lib/component/hooks/useCheckExperimentalFeature.js +2 -1
- package/lib/component/hooks/useCheckToolsVisibility.d.ts +1 -0
- package/lib/component/hooks/useCheckToolsVisibility.js +6 -0
- package/lib/component/{1d/utilities → hooks}/useIntegralPath.d.ts +0 -0
- package/lib/component/hooks/useIntegralPath.js +53 -0
- package/lib/component/hooks/useToolsFunctions.js +6 -6
- package/lib/component/hooks/useXScale.d.ts +2 -0
- package/lib/component/hooks/useXScale.js +7 -0
- package/lib/component/loader/DropZone.js +87 -87
- package/lib/component/modal/PredictSpectraModal.d.ts +0 -28
- package/lib/component/modal/PredictSpectraModal.js +2 -32
- package/lib/component/modal/changeSum/ChangeSumModal.js +4 -2
- package/lib/component/modal/editRange/forms/validation/EditRangeValidation.js +1 -1
- package/lib/component/modal/editZone/EditPathLengthFormik.d.ts +5 -0
- package/lib/component/modal/editZone/EditPathLengthFormik.js +72 -0
- package/lib/component/modal/editZone/EditZoneModal.d.ts +8 -0
- package/lib/component/modal/editZone/EditZoneModal.js +96 -0
- package/lib/component/modal/editZone/SignalFormTab.d.ts +6 -0
- package/lib/component/modal/editZone/SignalFormTab.js +6 -0
- package/lib/component/modal/editZone/SignalsForm.d.ts +2 -0
- package/lib/component/modal/editZone/SignalsForm.js +62 -0
- package/lib/component/modal/editZone/validation/EditZoneValidation.d.ts +534 -0
- package/lib/component/modal/editZone/validation/EditZoneValidation.js +17 -0
- package/lib/component/modal/editZone/validation/isDefaultPathLength.d.ts +3 -0
- package/lib/component/modal/editZone/validation/isDefaultPathLength.js +7 -0
- package/lib/component/modal/setting/ControllersTabContent.js +1 -1
- package/lib/component/modal/setting/DisplayTabContent.js +5 -1
- package/lib/component/modal/setting/GeneralSettings.d.ts +1 -2
- package/lib/component/modal/setting/GeneralSettings.js +13 -9
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.d.ts +2 -0
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +13 -0
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.d.ts +7 -0
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.js +38 -0
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +0 -3
- package/lib/component/panels/IntegralsPanel/IntegralsPreferences.js +4 -17
- package/lib/component/panels/MoleculesPanel/MoleculePanel.d.ts +10 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanel.js +27 -17
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts +9 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +2 -2
- package/lib/component/panels/Panels.d.ts +1 -1
- package/lib/component/panels/Panels.js +17 -14
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +0 -3
- package/lib/component/panels/PeaksPanel/PeaksPreferences.js +5 -14
- package/lib/component/panels/RangesPanel/RangesPanel.js +2 -5
- package/lib/component/panels/RangesPanel/RangesPreferences.js +5 -18
- package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +13 -3
- package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.js +7 -2
- package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnHeader.js +7 -2
- package/lib/component/panels/SummaryPanel/CorrelationTable/Constants.d.ts +1 -6
- package/lib/component/panels/SummaryPanel/CorrelationTable/Constants.js +1 -7
- package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTable.d.ts +2 -3
- package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTable.js +4 -5
- package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.d.ts +2 -3
- package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +21 -25
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +24 -30
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditPathLength.d.ts +8 -0
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditPathLength.js +89 -0
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/MoveLink.d.ts +1 -1
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/MoveLink.js +1 -1
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +39 -42
- package/lib/component/panels/SummaryPanel/utilities/IsInView.d.ts +6 -0
- package/lib/component/panels/SummaryPanel/utilities/IsInView.js +16 -0
- package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +29 -0
- package/lib/component/panels/SummaryPanel/{Utilities.js → utilities/Utilities.js} +155 -19
- package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.d.ts +1 -0
- package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +26 -3
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +12 -7
- package/lib/component/panels/ZonesPanel/ZonesPreferences.js +5 -18
- package/lib/component/panels/ZonesPanel/ZonesTable.d.ts +3 -2
- package/lib/component/panels/ZonesPanel/ZonesTable.js +5 -2
- package/lib/component/panels/databasePanel/DatabasePanel.js +0 -3
- package/lib/component/panels/databasePanel/DatabasePreferences.js +4 -17
- package/lib/component/panels/predictionPanel/PredictionOptions.d.ts +6 -0
- package/lib/component/panels/predictionPanel/PredictionOptions.js +88 -0
- package/lib/component/panels/predictionPanel/PredictionPanel.d.ts +2 -0
- package/lib/component/panels/predictionPanel/PredictionPanel.js +33 -0
- package/lib/component/reducer/IgnoreActions.js +2 -1
- package/lib/component/reducer/Reducer.d.ts +9 -23
- package/lib/component/reducer/Reducer.js +7 -8
- package/lib/component/reducer/actions/DatabaseActions.js +1 -1
- package/lib/component/reducer/actions/DomainActions.d.ts +3 -1
- package/lib/component/reducer/actions/DomainActions.js +20 -1
- package/lib/component/reducer/actions/IntegralsActions.js +2 -0
- package/lib/component/reducer/actions/LoadActions.js +29 -1
- package/lib/component/reducer/actions/MoleculeActions.js +1 -1
- package/lib/component/reducer/actions/PreferencesActions.js +0 -2
- package/lib/component/reducer/actions/RangesActions.js +3 -1
- package/lib/component/reducer/actions/SpectrumsActions.js +1 -1
- package/lib/component/reducer/actions/ToolsActions.js +43 -56
- package/lib/component/reducer/actions/ZonesActions.d.ts +3 -1
- package/lib/component/reducer/actions/ZonesActions.js +33 -2
- package/lib/component/reducer/helper/Zoom1DManager.d.ts +17 -21
- package/lib/component/reducer/helper/Zoom1DManager.js +53 -69
- package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +1 -0
- package/lib/component/reducer/helper/ZoomHistoryManager.js +2 -1
- package/lib/component/reducer/preferencesReducer.d.ts +3 -8
- package/lib/component/reducer/preferencesReducer.js +86 -37
- package/lib/component/reducer/types/Types.d.ts +3 -1
- package/lib/component/reducer/types/Types.js +3 -1
- package/lib/component/toolbar/FunctionToolBar.js +7 -10
- package/lib/component/toolbar/ToolTypes.js +3 -3
- package/lib/component/workspaces/Workspace.d.ts +6 -0
- package/lib/component/workspaces/Workspace.js +1 -0
- package/lib/component/workspaces/basic.d.ts +2 -0
- package/lib/component/workspaces/basic.js +46 -0
- package/lib/component/workspaces/exercise1D.d.ts +2 -0
- package/lib/component/workspaces/exercise1D.js +46 -0
- package/lib/component/workspaces/index.d.ts +6 -0
- package/lib/component/workspaces/index.js +4 -0
- package/lib/component/workspaces/process1D.d.ts +2 -0
- package/lib/component/workspaces/process1D.js +44 -0
- package/lib/data/PredictionManager.d.ts +35 -3
- package/lib/data/PredictionManager.js +45 -7
- package/lib/data/constants/DefaultPathLengths.d.ts +6 -0
- package/lib/data/constants/DefaultPathLengths.js +8 -0
- package/lib/data/data1d/Spectrum1D/getSpectrumErrorValue.d.ts +2 -0
- package/lib/data/data1d/Spectrum1D/getSpectrumErrorValue.js +4 -0
- package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +7 -19
- package/lib/data/data1d/Spectrum1D/integrals/initiateIntegrals.d.ts +11 -0
- package/lib/data/data1d/Spectrum1D/integrals/initiateIntegrals.js +11 -0
- package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +2 -21
- package/lib/data/data1d/Spectrum1D/peaks/initiatePeaks.d.ts +9 -0
- package/lib/data/data1d/Spectrum1D/peaks/initiatePeaks.js +7 -0
- package/lib/data/data1d/Spectrum1D/peaks/mapPeaks.d.ts +2 -0
- package/lib/data/data1d/Spectrum1D/peaks/mapPeaks.js +29 -0
- package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +13 -0
- package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.js +14 -0
- package/lib/data/data1d/Spectrum1D/ranges/mapRanges.js +13 -8
- package/lib/data/migration/MigrationManager.js +3 -0
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/ExclusionZonesAnnotations.js +1 -2
- package/lib-cjs/component/1d/FooterBanner.js +1 -1
- package/lib-cjs/component/1d/Integral.js +1 -6
- package/lib-cjs/component/1d/Viewer1D.js +4 -4
- package/lib-cjs/component/1d/ranges/RangeIntegral.js +2 -6
- package/lib-cjs/component/1d/utilities/scale.js +7 -6
- package/lib-cjs/component/2d/Viewer2D.js +4 -4
- package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +98 -81
- package/lib-cjs/component/NMRium.js +3 -10
- package/lib-cjs/component/header/Header.js +13 -10
- package/lib-cjs/component/hooks/useCheckExperimentalFeature.js +5 -1
- package/lib-cjs/component/hooks/useCheckToolsVisibility.js +13 -0
- package/lib-cjs/component/hooks/useIntegralPath.js +56 -0
- package/lib-cjs/component/hooks/useToolsFunctions.js +6 -6
- package/lib-cjs/component/hooks/useXScale.js +11 -0
- package/lib-cjs/component/loader/DropZone.js +87 -87
- package/lib-cjs/component/modal/PredictSpectraModal.js +3 -33
- package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +4 -2
- package/lib-cjs/component/modal/editRange/forms/validation/EditRangeValidation.js +1 -1
- package/lib-cjs/component/modal/editZone/EditPathLengthFormik.js +77 -0
- package/lib-cjs/component/modal/editZone/EditZoneModal.js +101 -0
- package/lib-cjs/component/modal/editZone/SignalFormTab.js +11 -0
- package/lib-cjs/component/modal/editZone/SignalsForm.js +67 -0
- package/lib-cjs/component/modal/editZone/validation/EditZoneValidation.js +38 -0
- package/lib-cjs/component/modal/editZone/validation/isDefaultPathLength.js +12 -0
- package/lib-cjs/component/modal/setting/ControllersTabContent.js +1 -1
- package/lib-cjs/component/modal/setting/DisplayTabContent.js +5 -1
- package/lib-cjs/component/modal/setting/GeneralSettings.js +12 -8
- package/lib-cjs/component/panels/AutomaticAssignment/AutomaticAssignment.js +18 -0
- package/lib-cjs/component/panels/AutomaticAssignment/AutomaticAssignmentTable.js +43 -0
- package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +0 -3
- package/lib-cjs/component/panels/IntegralsPanel/IntegralsPreferences.js +3 -16
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanel.js +27 -17
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +2 -2
- package/lib-cjs/component/panels/Panels.js +18 -15
- package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +0 -3
- package/lib-cjs/component/panels/PeaksPanel/PeaksPreferences.js +4 -13
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +2 -5
- package/lib-cjs/component/panels/RangesPanel/RangesPreferences.js +4 -17
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraPanelHeader.js +13 -3
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.js +7 -2
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnHeader.js +7 -2
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/Constants.js +1 -8
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/CorrelationTable.js +4 -5
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +21 -25
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +43 -30
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/editLink/EditPathLength.js +94 -0
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/editLink/MoveLink.js +1 -1
- package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +38 -41
- package/lib-cjs/component/panels/SummaryPanel/utilities/IsInView.js +18 -0
- package/lib-cjs/component/panels/SummaryPanel/{Utilities.js → utilities/Utilities.js} +157 -19
- package/lib-cjs/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +24 -1
- package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +12 -7
- package/lib-cjs/component/panels/ZonesPanel/ZonesPreferences.js +4 -17
- package/lib-cjs/component/panels/ZonesPanel/ZonesTable.js +5 -2
- package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +0 -3
- package/lib-cjs/component/panels/databasePanel/DatabasePreferences.js +3 -16
- package/lib-cjs/component/panels/predictionPanel/PredictionOptions.js +112 -0
- package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +39 -0
- package/lib-cjs/component/reducer/IgnoreActions.js +2 -1
- package/lib-cjs/component/reducer/Reducer.js +7 -8
- package/lib-cjs/component/reducer/actions/DatabaseActions.js +2 -2
- package/lib-cjs/component/reducer/actions/DomainActions.js +21 -1
- package/lib-cjs/component/reducer/actions/IntegralsActions.js +2 -0
- package/lib-cjs/component/reducer/actions/LoadActions.js +29 -1
- package/lib-cjs/component/reducer/actions/MoleculeActions.js +1 -1
- package/lib-cjs/component/reducer/actions/PreferencesActions.js +0 -2
- package/lib-cjs/component/reducer/actions/RangesActions.js +2 -0
- package/lib-cjs/component/reducer/actions/SpectrumsActions.js +2 -2
- package/lib-cjs/component/reducer/actions/ToolsActions.js +50 -63
- package/lib-cjs/component/reducer/actions/ZonesActions.js +35 -2
- package/lib-cjs/component/reducer/helper/Zoom1DManager.js +55 -73
- package/lib-cjs/component/reducer/helper/ZoomHistoryManager.js +2 -1
- package/lib-cjs/component/reducer/preferencesReducer.js +87 -38
- package/lib-cjs/component/reducer/types/Types.js +6 -4
- package/lib-cjs/component/toolbar/FunctionToolBar.js +7 -10
- package/lib-cjs/component/toolbar/ToolTypes.js +3 -3
- package/lib-cjs/component/workspaces/Workspace.js +2 -0
- package/lib-cjs/component/workspaces/basic.js +49 -0
- package/lib-cjs/component/workspaces/exercise1D.js +49 -0
- package/lib-cjs/component/workspaces/index.js +6 -0
- package/lib-cjs/component/workspaces/process1D.js +47 -0
- package/lib-cjs/data/PredictionManager.js +46 -8
- package/lib-cjs/data/constants/DefaultPathLengths.js +10 -0
- package/lib-cjs/data/data1d/Spectrum1D/getSpectrumErrorValue.js +8 -0
- package/lib-cjs/data/data1d/Spectrum1D/initiateDatum1D.js +7 -19
- package/lib-cjs/data/data1d/Spectrum1D/integrals/initiateIntegrals.js +18 -0
- package/lib-cjs/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +2 -21
- package/lib-cjs/data/data1d/Spectrum1D/peaks/initiatePeaks.js +14 -0
- package/lib-cjs/data/data1d/Spectrum1D/peaks/mapPeaks.js +36 -0
- package/lib-cjs/data/data1d/Spectrum1D/ranges/initiateRanges.js +21 -0
- package/lib-cjs/data/data1d/Spectrum1D/ranges/mapRanges.js +13 -8
- package/lib-cjs/data/migration/MigrationManager.js +3 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +1 -1
- package/lib/component/1d/utilities/useIntegralPath.js +0 -63
- package/lib/component/nmriumMode/basic.d.ts +0 -38
- package/lib/component/nmriumMode/basic.js +0 -37
- package/lib/component/nmriumMode/exercise1D.d.ts +0 -38
- package/lib/component/nmriumMode/exercise1D.js +0 -37
- package/lib/component/nmriumMode/process1D.d.ts +0 -38
- package/lib/component/nmriumMode/process1D.js +0 -37
- package/lib/component/panels/SummaryPanel/Utilities.d.ts +0 -25
- package/lib/component/reducer/actions/Zoom.d.ts +0 -16
- package/lib/component/reducer/actions/Zoom.js +0 -92
- package/lib-cjs/component/1d/utilities/useIntegralPath.js +0 -66
- package/lib-cjs/component/nmriumMode/basic.js +0 -39
- package/lib-cjs/component/nmriumMode/exercise1D.js +0 -39
- package/lib-cjs/component/nmriumMode/process1D.js +0 -39
- package/lib-cjs/component/reducer/actions/Zoom.js +0 -116
|
@@ -8,13 +8,13 @@ import { LAYOUT } from '../../2d/utilities/DimensionLayout';
|
|
|
8
8
|
import { get2DYScale } from '../../2d/utilities/scale';
|
|
9
9
|
import { options } from '../../toolbar/ToolTypes';
|
|
10
10
|
import GroupByInfoKey from '../../utility/GroupByInfoKey';
|
|
11
|
+
import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
|
|
11
12
|
import { DISPLAYER_MODE, MARGIN } from '../core/Constants';
|
|
12
|
-
import
|
|
13
|
+
import { setZoom, wheelZoom, ZoomType } from '../helper/Zoom1DManager';
|
|
13
14
|
import zoomHistoryManager from '../helper/ZoomHistoryManager';
|
|
14
|
-
import { setDomain, setMode } from './DomainActions';
|
|
15
|
+
import { setDomain, setIntegralsYDomain, setMode, } from './DomainActions';
|
|
15
16
|
import { resetSpectrumByFilter } from './FiltersActions';
|
|
16
17
|
import { changeSpectrumVerticalAlignment } from './PreferencesActions';
|
|
17
|
-
import { setZoom1D, setZoom, ZoomType, wheel } from './Zoom';
|
|
18
18
|
function getStrongestPeak(draft) {
|
|
19
19
|
const { activeSpectrum, data } = draft;
|
|
20
20
|
if (activeSpectrum) {
|
|
@@ -180,7 +180,7 @@ function handleBrushEnd(draft, action) {
|
|
|
180
180
|
break;
|
|
181
181
|
}
|
|
182
182
|
if (brushHistory) {
|
|
183
|
-
brushHistory.push({ xDomain:
|
|
183
|
+
brushHistory.push({ xDomain: draft.xDomain, yDomain: draft.yDomain });
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
else {
|
|
@@ -204,34 +204,37 @@ function getSpectrumID(draft, index) {
|
|
|
204
204
|
return spectrum?.id ? spectrum.id : null;
|
|
205
205
|
}
|
|
206
206
|
function handleZoom(draft, action) {
|
|
207
|
-
const {
|
|
208
|
-
const { activeSpectrum, toolOptions: { data: { showRangesIntegrals }, }, } = draft;
|
|
209
|
-
if (
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
case LAYOUT.LEFT_1D: {
|
|
218
|
-
const id = getSpectrumID(draft, 1);
|
|
219
|
-
wheel(deltaY, deltaMode, draft, id);
|
|
220
|
-
setZoom1D(draft, draft.margin.left, 10, 1);
|
|
221
|
-
break;
|
|
207
|
+
const { event, trackID, selectedTool } = action;
|
|
208
|
+
const { activeSpectrum, toolOptions: { data: { showRangesIntegrals }, }, displayerMode, } = draft;
|
|
209
|
+
if (displayerMode === DISPLAYER_MODE.DM_2D) {
|
|
210
|
+
const index = trackID === LAYOUT.TOP_1D ? 0 : trackID === LAYOUT.LEFT_1D ? 1 : null;
|
|
211
|
+
if (index !== null) {
|
|
212
|
+
const id = getSpectrumID(draft, index);
|
|
213
|
+
if (id) {
|
|
214
|
+
const domain = draft.yDomains[id];
|
|
215
|
+
draft.yDomains[id] = wheelZoom(event, domain);
|
|
222
216
|
}
|
|
223
|
-
default:
|
|
224
|
-
break;
|
|
225
217
|
}
|
|
226
218
|
}
|
|
227
|
-
else if (activeSpectrum?.id &&
|
|
228
|
-
shiftKey &&
|
|
229
|
-
(showRangesIntegrals || selectedTool === options.integral.id)) {
|
|
230
|
-
Zoom1DManager(draft.zoom.integral).wheel(deltaY, activeSpectrum?.id);
|
|
231
|
-
}
|
|
232
219
|
else {
|
|
233
|
-
|
|
234
|
-
|
|
220
|
+
if (activeSpectrum?.id) {
|
|
221
|
+
if ((showRangesIntegrals || selectedTool === options.integral.id) &&
|
|
222
|
+
event.shiftKey) {
|
|
223
|
+
const domain = draft.integralsYDomains[activeSpectrum?.id];
|
|
224
|
+
draft.integralsYDomains[activeSpectrum?.id] = wheelZoom(event, domain);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
const domain = draft.yDomains[activeSpectrum?.id];
|
|
228
|
+
draft.yDomains[activeSpectrum?.id] = wheelZoom(event, domain);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
const spectra = getSpectraByNucleus(draft.activeTab, draft.data);
|
|
233
|
+
for (const spectrum of spectra) {
|
|
234
|
+
const domain = draft.yDomains[spectrum.id];
|
|
235
|
+
draft.yDomains[spectrum.id] = wheelZoom(event, domain);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
235
238
|
}
|
|
236
239
|
}
|
|
237
240
|
function zoomOut(draft, action) {
|
|
@@ -242,6 +245,7 @@ function zoomOut(draft, action) {
|
|
|
242
245
|
switch (zoomType) {
|
|
243
246
|
case ZoomType.HORIZONTAL: {
|
|
244
247
|
draft.xDomain = draft.originDomain.xDomain;
|
|
248
|
+
zoomHistory.clear();
|
|
245
249
|
break;
|
|
246
250
|
}
|
|
247
251
|
case ZoomType.VERTICAL:
|
|
@@ -264,34 +268,16 @@ function zoomOut(draft, action) {
|
|
|
264
268
|
}
|
|
265
269
|
else {
|
|
266
270
|
const { xDomain, yDomain, yDomains } = draft.originDomain;
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
const activeSpectrum = draft.tabActiveSpectrum[draft.activeTab.split(',')[1]];
|
|
278
|
-
draft.yDomain = yDomain;
|
|
279
|
-
if (activeSpectrum?.id) {
|
|
280
|
-
draft.yDomains[activeSpectrum.id] = yDomains[activeSpectrum.id];
|
|
281
|
-
}
|
|
282
|
-
break;
|
|
283
|
-
}
|
|
284
|
-
case LAYOUT.CENTER_2D: {
|
|
285
|
-
const zoomValue = zoomHistory.pop();
|
|
286
|
-
draft.xDomain = zoomValue ? zoomValue.xDomain : xDomain;
|
|
287
|
-
draft.yDomain = zoomValue ? zoomValue.yDomain : yDomain;
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
default:
|
|
291
|
-
draft.xDomain = xDomain;
|
|
292
|
-
draft.yDomain = yDomain;
|
|
293
|
-
draft.yDomains = yDomains;
|
|
294
|
-
break;
|
|
271
|
+
if ([LAYOUT.TOP_1D, LAYOUT.LEFT_1D, LAYOUT.CENTER_2D].includes(trackID)) {
|
|
272
|
+
const zoomValue = zoomHistory.pop();
|
|
273
|
+
draft.xDomain = zoomValue ? zoomValue.xDomain : xDomain;
|
|
274
|
+
draft.yDomain = zoomValue ? zoomValue.yDomain : yDomain;
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
zoomHistory.clear();
|
|
278
|
+
draft.xDomain = xDomain;
|
|
279
|
+
draft.yDomain = yDomain;
|
|
280
|
+
draft.yDomains = yDomains;
|
|
295
281
|
}
|
|
296
282
|
}
|
|
297
283
|
}
|
|
@@ -404,6 +390,7 @@ function setActiveTab(draft, options) {
|
|
|
404
390
|
resetTool(draft);
|
|
405
391
|
Processing2DData(draft, dataGroupByNucleus);
|
|
406
392
|
setDomain(draft, domainOptions);
|
|
393
|
+
setIntegralsYDomain(draft, dataGroupByNucleus[currentTab]);
|
|
407
394
|
const zoomHistory = zoomHistoryManager(draft.zoom.history, draft.activeTab);
|
|
408
395
|
const zoomValue = zoomHistory.getLast();
|
|
409
396
|
if (zoomValue) {
|
|
@@ -8,6 +8,8 @@ declare function changeZoneSignalDelta(draft: Draft<State>, action: any): void;
|
|
|
8
8
|
declare function handleChangeZoneSignalKind(draft: Draft<State>, action: any): void;
|
|
9
9
|
declare function handleDeleteZone(draft: Draft<State>, action: any): void;
|
|
10
10
|
declare function handleDeleteSignal(draft: Draft<State>, action: any): void;
|
|
11
|
+
declare function handleSetSignalPathLength(draft: Draft<State>, action: any): void;
|
|
11
12
|
declare function handleUnlinkZone(draft: Draft<State>, action: any): void;
|
|
12
13
|
declare function handleSetDiaIDZone(draft: Draft<State>, action: any): void;
|
|
13
|
-
|
|
14
|
+
declare function handleSaveEditedZone(draft: Draft<State>, action: any): void;
|
|
15
|
+
export { add2dZoneHandler, handleAutoZonesDetection, handleDeleteSignal, handleDeleteZone, changeZoneSignalDelta, handleChangeZoneSignalKind, handleUnlinkZone, handleSaveEditedZone, handleSetDiaIDZone, handleSetSignalPathLength, changeZonesFactorHandler, handleAutoSpectraZonesDetection, };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { original } from 'immer';
|
|
2
2
|
import lodashCloneDeep from 'lodash/cloneDeep';
|
|
3
|
+
import { setPathLength } from 'nmr-correlation';
|
|
3
4
|
import * as Filters from '../../../data/Filters';
|
|
4
5
|
import * as FiltersManager from '../../../data/FiltersManager';
|
|
5
6
|
import { DatumKind, SignalKindsToInclude, } from '../../../data/constants/SignalsKinds';
|
|
@@ -125,6 +126,21 @@ function handleDeleteSignal(draft, action) {
|
|
|
125
126
|
handleOnChangeZonesData(draft);
|
|
126
127
|
}
|
|
127
128
|
}
|
|
129
|
+
function handleSetSignalPathLength(draft, action) {
|
|
130
|
+
const { spectrum, zone, signal, pathLength } = action.payload;
|
|
131
|
+
if (spectrum && zone) {
|
|
132
|
+
const datum2D = draft.data.find((datum) => datum.id === spectrum.id);
|
|
133
|
+
const zoneIndex = datum2D.zones.values.findIndex((_zone) => _zone.id === zone.id);
|
|
134
|
+
const signalIndex = zone.signals.findIndex((_signal) => _signal.id === signal.id);
|
|
135
|
+
const _zone = unlink(lodashCloneDeep(zone), false, signalIndex, undefined);
|
|
136
|
+
_zone.signals[signalIndex].j = {
|
|
137
|
+
..._zone.signals[signalIndex].j,
|
|
138
|
+
pathLength,
|
|
139
|
+
};
|
|
140
|
+
datum2D.zones.values[zoneIndex] = _zone;
|
|
141
|
+
handleOnChangeZonesData(draft);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
128
144
|
function handleUnlinkZone(draft, action) {
|
|
129
145
|
const state = original(draft);
|
|
130
146
|
if (state.activeSpectrum?.id) {
|
|
@@ -163,10 +179,25 @@ function handleSetDiaIDZone(draft, action) {
|
|
|
163
179
|
_zone.signals[signalIndex][axis].diaIDs = diaIDs;
|
|
164
180
|
_zone.signals[signalIndex][axis].nbAtoms = getNbAtoms(nbAtoms, _zone.signals[signalIndex][axis].nbAtoms);
|
|
165
181
|
}
|
|
166
|
-
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function handleSaveEditedZone(draft, action) {
|
|
185
|
+
const state = original(draft);
|
|
186
|
+
if (state.activeSpectrum?.id) {
|
|
187
|
+
const { index } = state.activeSpectrum;
|
|
188
|
+
const { editedRowData } = action.payload;
|
|
189
|
+
delete editedRowData.tableMetaInfo;
|
|
190
|
+
const zoneIndex = getZoneIndex(state, index, editedRowData.id);
|
|
191
|
+
draft.data[index].zones.values[zoneIndex] = editedRowData;
|
|
192
|
+
if (editedRowData.signals) {
|
|
193
|
+
editedRowData.signals.forEach((signal) => {
|
|
194
|
+
setPathLength(draft.correlations.values, signal.id, signal.j?.pathLength);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
handleOnChangeZonesData(draft);
|
|
167
198
|
}
|
|
168
199
|
}
|
|
169
200
|
function handleOnChangeZonesData(draft) {
|
|
170
201
|
handleUpdateCorrelations(draft);
|
|
171
202
|
}
|
|
172
|
-
export { add2dZoneHandler, handleAutoZonesDetection, handleDeleteSignal, handleDeleteZone, changeZoneSignalDelta, handleChangeZoneSignalKind, handleUnlinkZone, handleSetDiaIDZone, changeZonesFactorHandler, handleAutoSpectraZonesDetection, };
|
|
203
|
+
export { add2dZoneHandler, handleAutoZonesDetection, handleDeleteSignal, handleDeleteZone, changeZoneSignalDelta, handleChangeZoneSignalKind, handleUnlinkZone, handleSaveEditedZone, handleSetDiaIDZone, handleSetSignalPathLength, changeZonesFactorHandler, handleAutoSpectraZonesDetection, };
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { Draft } from 'immer';
|
|
2
|
+
import { State } from '../Reducer';
|
|
3
|
+
export declare const ZoomType: {
|
|
4
|
+
HORIZONTAL: string;
|
|
5
|
+
VERTICAL: string;
|
|
6
|
+
STEP_HORIZONTAL: string;
|
|
7
|
+
FULL: string;
|
|
8
|
+
};
|
|
9
|
+
interface ZoomOptions {
|
|
10
|
+
factor?: number;
|
|
11
|
+
invert?: boolean;
|
|
10
12
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
getScale: (id: string) => number;
|
|
18
|
-
}
|
|
19
|
-
export declare function initZoom1D(): Zoom1D;
|
|
20
|
-
export declare function setAllScales(Zoom1DObject: Zoom1D, newScale: number): void;
|
|
21
|
-
export default function zoom1DManager(Zoom1DObject: Zoom1D, defaultScale?: number): Zoom1DManager;
|
|
22
|
-
export {};
|
|
13
|
+
declare function wheelZoom(event: WheelEvent, domain: number[], zoomOptions?: ZoomOptions): number[];
|
|
14
|
+
declare function setZoom(draft: Draft<State>, options?: {
|
|
15
|
+
scale?: number;
|
|
16
|
+
spectrumID?: string;
|
|
17
|
+
}): void;
|
|
18
|
+
export { setZoom, wheelZoom };
|
|
@@ -1,73 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return (id) => {
|
|
38
|
-
initZoomManager(Zoom1DObject, id, defaultScale);
|
|
39
|
-
return Zoom1DObject.scales[id];
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function prepareSetScale(Zoom1DObject, defaultScale) {
|
|
43
|
-
return (newScale, spectrumID) => {
|
|
44
|
-
initZoomManager(Zoom1DObject, spectrumID, defaultScale);
|
|
45
|
-
Zoom1DObject.scales[spectrumID] = newScale;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function prepareWheel(Zoom1DObject, defaultScale) {
|
|
49
|
-
return (deltaY, id) => {
|
|
50
|
-
initZoomManager(Zoom1DObject, id, defaultScale);
|
|
51
|
-
return wheel(Zoom1DObject, deltaY, id);
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function wheel(Zoom1DObject, deltaY, id) {
|
|
55
|
-
const { options: { slowZoomStep, fastZoomStep, speedThreshold }, } = Zoom1DObject;
|
|
56
|
-
const deltaYValue = Math.abs(deltaY).toString().length === 1
|
|
57
|
-
? Math.abs(deltaY)
|
|
58
|
-
: Math.abs(deltaY) / 100;
|
|
59
|
-
const LOW_STEP = 0.01 * slowZoomStep;
|
|
60
|
-
const FAST_STEP = 0.05 * fastZoomStep;
|
|
61
|
-
let ZOOM_STEP = deltaYValue <= speedThreshold ? LOW_STEP : FAST_STEP;
|
|
62
|
-
const direction = Math.sign(deltaY);
|
|
63
|
-
const _scale = direction === -1
|
|
64
|
-
? Zoom1DObject.scales[id] + ZOOM_STEP
|
|
65
|
-
: Zoom1DObject.scales[id] - ZOOM_STEP;
|
|
66
|
-
if (_scale >= 0) {
|
|
67
|
-
Zoom1DObject.scales[id] = _scale;
|
|
1
|
+
import { zoomIdentity, scaleLinear } from 'd3';
|
|
2
|
+
export const ZoomType = {
|
|
3
|
+
HORIZONTAL: 'HORIZONTAL',
|
|
4
|
+
VERTICAL: 'VERTICAL',
|
|
5
|
+
STEP_HORIZONTAL: 'STEP_HORIZONTAL',
|
|
6
|
+
FULL: 'FULL',
|
|
7
|
+
};
|
|
8
|
+
function wheelZoom(event, domain, zoomOptions = {}) {
|
|
9
|
+
const { factor = 1, invert = false } = zoomOptions;
|
|
10
|
+
const deltaY = Math.abs(event.deltaY) < 100 ? event.deltaY * 100 : event.deltaY;
|
|
11
|
+
const delta = deltaY * (invert ? -0.001 : 0.001) * factor;
|
|
12
|
+
const ratio = delta < 0 ? -1 / (delta - 1) : 1 + delta;
|
|
13
|
+
const [min, max] = domain;
|
|
14
|
+
return [min * ratio, max * ratio];
|
|
15
|
+
}
|
|
16
|
+
function setZoom(draft, options = {}) {
|
|
17
|
+
const { height, margin, activeSpectrum } = draft;
|
|
18
|
+
const { scale = 1, spectrumID = null } = options;
|
|
19
|
+
if (activeSpectrum === null && spectrumID === null) {
|
|
20
|
+
const { shareYDomain, yDomain, yDomains } = draft.originDomain;
|
|
21
|
+
draft.yDomains = Object.keys(draft.yDomains).reduce((acc, id) => {
|
|
22
|
+
const _scale = scaleLinear(shareYDomain ? yDomain : yDomains[id], [
|
|
23
|
+
height - margin.bottom,
|
|
24
|
+
margin.top,
|
|
25
|
+
]);
|
|
26
|
+
const [min, max] = shareYDomain ? yDomain : yDomains[id];
|
|
27
|
+
const maxPoint = Math.max(Math.abs(max), Math.abs(min));
|
|
28
|
+
const scalePoint = maxPoint === max ? 0 : min;
|
|
29
|
+
const t = zoomIdentity
|
|
30
|
+
.translate(0, Math.sign(scalePoint) >= 0 ? _scale(scalePoint) : _scale(scalePoint))
|
|
31
|
+
.scale(scale)
|
|
32
|
+
.translate(0, -_scale(0));
|
|
33
|
+
const newYDomain = t.rescaleY(_scale).domain();
|
|
34
|
+
acc[id] = newYDomain;
|
|
35
|
+
return acc;
|
|
36
|
+
}, {});
|
|
68
37
|
}
|
|
69
38
|
else {
|
|
70
|
-
|
|
39
|
+
const spectrumId = spectrumID || activeSpectrum?.id;
|
|
40
|
+
if (spectrumId) {
|
|
41
|
+
const _scale = scaleLinear(draft.originDomain.yDomains[spectrumId], [
|
|
42
|
+
height - margin.bottom,
|
|
43
|
+
margin.top,
|
|
44
|
+
]);
|
|
45
|
+
const t = zoomIdentity
|
|
46
|
+
.translate(0, _scale(0))
|
|
47
|
+
.scale(scale)
|
|
48
|
+
.translate(0, -_scale(0));
|
|
49
|
+
const yDomain = t.rescaleY(_scale).domain();
|
|
50
|
+
draft.yDomains = {
|
|
51
|
+
...draft.yDomains,
|
|
52
|
+
[spectrumId]: yDomain,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
71
55
|
}
|
|
72
|
-
return Zoom1DObject.scales[id];
|
|
73
56
|
}
|
|
57
|
+
export { setZoom, wheelZoom };
|
|
@@ -10,6 +10,7 @@ interface ZoomHistoryManager {
|
|
|
10
10
|
push: (value: HistoryItem) => void;
|
|
11
11
|
pop: () => HistoryItem;
|
|
12
12
|
getLast: () => HistoryItem;
|
|
13
|
+
clear: () => void;
|
|
13
14
|
}
|
|
14
15
|
export default function zoomHistoryManager(zoomHistory: ZoomHistory, nucleus: string): ZoomHistoryManager;
|
|
15
16
|
export {};
|
|
@@ -5,7 +5,8 @@ export default function zoomHistoryManager(zoomHistory, nucleus) {
|
|
|
5
5
|
const push = preparePush(zoomHistory[nucleus]);
|
|
6
6
|
const pop = preparePop(zoomHistory[nucleus]);
|
|
7
7
|
const getLast = prepareGetLast(zoomHistory[nucleus]);
|
|
8
|
-
|
|
8
|
+
const clear = () => (zoomHistory[nucleus] = []);
|
|
9
|
+
return { historyStack: zoomHistory[nucleus], push, pop, getLast, clear };
|
|
9
10
|
}
|
|
10
11
|
function preparePush(historyStack) {
|
|
11
12
|
return (val) => {
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
export declare const INIT_PREFERENCES = "INIT_PREFERENCES";
|
|
2
2
|
export declare const SET_PREFERENCES = "SET_PREFERENCES";
|
|
3
|
+
export declare const RESET_PREFERENCES = "RESET_PREFERENCES";
|
|
3
4
|
export declare const SET_PANELS_PREFERENCES = "SET_PANELS_PREFERENCES";
|
|
4
5
|
export interface PreferencesState {
|
|
5
6
|
basePreferences: any;
|
|
6
7
|
display: any;
|
|
7
8
|
controllers: {
|
|
8
|
-
mws: {
|
|
9
|
-
low: number;
|
|
10
|
-
high: number;
|
|
11
|
-
};
|
|
12
9
|
dimmedSpectraTransparency: number;
|
|
13
10
|
};
|
|
14
11
|
formatting: {
|
|
@@ -22,16 +19,13 @@ export interface PreferencesState {
|
|
|
22
19
|
panels: any;
|
|
23
20
|
};
|
|
24
21
|
dispatch: any;
|
|
22
|
+
workspace: string;
|
|
25
23
|
}
|
|
26
24
|
export declare const preferencesInitialState: PreferencesState;
|
|
27
25
|
declare const preferencesReducer: (base: {
|
|
28
26
|
readonly basePreferences: any;
|
|
29
27
|
readonly display: any;
|
|
30
28
|
readonly controllers: {
|
|
31
|
-
readonly mws: {
|
|
32
|
-
readonly low: number;
|
|
33
|
-
readonly high: number;
|
|
34
|
-
};
|
|
35
29
|
readonly dimmedSpectraTransparency: number;
|
|
36
30
|
};
|
|
37
31
|
readonly formatting: {
|
|
@@ -45,5 +39,6 @@ declare const preferencesReducer: (base: {
|
|
|
45
39
|
readonly panels: any;
|
|
46
40
|
};
|
|
47
41
|
readonly dispatch: any;
|
|
42
|
+
readonly workspace: string;
|
|
48
43
|
}, action: any) => import("immer/dist/internal").WritableDraft<PreferencesState>;
|
|
49
44
|
export default preferencesReducer;
|
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
import { produce } from 'immer';
|
|
2
2
|
import lodashMerge from 'lodash/merge';
|
|
3
|
-
import { NMRiumMode } from '../NMRium';
|
|
4
|
-
import basic from '../nmriumMode/basic';
|
|
5
|
-
import exercise1D from '../nmriumMode/exercise1D';
|
|
6
|
-
import process1D from '../nmriumMode/process1D';
|
|
7
3
|
import { getLocalStorage, removeData, storeData, } from '../utility/LocalStorage';
|
|
4
|
+
import workspaces from '../workspaces';
|
|
8
5
|
export const INIT_PREFERENCES = 'INIT_PREFERENCES';
|
|
9
6
|
export const SET_PREFERENCES = 'SET_PREFERENCES';
|
|
7
|
+
export const RESET_PREFERENCES = 'RESET_PREFERENCES';
|
|
10
8
|
export const SET_PANELS_PREFERENCES = 'SET_PANELS_PREFERENCES';
|
|
11
|
-
const
|
|
12
|
-
function
|
|
13
|
-
switch (
|
|
14
|
-
case
|
|
15
|
-
return exercise1D;
|
|
16
|
-
case
|
|
17
|
-
return process1D;
|
|
9
|
+
const LOCAL_STORAGE_VERSION = 3;
|
|
10
|
+
function getPreferencesByWorkspace(workspace) {
|
|
11
|
+
switch (workspace) {
|
|
12
|
+
case 'exercise1D':
|
|
13
|
+
return workspaces.exercise1D;
|
|
14
|
+
case 'process1D':
|
|
15
|
+
return workspaces.process1D;
|
|
18
16
|
default:
|
|
19
|
-
return basic;
|
|
17
|
+
return workspaces.basic;
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
20
|
export const preferencesInitialState = {
|
|
23
21
|
basePreferences: {},
|
|
24
|
-
display: basic,
|
|
22
|
+
display: workspaces.basic.display,
|
|
25
23
|
controllers: {
|
|
26
|
-
mws: { low: 2, high: 20 },
|
|
27
24
|
dimmedSpectraTransparency: 0.1,
|
|
28
25
|
},
|
|
29
26
|
formatting: {
|
|
@@ -39,7 +36,15 @@ export const preferencesInitialState = {
|
|
|
39
36
|
panels: {},
|
|
40
37
|
},
|
|
41
38
|
dispatch: null,
|
|
39
|
+
workspace: 'default',
|
|
42
40
|
};
|
|
41
|
+
function getTruthyObjectValues(data) {
|
|
42
|
+
return JSON.parse(JSON.stringify(data), (key, value) => {
|
|
43
|
+
if (value) {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
43
48
|
function mapNucleus(draft) {
|
|
44
49
|
if (draft.formatting.nucleus && Array.isArray(draft.formatting.nucleus)) {
|
|
45
50
|
draft.formatting.nucleusByKey = draft.formatting.nucleus.reduce((acc, item) => {
|
|
@@ -50,51 +55,93 @@ function mapNucleus(draft) {
|
|
|
50
55
|
}
|
|
51
56
|
function handleInit(draft, action) {
|
|
52
57
|
const nmrLocalStorageVersion = getLocalStorage('nmr-local-storage-version', false);
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
let localData = getLocalStorage('nmr-general-settings');
|
|
59
|
+
// remove old nmr-local-storage-version key
|
|
60
|
+
if (nmrLocalStorageVersion && localData?.version) {
|
|
61
|
+
removeData('nmr-local-storage-version');
|
|
62
|
+
}
|
|
63
|
+
if (!localData?.version || localData?.version !== LOCAL_STORAGE_VERSION) {
|
|
55
64
|
removeData('nmr-general-settings');
|
|
56
|
-
storeData('nmr-local-storage-version', LOCAL_STORGAE_VERSION);
|
|
57
65
|
}
|
|
58
|
-
const localData = getLocalStorage('nmr-general-settings');
|
|
59
66
|
if (action.payload) {
|
|
60
|
-
const { dispatch,
|
|
61
|
-
draft.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const { dispatch, workspace, ...resProps } = action.payload;
|
|
68
|
+
draft.workspace = workspace;
|
|
69
|
+
const workspacePreferences = getPreferencesByWorkspace(workspace);
|
|
70
|
+
if (!localData ||
|
|
71
|
+
!localData?.workspaces[workspace] ||
|
|
72
|
+
workspacePreferences.version !== localData?.workspaces[workspace]?.version) {
|
|
73
|
+
localData = localData || {};
|
|
74
|
+
localData = {
|
|
75
|
+
version: LOCAL_STORAGE_VERSION,
|
|
76
|
+
workspaces: {
|
|
77
|
+
...localData.workspaces,
|
|
78
|
+
[workspace]: {
|
|
79
|
+
...workspacePreferences,
|
|
80
|
+
controllers: draft.controllers,
|
|
81
|
+
formatting: draft.formatting,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
storeData('nmr-general-settings', JSON.stringify(localData));
|
|
86
|
+
}
|
|
87
|
+
draft.basePreferences = lodashMerge({}, workspacePreferences, resProps);
|
|
88
|
+
const hiddenModeFeatures = getTruthyObjectValues(draft.basePreferences.display);
|
|
89
|
+
let hiddenLocalStorageFeatures = {};
|
|
70
90
|
draft.dispatch = dispatch;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
91
|
+
const localStorageModePreferences = localData?.workspaces[workspace] || null;
|
|
92
|
+
if (localStorageModePreferences) {
|
|
93
|
+
Object.entries(localStorageModePreferences).forEach(([k, v]) => {
|
|
94
|
+
if (k === 'display') {
|
|
95
|
+
hiddenLocalStorageFeatures = getTruthyObjectValues(v);
|
|
96
|
+
}
|
|
97
|
+
else if (!['dispatch', 'basePreferences'].includes(k)) {
|
|
74
98
|
draft[k] = lodashMerge({}, resProps[k] ? resProps[k] : {}, v);
|
|
75
99
|
}
|
|
76
100
|
});
|
|
77
101
|
mapNucleus(draft);
|
|
78
102
|
}
|
|
103
|
+
draft.display = lodashMerge({}, getPreferencesByWorkspace('default').display, hiddenModeFeatures, hiddenLocalStorageFeatures);
|
|
79
104
|
}
|
|
80
105
|
}
|
|
81
106
|
function handleSetPreferences(draft, action) {
|
|
82
107
|
if (action.payload) {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
108
|
+
const { controllers, formatting, display } = action.payload;
|
|
109
|
+
let localData = getLocalStorage('nmr-general-settings');
|
|
110
|
+
localData.workspaces = {
|
|
111
|
+
...localData.workspaces,
|
|
112
|
+
[draft.workspace]: {
|
|
113
|
+
...localData.workspaces[draft.workspace],
|
|
114
|
+
controllers,
|
|
115
|
+
formatting,
|
|
116
|
+
display,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
storeData('nmr-general-settings', JSON.stringify(localData));
|
|
120
|
+
draft.controllers = controllers;
|
|
121
|
+
draft.formatting = formatting;
|
|
122
|
+
draft.display.panels = display.panels;
|
|
123
|
+
draft.display.general.hideExperimentalFeatures =
|
|
124
|
+
display.general.hideExperimentalFeatures;
|
|
89
125
|
mapNucleus(draft);
|
|
90
126
|
}
|
|
91
127
|
}
|
|
92
128
|
function handleSetPanelsPreferences(draft, action) {
|
|
93
129
|
if (action.payload) {
|
|
94
130
|
const { key, value } = action.payload;
|
|
131
|
+
let localData = getLocalStorage('nmr-general-settings');
|
|
132
|
+
localData.workspaces[draft.workspace].formatting.panels[key] = value;
|
|
133
|
+
storeData('nmr-general-settings', JSON.stringify(localData));
|
|
95
134
|
draft.formatting.panels[key] = value;
|
|
96
135
|
}
|
|
97
136
|
}
|
|
137
|
+
function handleResetPreferences(draft) {
|
|
138
|
+
let localData = getLocalStorage('nmr-general-settings');
|
|
139
|
+
const hiddenFeatures = getTruthyObjectValues(draft.basePreferences.display);
|
|
140
|
+
const workSpaceDisplayPreferences = lodashMerge({}, getPreferencesByWorkspace(draft.workspace).display, hiddenFeatures);
|
|
141
|
+
localData.workspaces[draft.workspace].display = workSpaceDisplayPreferences;
|
|
142
|
+
draft.display = workSpaceDisplayPreferences;
|
|
143
|
+
storeData('nmr-general-settings', JSON.stringify(localData));
|
|
144
|
+
}
|
|
98
145
|
function innerPreferencesReducer(draft, action) {
|
|
99
146
|
switch (action.type) {
|
|
100
147
|
case INIT_PREFERENCES:
|
|
@@ -103,6 +150,8 @@ function innerPreferencesReducer(draft, action) {
|
|
|
103
150
|
return handleSetPreferences(draft, action);
|
|
104
151
|
case SET_PANELS_PREFERENCES:
|
|
105
152
|
return handleSetPanelsPreferences(draft, action);
|
|
153
|
+
case RESET_PREFERENCES:
|
|
154
|
+
return handleResetPreferences(draft);
|
|
106
155
|
default:
|
|
107
156
|
return draft;
|
|
108
157
|
}
|
|
@@ -27,7 +27,7 @@ export declare const CHANGE_SPECTRUM_COLOR = "CHANGE_SPECTRUM_COLOR";
|
|
|
27
27
|
export declare const ADD_INTEGRAL = "ADD_INTEGRAL";
|
|
28
28
|
export declare const DELETE_INTEGRAL = "DELETE_INTEGRAL";
|
|
29
29
|
export declare const TOGGLE_REAL_IMAGINARY_VISIBILITY = "TOGGLE_REAL_IMAGINARY_VISIBILITY";
|
|
30
|
-
export declare const
|
|
30
|
+
export declare const SET_ZOOM = "SET_ZOOM";
|
|
31
31
|
export declare const ADD_MOLECULE = "ADD_MOLECULE";
|
|
32
32
|
export declare const SET_MOLECULE = "SET_MOLECULE";
|
|
33
33
|
export declare const DELETE_MOLECULE = "DELETE_MOLECULE";
|
|
@@ -76,6 +76,7 @@ export declare const SET_2D_LEVEL = "SET_2D_LEVEL";
|
|
|
76
76
|
export declare const ADD_2D_ZONE = "ADD_2D_ZONE";
|
|
77
77
|
export declare const DELETE_2D_ZONE = "DELETE_2D_ZONE";
|
|
78
78
|
export declare const DELETE_2D_SIGNAL = "DELETE_2D_SIGNAL";
|
|
79
|
+
export declare const SET_2D_SIGNAL_PATH_LENGTH = "SET_2D_SIGNAL_PATH_LENGTH";
|
|
79
80
|
export declare const ADD_MISSING_PROJECTION = "ADD_MISSING_PROJECTION";
|
|
80
81
|
export declare const SET_FILTER_SNAPSHOT = "SET_FILTER_SNAPSHOT";
|
|
81
82
|
export declare const CHANGE_RANGE_RELATIVE = "CHANGE_RANGE_RELATIVE";
|
|
@@ -93,6 +94,7 @@ export declare const FILTER_SPECTRA_COLUMN = "FILTER_SPECTRA_COLUMN";
|
|
|
93
94
|
export declare const ALIGN_SPECTRA = "ALIGN_SPECTRA";
|
|
94
95
|
export declare const CHANGE_ZONE_SIGNAL_VALUE = "CHANGE_ZONE_SIGNAL_VALUE";
|
|
95
96
|
export declare const CHANGE_ZONE_SIGNAL_KIND = "CHANGE_ZONE_SIGNAL_KIND";
|
|
97
|
+
export declare const SAVE_EDITED_ZONE = "SAVE_EDITED_ZONE";
|
|
96
98
|
export declare const UNLINK_ZONE = "UNLINK_ZONE";
|
|
97
99
|
export declare const SET_DIAID_ZONE = "SET_DIAID_ZONE";
|
|
98
100
|
export declare const PREDICT_SPECTRA = "PREDICT_SPECTRA";
|