nmrium 0.38.2 → 0.40.1
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/multiAnalysis/MultiAnalysisRanges.js +1 -1
- package/lib/component/EventsTrackers/KeysListenerTracker.js +90 -67
- package/lib/component/NMRium.d.ts +1 -0
- package/lib/component/NMRium.js +4 -2
- package/lib/component/context/LoggerContext.js +12 -2
- package/lib/component/context/PreferencesContext.d.ts +4 -2
- package/lib/component/elements/formik/FormikError.d.ts +8 -0
- package/lib/component/elements/formik/FormikError.js +22 -0
- package/lib/component/elements/popup/Alert/AlertBlock.d.ts +7 -0
- package/lib/component/elements/popup/Alert/AlertBlock.js +24 -0
- package/lib/component/elements/popup/Alert/Provider.js +2 -20
- package/lib/component/elements/popup/Modal/ConfirmDialog.js +2 -1
- package/lib/component/header/Header.js +2 -2
- package/lib/component/hooks/useSaveSettings.js +18 -16
- package/lib/component/modal/AboutUsModal.js +4 -2
- package/lib/component/modal/LoadJCAMPModal.js +41 -28
- package/lib/component/modal/LogsHistoryModal.d.ts +6 -0
- package/lib/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +6 -4
- package/lib/component/modal/PredictSpectraModal.js +12 -2
- package/lib/component/modal/editRange/EditRangeModal.d.ts +7 -6
- package/lib/component/modal/editRange/EditRangeModal.js +33 -13
- package/lib/component/modal/setting/GeneralSettings.js +29 -28
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +18 -16
- package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
- package/lib/component/panels/MultipleSpectraAnalysisPanel/preferences/AnalysisTablePreferences.js +1 -1
- package/lib/component/panels/Panels.js +2 -2
- package/lib/component/panels/RangesPanel/RangesHeader.js +9 -15
- package/lib/component/panels/RangesPanel/RangesPanel.js +7 -10
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.d.ts +1 -1
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +9 -12
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +7 -10
- package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -1
- package/lib/component/reducer/actions/DatabaseActions.js +6 -4
- package/lib/component/reducer/actions/DomainActions.js +3 -0
- package/lib/component/reducer/actions/IntegralsActions.js +3 -1
- package/lib/component/reducer/actions/SpectrumsActions.js +6 -6
- package/lib/component/reducer/actions/ToolsActions.js +3 -32
- package/lib/component/reducer/actions/ZonesActions.js +2 -4
- package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +8 -0
- package/lib/component/reducer/helper/ZoomHistoryManager.js +35 -0
- package/lib/component/reducer/preferences/actions/addWorkspace.js +2 -2
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +2 -2
- package/lib/component/utility/export.d.ts +5 -4
- package/lib/component/utility/export.js +24 -52
- package/lib/data/PredictionManager.d.ts +3 -1
- package/lib/data/PredictionManager.js +27 -1
- package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.d.ts +1 -2
- package/lib/data/data1d/Spectrum1D/integrals/initiateIntegrals.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectSignal.js +13 -6
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +23 -18
- package/lib/utils/clipboard/clipboard.d.ts +12 -0
- package/lib/utils/clipboard/clipboard.js +15 -0
- package/lib/utils/clipboard/clipboardComponents.d.ts +45 -0
- package/lib/utils/clipboard/clipboardComponents.js +150 -0
- package/lib/utils/clipboard/clipboardHooks.d.ts +94 -0
- package/lib/utils/clipboard/clipboardHooks.js +142 -0
- package/lib/utils/clipboard/types.d.ts +1 -0
- package/lib/utils/clipboard/types.js +1 -0
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/multiAnalysis/MultiAnalysisRanges.js +1 -1
- package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +90 -67
- package/lib-cjs/component/NMRium.js +4 -2
- package/lib-cjs/component/context/LoggerContext.js +11 -1
- package/lib-cjs/component/elements/formik/FormikError.js +27 -0
- package/lib-cjs/component/elements/popup/Alert/AlertBlock.js +30 -0
- package/lib-cjs/component/elements/popup/Alert/Provider.js +2 -20
- package/lib-cjs/component/elements/popup/Modal/ConfirmDialog.js +2 -1
- package/lib-cjs/component/header/Header.js +2 -2
- package/lib-cjs/component/hooks/useSaveSettings.js +17 -15
- package/lib-cjs/component/modal/AboutUsModal.js +4 -2
- package/lib-cjs/component/modal/LoadJCAMPModal.js +41 -28
- package/lib-cjs/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +8 -6
- package/lib-cjs/component/modal/PredictSpectraModal.js +12 -2
- package/lib-cjs/component/modal/editRange/EditRangeModal.js +32 -12
- package/lib-cjs/component/modal/setting/GeneralSettings.js +29 -28
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +17 -15
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/preferences/AnalysisTablePreferences.js +1 -1
- package/lib-cjs/component/panels/Panels.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +9 -15
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +7 -10
- package/lib-cjs/component/panels/RangesPanel/hooks/useEditRangeModal.js +9 -12
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraTable.js +7 -10
- package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +3 -1
- package/lib-cjs/component/reducer/actions/DatabaseActions.js +6 -4
- package/lib-cjs/component/reducer/actions/DomainActions.js +3 -0
- package/lib-cjs/component/reducer/actions/IntegralsActions.js +3 -1
- package/lib-cjs/component/reducer/actions/SpectrumsActions.js +6 -6
- package/lib-cjs/component/reducer/actions/ToolsActions.js +26 -32
- package/lib-cjs/component/reducer/actions/ZonesActions.js +2 -4
- package/lib-cjs/component/reducer/helper/ZoomHistoryManager.js +37 -0
- package/lib-cjs/component/reducer/preferences/actions/addWorkspace.js +2 -2
- package/lib-cjs/component/utility/export.js +24 -54
- package/lib-cjs/data/PredictionManager.js +27 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/detectSignal.js +13 -6
- package/lib-cjs/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +23 -18
- package/lib-cjs/utils/clipboard/clipboard.js +23 -0
- package/lib-cjs/utils/clipboard/clipboardComponents.js +158 -0
- package/lib-cjs/utils/clipboard/clipboardHooks.js +147 -0
- package/lib-cjs/utils/clipboard/types.js +2 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +17 -17
- package/lib/component/header/LogsHistory.d.ts +0 -1
|
@@ -11,6 +11,7 @@ const react_2 = require("react");
|
|
|
11
11
|
const PredictionManager_1 = require("../../data/PredictionManager");
|
|
12
12
|
const ChartContext_1 = require("../context/ChartContext");
|
|
13
13
|
const DispatchContext_1 = require("../context/DispatchContext");
|
|
14
|
+
const LoggerContext_1 = require("../context/LoggerContext");
|
|
14
15
|
const Button_1 = __importDefault(require("../elements/Button"));
|
|
15
16
|
const CheckBox_1 = __importDefault(require("../elements/CheckBox"));
|
|
16
17
|
const CloseButton_1 = __importDefault(require("../elements/CloseButton"));
|
|
@@ -59,6 +60,7 @@ function PredictSpectraModal({ onClose = () => null, molecule, }) {
|
|
|
59
60
|
name: `Prediction ${predictionIndex + 1}`,
|
|
60
61
|
});
|
|
61
62
|
}, [predictionPreferences, predictionIndex]);
|
|
63
|
+
const { logger } = (0, LoggerContext_1.useLogger)();
|
|
62
64
|
const submitHandler = (0, react_2.useCallback)((values) => {
|
|
63
65
|
void (async () => {
|
|
64
66
|
if (molecule) {
|
|
@@ -72,7 +74,7 @@ function PredictSpectraModal({ onClose = () => null, molecule, }) {
|
|
|
72
74
|
}
|
|
73
75
|
const hideLoading = await alert.showLoading(`Predict ${predictedSpectra.join(',')} in progress`);
|
|
74
76
|
try {
|
|
75
|
-
const data = await (0, PredictionManager_1.predictSpectra)(molfile);
|
|
77
|
+
const data = await (0, PredictionManager_1.predictSpectra)(molfile, logger);
|
|
76
78
|
dispatch({
|
|
77
79
|
type: 'PREDICT_SPECTRA',
|
|
78
80
|
payload: {
|
|
@@ -91,7 +93,15 @@ function PredictSpectraModal({ onClose = () => null, molecule, }) {
|
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
})();
|
|
94
|
-
}, [
|
|
96
|
+
}, [
|
|
97
|
+
alert,
|
|
98
|
+
dispatch,
|
|
99
|
+
isApproved,
|
|
100
|
+
molecule,
|
|
101
|
+
onClose,
|
|
102
|
+
logger,
|
|
103
|
+
setPredictionPreferences,
|
|
104
|
+
]);
|
|
95
105
|
const approveCheckHandler = (0, react_2.useCallback)((e) => {
|
|
96
106
|
setApproved(e.target.checked);
|
|
97
107
|
}, []);
|
|
@@ -57,18 +57,36 @@ const styles = (0, react_1.css) `
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
`;
|
|
60
|
-
function EditRangeModal({
|
|
60
|
+
function EditRangeModal({ onSave, onClose, onZoom, onRest, rangeId, }) {
|
|
61
61
|
const formRef = (0, react_2.useRef)(null);
|
|
62
62
|
const { view: { spectra: { activeTab }, }, } = (0, ChartContext_1.useChartData)();
|
|
63
63
|
const dispatch = (0, DispatchContext_1.useDispatch)();
|
|
64
|
+
const range = useRange(rangeId);
|
|
65
|
+
const originalRangeRef = (0, react_2.useRef)(range);
|
|
64
66
|
const rangesPreferences = (0, usePanelPreferences_1.usePanelPreferences)('ranges', activeTab);
|
|
65
|
-
const range = useRange(originRange, manualRange);
|
|
66
67
|
const handleOnZoom = (0, react_2.useCallback)(() => {
|
|
67
|
-
|
|
68
|
-
}, [
|
|
68
|
+
onZoom(range);
|
|
69
|
+
}, [onZoom, range]);
|
|
70
|
+
(0, react_2.useEffect)(() => {
|
|
71
|
+
dispatch({
|
|
72
|
+
type: 'SET_SELECTED_TOOL',
|
|
73
|
+
payload: {
|
|
74
|
+
selectedTool: 'zoom',
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
if (!range) {
|
|
78
|
+
onClose?.();
|
|
79
|
+
}
|
|
80
|
+
}, [activeTab, dispatch, onClose, range]);
|
|
69
81
|
const handleOnClose = (0, react_2.useCallback)(() => {
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
dispatch({
|
|
83
|
+
type: 'SET_SELECTED_TOOL',
|
|
84
|
+
payload: {
|
|
85
|
+
selectedTool: 'zoom',
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
onRest(originalRangeRef.current);
|
|
89
|
+
}, [dispatch, onRest]);
|
|
72
90
|
const getCouplings = (0, react_2.useCallback)((couplings) => couplings
|
|
73
91
|
.filter((coupling) => coupling.coupling !== '')
|
|
74
92
|
.map((coupling) => {
|
|
@@ -93,9 +111,9 @@ function EditRangeModal({ onSaveEditRangeModal = () => null, onCloseEditRangeMod
|
|
|
93
111
|
void (async () => {
|
|
94
112
|
const _range = { ...range };
|
|
95
113
|
_range.signals = getSignals(formValues.signals);
|
|
96
|
-
await
|
|
114
|
+
await onSave(_range);
|
|
97
115
|
})();
|
|
98
|
-
}, [getSignals,
|
|
116
|
+
}, [getSignals, onSave, range]);
|
|
99
117
|
const data = (0, react_2.useMemo)(() => {
|
|
100
118
|
const signals = range?.signals.map((signal) => {
|
|
101
119
|
// counter within j array to access to right j values
|
|
@@ -119,7 +137,7 @@ function EditRangeModal({ onSaveEditRangeModal = () => null, onCloseEditRangeMod
|
|
|
119
137
|
return { ...signal, js: couplings };
|
|
120
138
|
});
|
|
121
139
|
return { activeTab: '0', signals };
|
|
122
|
-
}, [range?.signals, rangesPreferences
|
|
140
|
+
}, [range?.signals, rangesPreferences]);
|
|
123
141
|
const changeHandler = (0, react_2.useCallback)((values) => {
|
|
124
142
|
const signals = getSignals(values.signals);
|
|
125
143
|
if (JSON.stringify(range?.signals, (key, value) => {
|
|
@@ -136,14 +154,16 @@ function EditRangeModal({ onSaveEditRangeModal = () => null, onCloseEditRangeMod
|
|
|
136
154
|
});
|
|
137
155
|
}
|
|
138
156
|
}, [dispatch, getSignals, range]);
|
|
157
|
+
if (!rangesPreferences || !range) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
139
160
|
return ((0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsxs)("div", { className: "header handle", children: [(0, jsx_runtime_1.jsx)(Button_1.default.Action, { onClick: handleOnZoom, fill: "outline", style: { fontSize: '14' }, color: { base: '#5f5f5f', hover: 'white' }, children: (0, jsx_runtime_1.jsx)(fa_1.FaSearchPlus, { title: "Set to default view on range in spectrum" }) }), (0, jsx_runtime_1.jsx)("span", { className: "title", children: ` Range and Signal edition: ${(0, formatNumber_1.formatNumber)(range?.from, rangesPreferences.from.format)} ppm to ${(0, formatNumber_1.formatNumber)(range?.to, rangesPreferences.to.format)} ppm` }), (0, jsx_runtime_1.jsx)(SaveButton_1.default, { onClick: () => formRef.current.submitForm(), popupTitle: "Save and Exit" }), (0, jsx_runtime_1.jsx)(CloseButton_1.default, { onClick: handleOnClose })] }), (0, jsx_runtime_1.jsx)(formik_1.Formik, { innerRef: formRef, initialValues: data, validationSchema: EditRangeValidation_1.default, onSubmit: handleOnSave, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SignalsForm_1.default, { range: range, preferences: rangesPreferences }), (0, jsx_runtime_1.jsx)(FormikOnChange_1.default, { onChange: changeHandler })] }) })] }));
|
|
140
161
|
}
|
|
141
|
-
function useRange(
|
|
162
|
+
function useRange(rangeId) {
|
|
142
163
|
const { ranges } = (0, useSpectrum_1.default)({
|
|
143
164
|
ranges: { values: [] },
|
|
144
165
|
});
|
|
145
|
-
const
|
|
146
|
-
const index = ranges.values.findIndex((rangeRecord) => rangeRecord.id === id);
|
|
166
|
+
const index = ranges.values.findIndex((rangeRecord) => rangeRecord.id === rangeId);
|
|
147
167
|
return ranges.values[index];
|
|
148
168
|
}
|
|
149
169
|
exports.default = EditRangeModal;
|
|
@@ -33,6 +33,8 @@ const formik_1 = require("formik");
|
|
|
33
33
|
const react_2 = require("react");
|
|
34
34
|
const fa_1 = require("react-icons/fa");
|
|
35
35
|
const ui_1 = require("react-science/ui");
|
|
36
|
+
const clipboardComponents_1 = require("../../../utils/clipboard/clipboardComponents");
|
|
37
|
+
const clipboardHooks_1 = require("../../../utils/clipboard/clipboardHooks");
|
|
36
38
|
const PreferencesContext_1 = require("../../context/PreferencesContext");
|
|
37
39
|
const ActionButtons_1 = __importDefault(require("../../elements/ActionButtons"));
|
|
38
40
|
const Button_1 = __importDefault(require("../../elements/Button"));
|
|
@@ -43,7 +45,6 @@ const DropDownButton_1 = __importDefault(require("../../elements/dropDownButton/
|
|
|
43
45
|
const Alert_1 = require("../../elements/popup/Alert");
|
|
44
46
|
const useSaveSettings_1 = require("../../hooks/useSaveSettings");
|
|
45
47
|
const getPreferencesByWorkspace_1 = require("../../reducer/preferences/utilities/getPreferencesByWorkspace");
|
|
46
|
-
const export_1 = require("../../utility/export");
|
|
47
48
|
const workspaces_1 = __importDefault(require("../../workspaces"));
|
|
48
49
|
const WorkspaceItem_1 = __importDefault(require("./WorkspaceItem"));
|
|
49
50
|
const DatabasesTabContent_1 = __importDefault(require("./settings-tabs/DatabasesTabContent"));
|
|
@@ -56,7 +57,8 @@ const OnLoadProcessingTabContent_1 = __importDefault(require("./settings-tabs/On
|
|
|
56
57
|
const ToolsTabContent_1 = __importDefault(require("./settings-tabs/ToolsTabContent"));
|
|
57
58
|
const settingsValidation_1 = require("./settingsValidation");
|
|
58
59
|
const styles = (0, react_1.css) `
|
|
59
|
-
width:
|
|
60
|
+
width: 50vw;
|
|
61
|
+
min-width: 800px;
|
|
60
62
|
|
|
61
63
|
.main-content {
|
|
62
64
|
width: 100%;
|
|
@@ -161,7 +163,7 @@ function GeneralSettingsModal({ height }) {
|
|
|
161
163
|
dispatch({
|
|
162
164
|
type: 'ADD_WORKSPACE',
|
|
163
165
|
payload: {
|
|
164
|
-
|
|
166
|
+
workspaceKey: name,
|
|
165
167
|
data: refForm.current?.values,
|
|
166
168
|
},
|
|
167
169
|
});
|
|
@@ -203,20 +205,16 @@ function GeneralSettingsModal({ height }) {
|
|
|
203
205
|
function handleDisabledRestButton(values) {
|
|
204
206
|
setRestDisabled(isRestButtonDisable(values, workspaceName, originalWorkspaces));
|
|
205
207
|
}
|
|
208
|
+
const { readText, rawWriteWithType, shouldFallback, cleanShouldFallback, text, } = (0, clipboardHooks_1.useClipboard)();
|
|
206
209
|
function handleCopyWorkspace() {
|
|
207
210
|
const data = { [workspaceName]: refForm.current?.values };
|
|
208
|
-
void (
|
|
209
|
-
|
|
210
|
-
alert.success('Workspace copied to clipboard');
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
alert.error('copied not completed');
|
|
214
|
-
}
|
|
211
|
+
void rawWriteWithType(JSON.stringify(data)).then(() => {
|
|
212
|
+
alert.success('Workspace copied to clipboard');
|
|
215
213
|
});
|
|
216
214
|
}
|
|
217
215
|
const setWorkspaceSetting = (0, react_2.useCallback)((inputWorkspace) => {
|
|
218
216
|
const parseWorkspaceName = Object.keys(inputWorkspace)[0];
|
|
219
|
-
if (preferences
|
|
217
|
+
if (preferences.workspace.current === parseWorkspaceName) {
|
|
220
218
|
refForm.current?.setValues(inputWorkspace[parseWorkspaceName]);
|
|
221
219
|
}
|
|
222
220
|
else if (preferences.workspaces[parseWorkspaceName]) {
|
|
@@ -229,41 +227,44 @@ function GeneralSettingsModal({ height }) {
|
|
|
229
227
|
},
|
|
230
228
|
});
|
|
231
229
|
}
|
|
232
|
-
}, [dispatch, preferences
|
|
233
|
-
function handlePastWorkspace() {
|
|
234
|
-
void navigator.clipboard.readText().then((text) => {
|
|
235
|
-
try {
|
|
236
|
-
const parseWorkspaces = JSON.parse(text);
|
|
237
|
-
setWorkspaceSetting(parseWorkspaces);
|
|
238
|
-
}
|
|
239
|
-
catch {
|
|
240
|
-
alert.error('object parse error');
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
}
|
|
230
|
+
}, [dispatch, preferences.workspace, preferences.workspaces]);
|
|
244
231
|
(0, react_2.useEffect)(() => {
|
|
245
232
|
if (pastRef.current) {
|
|
246
233
|
setWorkspaceSetting(pastRef.current);
|
|
247
234
|
pastRef.current = null;
|
|
248
235
|
}
|
|
249
236
|
}, [setWorkspaceSetting]);
|
|
250
|
-
|
|
237
|
+
function handlePastWorkspace(text) {
|
|
238
|
+
if (!text)
|
|
239
|
+
return;
|
|
240
|
+
try {
|
|
241
|
+
const parseWorkspaces = JSON.parse(text);
|
|
242
|
+
setWorkspaceSetting(parseWorkspaces);
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
alert.error('object parse error');
|
|
246
|
+
}
|
|
247
|
+
cleanShouldFallback();
|
|
248
|
+
}
|
|
249
|
+
function handlePastWorkspaceAction() {
|
|
250
|
+
void readText().then(handlePastWorkspace);
|
|
251
|
+
}
|
|
252
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ui_1.Toolbar.Item, { id: "general-settings", onClick: openDialog, title: "General settings", children: (0, jsx_runtime_1.jsx)(fa_1.FaWrench, {}) }), (0, jsx_runtime_1.jsxs)(ui_1.Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, maxWidth: 1000, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
251
253
|
display: 'flex',
|
|
252
254
|
flexDirection: 'column',
|
|
253
|
-
width: '100%',
|
|
254
255
|
}, children: [(0, jsx_runtime_1.jsx)("span", { children: "General Settings" }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
255
256
|
display: 'flex',
|
|
256
257
|
alignItems: 'center',
|
|
257
258
|
cursor: 'default',
|
|
258
259
|
paddingTop: '10px',
|
|
259
|
-
}, children: [(0, jsx_runtime_1.jsx)(Label_1.default, { title: "Workspace", children: (0, jsx_runtime_1.jsx)(DropDownButton_1.default, { data: workspacesList, renderItem: renderItem, selectedKey: preferences
|
|
260
|
+
}, children: [(0, jsx_runtime_1.jsx)(Label_1.default, { title: "Workspace", children: (0, jsx_runtime_1.jsx)(DropDownButton_1.default, { data: workspacesList, renderItem: renderItem, selectedKey: preferences.workspace.current, onSelect: ChangeWorkspaceHandler }) }), (0, jsx_runtime_1.jsx)(Button_1.default.Action, { size: "xSmall", onClick: handleReset, toolTip: "Reset workspace preferences", tooltipOrientation: "horizontal", style: {
|
|
260
261
|
marginLeft: '10px',
|
|
261
262
|
}, disabled: isRestDisabled, children: (0, jsx_runtime_1.jsx)(fa_1.FaBolt, {}) }), (0, jsx_runtime_1.jsx)(Button_1.default.Done, { size: "xSmall", fill: "outline", onClick: handleCopyWorkspace, toolTip: "Copy workspace preferences", tooltipOrientation: "horizontal", style: {
|
|
262
263
|
marginLeft: '10px',
|
|
263
|
-
}, children: (0, jsx_runtime_1.jsx)(fa_1.FaRegCopy, {}) }), (0, jsx_runtime_1.jsx)(Button_1.default.Action, { size: "xSmall", fill: "outline", onClick:
|
|
264
|
+
}, children: (0, jsx_runtime_1.jsx)(fa_1.FaRegCopy, {}) }), (0, jsx_runtime_1.jsx)(Button_1.default.Action, { size: "xSmall", fill: "outline", onClick: handlePastWorkspaceAction, toolTip: "Past workspace preferences", tooltipOrientation: "horizontal", style: {
|
|
264
265
|
marginLeft: '10px',
|
|
265
266
|
}, children: (0, jsx_runtime_1.jsx)(fa_1.FaPaste, {}) })] })] }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Body, { children: (0, jsx_runtime_1.jsx)("div", { css: styles, style: { height }, children: (0, jsx_runtime_1.jsx)(formik_1.Formik, { enableReinitialize: true, innerRef: refForm, initialValues: currentWorkspace, validationSchema: settingsValidation_1.validation, onSubmit: submitHandler, validate: handleDisabledRestButton, children: (0, jsx_runtime_1.jsxs)(Tabs_1.default, { position: Tabs_1.PositionsEnum.LEFT, activeTab: activeTab, onClick: tabChangeHandler, children: [(0, jsx_runtime_1.jsx)(Tab_1.default, { title: "General", tabid: "general", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(GeneralTabContent_1.default, {}) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Formatting", tabid: "formatting", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(FormattingTabContent_1.default, {}) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Panels", tabid: "display", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(DisplayTabContent_1.default, {}) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Tools", tabid: "tools", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(ToolsTabContent_1.default, {}) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Databases", tabid: "databases", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(DatabasesTabContent_1.default, { currentWorkspace: workspaceName, originalWorkspaces: originalWorkspaces }) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Import filters", tabid: "importation-filters", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(ImportationFiltersTabContent_1.default, {}) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Title Block", tabid: "title-block", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(InfoBlockTabContent_1.default, {}) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "On Load Processing", tabid: "on-load-processing", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(OnLoadProcessingTabContent_1.default, {}) }) })] }) }) }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Footer, { children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', justifyContent: 'flex-end' }, children: [(0, jsx_runtime_1.jsx)(ActionButtons_1.default, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: () => refForm.current?.submitForm(), doneLabel: "Apply and Save", onCancel: () => {
|
|
266
267
|
closeDialog?.();
|
|
267
|
-
} }), (0, jsx_runtime_1.jsx)(Button_1.default.Secondary, { style: { margin: '0 10px' }, onClick: applyPreferencesHandler, children: "Apply" })] }) })] }), (0, jsx_runtime_1.jsx)(SaveSettingsModal, {})] }));
|
|
268
|
+
} }), (0, jsx_runtime_1.jsx)(Button_1.default.Secondary, { style: { margin: '0 10px' }, onClick: applyPreferencesHandler, children: "Apply" })] }) })] }), (0, jsx_runtime_1.jsx)(SaveSettingsModal, {}), (0, jsx_runtime_1.jsx)(clipboardComponents_1.ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePastWorkspace, text: text, label: "Workspace" })] }));
|
|
268
269
|
}
|
|
269
270
|
exports.default = GeneralSettingsModal;
|
|
@@ -10,6 +10,8 @@ const react_1 = require("react");
|
|
|
10
10
|
const fa_1 = require("react-icons/fa");
|
|
11
11
|
const io5_1 = require("react-icons/io5");
|
|
12
12
|
const ui_1 = require("react-science/ui");
|
|
13
|
+
const clipboardComponents_1 = require("../../../utils/clipboard/clipboardComponents");
|
|
14
|
+
const clipboardHooks_1 = require("../../../utils/clipboard/clipboardHooks");
|
|
13
15
|
const AssignmentsContext_1 = require("../../assignment/AssignmentsContext");
|
|
14
16
|
const DispatchContext_1 = require("../../context/DispatchContext");
|
|
15
17
|
const GlobalContext_1 = require("../../context/GlobalContext");
|
|
@@ -92,16 +94,12 @@ function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMolecul
|
|
|
92
94
|
(0, export_1.copyPNGToClipboard)(rootRef, `molSVG${currentIndex} `);
|
|
93
95
|
alert.success('MOL copied as PNG to clipboard');
|
|
94
96
|
}, [rootRef, alert, currentIndex]);
|
|
97
|
+
const { rawWriteWithType, readText, shouldFallback, cleanShouldFallback, text, } = (0, clipboardHooks_1.useClipboard)();
|
|
95
98
|
const saveAsMolHandler = (0, react_1.useCallback)((molfile) => {
|
|
96
|
-
void (
|
|
97
|
-
|
|
98
|
-
alert.success('MOLFile copied to clipboard');
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
alert.error('copied not completed');
|
|
102
|
-
}
|
|
99
|
+
void rawWriteWithType(molfile).then(() => {
|
|
100
|
+
alert.success('MOLFile copied to clipboard');
|
|
103
101
|
});
|
|
104
|
-
}, [alert]);
|
|
102
|
+
}, [alert, rawWriteWithType]);
|
|
105
103
|
const exportHandler = (0, react_1.useCallback)((selected) => {
|
|
106
104
|
const molecule = molecules?.[currentIndex];
|
|
107
105
|
if (molecule) {
|
|
@@ -130,11 +128,15 @@ function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMolecul
|
|
|
130
128
|
saveAsPNGHandler,
|
|
131
129
|
saveAsSVGHandler,
|
|
132
130
|
]);
|
|
133
|
-
|
|
134
|
-
void
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
function handlePasteMolfileAction() {
|
|
132
|
+
void readText().then(handlePasteMolfile);
|
|
133
|
+
}
|
|
134
|
+
function handlePasteMolfile(molfile) {
|
|
135
|
+
if (!molfile)
|
|
136
|
+
return;
|
|
137
|
+
dispatch({ type: 'ADD_MOLECULE', payload: { molfile } });
|
|
138
|
+
cleanShouldFallback();
|
|
139
|
+
}
|
|
138
140
|
const handleDelete = (0, react_1.useCallback)(() => {
|
|
139
141
|
if (molecules[currentIndex]?.id) {
|
|
140
142
|
onMoleculeIndexChange?.(0);
|
|
@@ -163,8 +165,8 @@ function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMolecul
|
|
|
163
165
|
});
|
|
164
166
|
}
|
|
165
167
|
const hasMolecules = molecules && molecules.length > 0;
|
|
166
|
-
return ((0, jsx_runtime_1.jsxs)(PanelHeader_1.default, { children: [renderSource === 'predictionPanel' && (0, jsx_runtime_1.jsx)(AboutPredictionModal_1.default, {}), renderSource === 'moleculePanel' && ((0, jsx_runtime_1.jsx)(ui_1.DropdownMenu, { trigger: "click", options: MOL_EXPORT_MENU, onSelect: exportHandler, children: (0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { as: "div", disabled: !hasMolecules, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Export As", tooltipOrientation: "horizontal", children: (0, jsx_runtime_1.jsx)(fa_1.FaFileExport, {}) }) })), (0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick:
|
|
168
|
+
return ((0, jsx_runtime_1.jsxs)(PanelHeader_1.default, { children: [renderSource === 'predictionPanel' && (0, jsx_runtime_1.jsx)(AboutPredictionModal_1.default, {}), renderSource === 'moleculePanel' && ((0, jsx_runtime_1.jsx)(ui_1.DropdownMenu, { trigger: "click", options: MOL_EXPORT_MENU, onSelect: exportHandler, children: (0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { as: "div", disabled: !hasMolecules, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Export As", tooltipOrientation: "horizontal", children: (0, jsx_runtime_1.jsx)(fa_1.FaFileExport, {}) }) })), (0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: handlePasteMolfileAction, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Paste molfile", tooltipOrientation: "horizontal", children: (0, jsx_runtime_1.jsx)(fa_1.FaPaste, {}) }), (0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: onOpenMoleculeEditor, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Add molecule", tooltipOrientation: "horizontal", children: (0, jsx_runtime_1.jsx)(fa_1.FaPlus, {}) }), renderSource === 'moleculePanel' && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: handleDelete, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Delete molecule", tooltipOrientation: "horizontal", disabled: !hasMolecules, children: (0, jsx_runtime_1.jsx)(fa_1.FaRegTrashAlt, {}) }), hasMolecules && ((0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { color: { base: '#4e4e4e', hover: '#4e4e4e' }, onClick: () => openPredictSpectraModal(molecules[currentIndex]), toolTip: "Predict spectra", tooltipOrientation: "horizontal", children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrFt, {}) }))] })), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { value: moleculesView?.[moleculeKey]?.floating.visible || false, popupTitle: "Float molecule", popupPlacement: "left", onClick: floatMoleculeHandler, disabled: !hasMolecules, children: (0, jsx_runtime_1.jsx)(io5_1.IoOpenOutline, {}) }), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { style: { marginLeft: '2px' }, value: moleculesView?.[moleculeKey]?.showAtomNumber || false, popupTitle: "Show atom number", popupPlacement: "left", onClick: showAtomNumbersHandler, disabled: !hasMolecules, children: (0, jsx_runtime_1.jsx)("p", { style: styles.atomLabel, children: "#" }) }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1 }, children: children }), (0, jsx_runtime_1.jsxs)("p", { style: styles.counter, children: [molecules &&
|
|
167
169
|
molecules.length > 0 &&
|
|
168
|
-
`${+(currentIndex + 1)} / ${molecules.length}`, ' '] }), onClickPreferences && ((0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { color: { base: 'black', hover: 'black' }, onClick: onClickPreferences, toolTip: "Preferences", tooltipOrientation: "vertical", children: (0, jsx_runtime_1.jsx)(fa_1.FaCog, {}) }))] }));
|
|
170
|
+
`${+(currentIndex + 1)} / ${molecules.length}`, ' '] }), onClickPreferences && ((0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { color: { base: 'black', hover: 'black' }, onClick: onClickPreferences, toolTip: "Preferences", tooltipOrientation: "vertical", children: (0, jsx_runtime_1.jsx)(fa_1.FaCog, {}) })), (0, jsx_runtime_1.jsx)(clipboardComponents_1.ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePasteMolfile, text: text, label: "Molfile" })] }));
|
|
169
171
|
}
|
|
170
172
|
exports.default = MoleculePanelHeader;
|
package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js
CHANGED
|
@@ -11,6 +11,8 @@ const react_2 = require("react");
|
|
|
11
11
|
const fa_1 = require("react-icons/fa");
|
|
12
12
|
const io5_1 = require("react-icons/io5");
|
|
13
13
|
const multipleSpectraAnalysis_1 = require("../../../data/data1d/multipleSpectraAnalysis");
|
|
14
|
+
const clipboardComponents_1 = require("../../../utils/clipboard/clipboardComponents");
|
|
15
|
+
const clipboardHooks_1 = require("../../../utils/clipboard/clipboardHooks");
|
|
14
16
|
const ChartContext_1 = require("../../context/ChartContext");
|
|
15
17
|
const DispatchContext_1 = require("../../context/DispatchContext");
|
|
16
18
|
const ButtonToolTip_1 = __importDefault(require("../../elements/ButtonToolTip"));
|
|
@@ -19,7 +21,6 @@ const Alert_1 = require("../../elements/popup/Alert");
|
|
|
19
21
|
const Modal_1 = require("../../elements/popup/Modal");
|
|
20
22
|
const usePanelPreferences_1 = require("../../hooks/usePanelPreferences");
|
|
21
23
|
const AlignSpectraModal_1 = __importDefault(require("../../modal/AlignSpectraModal"));
|
|
22
|
-
const export_1 = require("../../utility/export");
|
|
23
24
|
const getSpectraByNucleus_1 = require("../../utility/getSpectraByNucleus");
|
|
24
25
|
const BasicPanelStyle_1 = require("../extra/BasicPanelStyle");
|
|
25
26
|
const DefaultPanelHeader_1 = __importDefault(require("../header/DefaultPanelHeader"));
|
|
@@ -55,18 +56,13 @@ function MultipleSpectraAnalysisPanelInner({ activeTab, spectra, showLegend, })
|
|
|
55
56
|
width: 500,
|
|
56
57
|
});
|
|
57
58
|
}, [activeTab, modal, dispatch]);
|
|
59
|
+
const { rawWriteWithType, cleanShouldFallback, shouldFallback, text } = (0, clipboardHooks_1.useClipboard)();
|
|
58
60
|
const copyToClipboardHandler = (0, react_2.useCallback)(() => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
alert.error('copy to clipboard failed');
|
|
67
|
-
}
|
|
68
|
-
})();
|
|
69
|
-
}, [alert, spectra, spectraAnalysis, spectraPreferences]);
|
|
61
|
+
const data = (0, multipleSpectraAnalysis_1.getDataAsString)(spectraAnalysis, spectra, spectraPreferences);
|
|
62
|
+
if (!data)
|
|
63
|
+
return;
|
|
64
|
+
void rawWriteWithType(data).then(() => alert.success('Data copied to clipboard'));
|
|
65
|
+
}, [alert, rawWriteWithType, spectra, spectraAnalysis, spectraPreferences]);
|
|
70
66
|
return ((0, jsx_runtime_1.jsxs)("div", { css: [
|
|
71
67
|
BasicPanelStyle_1.tablePanelStyle,
|
|
72
68
|
isFlipped &&
|
|
@@ -75,7 +71,7 @@ function MultipleSpectraAnalysisPanelInner({ activeTab, spectra, showLegend, })
|
|
|
75
71
|
position: relative;
|
|
76
72
|
}
|
|
77
73
|
`,
|
|
78
|
-
], children: [!isFlipped && ((0, jsx_runtime_1.jsxs)(DefaultPanelHeader_1.default, { deleteToolTip: "Delete All Peaks", showSettingButton: true, canDelete: false, onSettingClick: settingsPanelHandler, children: [(0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Copy To Clipboard", onClick: copyToClipboardHandler, children: (0, jsx_runtime_1.jsx)(fa_1.FaFileExport, {}) }), (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Spectra calibration", onClick: openAlignSpectra, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrOverlay, { style: { fontSize: '18px' } }) }), (0, jsx_runtime_1.jsx)(ToggleButton_1.default, { popupTitle: "Y spectra tracker", popupPlacement: "right", onClick: showTrackerHandler, defaultValue: showLegend, children: (0, jsx_runtime_1.jsx)(io5_1.IoPulseOutline, {}) }, `${showLegend}`)] })), isFlipped && ((0, jsx_runtime_1.jsx)(PreferencesHeader_1.default, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), (0, jsx_runtime_1.jsx)("div", { className: "inner-container", children: !isFlipped ? ((0, jsx_runtime_1.jsx)(MultipleSpectraAnalysisTable_1.default, { data: spectraAnalysis, resortSpectra: preferences.analysisOptions.resortSpectra, activeTab: activeTab })) : ((0, jsx_runtime_1.jsx)(preferences_1.default, { data: spectraAnalysis, activeTab: activeTab, onAfterSave: afterSaveHandler, ref: settingRef })) })] }));
|
|
74
|
+
], children: [!isFlipped && ((0, jsx_runtime_1.jsxs)(DefaultPanelHeader_1.default, { deleteToolTip: "Delete All Peaks", showSettingButton: true, canDelete: false, onSettingClick: settingsPanelHandler, children: [(0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Copy To Clipboard", onClick: copyToClipboardHandler, children: (0, jsx_runtime_1.jsx)(fa_1.FaFileExport, {}) }), (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Spectra calibration", onClick: openAlignSpectra, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrOverlay, { style: { fontSize: '18px' } }) }), (0, jsx_runtime_1.jsx)(ToggleButton_1.default, { popupTitle: "Y spectra tracker", popupPlacement: "right", onClick: showTrackerHandler, defaultValue: showLegend, children: (0, jsx_runtime_1.jsx)(io5_1.IoPulseOutline, {}) }, `${showLegend}`)] })), isFlipped && ((0, jsx_runtime_1.jsx)(PreferencesHeader_1.default, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), (0, jsx_runtime_1.jsx)("div", { className: "inner-container", children: !isFlipped ? ((0, jsx_runtime_1.jsx)(MultipleSpectraAnalysisTable_1.default, { data: spectraAnalysis, resortSpectra: preferences.analysisOptions.resortSpectra, activeTab: activeTab })) : ((0, jsx_runtime_1.jsx)(preferences_1.default, { data: spectraAnalysis, activeTab: activeTab, onAfterSave: afterSaveHandler, ref: settingRef })) }), (0, jsx_runtime_1.jsx)(clipboardComponents_1.ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Spectra Analysis" })] }));
|
|
79
75
|
}
|
|
80
76
|
const MemoizedMultipleSpectraAnalysisPanel = (0, react_2.memo)(MultipleSpectraAnalysisPanelInner);
|
|
81
77
|
function MultipleSpectraAnalysisPanel() {
|
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.AnalysisTablePreferences = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const formik_1 = require("formik");
|
|
9
|
+
const nmr_load_save_1 = require("nmr-load-save");
|
|
9
10
|
const react_1 = require("react");
|
|
10
11
|
const fa_1 = require("react-icons/fa");
|
|
11
12
|
const Button_1 = __importDefault(require("../../../elements/Button"));
|
|
12
13
|
const ReactTable_1 = __importDefault(require("../../../elements/ReactTable/ReactTable"));
|
|
13
14
|
const FormikInput_1 = __importDefault(require("../../../elements/formik/FormikInput"));
|
|
14
|
-
const nmr_load_save_1 = require("nmr-load-save");
|
|
15
15
|
const inputStyle = { input: { width: '100%', fontSize: '1.15em' } };
|
|
16
16
|
function AnalysisTablePreferences() {
|
|
17
17
|
const { values: { analysisOptions: { columns }, }, setFieldValue, } = (0, formik_1.useFormikContext)();
|
|
@@ -44,7 +44,7 @@ const accordionItems = [
|
|
|
44
44
|
title: 'Peaks',
|
|
45
45
|
component: (0, jsx_runtime_1.jsx)(PeaksPanel_1.default, {}),
|
|
46
46
|
hidePreferenceKey: 'peaksPanel',
|
|
47
|
-
mode:
|
|
47
|
+
mode: Constants_1.DISPLAYER_MODE.DM_1D,
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
title: 'Processings',
|
|
@@ -56,7 +56,7 @@ const accordionItems = [
|
|
|
56
56
|
title: 'Integrals',
|
|
57
57
|
component: (0, jsx_runtime_1.jsx)(IntegralPanel_1.default, {}),
|
|
58
58
|
hidePreferenceKey: 'integralsPanel',
|
|
59
|
-
mode:
|
|
59
|
+
mode: Constants_1.DISPLAYER_MODE.DM_1D,
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
title: 'Ranges',
|
|
@@ -11,6 +11,8 @@ const get_1 = __importDefault(require("lodash/get"));
|
|
|
11
11
|
const nmr_processing_1 = require("nmr-processing");
|
|
12
12
|
const fa_1 = require("react-icons/fa");
|
|
13
13
|
const im_1 = require("react-icons/im");
|
|
14
|
+
const clipboardComponents_1 = require("../../../utils/clipboard/clipboardComponents");
|
|
15
|
+
const clipboardHooks_1 = require("../../../utils/clipboard/clipboardHooks");
|
|
14
16
|
const AssignmentsContext_1 = require("../../assignment/AssignmentsContext");
|
|
15
17
|
const DispatchContext_1 = require("../../context/DispatchContext");
|
|
16
18
|
const ActiveButton_1 = __importDefault(require("../../elements/ActiveButton"));
|
|
@@ -20,7 +22,6 @@ const Modal_1 = require("../../elements/popup/Modal");
|
|
|
20
22
|
const usePanelPreferences_1 = require("../../hooks/usePanelPreferences");
|
|
21
23
|
const CopyClipboardModal_1 = __importDefault(require("../../modal/CopyClipboardModal"));
|
|
22
24
|
const ChangeSumModal_1 = __importDefault(require("../../modal/changeSum/ChangeSumModal"));
|
|
23
|
-
const export_1 = require("../../utility/export");
|
|
24
25
|
const formatNumber_1 = require("../../utility/formatNumber");
|
|
25
26
|
const DefaultPanelHeader_1 = __importDefault(require("../header/DefaultPanelHeader"));
|
|
26
27
|
const style = (0, react_1.css) `
|
|
@@ -92,16 +93,9 @@ function RangesHeader({ id, ranges, info, onUnlink, onFilterActivated, onSetting
|
|
|
92
93
|
function handleShowJGraph() {
|
|
93
94
|
dispatch({ type: 'SHOW_J_GRAPH', payload: { id } });
|
|
94
95
|
}
|
|
96
|
+
const { rawWriteWithType, shouldFallback, cleanShouldFallback, text } = (0, clipboardHooks_1.useClipboard)();
|
|
95
97
|
function saveToClipboardHandler(value) {
|
|
96
|
-
void (
|
|
97
|
-
const success = await (0, export_1.copyHTMLToClipboard)(value);
|
|
98
|
-
if (success) {
|
|
99
|
-
alert.success('Data copied to clipboard');
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
alert.error('copy to clipboard failed');
|
|
103
|
-
}
|
|
104
|
-
})();
|
|
98
|
+
void rawWriteWithType(value, 'text/html').then(() => alert.success('Data copied to clipboard'));
|
|
105
99
|
}
|
|
106
100
|
function saveAsHTMLHandler() {
|
|
107
101
|
if (Array.isArray(ranges?.values) && ranges.values.length > 0) {
|
|
@@ -123,10 +117,10 @@ function RangesHeader({ id, ranges, info, onUnlink, onFilterActivated, onSetting
|
|
|
123
117
|
});
|
|
124
118
|
}
|
|
125
119
|
const hasRanges = Array.isArray(ranges?.values) && ranges.values.length > 0;
|
|
126
|
-
return ((0, jsx_runtime_1.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
120
|
+
return ((0, jsx_runtime_1.jsxs)("div", { css: style, children: [(0, jsx_runtime_1.jsxs)(DefaultPanelHeader_1.default, { counter: ranges?.values?.length || 0, onDelete: handleDeleteAll, deleteToolTip: "Delete All Ranges", onFilter: onFilterActivated, filterToolTip: isFilterActive ? 'Show all ranges' : 'Hide ranges out of view', filterIsActive: isFilterActive, counterFiltered: filterCounter, showSettingButton: true, onSettingClick: onSettingClick, children: [(0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Preview publication string", popupPlacement: "right", onClick: saveAsHTMLHandler, className: "btn preview-publication-icon", disabled: !hasRanges, children: (0, jsx_runtime_1.jsx)(fa_1.FaFileExport, {}) }), (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: currentSum
|
|
121
|
+
? `Change ranges sum (${Number(currentSum).toFixed(2)})`
|
|
122
|
+
: 'Change ranges sum', popupPlacement: "right", onClick: showChangeRangesSumModal, className: "btn icon", children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrSum, {}) }), (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Remove all assignments", popupPlacement: "right", onClick: handleOnRemoveAssignments, disabled: !hasRanges, className: "btn icon", children: (0, jsx_runtime_1.jsx)(fa_1.FaUnlink, {}) }), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { popupTitle: showMultiplicityTrees
|
|
123
|
+
? 'Hide multiplicity trees in spectrum'
|
|
124
|
+
: 'Show multiplicity trees in spectrum', popupPlacement: "right", onClick: handleSetShowMultiplicityTrees, value: showMultiplicityTrees, disabled: !hasRanges, children: (0, jsx_runtime_1.jsx)(fa_1.FaSitemap, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { popupTitle: showJGraph ? 'Hide J Graph' : 'Show J Graph', popupPlacement: "right", onClick: handleShowJGraph, value: showJGraph, disabled: !hasRanges, children: (0, jsx_runtime_1.jsx)(fa_1.FaChartBar, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { popupTitle: showRangesIntegrals ? 'Hide integrals' : 'Show integrals', popupPlacement: "right", onClick: handleShowIntegrals, value: showRangesIntegrals, disabled: !hasRanges, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrIntegrate, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), (0, jsx_runtime_1.jsx)(ActiveButton_1.default, { className: "icon", popupTitle: "Fix integral values", popupPlacement: "right", onClick: changeSumConstantFlagHandler, value: ranges?.options?.isSumConstant, children: (0, jsx_runtime_1.jsx)(im_1.ImLink, {}) })] }), (0, jsx_runtime_1.jsx)(clipboardComponents_1.ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Preview publication string" })] }));
|
|
131
125
|
}
|
|
132
126
|
exports.default = RangesHeader;
|
|
@@ -9,6 +9,8 @@ const react_1 = require("@emotion/react");
|
|
|
9
9
|
const ml_spectra_processing_1 = require("ml-spectra-processing");
|
|
10
10
|
const react_2 = require("react");
|
|
11
11
|
const fa_1 = require("react-icons/fa");
|
|
12
|
+
const clipboardComponents_1 = require("../../../utils/clipboard/clipboardComponents");
|
|
13
|
+
const clipboardHooks_1 = require("../../../utils/clipboard/clipboardHooks");
|
|
12
14
|
const AssignmentsContext_1 = require("../../assignment/AssignmentsContext");
|
|
13
15
|
const ChartContext_1 = require("../../context/ChartContext");
|
|
14
16
|
const DispatchContext_1 = require("../../context/DispatchContext");
|
|
@@ -16,7 +18,6 @@ const Alert_1 = require("../../elements/popup/Alert");
|
|
|
16
18
|
const usePanelPreferences_1 = require("../../hooks/usePanelPreferences");
|
|
17
19
|
const useSpectrum_1 = __importDefault(require("../../hooks/useSpectrum"));
|
|
18
20
|
const Reducer_1 = require("../../reducer/Reducer");
|
|
19
|
-
const export_1 = require("../../utility/export");
|
|
20
21
|
const BasicPanelStyle_1 = require("../extra/BasicPanelStyle");
|
|
21
22
|
const NoTableData_1 = __importDefault(require("../extra/placeholder/NoTableData"));
|
|
22
23
|
const PreferencesHeader_1 = __importDefault(require("../header/PreferencesHeader"));
|
|
@@ -73,6 +74,7 @@ function RangesTablePanelInner({ id, ranges, data, info, xDomain, preferences, a
|
|
|
73
74
|
},
|
|
74
75
|
});
|
|
75
76
|
}, [assignmentData, dispatch]);
|
|
77
|
+
const { rawWriteWithType, shouldFallback, cleanShouldFallback, text } = (0, clipboardHooks_1.useClipboard)();
|
|
76
78
|
const saveJSONToClipboardHandler = (0, react_2.useCallback)(async (value) => {
|
|
77
79
|
if (data.x && data.re) {
|
|
78
80
|
const { x, re } = data;
|
|
@@ -86,15 +88,10 @@ function RangesTablePanelInner({ id, ranges, data, info, xDomain, preferences, a
|
|
|
86
88
|
y: Array.from(re.slice(fromIndex, toIndex)),
|
|
87
89
|
...value,
|
|
88
90
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
alert.show('Data copied to clipboard');
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
alert.error('copy to clipboard failed');
|
|
95
|
-
}
|
|
91
|
+
await rawWriteWithType(JSON.stringify(dataToClipboard, undefined, 2));
|
|
92
|
+
alert.show('Data copied to clipboard');
|
|
96
93
|
}
|
|
97
|
-
}, [data, alert]);
|
|
94
|
+
}, [data, rawWriteWithType, alert]);
|
|
98
95
|
const contextMenuSelectHandler = (0, react_2.useCallback)((option, data) => {
|
|
99
96
|
void saveJSONToClipboardHandler(data);
|
|
100
97
|
}, [saveJSONToClipboardHandler]);
|
|
@@ -124,7 +121,7 @@ function RangesTablePanelInner({ id, ranges, data, info, xDomain, preferences, a
|
|
|
124
121
|
showRangesIntegrals,
|
|
125
122
|
showMultiplicityTrees,
|
|
126
123
|
showJGraph,
|
|
127
|
-
isFilterActive, onUnlink: unlinkRangeHandler, onFilterActivated: filterHandler, onSettingClick: settingsPanelHandler, filterCounter: rangesData.length })), isFlipped && ((0, jsx_runtime_1.jsx)(PreferencesHeader_1.default, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), (0, jsx_runtime_1.jsx)("div", { className: "inner-container", children: !isFlipped ? ((0, jsx_runtime_1.jsx)("div", { className: "table-container", children: rangesData && rangesData.length > 0 ? ((0, jsx_runtime_1.jsx)(RangesTable_1.default, { activeTab: activeTab, tableData: rangesData, onUnlink: unlinkRangeHandler, contextMenu: rangesContextMenuOptions, onContextMenuSelect: contextMenuSelectHandler, preferences: preferences, info: info })) : ((0, jsx_runtime_1.jsx)(NoTableData_1.default, {})) })) : ((0, jsx_runtime_1.jsx)(RangesPreferences_1.default, { ref: settingRef })) })] }));
|
|
124
|
+
isFilterActive, onUnlink: unlinkRangeHandler, onFilterActivated: filterHandler, onSettingClick: settingsPanelHandler, filterCounter: rangesData.length })), isFlipped && ((0, jsx_runtime_1.jsx)(PreferencesHeader_1.default, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), (0, jsx_runtime_1.jsx)("div", { className: "inner-container", children: !isFlipped ? ((0, jsx_runtime_1.jsx)("div", { className: "table-container", children: rangesData && rangesData.length > 0 ? ((0, jsx_runtime_1.jsx)(RangesTable_1.default, { activeTab: activeTab, tableData: rangesData, onUnlink: unlinkRangeHandler, contextMenu: rangesContextMenuOptions, onContextMenuSelect: contextMenuSelectHandler, preferences: preferences, info: info })) : ((0, jsx_runtime_1.jsx)(NoTableData_1.default, {})) })) : ((0, jsx_runtime_1.jsx)(RangesPreferences_1.default, { ref: settingRef })) }), (0, jsx_runtime_1.jsx)(clipboardComponents_1.ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Range" })] }));
|
|
128
125
|
}
|
|
129
126
|
const MemoizedRangesTablePanel = (0, react_2.memo)(RangesTablePanelInner);
|
|
130
127
|
const emptyData = { ranges: {}, data: {}, info: {} };
|
|
@@ -62,31 +62,28 @@ function useEditRangeModal(range) {
|
|
|
62
62
|
modal.close();
|
|
63
63
|
}
|
|
64
64
|
}, [assignmentData, dispatch, modal]);
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
deleteRange(range.id, true);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
saveEditRangeHandler(originalRange, false);
|
|
71
|
-
}
|
|
65
|
+
const resetHandler = (0, react_1.useCallback)((originalRange) => {
|
|
66
|
+
saveEditRangeHandler(originalRange, false);
|
|
72
67
|
modal.close();
|
|
73
|
-
}, [
|
|
74
|
-
const editRange = (0, react_1.useCallback)((
|
|
68
|
+
}, [modal, saveEditRangeHandler]);
|
|
69
|
+
const editRange = (0, react_1.useCallback)(() => {
|
|
70
|
+
if (!range?.id)
|
|
71
|
+
return;
|
|
75
72
|
dispatch({
|
|
76
73
|
type: 'SET_SELECTED_TOOL',
|
|
77
74
|
payload: { selectedTool: 'editRange' },
|
|
78
75
|
});
|
|
79
|
-
modal.show((0, jsx_runtime_1.jsx)(EditRangeModal_1.default, {
|
|
76
|
+
modal.show((0, jsx_runtime_1.jsx)(EditRangeModal_1.default, { onRest: resetHandler, onSave: saveEditRangeHandler, onZoom: zoomRange, rangeId: range?.id }), {
|
|
80
77
|
position: options_1.positions.MIDDLE_RIGHT,
|
|
81
78
|
transition: options_1.transitions.SCALE,
|
|
82
79
|
isBackgroundBlur: false,
|
|
83
80
|
});
|
|
84
81
|
zoomRange();
|
|
85
82
|
}, [
|
|
86
|
-
closeEditRangeHandler,
|
|
87
83
|
dispatch,
|
|
88
84
|
modal,
|
|
89
|
-
range,
|
|
85
|
+
range?.id,
|
|
86
|
+
resetHandler,
|
|
90
87
|
saveEditRangeHandler,
|
|
91
88
|
zoomRange,
|
|
92
89
|
]);
|