nmrium 0.38.2 → 0.39.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/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 +5 -0
- 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/hooks/useSaveSettings.js +18 -16
- package/lib/component/modal/LoadJCAMPModal.js +41 -28
- 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 +1 -1
- package/lib/component/panels/MultipleSpectraAnalysisPanel/preferences/AnalysisTablePreferences.js +1 -1
- package/lib/component/panels/Panels.js +2 -2
- 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/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/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/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 +5 -0
- package/lib-cjs/component/elements/formik/FormikError.js +27 -0
- package/lib-cjs/component/hooks/useSaveSettings.js +17 -15
- package/lib-cjs/component/modal/LoadJCAMPModal.js +41 -28
- 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 +1 -1
- 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/hooks/useEditRangeModal.js +9 -12
- 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/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/versionInfo.js +1 -1
- package/package.json +10 -10
|
@@ -34,81 +34,98 @@ function KeysListenerTracker() {
|
|
|
34
34
|
return displayerMode === Constants_1.DISPLAYER_MODE.DM_1D && data && data.length > 0;
|
|
35
35
|
}, [data, displayerMode]);
|
|
36
36
|
const deleteHandler = (0, react_1.useCallback)(async (sourceData) => {
|
|
37
|
-
const { type, extra
|
|
37
|
+
const { type, extra } = sourceData;
|
|
38
38
|
switch (type) {
|
|
39
39
|
case index_1.HighlightEventSource.INTEGRAL: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
const { id } = extra || {};
|
|
41
|
+
if (id) {
|
|
42
|
+
dispatch({
|
|
43
|
+
type: 'DELETE_INTEGRAL',
|
|
44
|
+
payload: {
|
|
45
|
+
id,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
// remove keys from the highlighted list after delete
|
|
49
|
+
remove();
|
|
50
|
+
}
|
|
48
51
|
break;
|
|
49
52
|
}
|
|
50
53
|
case index_1.HighlightEventSource.PEAK: {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const { id } = extra || {};
|
|
55
|
+
if (id) {
|
|
56
|
+
dispatch({
|
|
57
|
+
type: 'DELETE_PEAK',
|
|
58
|
+
payload: {
|
|
59
|
+
id,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
// remove keys from the highlighted list after delete
|
|
63
|
+
remove();
|
|
64
|
+
}
|
|
59
65
|
break;
|
|
60
66
|
}
|
|
61
67
|
case index_1.HighlightEventSource.RANGE: {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
const { id } = extra || {};
|
|
69
|
+
if (id) {
|
|
70
|
+
dispatch({
|
|
71
|
+
type: 'DELETE_RANGE',
|
|
72
|
+
payload: {
|
|
73
|
+
id,
|
|
74
|
+
assignmentData,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
// remove keys from the highlighted list after delete
|
|
78
|
+
remove();
|
|
79
|
+
}
|
|
71
80
|
break;
|
|
72
81
|
}
|
|
73
82
|
case index_1.HighlightEventSource.ZONE: {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
const { id } = extra || {};
|
|
84
|
+
if (id) {
|
|
85
|
+
dispatch({
|
|
86
|
+
type: 'DELETE_2D_ZONE',
|
|
87
|
+
payload: {
|
|
88
|
+
id,
|
|
89
|
+
assignmentData,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
// remove keys from the highlighted list after delete
|
|
93
|
+
remove();
|
|
94
|
+
}
|
|
83
95
|
break;
|
|
84
96
|
}
|
|
85
97
|
case index_1.HighlightEventSource.EXCLUSION_ZONE: {
|
|
98
|
+
const { zone, spectrumID } = extra || {};
|
|
86
99
|
const buttons = [
|
|
87
100
|
{
|
|
88
101
|
text: 'Yes, for all spectra',
|
|
89
102
|
handler: async () => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
103
|
+
if (zone) {
|
|
104
|
+
const hideLoading = await alert.showLoading('Delete all spectra exclusion zones in progress');
|
|
105
|
+
dispatch({
|
|
106
|
+
type: 'DELETE_EXCLUSION_ZONE',
|
|
107
|
+
payload: {
|
|
108
|
+
zone,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
hideLoading();
|
|
112
|
+
}
|
|
98
113
|
},
|
|
99
114
|
},
|
|
100
115
|
{
|
|
101
116
|
text: 'Yes',
|
|
102
117
|
handler: async () => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
118
|
+
if (spectrumID) {
|
|
119
|
+
const hideLoading = await alert.showLoading('Delete exclusion zones in progress');
|
|
120
|
+
dispatch({
|
|
121
|
+
type: 'DELETE_EXCLUSION_ZONE',
|
|
122
|
+
payload: {
|
|
123
|
+
zone,
|
|
124
|
+
spectrumId: spectrumID,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
hideLoading();
|
|
128
|
+
}
|
|
112
129
|
},
|
|
113
130
|
},
|
|
114
131
|
{ text: 'No' },
|
|
@@ -120,19 +137,22 @@ function KeysListenerTracker() {
|
|
|
120
137
|
break;
|
|
121
138
|
}
|
|
122
139
|
case index_1.HighlightEventSource.MATRIX_GENERATION_EXCLUSION_ZONE: {
|
|
140
|
+
const { zone } = extra || {};
|
|
123
141
|
const buttons = [
|
|
124
142
|
{
|
|
125
143
|
text: 'Yes',
|
|
126
144
|
handler: async () => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
145
|
+
if (zone) {
|
|
146
|
+
const hideLoading = await alert.showLoading('Delete all spectra exclusion zones in progress');
|
|
147
|
+
dispatchPreferences({
|
|
148
|
+
type: 'DELETE_MATRIX_GENERATION_EXCLUSION_ZONE',
|
|
149
|
+
payload: {
|
|
150
|
+
zone,
|
|
151
|
+
nucleus: activeTab,
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
hideLoading();
|
|
155
|
+
}
|
|
136
156
|
},
|
|
137
157
|
},
|
|
138
158
|
{ text: 'No' },
|
|
@@ -144,12 +164,15 @@ function KeysListenerTracker() {
|
|
|
144
164
|
break;
|
|
145
165
|
}
|
|
146
166
|
case index_1.HighlightEventSource.MULTIPLE_ANALYSIS_ZONE: {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
167
|
+
const { colKey } = extra || {};
|
|
168
|
+
if (colKey) {
|
|
169
|
+
dispatchPreferences({
|
|
170
|
+
type: 'DELETE_ANALYSIS_COLUMN',
|
|
171
|
+
payload: { columnKey: colKey, nucleus: activeTab },
|
|
172
|
+
});
|
|
173
|
+
// remove keys from the highlighted list after delete
|
|
174
|
+
remove();
|
|
175
|
+
}
|
|
153
176
|
break;
|
|
154
177
|
}
|
|
155
178
|
default:
|
|
@@ -109,8 +109,10 @@ const defaultData = {
|
|
|
109
109
|
spectra: [],
|
|
110
110
|
};
|
|
111
111
|
const NMRium = (0, react_2.forwardRef)(function NMRium(props, ref) {
|
|
112
|
-
const { onError, ...otherProps } = props;
|
|
113
|
-
|
|
112
|
+
const { noErrorBoundary = false, onError, ...otherProps } = props;
|
|
113
|
+
const innerNmrium = (0, jsx_runtime_1.jsx)(InnerNMRium, { ...otherProps, innerRef: ref });
|
|
114
|
+
const children = noErrorBoundary ? (innerNmrium) : ((0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: ErrorOverlay_1.default, onError: onError, children: innerNmrium }));
|
|
115
|
+
return (0, jsx_runtime_1.jsx)(ui_1.RootLayout, { style: { width: '100%' }, children: children });
|
|
114
116
|
});
|
|
115
117
|
function InnerNMRium({ data: dataProp = defaultData, workspace, customWorkspaces, preferences, getSpinner = SpinnerContext_1.defaultGetSpinner, onChange, emptyText, innerRef, }) {
|
|
116
118
|
const rootRef = (0, react_2.useRef)(null);
|
|
@@ -20,6 +20,11 @@ function LoggerProvider({ children }) {
|
|
|
20
20
|
const [logsHistory, setLogsHistory] = (0, react_1.useState)([]);
|
|
21
21
|
const loggerRef = (0, react_1.useRef)(new fifo_logger_1.FifoLogger({
|
|
22
22
|
onChange: (log, logs) => {
|
|
23
|
+
if (log?.error &&
|
|
24
|
+
(log?.levelLabel === 'error' || log?.levelLabel === 'fatal')) {
|
|
25
|
+
// eslint-disable-next-line no-console
|
|
26
|
+
console.error(log.error);
|
|
27
|
+
}
|
|
23
28
|
setLogsHistory(logs.slice());
|
|
24
29
|
},
|
|
25
30
|
}));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const formik_1 = require("formik");
|
|
8
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
9
|
+
const styles = {
|
|
10
|
+
container: {
|
|
11
|
+
padding: '0.4rem',
|
|
12
|
+
display: 'flex',
|
|
13
|
+
flexDirection: 'column',
|
|
14
|
+
},
|
|
15
|
+
text: {
|
|
16
|
+
color: '#fd000c',
|
|
17
|
+
margin: '0.5px',
|
|
18
|
+
fontSize: '0.9em',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
function FormikError({ style, name, children }) {
|
|
22
|
+
const { errors, isValid, dirty, touched } = (0, formik_1.useFormikContext)();
|
|
23
|
+
const errorText = (0, get_1.default)(errors, name);
|
|
24
|
+
const isTouched = (0, get_1.default)(touched, name);
|
|
25
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { ...styles.container, ...style?.container }, children: [children, !isValid && dirty && isTouched && ((0, jsx_runtime_1.jsx)("span", { style: { ...styles.text, ...style?.text }, children: errorText }))] }));
|
|
26
|
+
}
|
|
27
|
+
exports.default = FormikError;
|
|
@@ -52,30 +52,32 @@ const WorkspaceAddForm = (0, react_1.forwardRef)(({ className, message, onSave }
|
|
|
52
52
|
function useSaveSettings() {
|
|
53
53
|
const alert = (0, Context_1.useAlert)();
|
|
54
54
|
const [isOpenDialog, openDialog, closeDialog] = (0, ui_1.useOnOff)(false);
|
|
55
|
-
const
|
|
55
|
+
const settingsRef = (0, react_1.useRef)();
|
|
56
56
|
const { dispatch, current } = (0, PreferencesContext_1.usePreferences)();
|
|
57
57
|
const formRef = (0, react_1.useRef)(null);
|
|
58
|
-
function addNewWorkspace(workspaceName
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
function addNewWorkspace({ workspaceName }) {
|
|
59
|
+
if (settingsRef.current) {
|
|
60
|
+
dispatch({
|
|
61
|
+
type: 'ADD_WORKSPACE',
|
|
62
|
+
payload: {
|
|
63
|
+
workspaceKey: workspaceName,
|
|
64
|
+
data: settingsRef.current,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
closeDialog();
|
|
68
|
+
alert.success('Preferences saved successfully');
|
|
69
|
+
}
|
|
68
70
|
}
|
|
69
71
|
return {
|
|
70
|
-
saveSettings: (values
|
|
71
|
-
|
|
72
|
+
saveSettings: (values) => {
|
|
73
|
+
settingsRef.current = values;
|
|
72
74
|
if (current.source !== 'user') {
|
|
73
75
|
openDialog();
|
|
74
76
|
}
|
|
75
77
|
else {
|
|
76
78
|
dispatch({
|
|
77
79
|
type: 'SET_PREFERENCES',
|
|
78
|
-
payload: values,
|
|
80
|
+
...(values && { payload: values }),
|
|
79
81
|
});
|
|
80
82
|
closeDialog();
|
|
81
83
|
}
|
|
@@ -83,7 +85,7 @@ function useSaveSettings() {
|
|
|
83
85
|
SaveSettingsModal: () => {
|
|
84
86
|
const alertConfig = {
|
|
85
87
|
message: 'Please enter a new user workspace name in order to save your changes locally',
|
|
86
|
-
render: (props) => ((0, jsx_runtime_1.jsx)(WorkspaceAddForm, { ...props, onSave:
|
|
88
|
+
render: (props) => ((0, jsx_runtime_1.jsx)(WorkspaceAddForm, { ...props, onSave: addNewWorkspace, ref: formRef })),
|
|
87
89
|
buttons: [
|
|
88
90
|
{
|
|
89
91
|
text: 'Save',
|
|
@@ -37,12 +37,27 @@ const Yup = __importStar(require("yup"));
|
|
|
37
37
|
const DispatchContext_1 = require("../context/DispatchContext");
|
|
38
38
|
const Button_1 = __importDefault(require("../elements/Button"));
|
|
39
39
|
const Label_1 = __importDefault(require("../elements/Label"));
|
|
40
|
+
const FormikError_1 = __importDefault(require("../elements/formik/FormikError"));
|
|
40
41
|
const FormikInput_1 = __importDefault(require("../elements/formik/FormikInput"));
|
|
41
42
|
const Context_1 = require("../elements/popup/Alert/Context");
|
|
42
|
-
const FileUtility_1 = require("../utility/FileUtility");
|
|
43
43
|
const allowedExtensions = new Set(['dx', 'jdx', 'jcamp']);
|
|
44
44
|
const loadFormValidation = Yup.object({
|
|
45
|
-
url: Yup.string()
|
|
45
|
+
url: Yup.string()
|
|
46
|
+
.url()
|
|
47
|
+
.required()
|
|
48
|
+
.test('file type', 'Imported file must be one of those extensions [ .jdx, .dx, .jcamp ]', (url) => {
|
|
49
|
+
try {
|
|
50
|
+
const fileURL = new URL(url);
|
|
51
|
+
const extension = fileURL.pathname.split('.')?.[1] || '';
|
|
52
|
+
if (allowedExtensions.has(extension)) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}),
|
|
46
61
|
});
|
|
47
62
|
const labelStyle = {
|
|
48
63
|
wrapper: { display: 'flex', height: '100%', flex: 1 },
|
|
@@ -54,34 +69,32 @@ function LoadJCAMPModal({ onCloseDialog, isOpen }) {
|
|
|
54
69
|
if (!isOpen)
|
|
55
70
|
return;
|
|
56
71
|
async function loadJCAMPHandler({ url }) {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
alert.error(`Failed to load ${url}`);
|
|
72
|
-
}
|
|
73
|
-
finally {
|
|
74
|
-
hidLoading();
|
|
75
|
-
onCloseDialog?.();
|
|
76
|
-
}
|
|
72
|
+
const hidLoading = await alert.showLoading('Load JCAMP from external URL in progress ...');
|
|
73
|
+
const { pathname, origin } = new URL(url);
|
|
74
|
+
try {
|
|
75
|
+
const nmriumState = await (0, nmr_load_save_1.readFromWebSource)({
|
|
76
|
+
entries: [{ relativePath: pathname, baseURL: origin }],
|
|
77
|
+
});
|
|
78
|
+
dispatch({
|
|
79
|
+
type: 'LOAD_DROP_FILES',
|
|
80
|
+
payload: { nmriumState, resetSourceObject: false },
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
alert.error(`Failed to load ${url}`);
|
|
77
85
|
}
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
finally {
|
|
87
|
+
hidLoading();
|
|
88
|
+
onCloseDialog?.();
|
|
80
89
|
}
|
|
81
90
|
}
|
|
82
|
-
return ((0, jsx_runtime_1.jsxs)(ui_1.Modal, { hasCloseButton: true, isOpen: true, onRequestClose: onCloseDialog, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: "Load JCAMP Dialog" }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Body, { children: (0, jsx_runtime_1.jsx)("div", { style: { minWidth: '400px', padding: '1.5em' }, children: (0, jsx_runtime_1.jsx)(formik_1.Formik, { initialValues: { url: '' }, validationSchema: loadFormValidation, onSubmit: loadJCAMPHandler, innerRef: ref, children: (0, jsx_runtime_1.jsx)(Label_1.default, { title: "URL", style: labelStyle, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: "url", type: "string", style: {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
return ((0, jsx_runtime_1.jsxs)(ui_1.Modal, { hasCloseButton: true, isOpen: true, onRequestClose: onCloseDialog, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: "Load JCAMP Dialog" }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Body, { children: (0, jsx_runtime_1.jsx)("div", { style: { minWidth: '400px', padding: '1.5em' }, children: (0, jsx_runtime_1.jsx)(formik_1.Formik, { initialValues: { url: '' }, validationSchema: loadFormValidation, onSubmit: loadJCAMPHandler, innerRef: ref, children: (0, jsx_runtime_1.jsx)(Label_1.default, { title: "URL", style: labelStyle, children: (0, jsx_runtime_1.jsx)(FormikError_1.default, { name: "url", style: { container: { flex: 1 } }, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: "url", type: "string", style: {
|
|
92
|
+
input: {
|
|
93
|
+
padding: '0.8em',
|
|
94
|
+
textAlign: 'left',
|
|
95
|
+
width: '100%',
|
|
96
|
+
},
|
|
97
|
+
inputWrapper: { width: '100%' },
|
|
98
|
+
}, placeholder: "Enter URL to JCAMP-DX file" }) }) }) }) }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Footer, { children: (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'row-reverse' }, children: (0, jsx_runtime_1.jsx)(Button_1.default.Done, { onClick: () => ref.current?.submitForm(), children: "Load" }) }) })] }));
|
|
86
99
|
}
|
|
87
100
|
exports.LoadJCAMPModal = LoadJCAMPModal;
|
|
@@ -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;
|
|
@@ -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',
|
|
@@ -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
|
]);
|
|
@@ -11,6 +11,7 @@ const ui_1 = require("react-science/ui");
|
|
|
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 NextPrev_1 = __importDefault(require("../../elements/NextPrev"));
|
|
16
17
|
const Alert_1 = require("../../elements/popup/Alert");
|
|
@@ -36,6 +37,7 @@ function PredictionPanel() {
|
|
|
36
37
|
const { molecules, view: { molecules: moleculesView, predictions }, } = (0, ChartContext_1.useChartData)();
|
|
37
38
|
const dispatch = (0, DispatchContext_1.useDispatch)();
|
|
38
39
|
const alert = (0, Alert_1.useAlert)();
|
|
40
|
+
const { logger } = (0, LoggerContext_1.useLogger)();
|
|
39
41
|
const [currentIndex, setCurrentIndex] = (0, react_1.useState)(0);
|
|
40
42
|
const [molfile, setMolfile] = (0, react_1.useState)(null);
|
|
41
43
|
const [isFlipped, setFlipStatus] = (0, react_1.useState)(false);
|
|
@@ -75,7 +77,7 @@ function PredictionPanel() {
|
|
|
75
77
|
}
|
|
76
78
|
const hideLoading = await alert.showLoading(`Predict ${predictedSpectra.join(',')} in progress`);
|
|
77
79
|
try {
|
|
78
|
-
const data = await (0, PredictionManager_1.predictSpectra)(molfile);
|
|
80
|
+
const data = await (0, PredictionManager_1.predictSpectra)(molfile, logger);
|
|
79
81
|
dispatch({
|
|
80
82
|
type: 'PREDICT_SPECTRA',
|
|
81
83
|
payload: {
|