nmrium 0.50.1 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/component/1d/Chart1D.js +1 -1
- package/lib/component/1d/LinesSeries.js +2 -2
- package/lib/component/1d/Viewer1D.js +6 -11
- package/lib/component/1d/database/DatabaseSpectrum.js +3 -3
- package/lib/component/2d/1d-tracer/HorizontalSliceChart.js +6 -2
- package/lib/component/2d/1d-tracer/VerticalSliceChart.js +8 -1
- package/lib/component/2d/1d-tracer/phase-correction-traces/PhaseTraceWithMouse.js +2 -21
- package/lib/component/2d/1d-tracer/phase-correction-traces/PhaseTraces.js +1 -1
- package/lib/component/2d/1d-tracer/phase-correction-traces/SpectraPhaseTraces.d.ts +1 -1
- package/lib/component/2d/1d-tracer/phase-correction-traces/SpectraPhaseTraces.js +6 -17
- package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.d.ts +6 -10
- package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.js +62 -13
- package/lib/component/2d/1d-tracer/phase-correction-traces/useActivePhaseTraces.d.ts +1 -0
- package/lib/component/2d/1d-tracer/phase-correction-traces/useActivePhaseTraces.js +2 -1
- package/lib/component/2d/Viewer2D.js +16 -15
- package/lib/component/2d/ft/Contours.js +6 -3
- package/lib/component/2d/utilities/scale.d.ts +2 -1
- package/lib/component/2d/utilities/scale.js +12 -2
- package/lib/component/EventsTrackers/BrushTracker.d.ts +5 -3
- package/lib/component/EventsTrackers/BrushTracker.js +2 -2
- package/lib/component/EventsTrackers/KeysListenerTracker.d.ts +1 -1
- package/lib/component/EventsTrackers/KeysListenerTracker.js +29 -15
- package/lib/component/context/ToasterContext.d.ts +13 -0
- package/lib/component/context/ToasterContext.js +34 -0
- package/lib/component/elements/Select.js +2 -2
- package/lib/component/elements/ToolbarPopoverItem.js +1 -1
- package/lib/component/header/AutoPeakPickingOptionPanel.js +6 -3
- package/lib/component/header/Header.d.ts +1 -11
- package/lib/component/header/Header.js +5 -6
- package/lib/component/header/PhaseCorrectionPanel.js +24 -33
- package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.d.ts +1 -1
- package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.js +96 -42
- package/lib/component/header/RangesPickingOptionPanel.js +6 -3
- package/lib/component/hooks/useDialogToggle.d.ts +5 -0
- package/lib/component/hooks/useDialogToggle.js +16 -0
- package/lib/component/hooks/useExport.d.ts +9 -1
- package/lib/component/hooks/useExport.js +34 -36
- package/lib/component/hooks/useSaveSettings.js +6 -3
- package/lib/component/hooks/useToolsFunctions.js +6 -4
- package/lib/component/loader/DropZone.js +14 -14
- package/lib/component/main/InnerNMRium.js +5 -9
- package/lib/component/main/InnerNMRiumContents.d.ts +0 -2
- package/lib/component/main/InnerNMRiumContents.js +5 -3
- package/lib/component/main/NMRium.js +2 -2
- package/lib/component/modal/AboutPredictionModal.js +1 -1
- package/lib/component/modal/ExportAsJcampModal.js +15 -15
- package/lib/component/modal/ImportPublicationStringModal.js +5 -3
- package/lib/component/modal/LoadJCAMPModal.js +6 -4
- package/lib/component/modal/PredictSpectraModal.js +11 -9
- package/lib/component/modal/SaveAsModal.d.ts +3 -4
- package/lib/component/modal/SaveAsModal.js +27 -27
- package/lib/component/modal/editRange/EditRangeModal.js +2 -2
- package/lib/component/modal/editRange/forms/components/DeltaInput.d.ts +2 -3
- package/lib/component/modal/editRange/forms/components/DeltaInput.js +2 -3
- package/lib/component/modal/editRange/forms/components/InfoBlock.d.ts +1 -0
- package/lib/component/modal/editRange/forms/components/{SignalFormInfo.js → InfoBlock.js} +2 -2
- package/lib/component/modal/editRange/forms/components/NewSignalTab.d.ts +5 -0
- package/lib/component/modal/editRange/forms/components/NewSignalTab.js +85 -0
- package/lib/component/modal/editRange/forms/components/SignalTab.d.ts +7 -0
- package/lib/component/modal/editRange/forms/components/SignalTab.js +24 -0
- package/lib/component/modal/editRange/forms/components/SignalsContent.d.ts +8 -0
- package/lib/component/modal/editRange/forms/components/SignalsContent.js +57 -0
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.d.ts +5 -0
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +133 -0
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.d.ts +5 -0
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +141 -0
- package/lib/component/modal/metaImportation/MetaImportationModal.d.ts +7 -4
- package/lib/component/modal/metaImportation/MetaImportationModal.js +23 -13
- package/lib/component/modal/metaImportation/utils/mapColumnToSelectItems.js +1 -1
- package/lib/component/modal/setting/GeneralSettings.js +7 -4
- package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js +7 -4
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +13 -7
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +6 -4
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +6 -3
- package/lib/component/panels/RangesPanel/RangesHeader.js +3 -3
- package/lib/component/panels/RangesPanel/RangesPanel.js +4 -4
- package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -3
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +11 -5
- package/lib/component/panels/databasePanel/DatabasePanel.js +37 -19
- package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +1 -1
- package/lib/component/panels/filtersPanel/FilterPanel.js +5 -3
- package/lib/component/panels/filtersPanel/FiltersTable.js +27 -23
- package/lib/component/panels/header/SpectraAutomaticPickingButton.js +6 -4
- package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +2 -2
- package/lib/component/panels/multipleAnalysisPanel/AnalysisChart.js +3 -3
- package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +5 -5
- package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +4 -2
- package/lib/component/panels/predictionPanel/PredictionPanel.js +7 -5
- package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +1 -0
- package/lib/component/reducer/Reducer.d.ts +2 -2
- package/lib/component/reducer/Reducer.js +23 -16
- package/lib/component/reducer/actions/FiltersActions.d.ts +11 -4
- package/lib/component/reducer/actions/FiltersActions.js +243 -91
- package/lib/component/reducer/actions/IntegralsActions.js +2 -2
- package/lib/component/reducer/actions/MoleculeActions.js +0 -1
- package/lib/component/reducer/actions/RangesActions.js +16 -6
- package/lib/component/reducer/actions/ToolsActions.d.ts +3 -3
- package/lib/component/reducer/actions/ToolsActions.js +75 -14
- package/lib/component/reducer/helper/Zoom1DManager.d.ts +4 -3
- package/lib/component/reducer/helper/Zoom1DManager.js +4 -4
- package/lib/component/reducer/helper/ZoomHistoryManager.js +1 -5
- package/lib/component/reducer/helper/findStrongestPeak.d.ts +6 -0
- package/lib/component/reducer/helper/findStrongestPeak.js +13 -0
- package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.d.ts +2 -1
- package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.js +7 -1
- package/lib/component/toolbar/ToolBar.js +17 -12
- package/lib/component/utility/Events.d.ts +11 -0
- package/lib/component/utility/Events.js +22 -0
- package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +0 -33
- package/lib/data/data1d/Spectrum1D/ranges/addRange.js +5 -15
- package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -4
- package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectRanges.d.ts +6 -4
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +13 -3
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +6 -0
- package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.d.ts +13 -3
- package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js +78 -18
- package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +2 -2
- package/lib/data/data1d/spectrumSimulation.d.ts +1 -1
- package/lib/data/data2d/Spectrum2D/contours.js +3 -3
- package/lib/data/data2d/Spectrum2D/getMissingProjection.js +2 -2
- package/lib/data/data2d/Spectrum2D/getSlice.js +3 -3
- package/lib/data/getDefaultMatrixFilters.js +2 -2
- package/lib/data/matrixGeneration.js +1 -1
- package/lib/data/utilities/calculateSanPlot.d.ts +1 -6
- package/lib/versionInfo.js +1 -1
- package/package.json +31 -30
- package/lib/component/elements/popup/Alert/AlertBlock.d.ts +0 -8
- package/lib/component/elements/popup/Alert/AlertBlock.js +0 -30
- package/lib/component/elements/popup/Alert/Context.d.ts +0 -27
- package/lib/component/elements/popup/Alert/Context.js +0 -10
- package/lib/component/elements/popup/Alert/ProgressIndicator.d.ts +0 -1
- package/lib/component/elements/popup/Alert/ProgressIndicator.js +0 -33
- package/lib/component/elements/popup/Alert/Provider.d.ts +0 -19
- package/lib/component/elements/popup/Alert/Provider.js +0 -127
- package/lib/component/elements/popup/Alert/index.d.ts +0 -3
- package/lib/component/elements/popup/Alert/index.js +0 -3
- package/lib/component/modal/editRange/forms/components/AddSignalFormTab.d.ts +0 -10
- package/lib/component/modal/editRange/forms/components/AddSignalFormTab.js +0 -81
- package/lib/component/modal/editRange/forms/components/CouplingsTable.d.ts +0 -13
- package/lib/component/modal/editRange/forms/components/CouplingsTable.js +0 -63
- package/lib/component/modal/editRange/forms/components/SignalFormInfo.d.ts +0 -1
- package/lib/component/modal/editRange/forms/components/SignalFormTab.d.ts +0 -8
- package/lib/component/modal/editRange/forms/components/SignalFormTab.js +0 -18
- package/lib/component/modal/editRange/forms/components/SignalsForm.d.ts +0 -10
- package/lib/component/modal/editRange/forms/components/SignalsForm.js +0 -114
- package/lib/component/modal/metaImportation/index.d.ts +0 -2
- package/lib/component/modal/metaImportation/index.js +0 -17
- package/lib/component/reducer/helper/getStrongestPeak.d.ts +0 -7
- package/lib/component/reducer/helper/getStrongestPeak.js +0 -15
|
@@ -2,11 +2,11 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { Formik } from 'formik';
|
|
3
3
|
import * as Yup from 'yup';
|
|
4
4
|
import { useDispatch } from '../context/DispatchContext';
|
|
5
|
+
import { useToaster } from '../context/ToasterContext';
|
|
5
6
|
import Button from '../elements/Button';
|
|
6
7
|
import Label from '../elements/Label';
|
|
7
8
|
import FormikCheckBox from '../elements/formik/FormikCheckBox';
|
|
8
9
|
import FormikInput from '../elements/formik/FormikInput';
|
|
9
|
-
import { useAlert } from '../elements/popup/Alert';
|
|
10
10
|
import { MIN_AREA_POINTS, useCheckPointsNumberInWindowArea, } from '../hooks/useCheckPointsNumberInWindowArea';
|
|
11
11
|
import { headerLabelStyle } from './Header';
|
|
12
12
|
import { HeaderContainer } from './HeaderContainer';
|
|
@@ -20,7 +20,7 @@ const initialValues = {
|
|
|
20
20
|
function RangesPickingOptionPanel() {
|
|
21
21
|
const dispatch = useDispatch();
|
|
22
22
|
const pointsNumber = useCheckPointsNumberInWindowArea();
|
|
23
|
-
const
|
|
23
|
+
const toaster = useToaster();
|
|
24
24
|
function handleRangesPicking(values) {
|
|
25
25
|
if (pointsNumber > MIN_AREA_POINTS) {
|
|
26
26
|
dispatch({
|
|
@@ -29,7 +29,10 @@ function RangesPickingOptionPanel() {
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
|
-
|
|
32
|
+
toaster.show({
|
|
33
|
+
message: `Auto range picking only available for area more than ${MIN_AREA_POINTS} points`,
|
|
34
|
+
intent: 'danger',
|
|
35
|
+
});
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
return (_jsx(HeaderContainer, { children: _jsx(Formik, { onSubmit: handleRangesPicking, initialValues: initialValues, validationSchema: validationSchema, children: ({ handleSubmit, isValid }) => (_jsxs(_Fragment, { children: [_jsx(Label, { title: "Detect negative:", htmlFor: "lookNegative", style: headerLabelStyle, children: _jsx(FormikCheckBox, { name: "lookNegative" }) }), _jsx(Label, { title: "Min Max Ratio:", style: headerLabelStyle, children: _jsx(FormikInput, { type: "number", name: "minMaxRatio", style: {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
export function useDialogToggle(initState) {
|
|
3
|
+
const [dialog, setDialogState] = useState(initState);
|
|
4
|
+
function openDialog(id) {
|
|
5
|
+
const newState = { ...dialog, [id]: true };
|
|
6
|
+
setDialogState(newState);
|
|
7
|
+
}
|
|
8
|
+
function closeDialog() {
|
|
9
|
+
const newState = {};
|
|
10
|
+
for (const id in dialog) {
|
|
11
|
+
newState[id] = false;
|
|
12
|
+
}
|
|
13
|
+
setDialogState(newState);
|
|
14
|
+
}
|
|
15
|
+
return { dialog, closeDialog, openDialog };
|
|
16
|
+
}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
import { ExportOptions } from '../../data/SpectraManager';
|
|
2
|
+
interface SaveOptions {
|
|
3
|
+
include: ExportOptions;
|
|
4
|
+
name: string;
|
|
5
|
+
compressed: boolean;
|
|
6
|
+
pretty: boolean;
|
|
7
|
+
}
|
|
1
8
|
export default function useExport(): {
|
|
2
9
|
saveToClipboardHandler: () => Promise<void>;
|
|
3
10
|
saveAsJSONHandler: (spaceIndent?: number, isCompressed?: boolean) => void;
|
|
4
11
|
saveAsSVGHandler: () => Promise<void>;
|
|
5
12
|
saveAsPNGHandler: () => Promise<void>;
|
|
6
|
-
|
|
13
|
+
saveHandler: (options: SaveOptions) => void;
|
|
7
14
|
};
|
|
15
|
+
export {};
|
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import { useCallback } from 'react';
|
|
3
2
|
import { toJSON } from '../../data/SpectraManager';
|
|
4
3
|
import { useChartData } from '../context/ChartContext';
|
|
5
4
|
import { useGlobal } from '../context/GlobalContext';
|
|
6
5
|
import { usePreferences } from '../context/PreferencesContext';
|
|
7
|
-
import {
|
|
8
|
-
import { positions, useModal } from '../elements/popup/Modal';
|
|
9
|
-
import SaveAsModal from '../modal/SaveAsModal';
|
|
6
|
+
import { useToaster } from '../context/ToasterContext';
|
|
10
7
|
import { copyPNGToClipboard, exportAsJSON, exportAsPng, exportAsSVG, } from '../utility/export';
|
|
11
8
|
export default function useExport() {
|
|
12
9
|
const { rootRef } = useGlobal();
|
|
13
|
-
const
|
|
14
|
-
const alert = useAlert();
|
|
10
|
+
const toaster = useToaster();
|
|
15
11
|
const state = useChartData();
|
|
16
12
|
const preferencesState = usePreferences();
|
|
17
13
|
const saveToClipboardHandler = useCallback(async () => {
|
|
18
14
|
if (state.data.length > 0 && rootRef) {
|
|
19
|
-
const hideLoading =
|
|
15
|
+
const hideLoading = toaster.showLoading({
|
|
16
|
+
message: 'Exporting as NMRium process in progress',
|
|
17
|
+
});
|
|
20
18
|
setTimeout(async () => {
|
|
21
19
|
await copyPNGToClipboard(rootRef, 'nmrSVG');
|
|
22
20
|
hideLoading();
|
|
23
|
-
|
|
21
|
+
toaster.show({
|
|
22
|
+
message: 'Image copied to clipboard',
|
|
23
|
+
intent: 'success',
|
|
24
|
+
});
|
|
24
25
|
}, 0);
|
|
25
26
|
}
|
|
26
|
-
}, [
|
|
27
|
+
}, [state.data.length, rootRef, toaster]);
|
|
27
28
|
const saveAsJSONHandler = useCallback((spaceIndent = 0, isCompressed = true) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const hideLoading = toaster.showLoading({
|
|
30
|
+
message: 'Exporting as NMRium process in progress',
|
|
31
|
+
});
|
|
32
|
+
try {
|
|
33
|
+
void (async () => {
|
|
33
34
|
const fileName = state.data[0]?.info?.name;
|
|
34
35
|
const exportedData = toJSON(state, preferencesState, {
|
|
35
36
|
exportTarget: 'nmrium',
|
|
@@ -37,37 +38,42 @@ export default function useExport() {
|
|
|
37
38
|
});
|
|
38
39
|
await exportAsJSON(exportedData, fileName, spaceIndent, isCompressed);
|
|
39
40
|
hideLoading();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
}, [alert, preferencesState, state]);
|
|
41
|
+
})();
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
reportError(error);
|
|
45
|
+
}
|
|
46
|
+
}, [preferencesState, state, toaster]);
|
|
47
47
|
const saveAsSVGHandler = useCallback(async () => {
|
|
48
48
|
if (state.data.length > 0 && rootRef) {
|
|
49
|
-
const hideLoading =
|
|
49
|
+
const hideLoading = toaster.showLoading({
|
|
50
|
+
message: 'Exporting as SVG process in progress',
|
|
51
|
+
});
|
|
50
52
|
setTimeout(() => {
|
|
51
53
|
const fileName = state.data[0]?.info?.name;
|
|
52
54
|
exportAsSVG(rootRef, 'nmrSVG', fileName);
|
|
53
55
|
hideLoading();
|
|
54
56
|
}, 0);
|
|
55
57
|
}
|
|
56
|
-
}, [
|
|
58
|
+
}, [state.data, rootRef, toaster]);
|
|
57
59
|
const saveAsPNGHandler = useCallback(async () => {
|
|
58
60
|
if (state.data.length > 0 && rootRef) {
|
|
59
|
-
const hideLoading =
|
|
61
|
+
const hideLoading = toaster.showLoading({
|
|
62
|
+
message: 'Exporting as PNG process in progress',
|
|
63
|
+
});
|
|
60
64
|
setTimeout(() => {
|
|
61
65
|
const fileName = state.data[0]?.info?.name;
|
|
62
66
|
exportAsPng(rootRef, 'nmrSVG', fileName);
|
|
63
67
|
hideLoading();
|
|
64
68
|
}, 0);
|
|
65
69
|
}
|
|
66
|
-
}, [
|
|
70
|
+
}, [state.data, rootRef, toaster]);
|
|
67
71
|
const saveHandler = useCallback((options) => {
|
|
68
72
|
async function handler() {
|
|
69
73
|
const { name, pretty, compressed, include } = options;
|
|
70
|
-
const hideLoading =
|
|
74
|
+
const hideLoading = toaster.showLoading({
|
|
75
|
+
message: `Exporting as ${name}.nmrium process in progress`,
|
|
76
|
+
});
|
|
71
77
|
setTimeout(() => {
|
|
72
78
|
void (async () => {
|
|
73
79
|
const exportedData = toJSON(state, preferencesState, {
|
|
@@ -81,20 +87,12 @@ export default function useExport() {
|
|
|
81
87
|
}, 0);
|
|
82
88
|
}
|
|
83
89
|
void handler();
|
|
84
|
-
}, [
|
|
85
|
-
const saveAsHandler = useCallback(async () => {
|
|
86
|
-
const fileName = state.data[0]?.info?.name;
|
|
87
|
-
modal.show(_jsx(SaveAsModal, { name: fileName, onSave: saveHandler }), {
|
|
88
|
-
isBackgroundBlur: false,
|
|
89
|
-
position: positions.TOP_CENTER,
|
|
90
|
-
width: 500,
|
|
91
|
-
});
|
|
92
|
-
}, [modal, saveHandler, state.data]);
|
|
90
|
+
}, [preferencesState, state, toaster]);
|
|
93
91
|
return {
|
|
94
92
|
saveToClipboardHandler,
|
|
95
93
|
saveAsJSONHandler,
|
|
96
94
|
saveAsSVGHandler,
|
|
97
95
|
saveAsPNGHandler,
|
|
98
|
-
|
|
96
|
+
saveHandler,
|
|
99
97
|
};
|
|
100
98
|
}
|
|
@@ -5,8 +5,8 @@ import { useRef, forwardRef } from 'react';
|
|
|
5
5
|
import { useOnOff } from 'react-science/ui';
|
|
6
6
|
import * as Yup from 'yup';
|
|
7
7
|
import { usePreferences } from '../context/PreferencesContext';
|
|
8
|
+
import { useToaster } from '../context/ToasterContext';
|
|
8
9
|
import FormikInput from '../elements/formik/FormikInput';
|
|
9
|
-
import { useAlert } from '../elements/popup/Alert/Context';
|
|
10
10
|
import ConfirmationDialog from '../elements/popup/Modal/ConfirmDialog';
|
|
11
11
|
const schema = Yup.object().shape({
|
|
12
12
|
workspaceName: Yup.string().required(),
|
|
@@ -22,7 +22,7 @@ const WorkspaceAddForm = forwardRef(({ className, message, onSave }, ref) => {
|
|
|
22
22
|
}, autoFocus: true }) })] }));
|
|
23
23
|
});
|
|
24
24
|
export function useSaveSettings() {
|
|
25
|
-
const
|
|
25
|
+
const toaster = useToaster();
|
|
26
26
|
const [isOpenDialog, openDialog, closeDialog] = useOnOff(false);
|
|
27
27
|
const settingsRef = useRef();
|
|
28
28
|
const { dispatch, current } = usePreferences();
|
|
@@ -36,7 +36,10 @@ export function useSaveSettings() {
|
|
|
36
36
|
},
|
|
37
37
|
});
|
|
38
38
|
closeDialog();
|
|
39
|
-
|
|
39
|
+
toaster.show({
|
|
40
|
+
message: 'Preferences saved successfully',
|
|
41
|
+
intent: 'success',
|
|
42
|
+
});
|
|
40
43
|
}
|
|
41
44
|
return {
|
|
42
45
|
saveSettings: (values) => {
|
|
@@ -4,12 +4,12 @@ import { useCallback, useRef, useState } from 'react';
|
|
|
4
4
|
import { useToggleAccordion } from 'react-science/ui';
|
|
5
5
|
import { useDispatch } from '../context/DispatchContext';
|
|
6
6
|
import { usePreferences } from '../context/PreferencesContext';
|
|
7
|
-
import {
|
|
7
|
+
import { useToaster } from '../context/ToasterContext';
|
|
8
8
|
import { TOOLS_PANELS_ACCORDION } from '../panels/Panels';
|
|
9
9
|
import { options } from '../toolbar/ToolTypes';
|
|
10
10
|
export default function useToolsFunctions() {
|
|
11
11
|
const dispatch = useDispatch();
|
|
12
|
-
const
|
|
12
|
+
const toaster = useToaster();
|
|
13
13
|
const { open: openPanel } = useToggleAccordion();
|
|
14
14
|
const [isRealSpectrumShown, setIsRealSpectrumShown] = useState(false);
|
|
15
15
|
const debounceClickEventsRef = useRef({ clicks: [] });
|
|
@@ -22,7 +22,9 @@ export default function useToolsFunctions() {
|
|
|
22
22
|
options.exclusionZones.id,
|
|
23
23
|
options.rangePicking.id,
|
|
24
24
|
].includes(selectedTool)) {
|
|
25
|
-
|
|
25
|
+
toaster.show({
|
|
26
|
+
message: `Press ${!invert ? 'Shift +' : ''} Left Mouse button to select zone`,
|
|
27
|
+
});
|
|
26
28
|
}
|
|
27
29
|
if (Object.keys(TOOLS_PANELS_ACCORDION).includes(selectedTool)) {
|
|
28
30
|
openPanel(TOOLS_PANELS_ACCORDION[selectedTool]);
|
|
@@ -31,7 +33,7 @@ export default function useToolsFunctions() {
|
|
|
31
33
|
type: 'SET_SELECTED_TOOL',
|
|
32
34
|
payload: { selectedTool: selectedTool || options.zoom.id },
|
|
33
35
|
});
|
|
34
|
-
}, [
|
|
36
|
+
}, [dispatch, invert, openPanel, toaster]);
|
|
35
37
|
const handleFullZoomOut = useCallback(() => {
|
|
36
38
|
if (debounceClickEventsRef.current.clicks.length === 0) {
|
|
37
39
|
dispatch({
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { fileCollectionFromFileList } from 'filelist-utils';
|
|
5
5
|
import { read as readDropFiles } from 'nmr-load-save';
|
|
6
|
-
import { useCallback } from 'react';
|
|
6
|
+
import { useCallback, useState } from 'react';
|
|
7
7
|
import { useDropzone } from 'react-dropzone';
|
|
8
8
|
import { FaUpload } from 'react-icons/fa';
|
|
9
9
|
import { isMetaFile, parseMetaFile } from '../../data/parseMeta';
|
|
@@ -12,10 +12,10 @@ import { useDispatch } from '../context/DispatchContext';
|
|
|
12
12
|
import { LoaderProvider } from '../context/LoaderContext';
|
|
13
13
|
import { useLogger } from '../context/LoggerContext';
|
|
14
14
|
import { usePreferences } from '../context/PreferencesContext';
|
|
15
|
-
import {
|
|
15
|
+
import { useToaster } from '../context/ToasterContext';
|
|
16
16
|
import useCheckExperimentalFeature from '../hooks/useCheckExperimentalFeature';
|
|
17
17
|
import { useCheckToolsVisibility } from '../hooks/useCheckToolsVisibility';
|
|
18
|
-
import {
|
|
18
|
+
import { MetaImportationModal } from '../modal/metaImportation/MetaImportationModal';
|
|
19
19
|
const style = css `
|
|
20
20
|
height: 100%;
|
|
21
21
|
background-color: #b5b5b599;
|
|
@@ -24,7 +24,7 @@ const style = css `
|
|
|
24
24
|
justify-content: center;
|
|
25
25
|
align-items: center;
|
|
26
26
|
flex-flow: column;
|
|
27
|
-
z-index:
|
|
27
|
+
z-index: 8;
|
|
28
28
|
|
|
29
29
|
p {
|
|
30
30
|
color: white;
|
|
@@ -53,14 +53,14 @@ function DropZone(props) {
|
|
|
53
53
|
const { dispatch: dispatchPreferences, current: workspacePreferences } = usePreferences();
|
|
54
54
|
const preferences = usePreferences();
|
|
55
55
|
const isToolEnabled = useCheckToolsVisibility();
|
|
56
|
-
const
|
|
57
|
-
const alert = useAlert();
|
|
56
|
+
const toaster = useToaster();
|
|
58
57
|
const { logger } = useLogger();
|
|
59
58
|
const experimentalFeatures = useCheckExperimentalFeature();
|
|
59
|
+
const [metaInformationFile, openMetaInformationDialog] = useState();
|
|
60
60
|
async function loadFilesHandler(files) {
|
|
61
61
|
try {
|
|
62
62
|
if (files.length === 1 && isMetaFile(files[0])) {
|
|
63
|
-
|
|
63
|
+
openMetaInformationDialog(files[0]);
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
66
|
const fileCollection = await fileCollectionFromFileList(files);
|
|
@@ -98,7 +98,7 @@ function DropZone(props) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
catch (error) {
|
|
101
|
-
|
|
101
|
+
toaster.show({ message: error.message, intent: 'danger' });
|
|
102
102
|
logger.error(error);
|
|
103
103
|
}
|
|
104
104
|
finally {
|
|
@@ -121,11 +121,11 @@ function DropZone(props) {
|
|
|
121
121
|
openImportDialog();
|
|
122
122
|
}
|
|
123
123
|
}, [isImportEnabled, openImportDialog]);
|
|
124
|
-
return (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
return (_jsxs(LoaderProvider, { value: open, children: [metaInformationFile && (_jsx(MetaImportationModal, { isOpen: true, file: metaInformationFile, onCloseDialog: () => openMetaInformationDialog(null) })), _jsxs("div", { ...getRootProps(), role: "none", css: containerStyle, children: [_jsx("input", { ...getInputProps() }), isDragActive && (_jsxs("div", { css: style, style: {
|
|
125
|
+
width: `${width}px`,
|
|
126
|
+
height: `${height}px`,
|
|
127
|
+
marginTop: '30px',
|
|
128
|
+
marginLeft: '30px',
|
|
129
|
+
}, children: [_jsx(FaUpload, {}), _jsx("p", { children: "Drop your files here" })] })), props.children] })] }));
|
|
130
130
|
}
|
|
131
131
|
export default DropZone;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useReducer, useRef, useImperativeHandle, } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import { useFullscreen } from 'react-use';
|
|
3
|
+
import { useFullscreen } from 'react-science/ui';
|
|
5
4
|
import { AssignmentProvider } from '../assignment';
|
|
6
5
|
import { GlobalProvider } from '../context/GlobalContext';
|
|
7
6
|
import { KeyModifiersProvider } from '../context/KeyModifierContext';
|
|
8
7
|
import { LoggerProvider } from '../context/LoggerContext';
|
|
9
8
|
import { PreferencesProvider } from '../context/PreferencesContext';
|
|
9
|
+
import { ToasterProvider } from '../context/ToasterContext';
|
|
10
10
|
import { TopicMoleculeProvider } from '../context/TopicMoleculeContext';
|
|
11
|
-
import { AlertProvider } from '../elements/popup/Alert';
|
|
12
11
|
import { ModalProvider } from '../elements/popup/Modal';
|
|
13
12
|
import { HighlightProvider } from '../highlight';
|
|
14
13
|
import { defaultGetSpinner, SpinnerProvider } from '../loader/SpinnerContext';
|
|
@@ -20,15 +19,12 @@ export function InnerNMRium({ data: nmriumData, workspace, customWorkspaces, pre
|
|
|
20
19
|
const rootRef = useRef(null);
|
|
21
20
|
const elementsWrapperRef = useRef(null);
|
|
22
21
|
const viewerRef = useRef(null);
|
|
23
|
-
const [enableFullscreen, , disableFullscreen, toggleFullscreen] = useOnOff(false);
|
|
24
22
|
const mainDivRef = useRef(null);
|
|
25
|
-
const
|
|
26
|
-
onClose: disableFullscreen,
|
|
27
|
-
});
|
|
23
|
+
const { isFullScreen } = useFullscreen();
|
|
28
24
|
const [preferencesState, dispatchPreferences] = useReducer(preferencesReducer, preferencesInitialState, initPreferencesState);
|
|
29
25
|
useEffect(() => {
|
|
30
26
|
rootRef.current?.focus();
|
|
31
|
-
}, [
|
|
27
|
+
}, [isFullScreen]);
|
|
32
28
|
useEffect(() => {
|
|
33
29
|
dispatchPreferences({
|
|
34
30
|
type: 'INIT_PREFERENCES',
|
|
@@ -49,5 +45,5 @@ export function InnerNMRium({ data: nmriumData, workspace, customWorkspaces, pre
|
|
|
49
45
|
rootRef: rootRef.current,
|
|
50
46
|
elementsWrapperRef: elementsWrapperRef.current,
|
|
51
47
|
viewerRef: viewerRef.current,
|
|
52
|
-
}, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx(LoggerProvider, { children: _jsx(KeyModifiersProvider, { children: _jsx(
|
|
48
|
+
}, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx(LoggerProvider, { children: _jsx(KeyModifiersProvider, { children: _jsx(ToasterProvider, { children: _jsx(NMRiumStateProvider, { onChange: onChange, nmriumData: nmriumData, children: _jsx(TopicMoleculeProvider, { children: _jsx(ModalProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(HighlightProvider, { children: _jsx(AssignmentProvider, { children: _jsx(SpinnerProvider, { value: getSpinner, children: _jsx(InnerNMRiumContents, { emptyText: emptyText, mainDivRef: mainDivRef, elementsWrapperRef: elementsWrapperRef, rootRef: rootRef, viewerRef: viewerRef }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
53
49
|
}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
import { RefObject } from 'react';
|
|
3
3
|
import { NMRiumProps } from '.';
|
|
4
4
|
interface InnerNMRiumContentsProps {
|
|
5
|
-
isFullscreenEnabled: boolean;
|
|
6
|
-
toggleFullscreen: () => void;
|
|
7
5
|
emptyText: NMRiumProps['emptyText'];
|
|
8
6
|
mainDivRef: RefObject<HTMLDivElement>;
|
|
9
7
|
elementsWrapperRef: RefObject<HTMLDivElement>;
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/reac
|
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { useCallback } from 'react';
|
|
5
|
+
import { useFullscreen } from 'react-science/ui';
|
|
5
6
|
import checkModifierKeyActivated from '../../data/utilities/checkModifierKeyActivated';
|
|
6
7
|
import Viewer1D from '../1d/Viewer1D';
|
|
7
8
|
import FloatMoleculeStructures from '../1d-2d/components/FloatMoleculeStructures';
|
|
@@ -56,8 +57,9 @@ const containerStyles = css `
|
|
|
56
57
|
}
|
|
57
58
|
`;
|
|
58
59
|
export function InnerNMRiumContents(props) {
|
|
59
|
-
const {
|
|
60
|
+
const { emptyText, mainDivRef, elementsWrapperRef, rootRef, viewerRef } = props;
|
|
60
61
|
const { displayerMode } = useChartData();
|
|
62
|
+
const { isFullScreen } = useFullscreen();
|
|
61
63
|
const preventContextMenuHandler = useCallback((e) => {
|
|
62
64
|
if (!checkModifierKeyActivated(e)) {
|
|
63
65
|
e.preventDefault();
|
|
@@ -68,7 +70,7 @@ export function InnerNMRiumContents(props) {
|
|
|
68
70
|
flexDirection: 'column',
|
|
69
71
|
backgroundColor: 'white',
|
|
70
72
|
width: '100%',
|
|
71
|
-
}, children: [_jsx(Header, {
|
|
73
|
+
}, children: [_jsx(Header, {}), _jsxs("div", { style: {
|
|
72
74
|
display: 'flex',
|
|
73
75
|
flexDirection: 'row',
|
|
74
76
|
height: '100%',
|
|
@@ -84,5 +86,5 @@ export function InnerNMRiumContents(props) {
|
|
|
84
86
|
right: 0,
|
|
85
87
|
top: 0,
|
|
86
88
|
bottom: 0,
|
|
87
|
-
} }, String(
|
|
89
|
+
} }, String(isFullScreen))] })] }) }) })] }));
|
|
88
90
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { memo, forwardRef } from 'react';
|
|
3
3
|
import { ErrorBoundary, } from 'react-error-boundary';
|
|
4
|
-
import { RootLayout } from 'react-science/ui';
|
|
4
|
+
import { FullScreenProvider, RootLayout } from 'react-science/ui';
|
|
5
5
|
import ErrorOverlay from './ErrorOverlay';
|
|
6
6
|
import { InnerNMRium } from './InnerNMRium';
|
|
7
7
|
const NMRiumBase = forwardRef(function NMRium(props, ref) {
|
|
8
8
|
const { noErrorBoundary = false, onError, ...otherProps } = props;
|
|
9
9
|
const innerNmrium = _jsx(InnerNMRium, { ...otherProps, innerRef: ref });
|
|
10
10
|
const children = noErrorBoundary ? (innerNmrium) : (_jsx(ErrorBoundary, { FallbackComponent: ErrorOverlay, onError: onError, children: innerNmrium }));
|
|
11
|
-
return _jsx(RootLayout, { style: { width: '100%' }, children: children });
|
|
11
|
+
return (_jsx(FullScreenProvider, { children: _jsx(RootLayout, { style: { width: '100%' }, children: children }) }));
|
|
12
12
|
});
|
|
13
13
|
export const NMRium = memo(NMRiumBase);
|
|
@@ -40,6 +40,6 @@ const styles = css `
|
|
|
40
40
|
`;
|
|
41
41
|
function AboutPredictionModal() {
|
|
42
42
|
const [isOpenDialog, openDialog, closeDialog] = useOnOff(false);
|
|
43
|
-
return (_jsxs(_Fragment, { children: [_jsx(Toolbar
|
|
43
|
+
return (_jsxs(_Fragment, { children: [_jsx(Toolbar.Item, { icon: _jsx(FaInfo, {}), onClick: openDialog, title: "About Prediction" }), _jsx(Dialog, { isOpen: isOpenDialog, onClose: closeDialog, title: "About Prediction", style: { width: '600px' }, children: _jsxs(DialogBody, { css: styles, children: [_jsx("p", { children: "If you are using our tools please cite us:" }), _jsxs("ul", { children: [_jsxs("li", { children: ["Damiano Banfi and Luc Patiny", ' ', _jsx("a", { href: "http://dx.doi.org/10.2533/chimia.2008.280", target: "_blank", rel: "noreferrer", children: "www.nmrdb.org: Resurrecting and processing NMR spectra on-line" }), ' ', _jsx("i", { children: "Chimia" }), ", ", _jsx("b", { children: "2008" }), ", 62(4), 280-281."] }), _jsxs("li", { children: ["Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist", ' ', _jsx("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems" }), ' ', _jsx("i", { children: "Journal of Magnetic Resonance" }), " ", _jsx("b", { children: "2011" }), ", 209(2), 123-130."] })] }), _jsxs("p", { children: [_jsx("sup", { children: "1" }), "H NMR prediction is possible thanks to the tool of the FCT-Universidade NOVA de Lisboa developed by Yuri Binev and Joao Aires-de-Sousa:"] }), _jsxs("ul", { children: [_jsxs("li", { children: ["Yuri Binev, Maria M. B. Marques and Jo\u00E3o Aires-de-Sousa", ' ', _jsxs("a", { href: "http://dx.doi.org/10.1021/ci700172n", target: "_blank", rel: "noreferrer", children: ["Prediction of ", _jsx("sup", { children: "1" }), "H NMR coupling constants with associative neural networks trained for chemical shifts"] }), ' ', _jsx("i", { children: "J. Chem. Inf. Model." }), " ", _jsx("b", { children: "2007" }), ", 47(6), 2089-2097."] }), _jsxs("li", { children: ["Jo\u00E3o Aires-de-Sousa, Markus C. Hemmer and Johann Gasteiger", ' ', _jsxs("a", { href: "http://dx.doi.org/10.1021/ac010737m", target: "_blank", rel: "noreferrer", children: ["Prediction of ", _jsx("sup", { children: "1" }), "H NMR Chemical Shifts Using Neural Networks"] }), ", ", _jsx("i", { children: "Analytical Chemistry" }), ", ", _jsx("b", { children: "2002" }), ", 74(1), 80-90."] })] }), _jsxs("p", { children: [_jsx("sup", { children: "13" }), "C NMR prediction was possible thanks to NMRshiftDB:"] }), _jsx("ul", { children: _jsxs("li", { children: ["Steinbeck, Christoph, Stefan Krause, and Stefan Kuhn", ' ', _jsx("a", { href: "http://dx.doi.org/10.1021/ci0341363", target: "_blank", rel: "noreferrer", children: "NMRShiftDB Constructing a Free Chemical Information System with Open-Source Components" }), ' ', _jsx("i", { children: "Journal of chemical information and computer sciences" }), ",", ' ', _jsx("b", { children: "2003" }), ", 43(6): 1733-1739."] }) })] }) })] }));
|
|
44
44
|
}
|
|
45
45
|
export default AboutPredictionModal;
|
|
@@ -5,10 +5,10 @@ import { css } from '@emotion/react';
|
|
|
5
5
|
import { Formik } from 'formik';
|
|
6
6
|
import { useRef } from 'react';
|
|
7
7
|
import { DataExportStage, exportAsJcamp, } from '../../data/SpectraManager';
|
|
8
|
+
import { useToaster } from '../context/ToasterContext';
|
|
8
9
|
import ActionButtons from '../elements/ActionButtons';
|
|
9
10
|
import FormikCheckBox from '../elements/formik/FormikCheckBox';
|
|
10
11
|
import FormikSelect from '../elements/formik/FormikSelect';
|
|
11
|
-
import { useAlert } from '../elements/popup/Alert';
|
|
12
12
|
const initValues = {
|
|
13
13
|
onlyReal: true,
|
|
14
14
|
dataExportStage: 'PROCESSED',
|
|
@@ -41,21 +41,21 @@ const DATA_STAGES = Object.keys(DataExportStage).map((key) => ({
|
|
|
41
41
|
function ExportAsJcampModal(props) {
|
|
42
42
|
const { closeDialog, spectrum } = props;
|
|
43
43
|
const refForm = useRef(null);
|
|
44
|
-
const
|
|
44
|
+
const toaster = useToaster();
|
|
45
45
|
function submitHandler(options) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
46
|
+
const hideLoading = toaster.showLoading({
|
|
47
|
+
message: 'export as JCAMP-DX in progress',
|
|
48
|
+
});
|
|
49
|
+
try {
|
|
50
|
+
exportAsJcamp(spectrum, options);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
toaster.show({ message: error.message, intent: 'danger' });
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
closeDialog?.();
|
|
57
|
+
hideLoading();
|
|
58
|
+
}
|
|
59
59
|
}
|
|
60
60
|
return (_jsxs(Dialog, { isOpen: true, onClose: closeDialog, title: "Export as JCAMP", children: [_jsx(DialogBody, { css: css `
|
|
61
61
|
background-color: white;
|
|
@@ -7,11 +7,11 @@ import { resurrect } from 'nmr-processing';
|
|
|
7
7
|
import { useMemo, useRef, useState } from 'react';
|
|
8
8
|
import * as yup from 'yup';
|
|
9
9
|
import { useDispatch } from '../context/DispatchContext';
|
|
10
|
+
import { useToaster } from '../context/ToasterContext';
|
|
10
11
|
import Button from '../elements/Button';
|
|
11
12
|
import { GroupPane } from '../elements/GroupPane';
|
|
12
13
|
import ReactTable from '../elements/ReactTable/ReactTable';
|
|
13
14
|
import FormikTextarea from '../elements/formik/FormikTextarea';
|
|
14
|
-
import { useAlert } from '../elements/popup/Alert';
|
|
15
15
|
const validationSchema = yup.object({
|
|
16
16
|
publicationText: yup.string().required(),
|
|
17
17
|
});
|
|
@@ -33,7 +33,7 @@ function ImportPublicationStringModal(props) {
|
|
|
33
33
|
const { onClose, isOpen } = props;
|
|
34
34
|
const formRef = useRef();
|
|
35
35
|
const dispatch = useDispatch();
|
|
36
|
-
const
|
|
36
|
+
const toaster = useToaster();
|
|
37
37
|
const [logs, setLogs] = useState([]);
|
|
38
38
|
const loggerRef = useRef(new FifoLogger({
|
|
39
39
|
onChange: (log, logs) => {
|
|
@@ -63,7 +63,9 @@ function ImportPublicationStringModal(props) {
|
|
|
63
63
|
return;
|
|
64
64
|
function publicationStringHandler({ publicationText }) {
|
|
65
65
|
void (async () => {
|
|
66
|
-
const hideLoading =
|
|
66
|
+
const hideLoading = toaster.showLoading({
|
|
67
|
+
message: 'Generate spectrum from publication string in progress',
|
|
68
|
+
});
|
|
67
69
|
const { ranges, info: { nucleus, solvent = '', frequency }, parts, } = resurrect(publicationText, { logger: loggerRef.current });
|
|
68
70
|
setTimeout(() => {
|
|
69
71
|
dispatch({
|
|
@@ -7,11 +7,11 @@ import { readFromWebSource } from 'nmr-load-save';
|
|
|
7
7
|
import { useRef } from 'react';
|
|
8
8
|
import * as Yup from 'yup';
|
|
9
9
|
import { useDispatch } from '../context/DispatchContext';
|
|
10
|
+
import { useToaster } from '../context/ToasterContext';
|
|
10
11
|
import Button from '../elements/Button';
|
|
11
12
|
import Label from '../elements/Label';
|
|
12
13
|
import FormikError from '../elements/formik/FormikError';
|
|
13
14
|
import FormikInput from '../elements/formik/FormikInput';
|
|
14
|
-
import { useAlert } from '../elements/popup/Alert/Context';
|
|
15
15
|
const allowedExtensions = new Set(['dx', 'jdx', 'jcamp']);
|
|
16
16
|
const loadFormValidation = Yup.object({
|
|
17
17
|
url: Yup.string()
|
|
@@ -36,12 +36,14 @@ const labelStyle = {
|
|
|
36
36
|
};
|
|
37
37
|
export function LoadJCAMPModal({ onCloseDialog, isOpen }) {
|
|
38
38
|
const dispatch = useDispatch();
|
|
39
|
-
const
|
|
39
|
+
const toaster = useToaster();
|
|
40
40
|
const ref = useRef(null);
|
|
41
41
|
if (!isOpen)
|
|
42
42
|
return;
|
|
43
43
|
async function loadJCAMPHandler({ url }) {
|
|
44
|
-
const hidLoading =
|
|
44
|
+
const hidLoading = toaster.showLoading({
|
|
45
|
+
message: 'Load JCAMP from external URL in progress ...',
|
|
46
|
+
});
|
|
45
47
|
const { pathname, origin } = new URL(url);
|
|
46
48
|
try {
|
|
47
49
|
const nmriumState = await readFromWebSource({
|
|
@@ -53,7 +55,7 @@ export function LoadJCAMPModal({ onCloseDialog, isOpen }) {
|
|
|
53
55
|
});
|
|
54
56
|
}
|
|
55
57
|
catch {
|
|
56
|
-
|
|
58
|
+
toaster.show({ message: `Failed to load ${url}`, intent: 'danger' });
|
|
57
59
|
}
|
|
58
60
|
finally {
|
|
59
61
|
hidLoading();
|