nmrium 0.57.1 → 0.59.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/integral/IntegralResizable.js +2 -2
- package/lib/component/1d/matrix/useMatrix.d.ts +1 -1
- package/lib/component/1d/multiAnalysis/AnalysisRange.js +1 -1
- package/lib/component/1d/ranges/Atoms.js +6 -4
- package/lib/component/1d-2d/components/SpectrumInfoBlock.d.ts +1 -1
- package/lib/component/1d-2d/components/SpectrumInfoBlock.js +114 -7
- package/lib/component/2d/Viewer2D.js +6 -2
- package/lib/component/2d/zones/Zone.js +2 -2
- package/lib/component/EventsTrackers/KeysListenerTracker.js +8 -8
- package/lib/component/context/ChartContext.js +12 -1
- package/lib/component/context/ShareDataContext.d.ts +1 -1
- package/lib/component/context/ShareDataContext.js +2 -4
- package/lib/component/context/ToasterContext.d.ts +1 -0
- package/lib/component/context/ToasterContext.js +12 -3
- package/lib/component/elements/ActionsButtonsPopover.d.ts +7 -1
- package/lib/component/elements/ActionsButtonsPopover.js +7 -6
- package/lib/component/elements/Alert.d.ts +20 -0
- package/lib/component/elements/Alert.js +80 -0
- package/lib/component/elements/ContextMenuBluePrint.d.ts +7 -2
- package/lib/component/elements/ContextMenuBluePrint.js +9 -3
- package/lib/component/elements/Input2.js +2 -2
- package/lib/component/elements/Input2Controller.d.ts +4 -2
- package/lib/component/elements/Input2Controller.js +22 -6
- package/lib/component/elements/MoleculeSelection.js +2 -2
- package/lib/component/elements/NextPrev.d.ts +4 -5
- package/lib/component/elements/NextPrev.js +76 -79
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +1 -1
- package/lib/component/elements/ReactTable/ReactTableFlexLayout.d.ts +0 -3
- package/lib/component/elements/ReactTable/ReactTableFlexLayout.js +1 -1
- package/lib/component/elements/Select2.d.ts +12 -7
- package/lib/component/elements/Select2.js +5 -4
- package/lib/component/elements/Select2Controller.d.ts +2 -2
- package/lib/component/elements/Select2Controller.js +5 -5
- package/lib/component/elements/ToolbarPopoverItem.d.ts +7 -6
- package/lib/component/elements/ToolbarPopoverItem.js +13 -5
- package/lib/component/elements/print/PrintContent.d.ts +17 -0
- package/lib/component/elements/print/PrintContent.js +281 -0
- package/lib/component/elements/print/PrintProvider.d.ts +12 -0
- package/lib/component/elements/print/PrintProvider.js +28 -0
- package/lib/component/elements/print/index.d.ts +2 -0
- package/lib/component/elements/print/index.js +2 -0
- package/lib/component/header/ApodizationOptionsPanel.js +14 -7
- package/lib/component/header/BaseLineCorrectionPanel.js +20 -10
- package/lib/component/header/ZeroFillingOptionsPanel.js +17 -10
- package/lib/component/hooks/useSaveSettings.js +43 -26
- package/lib/component/hooks/useToggleSpectraVisibility.d.ts +14 -9
- package/lib/component/hooks/useToggleSpectraVisibility.js +45 -16
- package/lib/component/hooks/useWorkspaceAction.js +12 -14
- package/lib/component/loader/DropZone.js +3 -67
- package/lib/component/loader/useLoadFiles.d.ts +1 -0
- package/lib/component/loader/useLoadFiles.js +78 -0
- package/lib/component/main/InnerNMRium.d.ts +4 -3
- package/lib/component/main/InnerNMRium.js +4 -9
- package/lib/component/main/InnerNMRiumContents.d.ts +3 -2
- package/lib/component/main/InnerNMRiumContents.js +33 -29
- package/lib/component/main/NMRium.d.ts +2 -5
- package/lib/component/main/NMRium.js +1 -1
- package/lib/component/main/NMRiumRefAPI.d.ts +7 -0
- package/lib/component/main/NMRiumRefAPI.js +12 -0
- package/lib/component/main/NMRiumViewer.d.ts +10 -0
- package/lib/component/main/NMRiumViewer.js +35 -0
- package/lib/component/main/index.d.ts +1 -0
- package/lib/component/modal/CopyClipboardModal.d.ts +3 -2
- package/lib/component/modal/CopyClipboardModal.js +18 -32
- package/lib/component/modal/ExportAsJcampModal.d.ts +6 -3
- package/lib/component/modal/ExportAsJcampModal.js +69 -35
- package/lib/component/modal/ImportPublicationStringModal.js +1 -1
- package/lib/component/modal/LoadJCAMPModal.d.ts +3 -1
- package/lib/component/modal/LoadJCAMPModal.js +17 -18
- package/lib/component/modal/SaveAsModal.d.ts +3 -1
- package/lib/component/modal/SaveAsModal.js +20 -30
- package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
- package/lib/component/modal/changeSum/ChangeSumModalContents.js +35 -47
- package/lib/component/modal/changeSum/SelectMolecule.d.ts +2 -5
- package/lib/component/modal/changeSum/SelectMolecule.js +9 -8
- package/lib/component/modal/setting/GeneralSettings.js +4 -2
- package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.d.ts +1 -0
- package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.js +89 -0
- package/lib/component/modal/setting/settingsValidation.js +15 -1
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +8 -5
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +5 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanel.js +5 -3
- package/lib/component/panels/Panels.js +15 -15
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +8 -5
- package/lib/component/panels/RangesPanel/RangesHeader.js +52 -12
- package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +13 -6
- package/lib/component/panels/SpectraPanel/SpectraTable.js +63 -21
- package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnHeader.js +6 -2
- package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +6 -2
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +4 -0
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +16 -8
- package/lib/component/panels/databasePanel/DatabasePanel.js +7 -8
- package/lib/component/panels/filtersPanel/FilterPanel.js +9 -6
- package/lib/component/panels/filtersPanel/FiltersTable.js +12 -10
- package/lib/component/panels/header/DefaultPanelHeader.d.ts +1 -0
- package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
- package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +10 -12
- package/lib/component/panels/predictionPanel/PredictionPanel.js +2 -2
- package/lib/component/reducer/IgnoreActions.js +1 -0
- package/lib/component/reducer/Reducer.js +2 -4
- package/lib/component/reducer/actions/DatabaseActions.d.ts +15 -13
- package/lib/component/reducer/actions/DatabaseActions.js +52 -34
- package/lib/component/reducer/actions/DomainActions.d.ts +2 -2
- package/lib/component/reducer/actions/FiltersActions.js +9 -4
- package/lib/component/reducer/actions/SpectraActions.d.ts +2 -1
- package/lib/component/reducer/actions/SpectraActions.js +53 -43
- package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.d.ts +3 -0
- package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.js +16 -0
- package/lib/component/reducer/preferences/actions/changeInformationBlockPosition.d.ts +3 -0
- package/lib/component/reducer/preferences/actions/changeInformationBlockPosition.js +5 -0
- package/lib/component/reducer/preferences/actions/changePrintPageSettings.d.ts +3 -0
- package/lib/component/reducer/preferences/actions/changePrintPageSettings.js +6 -0
- package/lib/component/reducer/preferences/actions/toggleInformationBlock.d.ts +3 -0
- package/lib/component/reducer/preferences/actions/toggleInformationBlock.js +7 -0
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +12 -2
- package/lib/component/reducer/preferences/preferencesReducer.js +9 -0
- package/lib/component/toolbar/ToolBar.js +33 -14
- package/lib/component/workspaces/workspaceDefaultProperties.js +2 -0
- package/lib/data/SpectraManager.d.ts +7 -10
- package/lib/data/SpectraManager.js +51 -30
- package/lib/data/data1d/Spectrum1D/SumManager.d.ts +0 -1
- package/lib/data/data1d/Spectrum1D/SumManager.js +2 -10
- package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/index.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/index.js +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +10 -10
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +2 -1
- package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +10 -10
- package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +10 -10
- package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.d.ts +13 -0
- package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.js +65 -0
- package/lib/data/molecules/MoleculeManager.js +16 -38
- package/lib/data/utilities/getCustomColor.d.ts +1 -1
- package/lib/data/utilities/removeByPaths.d.ts +3 -0
- package/lib/data/utilities/removeByPaths.js +33 -0
- package/lib/versionInfo.js +1 -1
- package/package.json +36 -36
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.d.ts +0 -11
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +0 -29
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Classes } from '@blueprintjs/core';
|
|
3
|
+
import { EXTERNAL_API_KEYS } from 'nmr-load-save';
|
|
4
|
+
import { useCallback, useMemo } from 'react';
|
|
5
|
+
import { useFormContext, useWatch } from 'react-hook-form';
|
|
6
|
+
import { FaPlus, FaRegTrashAlt } from 'react-icons/fa';
|
|
7
|
+
import { Button } from 'react-science/ui';
|
|
8
|
+
import { GroupPane } from '../../../elements/GroupPane';
|
|
9
|
+
import { Input2Controller } from '../../../elements/Input2Controller';
|
|
10
|
+
import ReactTable from '../../../elements/ReactTable/ReactTable';
|
|
11
|
+
import { Select2Controller } from '../../../elements/Select2Controller';
|
|
12
|
+
import { Section } from '../GeneralSettings';
|
|
13
|
+
function getKeyPath(index, key) {
|
|
14
|
+
return `externalAPIs.${index}.${key}`;
|
|
15
|
+
}
|
|
16
|
+
export function ExternalAPIsTabContent() {
|
|
17
|
+
const { control, setValue } = useFormContext();
|
|
18
|
+
const fields = useWatch({
|
|
19
|
+
name: 'externalAPIs',
|
|
20
|
+
}) || [];
|
|
21
|
+
const addHandler = useCallback((data, index) => {
|
|
22
|
+
let columns = [];
|
|
23
|
+
const emptyField = {
|
|
24
|
+
key: '',
|
|
25
|
+
serverLink: '',
|
|
26
|
+
APIKey: '',
|
|
27
|
+
};
|
|
28
|
+
if (data && Array.isArray(data)) {
|
|
29
|
+
columns = [...data.slice(0, index), emptyField, ...data.slice(index)];
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
columns.push(emptyField);
|
|
33
|
+
}
|
|
34
|
+
setValue('externalAPIs', columns);
|
|
35
|
+
}, [setValue]);
|
|
36
|
+
const deleteHandler = useCallback((data, index) => {
|
|
37
|
+
const _fields = data.filter((_, columnIndex) => columnIndex !== index);
|
|
38
|
+
setValue('externalAPIs', _fields);
|
|
39
|
+
}, [setValue]);
|
|
40
|
+
const COLUMNS = useMemo(() => [
|
|
41
|
+
{
|
|
42
|
+
Header: '#',
|
|
43
|
+
style: { width: '25px', textAlign: 'center' },
|
|
44
|
+
accessor: (_, index) => index + 1,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
Header: 'Service',
|
|
48
|
+
Cell: ({ row }) => {
|
|
49
|
+
const name = getKeyPath(row.index, 'key');
|
|
50
|
+
return (_jsx(Select2Controller, { placeholder: "Select API provider", control: control, name: name, items: [...EXTERNAL_API_KEYS], itemTextKey: "description", itemValueKey: "key", fill: true }));
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
Header: 'Server link',
|
|
55
|
+
Cell: ({ row }) => {
|
|
56
|
+
const name = getKeyPath(row.index, 'serverLink');
|
|
57
|
+
return (_jsx(Input2Controller, { control: control, name: name, noShadowBox: true, style: { backgroundColor: 'transparent' } }));
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
Header: 'API key',
|
|
62
|
+
Cell: ({ row }) => {
|
|
63
|
+
const name = getKeyPath(row.index, 'APIKey');
|
|
64
|
+
return (_jsx(Input2Controller, { control: control, name: name, noShadowBox: true, style: { backgroundColor: 'transparent' } }));
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
Header: '',
|
|
69
|
+
style: { width: '60px' },
|
|
70
|
+
id: 'op-buttons',
|
|
71
|
+
Cell: ({ data, row }) => {
|
|
72
|
+
const record = row.original;
|
|
73
|
+
return (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-evenly' }, children: [_jsx(Button, { small: true, intent: "success", outlined: true, onClick: () => addHandler(data, row.index + 1), children: _jsx(FaPlus, { className: Classes.ICON }) }), !record?.name && (_jsx(Button, { small: true, outlined: true, intent: "danger", onClick: () => deleteHandler(data, row.index), children: _jsx(FaRegTrashAlt, { className: Classes.ICON }) }))] }));
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
], [addHandler, control, deleteHandler]);
|
|
77
|
+
return (_jsx(GroupPane, { text: "External APIs", renderHeader: (text) => {
|
|
78
|
+
return _jsx(Header, { text: text, onAdd: () => addHandler(fields, 0) });
|
|
79
|
+
}, children: _jsx(ReactTable, { style: {
|
|
80
|
+
'thead tr th': { zIndex: 1 },
|
|
81
|
+
td: { padding: 0 },
|
|
82
|
+
}, rowStyle: {
|
|
83
|
+
hover: { backgroundColor: '#f7f7f7' },
|
|
84
|
+
active: { backgroundColor: '#f5f5f5' },
|
|
85
|
+
}, data: fields, columns: COLUMNS, emptyDataRowText: "No external APIs" }) }));
|
|
86
|
+
}
|
|
87
|
+
function Header({ onAdd, text }) {
|
|
88
|
+
return (_jsxs(Section, { children: [_jsx("p", { style: { flex: 1 }, children: text }), _jsx(Button, { outlined: true, small: true, intent: "success", tooltipProps: { content: '', disabled: true }, onClick: onAdd, children: "Add an external API" })] }));
|
|
89
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EXTERNAL_API_KEYS } from 'nmr-load-save';
|
|
2
|
+
import { array, object, string, number, mixed } from 'yup';
|
|
2
3
|
import { checkUniqueByKey } from '../../utility/checkUniqueByKey';
|
|
3
4
|
const nucleiValidation = array()
|
|
4
5
|
.of(object().shape({
|
|
@@ -35,10 +36,23 @@ const spectraColorsSchemaValidation = object({
|
|
|
35
36
|
const generalValidation = object({
|
|
36
37
|
dimmedSpectraOpacity: number().min(0).max(1).required(),
|
|
37
38
|
});
|
|
39
|
+
const externalAPIsValidation = array()
|
|
40
|
+
.of(object({
|
|
41
|
+
key: mixed()
|
|
42
|
+
.oneOf(EXTERNAL_API_KEYS.map(({ key }) => key))
|
|
43
|
+
.required(),
|
|
44
|
+
serverLink: string().url().required(),
|
|
45
|
+
APIKey: string().required(),
|
|
46
|
+
}))
|
|
47
|
+
.test('Unique', 'External API provider need te be unique', function check(apis) {
|
|
48
|
+
// eslint-disable-next-line no-invalid-this
|
|
49
|
+
return checkUniqueByKey(apis, 'key', this);
|
|
50
|
+
});
|
|
38
51
|
export const validation = object().shape({
|
|
39
52
|
nuclei: nucleiValidation,
|
|
40
53
|
databases: databasesValidation,
|
|
41
54
|
infoBlock: infoBlockValidation,
|
|
42
55
|
general: generalValidation,
|
|
43
56
|
spectraColors: spectraColorsSchemaValidation,
|
|
57
|
+
externalAPIs: externalAPIsValidation,
|
|
44
58
|
});
|
|
@@ -7,7 +7,7 @@ import { useCallback, useMemo, useState, useRef, memo } from 'react';
|
|
|
7
7
|
import { ImLink } from 'react-icons/im';
|
|
8
8
|
import { useChartData } from '../../context/ChartContext';
|
|
9
9
|
import { useDispatch } from '../../context/DispatchContext';
|
|
10
|
-
import {
|
|
10
|
+
import { useAlert } from '../../elements/Alert';
|
|
11
11
|
import { useActiveSpectrumIntegralsViewState } from '../../hooks/useActiveSpectrumIntegralsViewState';
|
|
12
12
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
13
13
|
import ChangeSumModal from '../../modal/changeSum/ChangeSumModal';
|
|
@@ -21,7 +21,7 @@ function IntegralPanelInner({ integrals, info, activeTab, xDomain, }) {
|
|
|
21
21
|
const [filterIsActive, setFilterIsActive] = useState(false);
|
|
22
22
|
const dispatch = useDispatch();
|
|
23
23
|
const { showIntegralsValues } = useActiveSpectrumIntegralsViewState();
|
|
24
|
-
const
|
|
24
|
+
const alert = useAlert();
|
|
25
25
|
const [isFlipped, setFlipStatus] = useState(false);
|
|
26
26
|
const settingRef = useRef();
|
|
27
27
|
function handleShowIntegralsValues() {
|
|
@@ -34,11 +34,14 @@ function IntegralPanelInner({ integrals, info, activeTab, xDomain, }) {
|
|
|
34
34
|
dispatch({ type: 'DELETE_INTEGRAL', payload: {} });
|
|
35
35
|
}, [dispatch]);
|
|
36
36
|
const handleDeleteAll = useCallback(() => {
|
|
37
|
-
|
|
37
|
+
alert.showAlert({
|
|
38
38
|
message: 'All records will be deleted, Are You sure?',
|
|
39
|
-
buttons: [
|
|
39
|
+
buttons: [
|
|
40
|
+
{ text: 'Yes', onClick: yesHandler, intent: 'danger' },
|
|
41
|
+
{ text: 'No' },
|
|
42
|
+
],
|
|
40
43
|
});
|
|
41
|
-
}, [
|
|
44
|
+
}, [alert, yesHandler]);
|
|
42
45
|
const changeIntegralSumHandler = useCallback((options) => {
|
|
43
46
|
dispatch({ type: 'CHANGE_INTEGRAL_SUM', payload: { options } });
|
|
44
47
|
}, [dispatch]);
|
|
@@ -92,7 +92,11 @@ function InnerMatrixGenerationPanel() {
|
|
|
92
92
|
const dispatch = useDispatch();
|
|
93
93
|
const { dispatch: dispatchPreferences } = usePreferences();
|
|
94
94
|
const { view: { spectra: { activeTab }, }, xDomain, originDomain, data, } = useChartData();
|
|
95
|
-
const { getToggleVisibilityButtons } = useToggleSpectraVisibility(
|
|
95
|
+
const { getToggleVisibilityButtons } = useToggleSpectraVisibility({
|
|
96
|
+
enableHideSelected: false,
|
|
97
|
+
enableShowSelected: false,
|
|
98
|
+
enableShowSelectedOnly: false,
|
|
99
|
+
});
|
|
96
100
|
const formRef = useRef(null);
|
|
97
101
|
const nucleusMatrixOptions = usePanelPreferences('matrixGeneration', activeTab);
|
|
98
102
|
const spectraPreferences = usePanelPreferences('spectra', activeTab);
|
|
@@ -7,7 +7,7 @@ import { ResponsiveChart } from 'react-d3-utils';
|
|
|
7
7
|
import OCLnmr from 'react-ocl-nmr';
|
|
8
8
|
import { useChartData } from '../../context/ChartContext';
|
|
9
9
|
import { useDispatch } from '../../context/DispatchContext';
|
|
10
|
-
import NextPrev from '../../elements/NextPrev';
|
|
10
|
+
import { NextPrev } from '../../elements/NextPrev';
|
|
11
11
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
12
12
|
import { useMoleculeEditor } from '../../modal/MoleculeStructureEditorModal';
|
|
13
13
|
import MoleculeHeader from './MoleculeHeader';
|
|
@@ -69,8 +69,10 @@ function MoleculePanelInner(props) {
|
|
|
69
69
|
function moleculeIndexHandler(index) {
|
|
70
70
|
setCurrentIndex(index);
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
const lastIndex = molecules?.length > 0 ? molecules.length - 1 : 0;
|
|
73
|
+
const activeIndex = currentIndex > lastIndex ? lastIndex : currentIndex;
|
|
74
|
+
return (_jsxs("div", { css: styles.panel, children: [_jsx(MoleculePanelHeader, { currentIndex: activeIndex, moleculesView: moleculesView, molecules: molecules, onOpenMoleculeEditor: () => openMoleculeEditor(), onMoleculeIndexChange: moleculeIndexHandler }), _jsx("div", { css: styles.innerPanel, children: _jsx("div", { css: styles.molecule, children: _jsx(ResponsiveChart, { children: ({ height, width }) => {
|
|
75
|
+
return (_jsx(NextPrev, { onChange: (slideIndex) => setCurrentIndex(slideIndex), index: currentIndex, children: molecules && molecules.length > 0 ? (molecules.map((mol, index) => (_jsxs("div", { css: styles.items, children: [_jsx(MoleculeHeader, { currentMolecule: mol, molecules: molecules }), _jsx("div", { css: styles.slider, className: "mol-svg-container", onDoubleClick: () => openMoleculeEditor(mol), style: {
|
|
74
76
|
backgroundColor: (index + 1) % 2 !== 0 ? '#fafafa' : 'white',
|
|
75
77
|
}, children: _jsx(OCLnmr, { OCL: OCL, id: `molSVG${index}`, width: width, height: height - 60, molfile: mol.molfile || '', setMolfile: (molfile) => handleReplaceMolecule(mol, molfile), setSelectedAtom: handleOnClickAtom, atomHighlightColor: currentDiaIDsToHighlight &&
|
|
76
78
|
currentDiaIDsToHighlight.length > 0
|
|
@@ -5,6 +5,7 @@ import { FaRegEdit } from 'react-icons/fa';
|
|
|
5
5
|
import { Accordion, Toolbar, } from 'react-science/ui';
|
|
6
6
|
import { useChartData } from '../context/ChartContext';
|
|
7
7
|
import { usePreferences } from '../context/PreferencesContext';
|
|
8
|
+
import { useActiveSpectrum } from '../hooks/useActiveSpectrum';
|
|
8
9
|
import useCheckExperimentalFeature from '../hooks/useCheckExperimentalFeature';
|
|
9
10
|
import { useDialogToggle } from '../hooks/useDialogToggle';
|
|
10
11
|
import AutomaticAssignment from './AutomaticAssignment/AutomaticAssignment';
|
|
@@ -57,7 +58,7 @@ const accordionItems = [
|
|
|
57
58
|
mode: '1D',
|
|
58
59
|
},
|
|
59
60
|
{
|
|
60
|
-
title: 'Ranges',
|
|
61
|
+
title: 'Ranges / Multiplet analysis',
|
|
61
62
|
component: _jsx(RangesPanel, {}),
|
|
62
63
|
hidePreferenceKey: 'rangesPanel',
|
|
63
64
|
mode: '1D',
|
|
@@ -121,7 +122,7 @@ export const TOOLS_PANELS_ACCORDION = {
|
|
|
121
122
|
null: 'Spectra',
|
|
122
123
|
peakPicking: 'Peaks',
|
|
123
124
|
integral: 'Integrals',
|
|
124
|
-
rangePicking: 'Ranges',
|
|
125
|
+
rangePicking: 'Ranges / Multiplet analysis',
|
|
125
126
|
zonePicking: 'Zones',
|
|
126
127
|
multipleSpectraAnalysis: 'Multiple Spectra Analysis',
|
|
127
128
|
};
|
|
@@ -158,26 +159,25 @@ function PanelsInner({ displayerMode: displayedMode }) {
|
|
|
158
159
|
const panelOptions = getPanelPreferences(item);
|
|
159
160
|
return panelOptions?.display && panelOptions?.open;
|
|
160
161
|
}
|
|
161
|
-
const toolbars = {
|
|
162
|
-
informationPanel: [
|
|
163
|
-
{
|
|
164
|
-
icon: _jsx(FaRegEdit, {}),
|
|
165
|
-
onClick: ({ event }) => {
|
|
166
|
-
event.stopPropagation();
|
|
167
|
-
openDialog('informationModal');
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
};
|
|
172
162
|
return (_jsxs("div", { style: { width: '100%', height: '100%', flex: '1 1 0%' }, children: [_jsx(InformationEditionModal, { isOpen: dialog.informationModal, onCloseDialog: closeDialog }), _jsx(Accordion, { children: accordionItems.map((item) => {
|
|
173
163
|
const { title, component, id } = item;
|
|
174
164
|
let toolbar;
|
|
175
|
-
if (id
|
|
176
|
-
toolbar = (_jsx(
|
|
165
|
+
if (id === 'informationPanel') {
|
|
166
|
+
toolbar = (_jsx(InformationPanelToolBar, { onEdit: ({ event }) => {
|
|
167
|
+
event.stopPropagation();
|
|
168
|
+
openDialog('informationModal');
|
|
169
|
+
} }));
|
|
177
170
|
}
|
|
178
171
|
return (check(item) && (_jsx(Accordion.Item, { title: title, defaultOpened: isOpened(item), toolbar: toolbar, children: component }, title)));
|
|
179
172
|
}) })] }));
|
|
180
173
|
}
|
|
174
|
+
function InformationPanelToolBar(props) {
|
|
175
|
+
const { onEdit } = props;
|
|
176
|
+
const activeSpectrum = useActiveSpectrum();
|
|
177
|
+
return (_jsx(Toolbar, { children: _jsx(Toolbar.Item, { disabled: !activeSpectrum, tooltipProps: { intent: !activeSpectrum ? 'danger' : 'none' }, icon: _jsx(FaRegEdit, {}), onClick: onEdit, tooltip: !activeSpectrum
|
|
178
|
+
? 'Select a spectrum to edit its meta information'
|
|
179
|
+
: 'Edit spectrum meta information' }) }));
|
|
180
|
+
}
|
|
181
181
|
const MemoizedPanels = memo(PanelsInner);
|
|
182
182
|
export default function Panels() {
|
|
183
183
|
const { displayerMode, toolOptions: { selectedTool }, } = useChartData();
|
|
@@ -10,7 +10,7 @@ import { useChartData } from '../../context/ChartContext';
|
|
|
10
10
|
import { useDispatch } from '../../context/DispatchContext';
|
|
11
11
|
import { usePreferences } from '../../context/PreferencesContext';
|
|
12
12
|
import { useToaster } from '../../context/ToasterContext';
|
|
13
|
-
import {
|
|
13
|
+
import { useAlert } from '../../elements/Alert';
|
|
14
14
|
import { useActiveSpectrumPeaksViewState } from '../../hooks/useActiveSpectrumPeaksViewState';
|
|
15
15
|
import useCheckExperimentalFeature from '../../hooks/useCheckExperimentalFeature';
|
|
16
16
|
import { useFormatNumberByNucleus } from '../../hooks/useFormatNumberByNucleus';
|
|
@@ -26,7 +26,7 @@ function PeaksPanelInner({ peaks, info, xDomain, activeTab, peaksViewState, }) {
|
|
|
26
26
|
const [isFlipped, setFlipStatus] = useState(false);
|
|
27
27
|
const format = useFormatNumberByNucleus(info.nucleus);
|
|
28
28
|
const dispatch = useDispatch();
|
|
29
|
-
const
|
|
29
|
+
const alert = useAlert();
|
|
30
30
|
const toaster = useToaster();
|
|
31
31
|
const isExperimental = useCheckExperimentalFeature();
|
|
32
32
|
const settingRef = useRef();
|
|
@@ -34,11 +34,14 @@ function PeaksPanelInner({ peaks, info, xDomain, activeTab, peaksViewState, }) {
|
|
|
34
34
|
dispatch({ type: 'DELETE_PEAK', payload: {} });
|
|
35
35
|
}, [dispatch]);
|
|
36
36
|
const handleDeleteAll = useCallback(() => {
|
|
37
|
-
|
|
37
|
+
alert.showAlert({
|
|
38
38
|
message: 'All records will be deleted, Are You sure?',
|
|
39
|
-
buttons: [
|
|
39
|
+
buttons: [
|
|
40
|
+
{ text: 'Yes', onClick: yesHandler, intent: 'danger' },
|
|
41
|
+
{ text: 'No' },
|
|
42
|
+
],
|
|
40
43
|
});
|
|
41
|
-
}, [
|
|
44
|
+
}, [alert, yesHandler]);
|
|
42
45
|
const settingsPanelHandler = useCallback(() => {
|
|
43
46
|
setFlipStatus(!isFlipped);
|
|
44
47
|
}, [isFlipped]);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { SvgNmrIntegrate, SvgNmrPeaks, SvgNmrPeaksTopLabels, } from 'cheminfo-font';
|
|
3
|
+
import { saveAs } from 'file-saver';
|
|
3
4
|
import lodashGet from 'lodash/get';
|
|
4
|
-
import { rangesToACS } from 'nmr-processing';
|
|
5
|
-
import {
|
|
5
|
+
import { rangesToACS, rangesToTSV } from 'nmr-processing';
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
import { FaFileExport, FaUnlink, FaSitemap, FaChartBar, FaCopy, FaDownload, } from 'react-icons/fa';
|
|
6
8
|
import { ImLink } from 'react-icons/im';
|
|
7
9
|
import { LuSubtitles } from 'react-icons/lu';
|
|
8
10
|
import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
|
|
@@ -10,6 +12,8 @@ import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
|
|
|
10
12
|
import { useAssignmentData } from '../../assignment/AssignmentsContext';
|
|
11
13
|
import { useDispatch } from '../../context/DispatchContext';
|
|
12
14
|
import { useToaster } from '../../context/ToasterContext';
|
|
15
|
+
import { useAlert } from '../../elements/Alert';
|
|
16
|
+
import { ToolbarPopoverItem, } from '../../elements/ToolbarPopoverItem';
|
|
13
17
|
import { useModal } from '../../elements/popup/Modal';
|
|
14
18
|
import { useActiveSpectrumRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
|
|
15
19
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
@@ -17,13 +21,31 @@ import CopyClipboardModal from '../../modal/CopyClipboardModal';
|
|
|
17
21
|
import ChangeSumModal from '../../modal/changeSum/ChangeSumModal';
|
|
18
22
|
import { booleanToString } from '../../utility/booleanToString';
|
|
19
23
|
import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
24
|
+
const EXPORT_MENU = [
|
|
25
|
+
{
|
|
26
|
+
icon: _jsx(FaCopy, {}),
|
|
27
|
+
text: 'Preview publication string',
|
|
28
|
+
data: {
|
|
29
|
+
id: 'publicationString',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
icon: _jsx(FaDownload, {}),
|
|
34
|
+
text: 'Export ranges as TSV',
|
|
35
|
+
data: {
|
|
36
|
+
id: 'rangesToTSV',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
];
|
|
20
40
|
function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClick, isFilterActive, filterCounter, activeTab, }) {
|
|
21
41
|
const dispatch = useDispatch();
|
|
22
42
|
const modal = useModal();
|
|
43
|
+
const alert = useAlert();
|
|
23
44
|
const toaster = useToaster();
|
|
24
45
|
const assignmentData = useAssignmentData();
|
|
25
46
|
const currentSum = lodashGet(ranges, 'options.sum', null);
|
|
26
47
|
const rangesPreferences = usePanelPreferences('ranges', activeTab);
|
|
48
|
+
const [acs, setACS] = useState();
|
|
27
49
|
const { showMultiplicityTrees, showJGraph, showIntegrals, showIntegralsValues, showPeaks, displayingMode, showAssignmentsLabels, } = useActiveSpectrumRangesViewState();
|
|
28
50
|
function changeRangesSumHandler(options) {
|
|
29
51
|
dispatch({ type: 'CHANGE_RANGE_SUM', payload: { options } });
|
|
@@ -33,23 +55,27 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
|
|
|
33
55
|
onUnlink();
|
|
34
56
|
}
|
|
35
57
|
function handleOnRemoveAssignments() {
|
|
36
|
-
|
|
58
|
+
alert.showAlert({
|
|
37
59
|
message: 'All assignments will be removed. Are you sure?',
|
|
38
|
-
buttons: [
|
|
60
|
+
buttons: [
|
|
61
|
+
{ text: 'Yes', onClick: removeAssignments, intent: 'danger' },
|
|
62
|
+
{ text: 'No' },
|
|
63
|
+
],
|
|
39
64
|
});
|
|
40
65
|
}
|
|
41
66
|
function handleDeleteAll() {
|
|
42
|
-
|
|
67
|
+
alert.showAlert({
|
|
43
68
|
message: 'All ranges will be deleted. Are You sure?',
|
|
44
69
|
buttons: [
|
|
45
70
|
{
|
|
46
71
|
text: 'Yes',
|
|
47
|
-
|
|
72
|
+
onClick: () => {
|
|
48
73
|
dispatch({
|
|
49
74
|
type: 'DELETE_RANGE',
|
|
50
75
|
payload: { assignmentData },
|
|
51
76
|
});
|
|
52
77
|
},
|
|
78
|
+
intent: 'danger',
|
|
53
79
|
},
|
|
54
80
|
{ text: 'No' },
|
|
55
81
|
],
|
|
@@ -98,7 +124,7 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
|
|
|
98
124
|
couplingFormat: rangesPreferences.coupling.format,
|
|
99
125
|
observedFrequency, //400
|
|
100
126
|
});
|
|
101
|
-
|
|
127
|
+
setACS(result);
|
|
102
128
|
}
|
|
103
129
|
}
|
|
104
130
|
function changeSumConstantFlagHandler() {
|
|
@@ -112,14 +138,28 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
|
|
|
112
138
|
function toggleDisplayingMode() {
|
|
113
139
|
dispatch({ type: 'TOGGLE_RANGES_PEAKS_DISPLAYING_MODE' });
|
|
114
140
|
}
|
|
141
|
+
function handleRangesToTSV() {
|
|
142
|
+
const tsv = rangesToTSV(ranges.values);
|
|
143
|
+
const blob = new Blob([tsv], { type: 'text/plain' });
|
|
144
|
+
saveAs(blob, `${info.name}.tsv`);
|
|
145
|
+
}
|
|
146
|
+
function exportHandler(data) {
|
|
147
|
+
switch (data?.id) {
|
|
148
|
+
case 'publicationString':
|
|
149
|
+
saveAsHTMLHandler();
|
|
150
|
+
break;
|
|
151
|
+
case 'rangesToTSV':
|
|
152
|
+
handleRangesToTSV();
|
|
153
|
+
break;
|
|
154
|
+
default:
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
115
158
|
const hasRanges = Array.isArray(ranges?.values) && ranges.values.length > 0;
|
|
116
159
|
const total = ranges?.values?.length || 0;
|
|
117
|
-
return (_jsxs("div", { children: [_jsx(DefaultPanelHeader, { total: total, counter: filterCounter, onDelete: handleDeleteAll, deleteToolTip: "Delete All Ranges", onFilter: onFilterActivated, filterToolTip: isFilterActive ? 'Show all ranges' : 'Hide ranges out of view', onSettingClick: onSettingClick, leftButtons: [
|
|
160
|
+
return (_jsxs("div", { children: [_jsx(CopyClipboardModal, { text: acs, title: "Publication string", onCopyClick: saveToClipboardHandler, onClose: () => setACS('') }), _jsx(DefaultPanelHeader, { total: total, counter: filterCounter, onDelete: handleDeleteAll, deleteToolTip: "Delete All Ranges", onFilter: onFilterActivated, filterToolTip: isFilterActive ? 'Show all ranges' : 'Hide ranges out of view', onSettingClick: onSettingClick, leftButtons: [
|
|
118
161
|
{
|
|
119
|
-
disabled: !hasRanges,
|
|
120
|
-
icon: _jsx(FaFileExport, {}),
|
|
121
|
-
tooltip: 'Preview publication string',
|
|
122
|
-
onClick: saveAsHTMLHandler,
|
|
162
|
+
component: (_jsx(ToolbarPopoverItem, { disabled: !hasRanges, icon: _jsx(FaFileExport, {}), tooltip: "Export as", options: EXPORT_MENU, onClick: exportHandler })),
|
|
123
163
|
},
|
|
124
164
|
{
|
|
125
165
|
component: (_jsx(ChangeSumModal, { onSave: changeRangesSumHandler, sumType: "ranges", currentSum: currentSum, sumOptions: ranges?.options })),
|
|
@@ -8,7 +8,7 @@ import { useChartData } from '../../context/ChartContext';
|
|
|
8
8
|
import { useDispatch } from '../../context/DispatchContext';
|
|
9
9
|
import { usePreferences } from '../../context/PreferencesContext';
|
|
10
10
|
import { useToaster } from '../../context/ToasterContext';
|
|
11
|
-
import {
|
|
11
|
+
import { useAlert } from '../../elements/Alert';
|
|
12
12
|
import { useActiveSpectra } from '../../hooks/useActiveSpectra';
|
|
13
13
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
14
14
|
import { useToggleSpectraVisibility } from '../../hooks/useToggleSpectraVisibility';
|
|
@@ -28,25 +28,25 @@ function getMissingProjection(spectraData, activeTab) {
|
|
|
28
28
|
return missingNucleus;
|
|
29
29
|
}
|
|
30
30
|
function SpectraPanelHeaderInner({ data, activeSpectrum, activeSpectra, activeTab, displayerMode, onSettingClick, }) {
|
|
31
|
-
const
|
|
31
|
+
const alert = useAlert();
|
|
32
32
|
const toaster = useToaster();
|
|
33
33
|
const dispatch = useDispatch();
|
|
34
|
-
const { getToggleVisibilityButtons } = useToggleSpectraVisibility('selected');
|
|
35
34
|
const { current: { spectraColors }, } = usePreferences();
|
|
36
35
|
const handleDelete = useCallback(() => {
|
|
37
|
-
|
|
36
|
+
alert.showAlert({
|
|
38
37
|
message: (_jsxs("span", { children: ["You are about to delete", _jsxs("span", { style: { color: 'black' }, children: [" ", activeSpectra?.length, " "] }), "spectra, Are you sure?"] })),
|
|
39
38
|
buttons: [
|
|
40
39
|
{
|
|
41
40
|
text: 'Yes',
|
|
42
|
-
|
|
41
|
+
onClick: () => {
|
|
43
42
|
dispatch({ type: 'DELETE_SPECTRA', payload: {} });
|
|
44
43
|
},
|
|
44
|
+
intent: 'danger',
|
|
45
45
|
},
|
|
46
46
|
{ text: 'No' },
|
|
47
47
|
],
|
|
48
48
|
});
|
|
49
|
-
}, [activeSpectra?.length,
|
|
49
|
+
}, [activeSpectra?.length, alert, dispatch]);
|
|
50
50
|
function addMissingProjectionHandler() {
|
|
51
51
|
const missingNucleus = getMissingProjection(data, activeTab);
|
|
52
52
|
if (missingNucleus.length > 0) {
|
|
@@ -79,6 +79,13 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeSpectra, activeTa
|
|
|
79
79
|
}
|
|
80
80
|
const hasActiveSpectra = activeSpectra && activeSpectra?.length > 0;
|
|
81
81
|
const spectraLengthPerTab = getSpectraByNucleus(activeTab, data)?.length;
|
|
82
|
+
const { getToggleVisibilityButtons } = useToggleSpectraVisibility(spectraLengthPerTab < 5
|
|
83
|
+
? {
|
|
84
|
+
enableHideSelected: false,
|
|
85
|
+
enableShowSelected: false,
|
|
86
|
+
enableShowSelectedOnly: false,
|
|
87
|
+
}
|
|
88
|
+
: {});
|
|
82
89
|
let leftButtons = getToggleVisibilityButtons(!hasActiveSpectra);
|
|
83
90
|
if (displayerMode === '2D' && activeSpectrum?.info.isFt) {
|
|
84
91
|
leftButtons.push({
|
|
@@ -4,9 +4,11 @@ import lodashGet from 'lodash/get';
|
|
|
4
4
|
import { useMemo, useCallback, useState } from 'react';
|
|
5
5
|
import { FaCopy, FaRegTrashAlt, FaFileExport } from 'react-icons/fa';
|
|
6
6
|
import { IoColorPaletteOutline } from 'react-icons/io5';
|
|
7
|
+
import { exportForCT } from '../../../data/SpectraManager';
|
|
7
8
|
import { isSpectrum1D } from '../../../data/data1d/Spectrum1D';
|
|
8
9
|
import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
|
|
9
10
|
import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
|
|
11
|
+
import { useChartData } from '../../context/ChartContext';
|
|
10
12
|
import { useDispatch } from '../../context/DispatchContext';
|
|
11
13
|
import { useToaster } from '../../context/ToasterContext';
|
|
12
14
|
import { ContextMenu, } from '../../elements/ContextMenuBluePrint';
|
|
@@ -46,6 +48,7 @@ var SpectraContextMenuOptionsKeys;
|
|
|
46
48
|
SpectraContextMenuOptionsKeys["ExportAsJcamp"] = "ExportAsJcamp";
|
|
47
49
|
SpectraContextMenuOptionsKeys["ExportAsText"] = "ExportAsText";
|
|
48
50
|
SpectraContextMenuOptionsKeys["CopyAsText"] = "CopyAsText";
|
|
51
|
+
SpectraContextMenuOptionsKeys["ExportForCT"] = "ExportForCT";
|
|
49
52
|
})(SpectraContextMenuOptionsKeys || (SpectraContextMenuOptionsKeys = {}));
|
|
50
53
|
const Spectra2DContextMenuOptions = [
|
|
51
54
|
{
|
|
@@ -59,24 +62,48 @@ const Spectra2DContextMenuOptions = [
|
|
|
59
62
|
data: { id: SpectraContextMenuOptionsKeys.Delete },
|
|
60
63
|
},
|
|
61
64
|
];
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
65
|
+
function getSpectra1DContextMenuOptions(options) {
|
|
66
|
+
const { molecules = [] } = options;
|
|
67
|
+
return [
|
|
68
|
+
...Spectra2DContextMenuOptions,
|
|
69
|
+
{
|
|
70
|
+
text: 'Export as JCAMP-DX',
|
|
71
|
+
icon: _jsx(FaFileExport, {}),
|
|
72
|
+
data: { id: SpectraContextMenuOptionsKeys.ExportAsJcamp },
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
text: 'Export as text',
|
|
76
|
+
icon: _jsx(FaFileExport, {}),
|
|
77
|
+
data: { id: SpectraContextMenuOptionsKeys.ExportAsText },
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
text: 'Copy as text',
|
|
81
|
+
icon: _jsx(FaCopy, {}),
|
|
82
|
+
data: { id: SpectraContextMenuOptionsKeys.CopyAsText },
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
text: 'Export for CT',
|
|
86
|
+
icon: _jsx(FaFileExport, {}),
|
|
87
|
+
data: { id: SpectraContextMenuOptionsKeys.ExportForCT },
|
|
88
|
+
tooltip: {
|
|
89
|
+
content: 'A chemical structure and a processed proton spectrum are required to use CT',
|
|
90
|
+
},
|
|
91
|
+
disabled: (spectrum) => !isValidExportForCT(spectrum, molecules),
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
function isValidExportForCT(spectrum, molecules) {
|
|
96
|
+
if (!isSpectrum1D(spectrum)) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
if (!spectrum.info.isFt) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
if (!(Array.isArray(molecules) && molecules.length > 0)) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
80
107
|
export function SpectraTable(props) {
|
|
81
108
|
const { data, activeSpectra, onChangeVisibility, onOpenSettingModal, onChangeActiveSpectrum, nucleus, } = props;
|
|
82
109
|
const toaster = useToaster();
|
|
@@ -85,6 +112,7 @@ export function SpectraTable(props) {
|
|
|
85
112
|
const activeSpectraObj = getActiveSpectraAsObject(activeSpectra);
|
|
86
113
|
const [exportedSpectrum, setExportedSpectrum] = useState();
|
|
87
114
|
const { rawWriteWithType, shouldFallback, cleanShouldFallback, text } = useClipboard();
|
|
115
|
+
const { molecules } = useChartData();
|
|
88
116
|
const COLUMNS = useMemo(() => ({
|
|
89
117
|
visible: {
|
|
90
118
|
id: 'hide-show-spectrum',
|
|
@@ -114,7 +142,7 @@ export function SpectraTable(props) {
|
|
|
114
142
|
},
|
|
115
143
|
},
|
|
116
144
|
}), [onChangeVisibility, onOpenSettingModal]);
|
|
117
|
-
const selectContextMenuHandler = useCallback((option, spectrum) => {
|
|
145
|
+
const selectContextMenuHandler = useCallback(async (option, spectrum) => {
|
|
118
146
|
const { id } = option;
|
|
119
147
|
switch (id) {
|
|
120
148
|
case SpectraContextMenuOptionsKeys.CopyToClipboard: {
|
|
@@ -152,11 +180,23 @@ export function SpectraTable(props) {
|
|
|
152
180
|
}));
|
|
153
181
|
break;
|
|
154
182
|
}
|
|
183
|
+
case SpectraContextMenuOptionsKeys.ExportForCT: {
|
|
184
|
+
try {
|
|
185
|
+
await exportForCT({ spectrum, molecules });
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
const message = error?.message;
|
|
189
|
+
if (message) {
|
|
190
|
+
toaster.show({ intent: 'danger', message });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
155
195
|
default: {
|
|
156
196
|
break;
|
|
157
197
|
}
|
|
158
198
|
}
|
|
159
|
-
}, [dispatch, rawWriteWithType, toaster]);
|
|
199
|
+
}, [dispatch, molecules, rawWriteWithType, toaster]);
|
|
160
200
|
function handleActiveRow(row) {
|
|
161
201
|
return activeSpectraObj?.[row?.original.id] || false;
|
|
162
202
|
}
|
|
@@ -219,7 +259,9 @@ export function SpectraTable(props) {
|
|
|
219
259
|
};
|
|
220
260
|
}
|
|
221
261
|
const contextMenu = nucleus.split(',').length === 1
|
|
222
|
-
?
|
|
262
|
+
? getSpectra1DContextMenuOptions({
|
|
263
|
+
molecules,
|
|
264
|
+
})
|
|
223
265
|
: Spectra2DContextMenuOptions;
|
|
224
266
|
return (_jsxs(_Fragment, { children: [_jsx(ReactTable, { rowStyle: handleRowStyle, activeRow: handleActiveRow, data: data, columns: tableColumns, onClick: (e, data) => onChangeActiveSpectrum(e, data.original), enableVirtualScroll: true, approxItemHeight: 24, contextMenu: contextMenu, onContextMenuSelect: selectContextMenuHandler, onSortEnd: handleSortEnd, style: { 'table td': { paddingTop: 0, paddingBottom: 0 } } }), exportedSpectrum && (_jsx(ExportAsJcampModal, { spectrum: exportedSpectrum, closeDialog: () => {
|
|
225
267
|
setExportedSpectrum(null);
|