nmrium 0.30.0 → 0.31.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/ApodizationLine.js +3 -1
- package/lib/component/1d/FooterBanner.js +3 -1
- package/lib/component/1d/IntegralsSeries.js +3 -1
- package/lib/component/1d/LinesSeries.js +3 -1
- package/lib/component/1d/SpectraTracker.js +1 -1
- package/lib/component/1d/Viewer1D.js +3 -1
- package/lib/component/1d/jCouplingGraph/JGraph.js +5 -1
- package/lib/component/1d/multiAnalysis/MultiAnalysisRanges.js +1 -1
- package/lib/component/1d/multiplicityTree/MultiplicityTree.js +3 -1
- package/lib/component/1d/peaks/PeakAnnotations.js +3 -1
- package/lib/component/1d/peaks/PeaksShapes.js +4 -2
- package/lib/component/1d/peaks/usePeakShapesPath.js +7 -3
- package/lib/component/1d/ranges/Ranges.js +8 -2
- package/lib/component/1d/tool/PeakPointer.js +3 -1
- package/lib/component/1d/tool/XLabelPointer.js +3 -1
- package/lib/component/2d/Contours.js +3 -1
- package/lib/component/2d/FooterBanner.js +3 -1
- package/lib/component/2d/Viewer2D.js +4 -4
- package/lib/component/2d/XAxis.js +2 -2
- package/lib/component/2d/YAxis.js +2 -2
- package/lib/component/2d/tools/XYLabelPointer.js +3 -1
- package/lib/component/2d/tools/slicing/SlicingView.js +3 -1
- package/lib/component/2d/zones/IndicationLines.js +1 -1
- package/lib/component/2d/zones/Zones.js +14 -19
- package/lib/component/NMRium.d.ts +2 -0
- package/lib/component/NMRium.js +14 -3
- package/lib/component/elements/popup/Modal/Provider.d.ts +3 -3
- package/lib/component/elements/popup/Modal/Provider.js +8 -11
- package/lib/component/header/ZeroFillingOptionsPanel.js +3 -1
- package/lib/component/hooks/useActiveSpectrumStyleOptions.js +2 -2
- package/lib/component/hooks/useDatumWithSpectraStatistics.js +3 -1
- package/lib/component/hooks/useExport.d.ts +0 -1
- package/lib/component/hooks/useExport.js +1 -17
- package/lib/component/hooks/useIntegralPath.js +5 -2
- package/lib/component/hooks/useNucleus.js +4 -4
- package/lib/component/hooks/useSpectraPerNucleus.js +1 -1
- package/lib/component/hooks/useSpectrum.js +3 -1
- package/lib/component/loader/DropZone.js +7 -147
- package/lib/component/modal/changeSum/SelectMolecule.js +1 -1
- package/lib/component/modal/editRange/EditRangeModal.js +1 -1
- package/lib/component/modal/setting/ToolsTabContent.js +4 -0
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanel.js +1 -1
- package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +1 -1
- package/lib/component/panels/RangesPanel/RangesHeader.d.ts +2 -1
- package/lib/component/panels/RangesPanel/RangesHeader.js +10 -9
- package/lib/component/panels/RangesPanel/RangesPanel.js +7 -3
- package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -1
- package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +3 -1
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +1 -1
- package/lib/component/panels/SummaryPanel/utilities/useInView.js +3 -1
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +19 -10
- package/lib/component/panels/databasePanel/DatabasePanel.js +1 -1
- package/lib/component/reducer/IgnoreActions.js +1 -0
- package/lib/component/reducer/Reducer.d.ts +108 -49
- package/lib/component/reducer/Reducer.js +45 -41
- package/lib/component/reducer/actions/DomainActions.d.ts +1 -1
- package/lib/component/reducer/actions/DomainActions.js +11 -9
- package/lib/component/reducer/actions/FiltersActions.d.ts +1 -1
- package/lib/component/reducer/actions/FiltersActions.js +218 -232
- package/lib/component/reducer/actions/IntegralsActions.js +13 -8
- package/lib/component/reducer/actions/LoadActions.d.ts +2 -5
- package/lib/component/reducer/actions/LoadActions.js +19 -34
- package/lib/component/reducer/actions/MoleculeActions.d.ts +2 -1
- package/lib/component/reducer/actions/MoleculeActions.js +22 -6
- package/lib/component/reducer/actions/PeaksActions.js +18 -12
- package/lib/component/reducer/actions/PreferencesActions.js +8 -10
- package/lib/component/reducer/actions/RangesActions.d.ts +3 -3
- package/lib/component/reducer/actions/RangesActions.js +85 -27
- package/lib/component/reducer/actions/SpectraAnalysisAction.js +5 -5
- package/lib/component/reducer/actions/SpectrumsActions.js +13 -10
- package/lib/component/reducer/actions/ToolsActions.js +38 -23
- package/lib/component/reducer/actions/ZonesActions.d.ts +4 -1
- package/lib/component/reducer/actions/ZonesActions.js +68 -17
- package/lib/component/reducer/helper/Zoom1DManager.js +2 -1
- package/lib/component/reducer/helper/getActiveSpectrumOrFail.d.ts +3 -0
- package/lib/component/reducer/helper/getActiveSpectrumOrFail.js +6 -0
- package/lib/component/reducer/helper/getSpectrum.js +3 -2
- package/lib/component/reducer/helper/getStrongestPeak.js +2 -1
- package/lib/component/reducer/types/Types.d.ts +5 -0
- package/lib/component/reducer/types/Types.js +5 -0
- package/lib/component/tool/FloatMoleculeStructures/DraggableStructure.d.ts +6 -0
- package/lib/component/tool/FloatMoleculeStructures/DraggableStructure.js +10 -3
- package/lib/component/tool/FloatMoleculeStructures/index.js +14 -8
- package/lib/component/toolbar/BasicToolBar.js +4 -6
- package/lib/component/toolbar/FunctionToolBar.js +3 -1
- package/lib/component/utility/assert.d.ts +1 -0
- package/lib/component/utility/assert.js +5 -0
- package/lib/component/workspaces/exercise.js +6 -0
- package/lib/data/SpectraManager.d.ts +0 -4
- package/lib/data/SpectraManager.js +2 -87
- package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +1 -0
- package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +1 -0
- package/lib/data/data1d/filter1d/fft.js +11 -0
- package/lib/data/data1d/filter1d/utils/padDataToNextPowerOfTwo.d.ts +2 -0
- package/lib/data/data1d/filter1d/utils/padDataToNextPowerOfTwo.js +35 -0
- package/lib/data/data2d/Spectrum2D/zones/getDetectionZones.d.ts +1 -1
- package/lib/data/molecules/Molecule.d.ts +5 -0
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/ApodizationLine.js +3 -1
- package/lib-cjs/component/1d/FooterBanner.js +3 -1
- package/lib-cjs/component/1d/IntegralsSeries.js +3 -1
- package/lib-cjs/component/1d/LinesSeries.js +3 -1
- package/lib-cjs/component/1d/SpectraTracker.js +1 -1
- package/lib-cjs/component/1d/Viewer1D.js +3 -1
- package/lib-cjs/component/1d/jCouplingGraph/JGraph.js +5 -1
- package/lib-cjs/component/1d/multiAnalysis/MultiAnalysisRanges.js +1 -1
- package/lib-cjs/component/1d/multiplicityTree/MultiplicityTree.js +3 -1
- package/lib-cjs/component/1d/peaks/PeakAnnotations.js +3 -1
- package/lib-cjs/component/1d/peaks/PeaksShapes.js +4 -2
- package/lib-cjs/component/1d/peaks/usePeakShapesPath.js +7 -3
- package/lib-cjs/component/1d/ranges/Ranges.js +7 -1
- package/lib-cjs/component/1d/tool/PeakPointer.js +3 -1
- package/lib-cjs/component/1d/tool/XLabelPointer.js +3 -1
- package/lib-cjs/component/2d/Contours.js +3 -1
- package/lib-cjs/component/2d/FooterBanner.js +3 -1
- package/lib-cjs/component/2d/Viewer2D.js +4 -4
- package/lib-cjs/component/2d/XAxis.js +2 -2
- package/lib-cjs/component/2d/YAxis.js +2 -2
- package/lib-cjs/component/2d/tools/XYLabelPointer.js +3 -1
- package/lib-cjs/component/2d/tools/slicing/SlicingView.js +3 -1
- package/lib-cjs/component/2d/zones/IndicationLines.js +1 -1
- package/lib-cjs/component/2d/zones/Zones.js +13 -18
- package/lib-cjs/component/NMRium.js +14 -3
- package/lib-cjs/component/elements/popup/Modal/Provider.js +8 -11
- package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +3 -1
- package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +2 -2
- package/lib-cjs/component/hooks/useDatumWithSpectraStatistics.js +3 -1
- package/lib-cjs/component/hooks/useExport.js +0 -16
- package/lib-cjs/component/hooks/useIntegralPath.js +5 -2
- package/lib-cjs/component/hooks/useNucleus.js +4 -4
- package/lib-cjs/component/hooks/useSpectraPerNucleus.js +1 -1
- package/lib-cjs/component/hooks/useSpectrum.js +3 -1
- package/lib-cjs/component/loader/DropZone.js +6 -149
- package/lib-cjs/component/modal/changeSum/SelectMolecule.js +1 -1
- package/lib-cjs/component/modal/editRange/EditRangeModal.js +1 -1
- package/lib-cjs/component/modal/setting/ToolsTabContent.js +4 -0
- package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +1 -1
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanel.js +1 -1
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
- package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +1 -1
- package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +10 -9
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +7 -3
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -1
- package/lib-cjs/component/panels/SpectrumsPanel/SpectrumsTabs.js +3 -1
- package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +1 -1
- package/lib-cjs/component/panels/SummaryPanel/utilities/useInView.js +3 -1
- package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +18 -9
- package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +1 -1
- package/lib-cjs/component/reducer/IgnoreActions.js +1 -0
- package/lib-cjs/component/reducer/Reducer.js +48 -43
- package/lib-cjs/component/reducer/actions/DomainActions.js +11 -9
- package/lib-cjs/component/reducer/actions/FiltersActions.js +219 -233
- package/lib-cjs/component/reducer/actions/IntegralsActions.js +13 -8
- package/lib-cjs/component/reducer/actions/LoadActions.js +18 -36
- package/lib-cjs/component/reducer/actions/MoleculeActions.js +23 -6
- package/lib-cjs/component/reducer/actions/PeaksActions.js +18 -12
- package/lib-cjs/component/reducer/actions/PreferencesActions.js +8 -10
- package/lib-cjs/component/reducer/actions/RangesActions.js +85 -27
- package/lib-cjs/component/reducer/actions/SpectraAnalysisAction.js +5 -5
- package/lib-cjs/component/reducer/actions/SpectrumsActions.js +13 -10
- package/lib-cjs/component/reducer/actions/ToolsActions.js +38 -23
- package/lib-cjs/component/reducer/actions/ZonesActions.js +71 -17
- package/lib-cjs/component/reducer/helper/Zoom1DManager.js +2 -1
- package/lib-cjs/component/reducer/helper/getActiveSpectrumOrFail.js +10 -0
- package/lib-cjs/component/reducer/helper/getSpectrum.js +3 -2
- package/lib-cjs/component/reducer/helper/getStrongestPeak.js +2 -1
- package/lib-cjs/component/reducer/types/Types.js +8 -3
- package/lib-cjs/component/tool/FloatMoleculeStructures/DraggableStructure.js +10 -3
- package/lib-cjs/component/tool/FloatMoleculeStructures/index.js +14 -8
- package/lib-cjs/component/toolbar/BasicToolBar.js +4 -6
- package/lib-cjs/component/toolbar/FunctionToolBar.js +3 -1
- package/lib-cjs/component/utility/assert.js +9 -0
- package/lib-cjs/component/workspaces/exercise.js +6 -0
- package/lib-cjs/data/SpectraManager.js +3 -92
- package/lib-cjs/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +1 -0
- package/lib-cjs/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +1 -0
- package/lib-cjs/data/data1d/filter1d/fft.js +11 -0
- package/lib-cjs/data/data1d/filter1d/utils/padDataToNextPowerOfTwo.js +39 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +22 -22
- package/lib/component/utility/nmredataToNmrium.d.ts +0 -4
- package/lib/component/utility/nmredataToNmrium.js +0 -66
- package/lib/component/utility/nmriumToNmredata.d.ts +0 -2
- package/lib/component/utility/nmriumToNmredata.js +0 -80
- package/lib/component/utility/util/nmredata/addRanges.d.ts +0 -1
- package/lib/component/utility/util/nmredata/addRanges.js +0 -52
- package/lib/component/utility/util/nmredata/addSource.d.ts +0 -6
- package/lib/component/utility/util/nmredata/addSource.js +0 -54
- package/lib/component/utility/util/nmredata/addZones.d.ts +0 -1
- package/lib/component/utility/util/nmredata/addZones.js +0 -41
- package/lib/component/utility/util/nmredata/flat2DSignals.d.ts +0 -1
- package/lib/component/utility/util/nmredata/flat2DSignals.js +0 -7
- package/lib/component/utility/util/nmredata/get1DSignals.d.ts +0 -10
- package/lib/component/utility/util/nmredata/get1DSignals.js +0 -96
- package/lib/component/utility/util/nmredata/get2DSignals.d.ts +0 -8
- package/lib/component/utility/util/nmredata/get2DSignals.js +0 -59
- package/lib/component/utility/util/nmredata/getCouplingObserved.d.ts +0 -1
- package/lib/component/utility/util/nmredata/getCouplingObserved.js +0 -11
- package/lib/component/utility/util/nmredata/getLabels.d.ts +0 -9
- package/lib/component/utility/util/nmredata/getLabels.js +0 -66
- package/lib/component/utility/util/nmredata/getToFix.d.ts +0 -1
- package/lib/component/utility/util/nmredata/getToFix.js +0 -19
- package/lib/data/migration/MigrationManager.d.ts +0 -2
- package/lib/data/migration/MigrationManager.js +0 -19
- package/lib/data/migration/changeKeys.d.ts +0 -1
- package/lib/data/migration/changeKeys.js +0 -9
- package/lib/data/migration/migrateToVersion1.d.ts +0 -11
- package/lib/data/migration/migrateToVersion1.js +0 -32
- package/lib/data/migration/migrateToVersion2.d.ts +0 -1
- package/lib/data/migration/migrateToVersion2.js +0 -111
- package/lib/data/migration/migrateToVersion3.d.ts +0 -1
- package/lib/data/migration/migrateToVersion3.js +0 -55
- package/lib-cjs/component/utility/nmredataToNmrium.js +0 -73
- package/lib-cjs/component/utility/nmriumToNmredata.js +0 -87
- package/lib-cjs/component/utility/util/nmredata/addRanges.js +0 -56
- package/lib-cjs/component/utility/util/nmredata/addSource.js +0 -61
- package/lib-cjs/component/utility/util/nmredata/addZones.js +0 -45
- package/lib-cjs/component/utility/util/nmredata/flat2DSignals.js +0 -11
- package/lib-cjs/component/utility/util/nmredata/get1DSignals.js +0 -100
- package/lib-cjs/component/utility/util/nmredata/get2DSignals.js +0 -63
- package/lib-cjs/component/utility/util/nmredata/getCouplingObserved.js +0 -15
- package/lib-cjs/component/utility/util/nmredata/getLabels.js +0 -70
- package/lib-cjs/component/utility/util/nmredata/getToFix.js +0 -23
- package/lib-cjs/data/migration/MigrationManager.js +0 -26
- package/lib-cjs/data/migration/changeKeys.js +0 -13
- package/lib-cjs/data/migration/migrateToVersion1.js +0 -35
- package/lib-cjs/data/migration/migrateToVersion2.js +0 -114
- package/lib-cjs/data/migration/migrateToVersion3.js +0 -58
|
@@ -6,8 +6,7 @@ import { useGlobal } from '../context/GlobalContext';
|
|
|
6
6
|
import { useAlert } from '../elements/popup/Alert';
|
|
7
7
|
import { positions, useModal } from '../elements/popup/Modal';
|
|
8
8
|
import SaveAsModal from '../modal/SaveAsModal';
|
|
9
|
-
import { copyPNGToClipboard, exportAsJSON,
|
|
10
|
-
import { nmriumToNmredata } from '../utility/nmriumToNmredata';
|
|
9
|
+
import { copyPNGToClipboard, exportAsJSON, exportAsPng, exportAsSVG, } from '../utility/Export';
|
|
11
10
|
export default function useExport() {
|
|
12
11
|
const { rootRef } = useGlobal();
|
|
13
12
|
const modal = useModal();
|
|
@@ -38,20 +37,6 @@ export default function useExport() {
|
|
|
38
37
|
}, 0);
|
|
39
38
|
}
|
|
40
39
|
}, [alert, state]);
|
|
41
|
-
const saveAsNMREHandler = useCallback(async () => {
|
|
42
|
-
if (state.data.length > 0) {
|
|
43
|
-
const hideLoading = await alert.showLoading('Exporting as NMRE process in progress');
|
|
44
|
-
setTimeout(() => {
|
|
45
|
-
async function handle() {
|
|
46
|
-
const fileName = state.data[0]?.display?.name;
|
|
47
|
-
const exportedData = await nmriumToNmredata(state);
|
|
48
|
-
exportAsNMRE(exportedData, fileName);
|
|
49
|
-
hideLoading();
|
|
50
|
-
}
|
|
51
|
-
void handle();
|
|
52
|
-
}, 0);
|
|
53
|
-
}
|
|
54
|
-
}, [alert, state]);
|
|
55
40
|
const saveAsSVGHandler = useCallback(async () => {
|
|
56
41
|
if (state.data.length > 0 && rootRef) {
|
|
57
42
|
const hideLoading = await alert.showLoading('Exporting as SVG process in progress');
|
|
@@ -100,7 +85,6 @@ export default function useExport() {
|
|
|
100
85
|
return {
|
|
101
86
|
saveToClipboardHandler,
|
|
102
87
|
saveAsJSONHandler,
|
|
103
|
-
saveAsNMREHandler,
|
|
104
88
|
saveAsSVGHandler,
|
|
105
89
|
saveAsPNGHandler,
|
|
106
90
|
saveAsHandler,
|
|
@@ -2,10 +2,12 @@ import { xyIntegral, xyReduce } from 'ml-spectra-processing';
|
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { getIntegralYScale } from '../1d/utilities/scale';
|
|
4
4
|
import { useChartData } from '../context/ChartContext';
|
|
5
|
+
import { useActiveSpectrum } from '../reducer/Reducer';
|
|
5
6
|
import { PathBuilder } from '../utility/PathBuilder';
|
|
6
7
|
import { useXScale } from './useXScale';
|
|
7
8
|
function useIntegralYDomain() {
|
|
8
|
-
const { height, margin, verticalAlign,
|
|
9
|
+
const { height, margin, verticalAlign, integralsYDomains } = useChartData();
|
|
10
|
+
const activeSpectrum = useActiveSpectrum();
|
|
9
11
|
return useMemo(() => getIntegralYScale({
|
|
10
12
|
height,
|
|
11
13
|
margin,
|
|
@@ -15,7 +17,8 @@ function useIntegralYDomain() {
|
|
|
15
17
|
}), [activeSpectrum, height, integralsYDomains, margin, verticalAlign]);
|
|
16
18
|
}
|
|
17
19
|
export default function useIntegralPath(integralOptions) {
|
|
18
|
-
const { data
|
|
20
|
+
const { data } = useChartData();
|
|
21
|
+
const activeSpectrum = useActiveSpectrum();
|
|
19
22
|
const scaleX = useXScale();
|
|
20
23
|
const scaleY = useIntegralYDomain();
|
|
21
24
|
const integral = useMemo(() => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useChartData } from '../context/ChartContext';
|
|
3
3
|
export default function useNucleus() {
|
|
4
|
-
const {
|
|
4
|
+
const { view: { spectra: { activeSpectra }, }, } = useChartData();
|
|
5
5
|
return useMemo(() => {
|
|
6
|
-
if (
|
|
7
|
-
return Object.keys(
|
|
6
|
+
if (activeSpectra && Object.keys(activeSpectra).length > 0) {
|
|
7
|
+
return Object.keys(activeSpectra);
|
|
8
8
|
}
|
|
9
9
|
return [];
|
|
10
|
-
}, [
|
|
10
|
+
}, [activeSpectra]);
|
|
11
11
|
}
|
|
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
|
|
|
2
2
|
import { useChartData } from '../context/ChartContext';
|
|
3
3
|
import nucleusToString from '../utility/nucleusToString';
|
|
4
4
|
export default function useSpectraByActiveNucleus() {
|
|
5
|
-
const { data, activeTab } = useChartData();
|
|
5
|
+
const { data, view: { spectra: { activeTab }, }, } = useChartData();
|
|
6
6
|
return useMemo(() => {
|
|
7
7
|
if (data) {
|
|
8
8
|
return (data.filter((spectrum) => activeTab === nucleusToString(spectrum.info.nucleus)) || []);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useChartData } from '../context/ChartContext';
|
|
3
|
+
import { useActiveSpectrum } from '../reducer/Reducer';
|
|
3
4
|
export default function useSpectrum(defaultValue) {
|
|
4
|
-
const { data
|
|
5
|
+
const { data } = useChartData();
|
|
6
|
+
const activeSpectrum = useActiveSpectrum();
|
|
5
7
|
return useMemo(() => {
|
|
6
8
|
if (data && activeSpectrum && activeSpectrum.id) {
|
|
7
9
|
const datum = data.find((datum) => datum.id === activeSpectrum.id) || defaultValue;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
|
-
import Zip from 'jszip';
|
|
5
4
|
import { useCallback } from 'react';
|
|
6
5
|
import { useDropzone } from 'react-dropzone';
|
|
7
6
|
import { FaUpload } from 'react-icons/fa';
|
|
8
7
|
import { useChartData } from '../context/ChartContext';
|
|
9
8
|
import { useDispatch } from '../context/DispatchContext';
|
|
10
9
|
import { LoaderProvider } from '../context/LoaderContext';
|
|
11
|
-
import { useAlert } from '../elements/popup/Alert';
|
|
12
10
|
import { useCheckToolsVisibility } from '../hooks/useCheckToolsVisibility';
|
|
13
|
-
import {
|
|
14
|
-
import { FILES_TYPES, FILES_SIGNATURES, getFileExtension, getFileSignature, loadFiles, loadFilesFromZip, } from '../utility/FileUtility';
|
|
11
|
+
import { SET_LOADING_FLAG, LOAD_DROP_FILES } from '../reducer/types/Types';
|
|
15
12
|
const style = css `
|
|
16
13
|
height: 100%;
|
|
17
14
|
background-color: #b5b5b599;
|
|
@@ -46,153 +43,16 @@ const containerStyle = css `
|
|
|
46
43
|
function DropZone(props) {
|
|
47
44
|
const { width, height } = useChartData();
|
|
48
45
|
const dispatch = useDispatch();
|
|
49
|
-
const alert = useAlert();
|
|
50
46
|
const isToolEnabled = useCheckToolsVisibility();
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const files = await loadFilesFromZip(selectedFilesByExtensions);
|
|
57
|
-
dispatch({ type: LOAD_MOL_FILE, files });
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
case FILES_TYPES.NMRIUM:
|
|
61
|
-
case FILES_TYPES.JSON: {
|
|
62
|
-
const files = await loadFilesFromZip(selectedFilesByExtensions, {
|
|
63
|
-
asBuffer: true,
|
|
64
|
-
});
|
|
65
|
-
if (selectedFilesByExtensions.length === 1) {
|
|
66
|
-
const decoder = new TextDecoder('utf8');
|
|
67
|
-
files[0].binary = decoder.decode(files[0].binary);
|
|
68
|
-
dispatch({ type: LOAD_JSON_FILE, files });
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
throw new Error('You can add only one json file');
|
|
72
|
-
}
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
case FILES_TYPES.JDX:
|
|
76
|
-
case FILES_TYPES.DX: {
|
|
77
|
-
const files = await loadFilesFromZip(selectedFilesByExtensions, {
|
|
78
|
-
asBuffer: true,
|
|
79
|
-
});
|
|
80
|
-
dispatch({ type: LOAD_JCAMP_FILE, files });
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
case FILES_TYPES.JDF: {
|
|
84
|
-
const files = await loadFilesFromZip(selectedFilesByExtensions, {
|
|
85
|
-
asBuffer: true,
|
|
86
|
-
});
|
|
87
|
-
dispatch({ type: LOAD_JDF_FILE, files });
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
default:
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
47
|
+
const loadFilesHandler = useCallback((files) => {
|
|
48
|
+
files.forEach((file) => {
|
|
49
|
+
Object.defineProperty(file, 'webkitRelativePath', { value: file.path });
|
|
50
|
+
});
|
|
51
|
+
dispatch({ type: LOAD_DROP_FILES, files });
|
|
94
52
|
}, [dispatch]);
|
|
95
|
-
const loadFilesHandler = useCallback(async (files) => {
|
|
96
|
-
const uniqueFileExtensions = [
|
|
97
|
-
...new Set(files.map((file) => getFileExtension(file.name))),
|
|
98
|
-
];
|
|
99
|
-
for (let extension of uniqueFileExtensions) {
|
|
100
|
-
const selectedFilesByExtensions = files.filter((file) => getFileExtension(file.name) === extension);
|
|
101
|
-
try {
|
|
102
|
-
switch (extension) {
|
|
103
|
-
case FILES_TYPES.MOL: {
|
|
104
|
-
const files = await loadFiles(selectedFilesByExtensions);
|
|
105
|
-
dispatch({ type: LOAD_MOL_FILE, files });
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
case FILES_TYPES.NMRIUM:
|
|
109
|
-
case FILES_TYPES.JSON:
|
|
110
|
-
if (selectedFilesByExtensions.length === 1) {
|
|
111
|
-
const files = await loadFiles(selectedFilesByExtensions, {
|
|
112
|
-
asBuffer: true,
|
|
113
|
-
});
|
|
114
|
-
// InputFileFormat
|
|
115
|
-
const fileSignature = getFileSignature(files[0].binary);
|
|
116
|
-
if (fileSignature === FILES_SIGNATURES.ZIP) {
|
|
117
|
-
const unzipResult = await Zip.loadAsync(files[0].binary);
|
|
118
|
-
await loadSubFilesFromZip(Object.values(unzipResult.files), [
|
|
119
|
-
FILES_TYPES.NMRIUM,
|
|
120
|
-
]);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
const decoder = new TextDecoder('utf8');
|
|
124
|
-
files[0].binary = decoder.decode(files[0].binary);
|
|
125
|
-
dispatch({ type: LOAD_JSON_FILE, files });
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
throw new Error('You can add only one json file');
|
|
130
|
-
}
|
|
131
|
-
break;
|
|
132
|
-
case FILES_TYPES.JDX:
|
|
133
|
-
case FILES_TYPES.DX: {
|
|
134
|
-
const files = await loadFiles(selectedFilesByExtensions, {
|
|
135
|
-
asBuffer: true,
|
|
136
|
-
});
|
|
137
|
-
dispatch({ type: LOAD_JCAMP_FILE, files });
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
case FILES_TYPES.JDF: {
|
|
141
|
-
const files = await loadFiles(selectedFilesByExtensions, {
|
|
142
|
-
asBuffer: true,
|
|
143
|
-
});
|
|
144
|
-
dispatch({ type: LOAD_JDF_FILE, files });
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
case FILES_TYPES.ZIP: {
|
|
148
|
-
const files = await loadFiles(selectedFilesByExtensions, {
|
|
149
|
-
asBuffer: true,
|
|
150
|
-
});
|
|
151
|
-
for (const zipFile of files) {
|
|
152
|
-
const unzipResult = await Zip.loadAsync(zipFile.binary);
|
|
153
|
-
const uniqueFileExtensions = [
|
|
154
|
-
...new Set(Object.values(unzipResult.files).map((file) => getFileExtension(file.name))),
|
|
155
|
-
];
|
|
156
|
-
const isNotZip = uniqueFileExtensions.some((ex) => FILES_TYPES[ex.toUpperCase()] && ex !== FILES_TYPES.ZIP);
|
|
157
|
-
if (isNotZip) {
|
|
158
|
-
const hasBruker = Object.keys(unzipResult.files).some((path) => {
|
|
159
|
-
return ['2rr', 'fid', '1r'].some((brukerFile) => path.endsWith(brukerFile));
|
|
160
|
-
});
|
|
161
|
-
if (hasBruker)
|
|
162
|
-
dispatch({ type: LOAD_ZIP_FILE, files });
|
|
163
|
-
await loadSubFilesFromZip(Object.values(unzipResult.files), uniqueFileExtensions);
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
dispatch({ type: LOAD_ZIP_FILE, files });
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
break;
|
|
170
|
-
}
|
|
171
|
-
case FILES_TYPES.NMREDATA:
|
|
172
|
-
void loadFiles(selectedFilesByExtensions, {
|
|
173
|
-
asBuffer: true,
|
|
174
|
-
}).then(async (files) => {
|
|
175
|
-
for (const zipFile of files) {
|
|
176
|
-
dispatch({
|
|
177
|
-
type: LOAD_NMREDATA_FILE,
|
|
178
|
-
file: zipFile,
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
break;
|
|
183
|
-
default:
|
|
184
|
-
throw new Error('The file extension must be zip, dx, jdx, json, mol, nmredata or nmrium.');
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
catch (e) {
|
|
188
|
-
dispatch({ type: SET_LOADING_FLAG, isLoading: false });
|
|
189
|
-
alert.error(e.message);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}, [alert, dispatch, loadSubFilesFromZip]);
|
|
193
53
|
const onDrop = useCallback((droppedFiles) => {
|
|
194
54
|
dispatch({ type: SET_LOADING_FLAG, isLoading: true });
|
|
195
|
-
|
|
55
|
+
loadFilesHandler(droppedFiles);
|
|
196
56
|
}, [dispatch, loadFilesHandler]);
|
|
197
57
|
const isImportEnabled = isToolEnabled('import');
|
|
198
58
|
const { getRootProps, getInputProps, isDragActive, open: openImportDialog, } = useDropzone({
|
|
@@ -41,7 +41,7 @@ const styles = css `
|
|
|
41
41
|
export default function SelectMolecule(props) {
|
|
42
42
|
const [currentIndex, setCurrentIndex] = useState();
|
|
43
43
|
const { setFieldValue, errors, values } = useFormikContext();
|
|
44
|
-
const { molecules, activeTab } = useChartData();
|
|
44
|
+
const { molecules, view: { spectra: { activeTab }, }, } = useChartData();
|
|
45
45
|
const element = getAtom(activeTab);
|
|
46
46
|
const newSum = useMemo(() => {
|
|
47
47
|
return element &&
|
|
@@ -51,7 +51,7 @@ const styles = css `
|
|
|
51
51
|
`;
|
|
52
52
|
function EditRangeModal({ onSaveEditRangeModal = () => null, onCloseEditRangeModal = () => null, onZoomEditRangeModal = () => null, manualRange = false, range: originRange, }) {
|
|
53
53
|
const formRef = useRef(null);
|
|
54
|
-
const { activeTab } = useChartData();
|
|
54
|
+
const { view: { spectra: { activeTab }, }, } = useChartData();
|
|
55
55
|
const dispatch = useDispatch();
|
|
56
56
|
const rangesPreferences = usePanelPreferences('ranges', activeTab);
|
|
57
57
|
const validation = useRangeFormValidation();
|
|
@@ -110,7 +110,7 @@ function IntegralPanelInner({ integrals, info, activeTab, xDomain, }) {
|
|
|
110
110
|
const MemoizedIntegralPanel = memo(IntegralPanelInner);
|
|
111
111
|
const emptyData = { integrals: {}, info: {} };
|
|
112
112
|
export default function IntegralPanel() {
|
|
113
|
-
const { xDomain, activeTab } = useChartData();
|
|
113
|
+
const { xDomain, view: { spectra: { activeTab }, }, } = useChartData();
|
|
114
114
|
const { integrals, info } = useSpectrum(emptyData);
|
|
115
115
|
return (_jsx(MemoizedIntegralPanel, { ...{
|
|
116
116
|
integrals,
|
|
@@ -87,7 +87,7 @@ function MoleculePanelInner({ zones, ranges, molecules: moleculesProp, floatingM
|
|
|
87
87
|
const MemoizedMoleculePanel = memo(MoleculePanelInner);
|
|
88
88
|
const emptyData = { ranges: {}, zones: {} };
|
|
89
89
|
export default function MoleculePanel({ onMoleculeChange, children, actionsOptions, emptyTextStyle, }) {
|
|
90
|
-
const { molecules, view: { floatingMolecules },
|
|
90
|
+
const { molecules, view: { floatingMolecules, spectra: { activeTab }, }, displayerMode, } = useChartData();
|
|
91
91
|
const data = useSpectrum(emptyData);
|
|
92
92
|
const ranges = data?.ranges || {};
|
|
93
93
|
const zones = data?.zones || {};
|
|
@@ -82,7 +82,7 @@ function MultipleSpectraAnalysisPanelInner({ activeTab, spectraAnalysis, }) {
|
|
|
82
82
|
}
|
|
83
83
|
const MemoizedMultipleSpectraAnalysisPanel = memo(MultipleSpectraAnalysisPanelInner);
|
|
84
84
|
export default function MultipleSpectraAnalysisPanel() {
|
|
85
|
-
const { activeTab, spectraAnalysis, displayerKey } = useChartData();
|
|
85
|
+
const { view: { spectra: { activeTab }, }, spectraAnalysis, displayerKey, } = useChartData();
|
|
86
86
|
if (!activeTab) {
|
|
87
87
|
return _jsx("div", {});
|
|
88
88
|
}
|
|
@@ -109,7 +109,7 @@ function PeaksPanelInner({ peaks, info, xDomain, activeTab, peaksOptions, }) {
|
|
|
109
109
|
const MemoizedPeaksPanel = memo(PeaksPanelInner);
|
|
110
110
|
const emptyData = { peaks: null, info: {} };
|
|
111
111
|
export default function PeaksPanel() {
|
|
112
|
-
const { xDomain, activeTab, toolOptions: { data: { peaksOptions }, }, } = useChartData();
|
|
112
|
+
const { xDomain, view: { spectra: { activeTab }, }, toolOptions: { data: { peaksOptions }, }, } = useChartData();
|
|
113
113
|
const { peaks, info } = useSpectrum(emptyData);
|
|
114
114
|
const preferences = usePreferences();
|
|
115
115
|
return (_jsx(MemoizedPeaksPanel, { ...{ peaks, info, xDomain, activeTab, preferences, peaksOptions } }));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
declare function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClick, isFilterActive, filterCounter, showMultiplicityTrees, showJGraph, showRangesIntegrals, activeTab, }: {
|
|
1
|
+
declare function RangesHeader({ id, ranges, info, onUnlink, onFilterActivated, onSettingClick, isFilterActive, filterCounter, showMultiplicityTrees, showJGraph, showRangesIntegrals, activeTab, }: {
|
|
2
|
+
id: any;
|
|
2
3
|
ranges: any;
|
|
3
4
|
info: any;
|
|
4
5
|
onUnlink: any;
|
|
@@ -9,6 +9,7 @@ import { FaFileExport, FaUnlink, FaSitemap, FaChartBar, FaPlus, } from 'react-ic
|
|
|
9
9
|
import { ImLink } from 'react-icons/im';
|
|
10
10
|
import { useAssignmentData } from '../../assignment/AssignmentsContext';
|
|
11
11
|
import { useDispatch } from '../../context/DispatchContext';
|
|
12
|
+
import ActiveButton from '../../elements/ActiveButton';
|
|
12
13
|
import Button from '../../elements/ButtonToolTip';
|
|
13
14
|
import ToggleButton from '../../elements/ToggleButton';
|
|
14
15
|
import { useAlert } from '../../elements/popup/Alert';
|
|
@@ -39,7 +40,7 @@ const style = css `
|
|
|
39
40
|
margin-right: 2px;
|
|
40
41
|
}
|
|
41
42
|
`;
|
|
42
|
-
function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClick, isFilterActive, filterCounter, showMultiplicityTrees, showJGraph, showRangesIntegrals, activeTab, }) {
|
|
43
|
+
function RangesHeader({ id, ranges, info, onUnlink, onFilterActivated, onSettingClick, isFilterActive, filterCounter, showMultiplicityTrees, showJGraph, showRangesIntegrals, activeTab, }) {
|
|
43
44
|
const dispatch = useDispatch();
|
|
44
45
|
const modal = useModal();
|
|
45
46
|
const alert = useAlert();
|
|
@@ -82,14 +83,14 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
|
|
|
82
83
|
});
|
|
83
84
|
}, [assignmentData, dispatch, modal]);
|
|
84
85
|
const handleSetShowMultiplicityTrees = useCallback(() => {
|
|
85
|
-
dispatch({ type: SHOW_MULTIPLICTY_TREES });
|
|
86
|
-
}, [dispatch]);
|
|
86
|
+
dispatch({ type: SHOW_MULTIPLICTY_TREES, payload: { id } });
|
|
87
|
+
}, [dispatch, id]);
|
|
87
88
|
const handleShowIntegrals = useCallback(() => {
|
|
88
|
-
dispatch({ type: SHOW_RANGES_INTEGRALS });
|
|
89
|
-
}, [dispatch]);
|
|
89
|
+
dispatch({ type: SHOW_RANGES_INTEGRALS, payload: { id } });
|
|
90
|
+
}, [dispatch, id]);
|
|
90
91
|
const handleShowJGraph = useCallback(() => {
|
|
91
|
-
dispatch({ type: SHOW_J_GRAPH });
|
|
92
|
-
}, [dispatch]);
|
|
92
|
+
dispatch({ type: SHOW_J_GRAPH, payload: { id } });
|
|
93
|
+
}, [dispatch, id]);
|
|
93
94
|
const saveToClipboardHandler = useCallback((value) => {
|
|
94
95
|
void (async () => {
|
|
95
96
|
const success = await copyHTMLToClipboard(value);
|
|
@@ -136,8 +137,8 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
|
|
|
136
137
|
}, [dispatch, editRange]);
|
|
137
138
|
return (_jsx("div", { css: style, children: _jsxs(DefaultPanelHeader, { counter: ranges?.values?.length, onDelete: handleDeleteAll, deleteToolTip: "Delete All Ranges", onFilter: onFilterActivated, filterToolTip: isFilterActive ? 'Show all ranges' : 'Hide ranges out of view', filterIsActive: isFilterActive, counterFiltered: filterCounter, showSettingButton: true, onSettingClick: onSettingClick, children: [_jsx(Button, { popupTitle: "Preview publication string", popupPlacement: "right", onClick: saveAsHTMLHandler, className: "btn preview-publication-icon", children: _jsx(FaFileExport, {}) }), _jsx(Button, { popupTitle: currentSum
|
|
138
139
|
? `Change Ranges Sum (${Number(currentSum).toFixed(2)})`
|
|
139
|
-
: 'Change Ranges Sum', popupPlacement: "right", onClick: showChangeRangesSumModal, className: "btn icon", children: _jsx(SvgNmrSum, {}) }), _jsx(Button, { popupTitle: "Remove all Assignments", popupPlacement: "right", onClick: handleOnRemoveAssignments, disabled: !ranges || !ranges.values || ranges.values.length === 0, className: "btn icon", children: _jsx(FaUnlink, {}) }), _jsx(
|
|
140
|
+
: 'Change Ranges Sum', popupPlacement: "right", onClick: showChangeRangesSumModal, className: "btn icon", children: _jsx(SvgNmrSum, {}) }), _jsx(Button, { popupTitle: "Remove all Assignments", popupPlacement: "right", onClick: handleOnRemoveAssignments, disabled: !ranges || !ranges.values || ranges.values.length === 0, className: "btn icon", children: _jsx(FaUnlink, {}) }), _jsx(ActiveButton, { popupTitle: showMultiplicityTrees
|
|
140
141
|
? 'Hide Multiplicity Trees in Spectrum'
|
|
141
|
-
: 'Show Multiplicity Trees in Spectrum', popupPlacement: "right", onClick: handleSetShowMultiplicityTrees, disabled: !ranges || !ranges.values || ranges.values.length === 0, children: _jsx(FaSitemap, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(
|
|
142
|
+
: 'Show Multiplicity Trees in Spectrum', popupPlacement: "right", onClick: handleSetShowMultiplicityTrees, value: showMultiplicityTrees, disabled: !ranges || !ranges.values || ranges.values.length === 0, children: _jsx(FaSitemap, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showJGraph ? 'Hide J Graph' : 'Show J Graph', popupPlacement: "right", onClick: handleShowJGraph, value: showJGraph, disabled: !ranges || !ranges.values || ranges.values.length === 0, children: _jsx(FaChartBar, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showRangesIntegrals ? 'Hide integrals' : 'Show integrals', popupPlacement: "right", onClick: handleShowIntegrals, value: showRangesIntegrals, disabled: !ranges || !ranges.values || ranges.values.length === 0, children: _jsx(SvgNmrIntegrate, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ToggleButton, { className: "icon", popupTitle: "fix integral values", popupPlacement: "right", onClick: changeSumConstantFlagHandler, children: _jsx(ImLink, {}) }), _jsx(Button, { popupTitle: "Add range", popupPlacement: "right", onClick: addRangeHandler, className: "btn icon", children: _jsx(FaPlus, {}) })] }) }));
|
|
142
143
|
}
|
|
143
144
|
export default RangesHeader;
|
|
@@ -9,6 +9,7 @@ import { useDispatch } from '../../context/DispatchContext';
|
|
|
9
9
|
import { useAlert } from '../../elements/popup/Alert';
|
|
10
10
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
11
11
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
12
|
+
import { rangeStateInit } from '../../reducer/Reducer';
|
|
12
13
|
import { UNLINK_RANGE } from '../../reducer/types/Types';
|
|
13
14
|
import { copyTextToClipboard } from '../../utility/Export';
|
|
14
15
|
import { tablePanelStyle } from '../extra/BasicPanelStyle';
|
|
@@ -17,7 +18,7 @@ import PreferencesHeader from '../header/PreferencesHeader';
|
|
|
17
18
|
import RangesHeader from './RangesHeader';
|
|
18
19
|
import RangesPreferences from './RangesPreferences';
|
|
19
20
|
import RangesTable from './RangesTable';
|
|
20
|
-
function RangesTablePanelInner({ ranges, data, info, xDomain, preferences, activeTab, molecules, showMultiplicityTrees, showJGraph, showRangesIntegrals, }) {
|
|
21
|
+
function RangesTablePanelInner({ id, ranges, data, info, xDomain, preferences, activeTab, molecules, showMultiplicityTrees, showJGraph, showRangesIntegrals, }) {
|
|
21
22
|
const [isFilterActive, setFilterIsActive] = useState(false);
|
|
22
23
|
const assignmentData = useAssignmentData();
|
|
23
24
|
const dispatch = useDispatch();
|
|
@@ -107,6 +108,7 @@ function RangesTablePanelInner({ ranges, data, info, xDomain, preferences, activ
|
|
|
107
108
|
}
|
|
108
109
|
`,
|
|
109
110
|
], children: [!isFlipped && (_jsx(RangesHeader, { ...{
|
|
111
|
+
id,
|
|
110
112
|
ranges,
|
|
111
113
|
info,
|
|
112
114
|
activeTab,
|
|
@@ -120,10 +122,12 @@ function RangesTablePanelInner({ ranges, data, info, xDomain, preferences, activ
|
|
|
120
122
|
const MemoizedRangesTablePanel = memo(RangesTablePanelInner);
|
|
121
123
|
const emptyData = { ranges: {}, data: {}, info: {} };
|
|
122
124
|
export default function RangesTablePanel() {
|
|
123
|
-
const {
|
|
124
|
-
const {
|
|
125
|
+
const { ranges, data, info, id } = useSpectrum(emptyData);
|
|
126
|
+
const { displayerKey, xDomain, view: { spectra: { activeTab }, }, molecules, toolOptions: { selectedTool }, view: { ranges: rangeState }, } = useChartData();
|
|
127
|
+
const { showMultiplicityTrees, showRangesIntegrals, showJGraph } = useMemo(() => rangeState.find((r) => r.spectrumID === id) || rangeStateInit, [id, rangeState]);
|
|
125
128
|
const rangesPreferences = usePanelPreferences('ranges', activeTab);
|
|
126
129
|
return (_jsx(MemoizedRangesTablePanel, { ...{
|
|
130
|
+
id,
|
|
127
131
|
ranges,
|
|
128
132
|
data,
|
|
129
133
|
info,
|
|
@@ -7,6 +7,7 @@ import { useDispatch } from '../../context/DispatchContext';
|
|
|
7
7
|
import Button from '../../elements/ButtonToolTip';
|
|
8
8
|
import { useAlert } from '../../elements/popup/Alert';
|
|
9
9
|
import { useModal } from '../../elements/popup/Modal';
|
|
10
|
+
import { useActiveSpectrum } from '../../reducer/Reducer';
|
|
10
11
|
import { DISPLAYER_MODE } from '../../reducer/core/Constants';
|
|
11
12
|
import { ADD_MISSING_PROJECTION, CHANGE_VISIBILITY, DELETE_SPECTRA, RESET_SPECTRA_SCALE, SET_SPECTRA_SAME_TOP, } from '../../reducer/types/Types';
|
|
12
13
|
import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
@@ -69,7 +70,8 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeTab, displayerMod
|
|
|
69
70
|
}
|
|
70
71
|
const MemoizedSpectraPanelHeader = memo(SpectraPanelHeaderInner);
|
|
71
72
|
export default function SpectrumsTabs({ spectrums }) {
|
|
72
|
-
const { data,
|
|
73
|
+
const { data, view: { spectra: { activeTab }, }, displayerMode, } = useChartData();
|
|
74
|
+
const activeSpectrum = useActiveSpectrum();
|
|
73
75
|
return (_jsx(MemoizedSpectraPanelHeader, { ...{
|
|
74
76
|
data,
|
|
75
77
|
activeSpectrum,
|
|
@@ -7,6 +7,7 @@ import ContextMenu from '../../elements/ContextMenu';
|
|
|
7
7
|
import Tab from '../../elements/Tab/Tab';
|
|
8
8
|
import Tabs from '../../elements/Tab/Tabs';
|
|
9
9
|
import { useAlert } from '../../elements/popup/Alert';
|
|
10
|
+
import { useActiveSpectrum } from '../../reducer/Reducer';
|
|
10
11
|
import { CHANGE_PEAKS_MARKERS_VISIBILITY, SET_ACTIVE_TAB, CHANGE_VISIBILITY, CHANGE_ACTIVE_SPECTRUM, DELETE_SPECTRA, } from '../../reducer/types/Types';
|
|
11
12
|
import { copyTextToClipboard } from '../../utility/Export';
|
|
12
13
|
import groupByInfoKey from '../../utility/GroupByInfoKey';
|
|
@@ -128,6 +129,7 @@ function SpectrumsTabsInner({ data, activeSpectrum, activeTab, onTabChange, }) {
|
|
|
128
129
|
}
|
|
129
130
|
const MemoizedSpectra = memo(SpectrumsTabsInner);
|
|
130
131
|
export default function SpectrumsTabs({ onTabChange }) {
|
|
131
|
-
const { data,
|
|
132
|
+
const { data, view: { spectra: { activeTab }, }, } = useChartData();
|
|
133
|
+
const activeSpectrum = useActiveSpectrum();
|
|
132
134
|
return (_jsx(MemoizedSpectra, { ...{ data, activeSpectrum, activeTab, onTabChange } }));
|
|
133
135
|
}
|
|
@@ -53,7 +53,7 @@ const panelStyle = css `
|
|
|
53
53
|
}
|
|
54
54
|
`;
|
|
55
55
|
function SummaryPanel() {
|
|
56
|
-
const { molecules, correlations: correlationsData, data: spectraData, xDomain, yDomain, displayerMode, activeTab, } = useChartData();
|
|
56
|
+
const { molecules, correlations: correlationsData, data: spectraData, xDomain, yDomain, displayerMode, view: { spectra: { activeTab }, }, } = useChartData();
|
|
57
57
|
const dispatch = useDispatch();
|
|
58
58
|
const modal = useModal();
|
|
59
59
|
const assignmentData = useAssignmentData();
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useChartData } from '../../../context/ChartContext';
|
|
3
|
+
import { useActiveSpectrum } from '../../../reducer/Reducer';
|
|
3
4
|
import { isInView } from './Utilities';
|
|
4
5
|
function useInView({ correlation }) {
|
|
5
|
-
const { data: spectraData, xDomain, yDomain, displayerMode, activeTab,
|
|
6
|
+
const { data: spectraData, xDomain, yDomain, displayerMode, view: { spectra: { activeTab }, }, } = useChartData();
|
|
7
|
+
const activeSpectrum = useActiveSpectrum();
|
|
6
8
|
return useMemo(() => isInView(spectraData, activeTab, activeSpectrum, xDomain, yDomain, displayerMode, correlation), [
|
|
7
9
|
activeSpectrum,
|
|
8
10
|
activeTab,
|
|
@@ -6,12 +6,12 @@ import { FaUnlink } from 'react-icons/fa';
|
|
|
6
6
|
import { useAssignmentData } from '../../assignment/AssignmentsContext';
|
|
7
7
|
import { useChartData } from '../../context/ChartContext';
|
|
8
8
|
import { useDispatch } from '../../context/DispatchContext';
|
|
9
|
-
import
|
|
9
|
+
import ActiveButton from '../../elements/ActiveButton';
|
|
10
10
|
import ToolTip from '../../elements/ToolTip/ToolTip';
|
|
11
11
|
import { useModal } from '../../elements/popup/Modal';
|
|
12
12
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
13
|
+
import { zoneStateInit } from '../../reducer/Reducer';
|
|
14
|
+
import { DELETE_2D_ZONE, SHOW_ZONES, SHOW_ZONES_PEAKS, SHOW_ZONES_SIGNALS, UNLINK_ZONE, } from '../../reducer/types/Types';
|
|
15
15
|
import { tablePanelStyle } from '../extra/BasicPanelStyle';
|
|
16
16
|
import NoTableData from '../extra/placeholder/NoTableData';
|
|
17
17
|
import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
@@ -39,7 +39,7 @@ const style = css `
|
|
|
39
39
|
align-items: center;
|
|
40
40
|
}
|
|
41
41
|
`;
|
|
42
|
-
function ZonesPanelInner({ zones, activeTab, xDomain, yDomain, experiment }) {
|
|
42
|
+
function ZonesPanelInner({ zones, activeTab, xDomain, yDomain, experiment, showZones, showSignals, showPeaks, id, }) {
|
|
43
43
|
const [filterIsActive, setFilterIsActive] = useState(false);
|
|
44
44
|
const assignmentData = useAssignmentData();
|
|
45
45
|
const dispatch = useDispatch();
|
|
@@ -122,9 +122,15 @@ function ZonesPanelInner({ zones, activeTab, xDomain, yDomain, experiment }) {
|
|
|
122
122
|
settingRef.current.saveSetting();
|
|
123
123
|
setFlipStatus(false);
|
|
124
124
|
}, []);
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
}
|
|
125
|
+
const handleSetShowZones = () => {
|
|
126
|
+
dispatch({ type: SHOW_ZONES, payload: { id } });
|
|
127
|
+
};
|
|
128
|
+
const handleSetShowSignals = () => {
|
|
129
|
+
dispatch({ type: SHOW_ZONES_SIGNALS, payload: { id } });
|
|
130
|
+
};
|
|
131
|
+
const handleSetShowPeaks = () => {
|
|
132
|
+
dispatch({ type: SHOW_ZONES_PEAKS, payload: { id } });
|
|
133
|
+
};
|
|
128
134
|
return (_jsxs("div", { css: [
|
|
129
135
|
tablePanelStyle,
|
|
130
136
|
style,
|
|
@@ -134,21 +140,24 @@ function ZonesPanelInner({ zones, activeTab, xDomain, yDomain, experiment }) {
|
|
|
134
140
|
position: relative;
|
|
135
141
|
}
|
|
136
142
|
`,
|
|
137
|
-
], children: [!isFlipped && (_jsxs(DefaultPanelHeader, { counter: zones.values ? zones.values.length : 0, onDelete: handleDeleteAll, deleteToolTip: "Delete All Zones", onFilter: handleOnFilter, filterToolTip: filterIsActive ? 'Show all zones' : 'Hide zones out of view', filterIsActive: filterIsActive, counterFiltered: tableData?.length, showSettingButton: true, onSettingClick: settingsPanelHandler, children: [_jsx(ToolTip, { title: `Remove all Assignments`, popupPlacement: "right", children: _jsx("button", { className: "remove-assignments-btn", type: "button", onClick: handleOnRemoveAssignments, disabled: !zones.values || zones.values.length === 0, children: _jsx(FaUnlink, {}) }) }), _jsx(
|
|
143
|
+
], children: [!isFlipped && (_jsxs(DefaultPanelHeader, { counter: zones.values ? zones.values.length : 0, onDelete: handleDeleteAll, deleteToolTip: "Delete All Zones", onFilter: handleOnFilter, filterToolTip: filterIsActive ? 'Show all zones' : 'Hide zones out of view', filterIsActive: filterIsActive, counterFiltered: tableData?.length, showSettingButton: true, onSettingClick: settingsPanelHandler, children: [_jsx(ToolTip, { title: `Remove all Assignments`, popupPlacement: "right", children: _jsx("button", { className: "remove-assignments-btn", type: "button", onClick: handleOnRemoveAssignments, disabled: !zones.values || zones.values.length === 0, children: _jsx(FaUnlink, {}) }) }), _jsx(ActiveButton, { popupTitle: "show/hide zones", popupPlacement: "right", value: showZones, onClick: handleSetShowZones, children: _jsx("span", { style: { fontSize: '12px', pointerEvents: 'none' }, children: "z" }) }), _jsx(ActiveButton, { popupTitle: "show/hide signals", popupPlacement: "right", value: showSignals, onClick: handleSetShowSignals, children: _jsx("span", { style: { fontSize: '12px', pointerEvents: 'none' }, children: "s" }) }), _jsx(ActiveButton, { popupTitle: "show/hide peaks", popupPlacement: "right", value: showPeaks, onClick: handleSetShowPeaks, children: _jsx("span", { style: { fontSize: '12px', pointerEvents: 'none' }, children: "p" }) })] })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: !isFlipped ? (_jsx("div", { className: "table-container", children: tableData && tableData.length > 0 ? (_jsx(ZonesTable, { tableData: tableData, onUnlink: unlinkZoneHandler, nuclei: activeTab && activeTab.split(',').length === 2
|
|
138
144
|
? activeTab.split(',')
|
|
139
145
|
: ['?', '?'], experiment: experiment })) : (_jsx(NoTableData, {})) })) : (_jsx(ZonesPreferences, { ref: settingRef })) })] }));
|
|
140
146
|
}
|
|
141
147
|
const MemoizedZonesPanel = memo(ZonesPanelInner);
|
|
142
148
|
const emptyData = { zones: {}, info: {} };
|
|
143
149
|
export default function ZonesPanel() {
|
|
144
|
-
const { displayerKey, xDomain, yDomain, activeTab } = useChartData();
|
|
145
|
-
const { zones, info } = useSpectrum(emptyData);
|
|
150
|
+
const { displayerKey, xDomain, yDomain, view: { zones: zoneState, spectra: { activeTab }, }, } = useChartData();
|
|
151
|
+
const { zones, info, id } = useSpectrum(emptyData);
|
|
152
|
+
const zoneProps = zoneState.find((r) => r.spectrumID === id) || zoneStateInit;
|
|
146
153
|
return (_jsx(MemoizedZonesPanel, { ...{
|
|
154
|
+
id,
|
|
147
155
|
xDomain,
|
|
148
156
|
yDomain,
|
|
149
157
|
activeTab,
|
|
150
158
|
displayerKey,
|
|
151
159
|
zones,
|
|
152
160
|
experiment: info.experiment,
|
|
161
|
+
...zoneProps,
|
|
153
162
|
} }));
|
|
154
163
|
}
|
|
@@ -256,7 +256,7 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
|
|
|
256
256
|
}
|
|
257
257
|
const MemoizedDatabasePanel = memo(DatabasePanelInner);
|
|
258
258
|
export default function PeaksPanel() {
|
|
259
|
-
const { activeTab, toolOptions: { selectedTool }, } = useChartData();
|
|
259
|
+
const { view: { spectra: { activeTab }, }, toolOptions: { selectedTool }, } = useChartData();
|
|
260
260
|
const { current } = usePreferences();
|
|
261
261
|
const { data, defaultDatabase } = current.databases;
|
|
262
262
|
const databases = DATA_BASES.concat(data.filter((datum) => datum.enabled));
|