nmrium 0.58.0 → 0.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/component/1d/LinesSeries.js +17 -5
- package/lib/component/1d/Viewer1D.js +10 -4
- package/lib/component/1d/integral/IntegralResizable.js +2 -2
- package/lib/component/1d/matrix/useMatrix.d.ts +1 -1
- package/lib/component/1d/multiAnalysis/AnalysisRange.js +1 -1
- package/lib/component/1d/ranges/Atoms.js +6 -4
- package/lib/component/1d/ranges/Range.js +4 -2
- package/lib/component/1d/tool/PivotIndicator.d.ts +1 -0
- package/lib/component/1d/tool/{VerticalIndicator.js → PivotIndicator.js} +8 -4
- package/lib/component/1d-2d/tools/BrushXY.js +0 -1
- package/lib/component/1d-2d/tools/CrossLinePointer.js +0 -1
- package/lib/component/2d/Viewer2D.js +7 -3
- package/lib/component/2d/tools/PivotIndicator.d.ts +1 -2
- package/lib/component/2d/tools/PivotIndicator.js +2 -3
- package/lib/component/2d/zones/Zone.js +2 -2
- package/lib/component/EventsTrackers/KeysListenerTracker.js +8 -8
- package/lib/component/context/ChartContext.js +12 -1
- package/lib/component/context/ShareDataContext.d.ts +1 -1
- package/lib/component/context/ShareDataContext.js +2 -4
- package/lib/component/context/ToasterContext.d.ts +1 -0
- package/lib/component/context/ToasterContext.js +12 -3
- package/lib/component/elements/ActionsButtonsPopover.js +1 -3
- package/lib/component/elements/Alert.d.ts +20 -0
- package/lib/component/elements/Alert.js +80 -0
- package/lib/component/elements/ContextMenuBluePrint.d.ts +7 -2
- package/lib/component/elements/ContextMenuBluePrint.js +9 -3
- package/lib/component/elements/DialogManager.d.ts +34 -0
- package/lib/component/elements/DialogManager.js +96 -0
- package/lib/component/elements/DraggableDialog.d.ts +13 -0
- package/lib/component/elements/DraggableDialog.js +156 -0
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +1 -1
- package/lib/component/elements/ReactTable/ReactTableFlexLayout.d.ts +0 -3
- package/lib/component/elements/ReactTable/ReactTableFlexLayout.js +1 -1
- package/lib/component/elements/Select2.d.ts +12 -7
- package/lib/component/elements/Select2.js +5 -4
- package/lib/component/elements/Select2Controller.d.ts +2 -2
- package/lib/component/elements/Select2Controller.js +5 -5
- package/lib/component/elements/TabTitle.d.ts +9 -0
- package/lib/component/elements/TabTitle.js +18 -0
- package/lib/component/elements/ToolbarPopoverItem.d.ts +7 -6
- package/lib/component/elements/ToolbarPopoverItem.js +13 -5
- package/lib/component/elements/print/PrintContent.d.ts +17 -0
- package/lib/component/elements/print/PrintContent.js +281 -0
- package/lib/component/elements/print/PrintProvider.d.ts +12 -0
- package/lib/component/elements/print/PrintProvider.js +28 -0
- package/lib/component/elements/print/index.d.ts +2 -0
- package/lib/component/elements/print/index.js +2 -0
- package/lib/component/header/ApodizationOptionsPanel.js +2 -2
- package/lib/component/header/BaseLineCorrectionPanel.js +3 -0
- package/lib/component/hooks/useSaveSettings.d.ts +1 -1
- package/lib/component/hooks/useSaveSettings.js +18 -22
- package/lib/component/hooks/useToggleSpectraVisibility.d.ts +14 -9
- package/lib/component/hooks/useToggleSpectraVisibility.js +45 -16
- package/lib/component/loader/DropZone.js +3 -67
- package/lib/component/loader/useLoadFiles.d.ts +1 -0
- package/lib/component/loader/useLoadFiles.js +78 -0
- package/lib/component/main/InnerNMRium.d.ts +4 -3
- package/lib/component/main/InnerNMRium.js +5 -10
- package/lib/component/main/InnerNMRiumContents.d.ts +3 -2
- package/lib/component/main/InnerNMRiumContents.js +38 -29
- package/lib/component/main/NMRium.d.ts +2 -5
- package/lib/component/main/NMRium.js +1 -1
- package/lib/component/main/NMRiumRefAPI.d.ts +7 -0
- package/lib/component/main/NMRiumRefAPI.js +12 -0
- package/lib/component/main/NMRiumViewer.d.ts +10 -0
- package/lib/component/main/NMRiumViewer.js +35 -0
- package/lib/component/main/index.d.ts +1 -0
- package/lib/component/modal/CopyClipboardModal.d.ts +3 -2
- package/lib/component/modal/CopyClipboardModal.js +18 -32
- package/lib/component/modal/EditPeakShapeModal.d.ts +4 -6
- package/lib/component/modal/EditPeakShapeModal.js +45 -33
- package/lib/component/modal/ExportAsJcampModal.d.ts +6 -3
- package/lib/component/modal/ExportAsJcampModal.js +69 -35
- package/lib/component/modal/ImportPublicationStringModal.js +1 -1
- package/lib/component/modal/editRange/EditRangeModal.d.ts +2 -10
- package/lib/component/modal/editRange/EditRangeModal.js +26 -54
- package/lib/component/modal/editZone/EditZoneModal.d.ts +3 -8
- package/lib/component/modal/editZone/EditZoneModal.js +74 -91
- package/lib/component/modal/editZone/SignalsForm.d.ts +1 -2
- package/lib/component/modal/editZone/SignalsForm.js +33 -50
- package/lib/component/modal/editZone/validation/isDefaultPathLength.d.ts +1 -2
- package/lib/component/modal/editZone/validation/isDefaultPathLength.js +3 -5
- package/lib/component/modal/setting/GeneralSettings.js +4 -2
- package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.d.ts +1 -0
- package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.js +89 -0
- package/lib/component/modal/setting/settingsValidation.js +15 -1
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +8 -5
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +5 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +13 -3
- package/lib/component/panels/Panels.js +2 -2
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +8 -5
- package/lib/component/panels/PeaksPanel/PeaksTable.js +7 -13
- package/lib/component/panels/RangesPanel/RangesHeader.js +52 -15
- package/lib/component/panels/RangesPanel/RangesTable.js +6 -3
- package/lib/component/panels/RangesPanel/TableColumns/ActionsColumn.js +21 -3
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.d.ts +6 -5
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +41 -64
- package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +13 -6
- package/lib/component/panels/SpectraPanel/SpectraTable.js +63 -21
- package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.d.ts +1 -2
- package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.js +33 -41
- package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnHeader.js +68 -53
- package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +70 -58
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.d.ts +13 -8
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +17 -81
- package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts +3 -0
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +8 -1
- package/lib/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
- package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +62 -43
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +16 -8
- package/lib/component/panels/ZonesPanel/ZonesTable.js +4 -1
- package/lib/component/panels/ZonesPanel/hooks/useZoneActions.d.ts +5 -0
- package/lib/component/panels/ZonesPanel/hooks/useZoneActions.js +40 -0
- package/lib/component/panels/databasePanel/DatabasePanel.js +7 -8
- package/lib/component/panels/filtersPanel/FilterPanel.js +9 -6
- package/lib/component/panels/filtersPanel/FiltersTable.js +12 -10
- package/lib/component/panels/header/DefaultPanelHeader.d.ts +1 -0
- package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
- package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +10 -12
- package/lib/component/reducer/IgnoreActions.js +1 -0
- package/lib/component/reducer/Reducer.js +2 -4
- package/lib/component/reducer/actions/DatabaseActions.d.ts +15 -13
- package/lib/component/reducer/actions/DatabaseActions.js +52 -34
- package/lib/component/reducer/actions/DomainActions.d.ts +2 -2
- package/lib/component/reducer/actions/FiltersActions.js +9 -4
- package/lib/component/reducer/actions/RangesActions.d.ts +1 -0
- package/lib/component/reducer/actions/RangesActions.js +9 -4
- package/lib/component/reducer/actions/SpectraActions.d.ts +2 -1
- package/lib/component/reducer/actions/SpectraActions.js +53 -43
- package/lib/component/reducer/actions/ToolsActions.js +0 -17
- package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.d.ts +3 -0
- package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.js +16 -0
- package/lib/component/reducer/preferences/actions/changePrintPageSettings.d.ts +3 -0
- package/lib/component/reducer/preferences/actions/changePrintPageSettings.js +6 -0
- package/lib/component/reducer/preferences/actions/matrixGeneration.d.ts +0 -4
- package/lib/component/reducer/preferences/actions/matrixGeneration.js +1 -2
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -2
- package/lib/component/reducer/preferences/preferencesReducer.js +4 -1
- package/lib/component/toolbar/ToolBar.js +33 -14
- package/lib/component/toolbar/ToolTypes.d.ts +1 -1
- package/lib/component/toolbar/ToolTypes.js +0 -14
- package/lib/component/workspaces/workspaceDefaultProperties.js +2 -0
- package/lib/data/SpectraManager.d.ts +7 -10
- package/lib/data/SpectraManager.js +51 -30
- package/lib/data/data1d/Spectrum1D/SumManager.d.ts +0 -1
- package/lib/data/data1d/Spectrum1D/SumManager.js +2 -10
- package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/index.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/index.js +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +10 -16
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +1 -7
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +2 -1
- package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +10 -16
- package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +10 -16
- package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.d.ts +13 -0
- package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.js +65 -0
- package/lib/data/molecules/MoleculeManager.d.ts +1 -1
- package/lib/data/molecules/MoleculeManager.js +21 -49
- package/lib/data/utilities/getCustomColor.d.ts +1 -1
- package/lib/data/utilities/removeByPaths.d.ts +3 -0
- package/lib/data/utilities/removeByPaths.js +33 -0
- package/lib/versionInfo.js +1 -1
- package/package.json +34 -34
- package/lib/component/1d/tool/VerticalIndicator.d.ts +0 -2
- package/lib/component/elements/ContextMenu.d.ts +0 -9
- package/lib/component/elements/ContextMenu.js +0 -116
- package/lib/component/elements/popup/Modal/ConfirmDialog.d.ts +0 -21
- package/lib/component/elements/popup/Modal/ConfirmDialog.js +0 -68
- package/lib/component/elements/popup/Modal/Context.d.ts +0 -2
- package/lib/component/elements/popup/Modal/Context.js +0 -6
- package/lib/component/elements/popup/Modal/Modal.d.ts +0 -9
- package/lib/component/elements/popup/Modal/Modal.js +0 -42
- package/lib/component/elements/popup/Modal/ModalContent.d.ts +0 -6
- package/lib/component/elements/popup/Modal/ModalContent.js +0 -27
- package/lib/component/elements/popup/Modal/Provider.d.ts +0 -11
- package/lib/component/elements/popup/Modal/Provider.js +0 -172
- package/lib/component/elements/popup/Modal/index.d.ts +0 -4
- package/lib/component/elements/popup/Modal/index.js +0 -4
- package/lib/component/elements/popup/Transition.d.ts +0 -14
- package/lib/component/elements/popup/Transition.js +0 -35
- package/lib/component/elements/popup/Wrapper.d.ts +0 -8
- package/lib/component/elements/popup/Wrapper.js +0 -83
- package/lib/component/elements/popup/options.d.ts +0 -28
- package/lib/component/elements/popup/options.js +0 -25
- package/lib/component/elements/popup/utility.d.ts +0 -2
- package/lib/component/elements/popup/utility.js +0 -13
- package/lib/component/modal/editZone/EditPathLengthFormik.d.ts +0 -5
- package/lib/component/modal/editZone/EditPathLengthFormik.js +0 -67
- package/lib/component/modal/editZone/SignalFormTab.d.ts +0 -5
- package/lib/component/modal/editZone/SignalFormTab.js +0 -6
- package/lib/component/modal/editZone/validation/EditZoneValidation.d.ts +0 -14
- package/lib/component/modal/editZone/validation/EditZoneValidation.js +0 -14
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.d.ts +0 -11
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +0 -29
|
@@ -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);
|
|
@@ -128,9 +128,19 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
|
|
|
128
128
|
async function handlePasteMolfile(molfile) {
|
|
129
129
|
if (!molfile)
|
|
130
130
|
return;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
try {
|
|
132
|
+
const molecules = getMolecules(molfile);
|
|
133
|
+
dispatch({ type: 'ADD_MOLECULES', payload: { molecules } });
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
toaster.show({
|
|
137
|
+
intent: 'danger',
|
|
138
|
+
message: 'Failed to parse SMILES or molfile. Please paste a valid format',
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
cleanShouldFallback();
|
|
143
|
+
}
|
|
134
144
|
}
|
|
135
145
|
const handleDelete = useCallback(() => {
|
|
136
146
|
if (molecules[currentIndex]?.id) {
|
|
@@ -58,7 +58,7 @@ const accordionItems = [
|
|
|
58
58
|
mode: '1D',
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
|
-
title: 'Ranges',
|
|
61
|
+
title: 'Ranges / Multiplet analysis',
|
|
62
62
|
component: _jsx(RangesPanel, {}),
|
|
63
63
|
hidePreferenceKey: 'rangesPanel',
|
|
64
64
|
mode: '1D',
|
|
@@ -122,7 +122,7 @@ export const TOOLS_PANELS_ACCORDION = {
|
|
|
122
122
|
null: 'Spectra',
|
|
123
123
|
peakPicking: 'Peaks',
|
|
124
124
|
integral: 'Integrals',
|
|
125
|
-
rangePicking: 'Ranges',
|
|
125
|
+
rangePicking: 'Ranges / Multiplet analysis',
|
|
126
126
|
zonePicking: 'Zones',
|
|
127
127
|
multipleSpectraAnalysis: 'Multiple Spectra Analysis',
|
|
128
128
|
};
|
|
@@ -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,15 +1,13 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import lodashGet from 'lodash/get';
|
|
3
|
-
import { useCallback, useMemo, memo } from 'react';
|
|
3
|
+
import { useCallback, useMemo, memo, useState } from 'react';
|
|
4
4
|
import { FaEdit, FaRegTrashAlt } from 'react-icons/fa';
|
|
5
5
|
import { useDispatch } from '../../context/DispatchContext';
|
|
6
6
|
import EditableColumn from '../../elements/EditableColumn';
|
|
7
7
|
import ReactTable from '../../elements/ReactTable/ReactTable';
|
|
8
8
|
import addCustomColumn, { createActionColumn, } from '../../elements/ReactTable/utility/addCustomColumn';
|
|
9
|
-
import { useModal } from '../../elements/popup/Modal';
|
|
10
|
-
import { positions, transitions } from '../../elements/popup/options';
|
|
11
9
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
12
|
-
import EditPeakShapeModal from '../../modal/EditPeakShapeModal';
|
|
10
|
+
import { EditPeakShapeModal } from '../../modal/EditPeakShapeModal';
|
|
13
11
|
import { formatNumber } from '../../utility/formatNumber';
|
|
14
12
|
import NoDataForFid from '../extra/placeholder/NoDataForFid';
|
|
15
13
|
import NoTableData from '../extra/placeholder/NoTableData';
|
|
@@ -18,8 +16,8 @@ function handleActiveRow(row) {
|
|
|
18
16
|
}
|
|
19
17
|
function PeaksTable({ activeTab, data, info }) {
|
|
20
18
|
const dispatch = useDispatch();
|
|
21
|
-
const modal = useModal();
|
|
22
19
|
const peaksPreferences = usePanelPreferences('peaks', activeTab);
|
|
20
|
+
const [peak, setEditedPeak] = useState();
|
|
23
21
|
const deletePeakHandler = useCallback((row) => {
|
|
24
22
|
const params = row.original;
|
|
25
23
|
dispatch({
|
|
@@ -28,12 +26,8 @@ function PeaksTable({ activeTab, data, info }) {
|
|
|
28
26
|
});
|
|
29
27
|
}, [dispatch]);
|
|
30
28
|
const editPeakHandler = useCallback((row) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
transition: transitions.SCALE,
|
|
34
|
-
isBackgroundBlur: false,
|
|
35
|
-
});
|
|
36
|
-
}, [modal, peaksPreferences]);
|
|
29
|
+
setEditedPeak(row.original);
|
|
30
|
+
}, []);
|
|
37
31
|
const saveDeltaPPMRefsHandler = useCallback((event, row) => {
|
|
38
32
|
const shift = Number.parseFloat(event.target.value) - Number.parseFloat(row.x);
|
|
39
33
|
dispatch({ type: 'SHIFT_SPECTRUM', payload: { shift } });
|
|
@@ -149,6 +143,6 @@ function PeaksTable({ activeTab, data, info }) {
|
|
|
149
143
|
if (!data || data.length === 0) {
|
|
150
144
|
return _jsx(NoTableData, {});
|
|
151
145
|
}
|
|
152
|
-
return (_jsx(ReactTable, { activeRow: handleActiveRow, rowStyle: { activated: { backgroundColor: '#f5f5dc' } }, data: data, columns: tableColumns, approxItemHeight: 24, enableVirtualScroll: true }));
|
|
146
|
+
return (_jsxs(_Fragment, { children: [_jsx(EditPeakShapeModal, { peak: peak, onCloseDialog: () => setEditedPeak(undefined) }), _jsx(ReactTable, { activeRow: handleActiveRow, rowStyle: { activated: { backgroundColor: '#f5f5dc' } }, data: data, columns: tableColumns, approxItemHeight: 24, enableVirtualScroll: true })] }));
|
|
153
147
|
}
|
|
154
148
|
export default memo(PeaksTable);
|
|
@@ -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,46 +12,67 @@ 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';
|
|
13
|
-
import {
|
|
15
|
+
import { useAlert } from '../../elements/Alert';
|
|
16
|
+
import { ToolbarPopoverItem, } from '../../elements/ToolbarPopoverItem';
|
|
14
17
|
import { useActiveSpectrumRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
|
|
15
18
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
16
19
|
import CopyClipboardModal from '../../modal/CopyClipboardModal';
|
|
17
20
|
import ChangeSumModal from '../../modal/changeSum/ChangeSumModal';
|
|
18
21
|
import { booleanToString } from '../../utility/booleanToString';
|
|
19
22
|
import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
23
|
+
const EXPORT_MENU = [
|
|
24
|
+
{
|
|
25
|
+
icon: _jsx(FaCopy, {}),
|
|
26
|
+
text: 'Preview publication string',
|
|
27
|
+
data: {
|
|
28
|
+
id: 'publicationString',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
icon: _jsx(FaDownload, {}),
|
|
33
|
+
text: 'Export ranges as TSV',
|
|
34
|
+
data: {
|
|
35
|
+
id: 'rangesToTSV',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
];
|
|
20
39
|
function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClick, isFilterActive, filterCounter, activeTab, }) {
|
|
21
40
|
const dispatch = useDispatch();
|
|
22
|
-
const
|
|
41
|
+
const alert = useAlert();
|
|
23
42
|
const toaster = useToaster();
|
|
24
43
|
const assignmentData = useAssignmentData();
|
|
25
44
|
const currentSum = lodashGet(ranges, 'options.sum', null);
|
|
26
45
|
const rangesPreferences = usePanelPreferences('ranges', activeTab);
|
|
46
|
+
const [acs, setACS] = useState();
|
|
27
47
|
const { showMultiplicityTrees, showJGraph, showIntegrals, showIntegralsValues, showPeaks, displayingMode, showAssignmentsLabels, } = useActiveSpectrumRangesViewState();
|
|
28
48
|
function changeRangesSumHandler(options) {
|
|
29
49
|
dispatch({ type: 'CHANGE_RANGE_SUM', payload: { options } });
|
|
30
|
-
modal.close();
|
|
31
50
|
}
|
|
32
51
|
function removeAssignments() {
|
|
33
52
|
onUnlink();
|
|
34
53
|
}
|
|
35
54
|
function handleOnRemoveAssignments() {
|
|
36
|
-
|
|
55
|
+
alert.showAlert({
|
|
37
56
|
message: 'All assignments will be removed. Are you sure?',
|
|
38
|
-
buttons: [
|
|
57
|
+
buttons: [
|
|
58
|
+
{ text: 'Yes', onClick: removeAssignments, intent: 'danger' },
|
|
59
|
+
{ text: 'No' },
|
|
60
|
+
],
|
|
39
61
|
});
|
|
40
62
|
}
|
|
41
63
|
function handleDeleteAll() {
|
|
42
|
-
|
|
64
|
+
alert.showAlert({
|
|
43
65
|
message: 'All ranges will be deleted. Are You sure?',
|
|
44
66
|
buttons: [
|
|
45
67
|
{
|
|
46
68
|
text: 'Yes',
|
|
47
|
-
|
|
69
|
+
onClick: () => {
|
|
48
70
|
dispatch({
|
|
49
71
|
type: 'DELETE_RANGE',
|
|
50
72
|
payload: { assignmentData },
|
|
51
73
|
});
|
|
52
74
|
},
|
|
75
|
+
intent: 'danger',
|
|
53
76
|
},
|
|
54
77
|
{ text: 'No' },
|
|
55
78
|
],
|
|
@@ -98,7 +121,7 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
|
|
|
98
121
|
couplingFormat: rangesPreferences.coupling.format,
|
|
99
122
|
observedFrequency, //400
|
|
100
123
|
});
|
|
101
|
-
|
|
124
|
+
setACS(result);
|
|
102
125
|
}
|
|
103
126
|
}
|
|
104
127
|
function changeSumConstantFlagHandler() {
|
|
@@ -112,14 +135,28 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
|
|
|
112
135
|
function toggleDisplayingMode() {
|
|
113
136
|
dispatch({ type: 'TOGGLE_RANGES_PEAKS_DISPLAYING_MODE' });
|
|
114
137
|
}
|
|
138
|
+
function handleRangesToTSV() {
|
|
139
|
+
const tsv = rangesToTSV(ranges.values);
|
|
140
|
+
const blob = new Blob([tsv], { type: 'text/plain' });
|
|
141
|
+
saveAs(blob, `${info.name}.tsv`);
|
|
142
|
+
}
|
|
143
|
+
function exportHandler(data) {
|
|
144
|
+
switch (data?.id) {
|
|
145
|
+
case 'publicationString':
|
|
146
|
+
saveAsHTMLHandler();
|
|
147
|
+
break;
|
|
148
|
+
case 'rangesToTSV':
|
|
149
|
+
handleRangesToTSV();
|
|
150
|
+
break;
|
|
151
|
+
default:
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
115
155
|
const hasRanges = Array.isArray(ranges?.values) && ranges.values.length > 0;
|
|
116
156
|
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: [
|
|
157
|
+
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
158
|
{
|
|
119
|
-
disabled: !hasRanges,
|
|
120
|
-
icon: _jsx(FaFileExport, {}),
|
|
121
|
-
tooltip: 'Preview publication string',
|
|
122
|
-
onClick: saveAsHTMLHandler,
|
|
159
|
+
component: (_jsx(ToolbarPopoverItem, { disabled: !hasRanges, icon: _jsx(FaFileExport, {}), tooltip: "Export as", options: EXPORT_MENU, onClick: exportHandler })),
|
|
123
160
|
},
|
|
124
161
|
{
|
|
125
162
|
component: (_jsx(ChangeSumModal, { onSave: changeRangesSumHandler, sumType: "ranges", currentSum: currentSum, sumOptions: ranges?.options })),
|
|
@@ -2,7 +2,9 @@ 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 { FaLink } from 'react-icons/fa';
|
|
5
|
+
import { withDialog } from '../../elements/DialogManager';
|
|
5
6
|
import useTableSortBy from '../../hooks/useTableSortBy';
|
|
7
|
+
import { EditRangeModal } from '../../modal/editRange/EditRangeModal';
|
|
6
8
|
import NoDataForFid from '../extra/placeholder/NoDataForFid';
|
|
7
9
|
import NoTableData from '../extra/placeholder/NoTableData';
|
|
8
10
|
import RangesTableRow from './RangesTableRow';
|
|
@@ -51,6 +53,7 @@ const tableStyle = css `
|
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
`;
|
|
56
|
+
const EditRangeDialog = withDialog(EditRangeModal, { force: true });
|
|
54
57
|
function RangesTable({ tableData, onUnlink, contextMenu = [], onContextMenuSelect, activeTab, preferences, info, }) {
|
|
55
58
|
const element = activeTab?.replace(/\d/g, '');
|
|
56
59
|
const { items: sortedData, isSortedDesc, onSort } = useTableSortBy(tableData);
|
|
@@ -64,8 +67,8 @@ function RangesTable({ tableData, onUnlink, contextMenu = [], onContextMenuSelec
|
|
|
64
67
|
const showActions = preferences.showDeleteAction ||
|
|
65
68
|
preferences.showEditAction ||
|
|
66
69
|
preferences.showZoomAction;
|
|
67
|
-
return (_jsxs("table", { css: tableStyle, children: [_jsx("thead", { children: _jsxs("tr", { children: [preferences.showSerialNumber && _jsx("th", { children: "#" }), preferences.showAssignmentLabel && (_jsx("th", { title: "Assignment", children: "Assignment" })), preferences.from.show && (_jsxs("th", { id: "from", ...onSort, children: ["From", isSortedDesc('from').content] })), preferences.to.show && (_jsxs("th", { id: "to", ...onSort, children: ["To ", isSortedDesc('to').content] })), preferences.deltaPPM.show && (_jsxs("th", { id: "from", ...onSort, children: ["\u03B4 (ppm) ", isSortedDesc('from').content] })), preferences.deltaHz.show && _jsx("th", { children: "\u03B4 (Hz) " }), preferences.relative.show && (_jsxs("th", { id: "integration", ...onSort, children: ["Rel. ", element, " ", isSortedDesc('integration').content] })), preferences.absolute.show && _jsx("th", { children: "Absolute" }), preferences.showMultiplicity && _jsx("th", { children: "Mult." }), preferences.coupling.show && _jsx("th", { children: "J (Hz)" }), preferences.showAssignment && (_jsxs(_Fragment, { children: [_jsx("th", { title: "Assign multiplets", children: _jsx(FaLink, { style: { fontSize: 10, margin: 'auto' } }) }), _jsx("th", { title: "Assign ranges", style: { minWidth: '50px' }, children: "\u03A3" })] })), preferences.showKind && _jsx("th", { children: "Kind" }), showActions && _jsx("th", { children: '' })] }) }), _jsx("tbody", { children: data?.map((range) => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
return (_jsxs(_Fragment, { children: [_jsx(EditRangeDialog, {}), _jsxs("table", { css: tableStyle, children: [_jsx("thead", { children: _jsxs("tr", { children: [preferences.showSerialNumber && _jsx("th", { children: "#" }), preferences.showAssignmentLabel && (_jsx("th", { title: "Assignment", children: "Assignment" })), preferences.from.show && (_jsxs("th", { id: "from", ...onSort, children: ["From", isSortedDesc('from').content] })), preferences.to.show && (_jsxs("th", { id: "to", ...onSort, children: ["To ", isSortedDesc('to').content] })), preferences.deltaPPM.show && (_jsxs("th", { id: "from", ...onSort, children: ["\u03B4 (ppm) ", isSortedDesc('from').content] })), preferences.deltaHz.show && _jsx("th", { children: "\u03B4 (Hz) " }), preferences.relative.show && (_jsxs("th", { id: "integration", ...onSort, children: ["Rel. ", element, " ", isSortedDesc('integration').content] })), preferences.absolute.show && _jsx("th", { children: "Absolute" }), preferences.showMultiplicity && _jsx("th", { children: "Mult." }), preferences.coupling.show && _jsx("th", { children: "J (Hz)" }), preferences.showAssignment && (_jsxs(_Fragment, { children: [_jsx("th", { title: "Assign multiplets", children: _jsx(FaLink, { style: { fontSize: 10, margin: 'auto' } }) }), _jsx("th", { title: "Assign ranges", style: { minWidth: '50px' }, children: "\u03A3" })] })), preferences.showKind && _jsx("th", { children: "Kind" }), showActions && _jsx("th", { children: '' })] }) }), _jsx("tbody", { children: data?.map((range) => {
|
|
71
|
+
return (_jsx(RangesTableRow, { rowData: range, onUnlink: onUnlink, preferences: preferences, info: info, contextMenu: contextMenu, onContextMenuSelect: onContextMenuSelect }, range.rowKey));
|
|
72
|
+
}) })] })] }));
|
|
70
73
|
}
|
|
71
74
|
export default RangesTable;
|
|
@@ -2,9 +2,12 @@ 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
4
|
import { Fragment } from 'react';
|
|
5
|
-
import { FaRegTrashAlt, FaSearchPlus
|
|
5
|
+
import { FaEdit, FaRegTrashAlt, FaSearchPlus } from 'react-icons/fa';
|
|
6
6
|
import { SIGNAL_KINDS } from '../../../../data/constants/signalsKinds';
|
|
7
|
+
import { useDispatch } from '../../../context/DispatchContext';
|
|
8
|
+
import { useDialog } from '../../../elements/DialogManager';
|
|
7
9
|
import Select from '../../../elements/Select';
|
|
10
|
+
import { EditRangeModal } from '../../../modal/editRange/EditRangeModal';
|
|
8
11
|
import useEditRangeModal from '../hooks/useEditRangeModal';
|
|
9
12
|
const styles = css `
|
|
10
13
|
width: 66px;
|
|
@@ -27,8 +30,23 @@ const selectBoxStyle = {
|
|
|
27
30
|
height: '20px',
|
|
28
31
|
};
|
|
29
32
|
function ActionsColumn({ row, onHoverSignal, rowSpanTags, showKind, showDeleteAction, showEditAction, showZoomAction, }) {
|
|
30
|
-
const {
|
|
33
|
+
const { deleteRange, changeRangeSignalKind, zoomRange } = useEditRangeModal();
|
|
31
34
|
const showActions = showDeleteAction || showEditAction || showZoomAction;
|
|
32
|
-
|
|
35
|
+
const { openDialog } = useDialog();
|
|
36
|
+
const dispatch = useDispatch();
|
|
37
|
+
return (_jsxs(Fragment, { children: [showKind && (_jsx("td", { ...onHoverSignal, children: !row?.tableMetaInfo?.signal ? ('') : (_jsx(Select, { onChange: (kind) => changeRangeSignalKind(kind, row), items: SIGNAL_KINDS, defaultValue: row?.tableMetaInfo?.signal?.kind, style: selectBoxStyle })) })), showActions && (_jsxs("td", { ...rowSpanTags, css: styles, children: [showDeleteAction && (_jsx("button", { type: "button", className: "delete-button", onClick: () => deleteRange(row?.id), children: _jsx(FaRegTrashAlt, {}) })), showZoomAction && (_jsx("button", { type: "button", className: "zoom-button", onClick: () => zoomRange(row), children: _jsx(FaSearchPlus, { title: "Zoom to range in spectrum" }) })), showEditAction && (_jsx("button", { type: "button", className: "edit-button", onClick: () => {
|
|
38
|
+
dispatch({
|
|
39
|
+
type: 'SET_SELECTED_TOOL',
|
|
40
|
+
payload: {
|
|
41
|
+
selectedTool: 'zoom',
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
dispatch({
|
|
45
|
+
type: 'TOGGLE_RANGES_VIEW_PROPERTY',
|
|
46
|
+
payload: { key: 'showMultiplicityTrees', value: true },
|
|
47
|
+
});
|
|
48
|
+
zoomRange(row);
|
|
49
|
+
openDialog(EditRangeModal, row.id);
|
|
50
|
+
}, children: _jsx(FaEdit, { color: "blue" }) }))] }))] }));
|
|
33
51
|
}
|
|
34
52
|
export default ActionsColumn;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { RangeData } from './useMapRanges';
|
|
2
|
-
export default function useEditRangeModal(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
export default function useEditRangeModal(): {
|
|
3
|
+
deleteRange: (id: string, resetSelectTool?: boolean) => void;
|
|
4
|
+
zoomRange: (range: RangeData) => void;
|
|
5
|
+
changeRangeSignalKind: (kind: any, range: RangeData) => void;
|
|
6
|
+
saveEditRange: (editedRange: any) => void;
|
|
7
|
+
reset: (originalRange: any) => void;
|
|
7
8
|
};
|