nmrium 0.20.2 → 0.21.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/EventsTrackers/KeysListenerTracker.js +98 -81
- package/lib/component/NMRium.d.ts +7 -2
- package/lib/component/NMRium.js +9 -9
- package/lib/component/header/Header.js +10 -3
- package/lib/component/hooks/useCheckExperimentalFeature.js +2 -1
- package/lib/component/hooks/useCheckToolsVisibility.d.ts +1 -0
- package/lib/component/hooks/useCheckToolsVisibility.js +6 -0
- package/lib/component/hooks/useToolsFunctions.js +2 -1
- package/lib/component/loader/DropZone.js +87 -87
- package/lib/component/modal/changeSum/ChangeSumModal.js +4 -2
- package/lib/component/modal/setting/DisplayTabContent.js +1 -1
- package/lib/component/modal/setting/GeneralSettings.js +1 -5
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +0 -3
- package/lib/component/panels/IntegralsPanel/IntegralsPreferences.js +4 -17
- package/lib/component/panels/MoleculesPanel/MoleculePanel.js +1 -1
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +0 -3
- package/lib/component/panels/PeaksPanel/PeaksPreferences.js +5 -14
- package/lib/component/panels/RangesPanel/RangesPanel.js +0 -3
- package/lib/component/panels/RangesPanel/RangesPreferences.js +5 -18
- package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +13 -3
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +0 -3
- package/lib/component/panels/ZonesPanel/ZonesPreferences.js +5 -18
- package/lib/component/panels/databasePanel/DatabasePanel.js +0 -3
- package/lib/component/panels/databasePanel/DatabasePreferences.js +4 -17
- package/lib/component/reducer/actions/ToolsActions.js +12 -29
- package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +1 -0
- package/lib/component/reducer/helper/ZoomHistoryManager.js +2 -1
- package/lib/component/reducer/preferencesReducer.d.ts +2 -0
- package/lib/component/reducer/preferencesReducer.js +76 -36
- package/lib/component/toolbar/FunctionToolBar.js +7 -10
- package/lib/component/toolbar/ToolTypes.js +3 -3
- package/lib/component/workspaces/Workspace.d.ts +6 -0
- package/lib/component/workspaces/Workspace.js +1 -0
- package/lib/component/workspaces/basic.d.ts +2 -0
- package/lib/component/workspaces/basic.js +45 -0
- package/lib/component/workspaces/exercise1D.d.ts +2 -0
- package/lib/component/workspaces/exercise1D.js +45 -0
- package/lib/component/workspaces/index.d.ts +6 -0
- package/lib/component/workspaces/index.js +4 -0
- package/lib/component/workspaces/process1D.d.ts +2 -0
- package/lib/component/workspaces/process1D.js +43 -0
- package/lib/data/migration/MigrationManager.js +3 -0
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +98 -81
- package/lib-cjs/component/NMRium.js +10 -10
- package/lib-cjs/component/header/Header.js +10 -3
- package/lib-cjs/component/hooks/useCheckExperimentalFeature.js +5 -1
- package/lib-cjs/component/hooks/useCheckToolsVisibility.js +13 -0
- package/lib-cjs/component/hooks/useToolsFunctions.js +2 -1
- package/lib-cjs/component/loader/DropZone.js +87 -87
- package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +4 -2
- package/lib-cjs/component/modal/setting/DisplayTabContent.js +1 -1
- package/lib-cjs/component/modal/setting/GeneralSettings.js +1 -5
- package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +0 -3
- package/lib-cjs/component/panels/IntegralsPanel/IntegralsPreferences.js +3 -16
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanel.js +1 -1
- package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +0 -3
- package/lib-cjs/component/panels/PeaksPanel/PeaksPreferences.js +4 -13
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +0 -3
- package/lib-cjs/component/panels/RangesPanel/RangesPreferences.js +4 -17
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraPanelHeader.js +13 -3
- package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +0 -3
- package/lib-cjs/component/panels/ZonesPanel/ZonesPreferences.js +4 -17
- package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +0 -3
- package/lib-cjs/component/panels/databasePanel/DatabasePreferences.js +3 -16
- package/lib-cjs/component/reducer/actions/ToolsActions.js +12 -29
- package/lib-cjs/component/reducer/helper/ZoomHistoryManager.js +2 -1
- package/lib-cjs/component/reducer/preferencesReducer.js +75 -35
- package/lib-cjs/component/toolbar/FunctionToolBar.js +7 -10
- package/lib-cjs/component/toolbar/ToolTypes.js +3 -3
- package/lib-cjs/component/workspaces/Workspace.js +2 -0
- package/lib-cjs/component/workspaces/basic.js +48 -0
- package/lib-cjs/component/workspaces/exercise1D.js +48 -0
- package/lib-cjs/component/workspaces/index.js +6 -0
- package/lib-cjs/component/workspaces/process1D.js +46 -0
- package/lib-cjs/data/migration/MigrationManager.js +3 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +1 -1
- package/lib/component/nmriumMode/basic.d.ts +0 -38
- package/lib/component/nmriumMode/basic.js +0 -37
- package/lib/component/nmriumMode/exercise1D.d.ts +0 -38
- package/lib/component/nmriumMode/exercise1D.js +0 -37
- package/lib/component/nmriumMode/process1D.d.ts +0 -38
- package/lib/component/nmriumMode/process1D.js +0 -37
- package/lib-cjs/component/nmriumMode/basic.js +0 -39
- package/lib-cjs/component/nmriumMode/exercise1D.js +0 -39
- package/lib-cjs/component/nmriumMode/process1D.js +0 -39
|
@@ -32,7 +32,6 @@ const Tab_1 = __importDefault(require("../../elements/Tab/Tab"));
|
|
|
32
32
|
const Tabs_1 = __importStar(require("../../elements/Tab/Tabs"));
|
|
33
33
|
const FormikForm_1 = __importDefault(require("../../elements/formik/FormikForm"));
|
|
34
34
|
const preferencesReducer_1 = require("../../reducer/preferencesReducer");
|
|
35
|
-
const LocalStorage_1 = require("../../utility/LocalStorage");
|
|
36
35
|
const ControllersTabContent_1 = __importDefault(require("./ControllersTabContent"));
|
|
37
36
|
const DisplayTabContent_1 = __importDefault(require("./DisplayTabContent"));
|
|
38
37
|
const FormattingTabContent_1 = __importDefault(require("./FormattingTabContent"));
|
|
@@ -166,17 +165,14 @@ const styles = (0, react_1.css) `
|
|
|
166
165
|
function GeneralSettings({ onClose, onSave }) {
|
|
167
166
|
const [activeTab, setActiveTab] = (0, react_2.useState)('controllers');
|
|
168
167
|
const preferences = (0, PreferencesContext_1.usePreferences)();
|
|
169
|
-
const [, setSettingsData] = (0, LocalStorage_1.useStateWithLocalStorage)('nmr-general-settings');
|
|
170
168
|
const refForm = (0, react_2.useRef)();
|
|
171
169
|
const handleSave = (0, react_2.useCallback)(() => {
|
|
172
170
|
refForm.current.submitForm();
|
|
173
171
|
}, []);
|
|
174
172
|
const submitHandler = (0, react_2.useCallback)((values) => {
|
|
175
|
-
const { dispatch, basePreferences, ...resValues } = values;
|
|
176
|
-
setSettingsData(resValues);
|
|
177
173
|
preferences.dispatch({ type: preferencesReducer_1.SET_PREFERENCES, payload: values });
|
|
178
174
|
onSave?.();
|
|
179
|
-
}, [onSave, preferences
|
|
175
|
+
}, [onSave, preferences]);
|
|
180
176
|
const tabChangeHandler = (0, react_2.useCallback)((tab) => {
|
|
181
177
|
setActiveTab(tab.tabid);
|
|
182
178
|
}, []);
|
|
@@ -68,9 +68,6 @@ function IntegralPanelInner({ integrals, info, activeTab, xDomain, preferences,
|
|
|
68
68
|
}, [changeIntegralSumHandler, currentSum, integrals?.options, modal]);
|
|
69
69
|
const settingsPanelHandler = (0, react_2.useCallback)(() => {
|
|
70
70
|
setFlipStatus(!isFlipped);
|
|
71
|
-
if (!isFlipped) {
|
|
72
|
-
settingRef.current.cancelSetting();
|
|
73
|
-
}
|
|
74
71
|
}, [isFlipped]);
|
|
75
72
|
const saveSettingHandler = (0, react_2.useCallback)(() => {
|
|
76
73
|
settingRef.current.saveSetting();
|
|
@@ -66,7 +66,6 @@ const formatFields = [
|
|
|
66
66
|
];
|
|
67
67
|
function IntegralsPreferencesInner({ nucleus, preferences, innerRef, }) {
|
|
68
68
|
const alert = (0, Alert_1.useAlert)();
|
|
69
|
-
const [, setSettingsData] = (0, LocalStorage_1.useStateWithLocalStorage)('nmr-general-settings');
|
|
70
69
|
const formRef = (0, react_1.useRef)();
|
|
71
70
|
const updateValues = (0, react_1.useCallback)(() => {
|
|
72
71
|
if (nucleus) {
|
|
@@ -83,31 +82,19 @@ function IntegralsPreferencesInner({ nucleus, preferences, innerRef, }) {
|
|
|
83
82
|
(0, react_1.useEffect)(() => {
|
|
84
83
|
updateValues();
|
|
85
84
|
}, [updateValues]);
|
|
86
|
-
const
|
|
87
|
-
setSettingsData(values, 'formatting.panels.integrals');
|
|
88
|
-
};
|
|
89
|
-
const saveHandler = (0, react_1.useCallback)((values, showMessage = false) => {
|
|
85
|
+
const saveHandler = (0, react_1.useCallback)((values) => {
|
|
90
86
|
preferences.dispatch({
|
|
91
87
|
type: preferencesReducer_1.SET_PANELS_PREFERENCES,
|
|
92
88
|
payload: { key: 'integrals', value: values },
|
|
93
89
|
});
|
|
94
|
-
|
|
95
|
-
alert.success('Integrals preferences saved successfully');
|
|
96
|
-
}
|
|
90
|
+
alert.success('Integrals preferences saved successfully');
|
|
97
91
|
}, [alert, preferences]);
|
|
98
92
|
(0, react_1.useImperativeHandle)(innerRef, () => ({
|
|
99
93
|
saveSetting: () => {
|
|
100
94
|
formRef.current.submitForm();
|
|
101
95
|
},
|
|
102
|
-
cancelSetting: () => {
|
|
103
|
-
updateValues();
|
|
104
|
-
},
|
|
105
96
|
}));
|
|
106
|
-
|
|
107
|
-
saveHandler(values, true);
|
|
108
|
-
saveToLocalStorgate(values);
|
|
109
|
-
};
|
|
110
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: styles.container, children: (0, jsx_runtime_1.jsxs)(FormikForm_1.default, { onSubmit: handleSubmit, ref: formRef, children: [(0, jsx_runtime_1.jsxs)("div", { style: styles.groupContainer, children: [(0, jsx_runtime_1.jsx)("p", { style: styles.header, children: "General" }, void 0), (0, jsx_runtime_1.jsx)(FormikColorInput_1.default, { name: "color" }, void 0), (0, jsx_runtime_1.jsx)(FormikNumberInput_1.default, { name: "strokeWidth", label: "stroke width :", style: {
|
|
97
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: styles.container, children: (0, jsx_runtime_1.jsxs)(FormikForm_1.default, { onSubmit: saveHandler, ref: formRef, children: [(0, jsx_runtime_1.jsxs)("div", { style: styles.groupContainer, children: [(0, jsx_runtime_1.jsx)("p", { style: styles.header, children: "General" }, void 0), (0, jsx_runtime_1.jsx)(FormikColorInput_1.default, { name: "color" }, void 0), (0, jsx_runtime_1.jsx)(FormikNumberInput_1.default, { name: "strokeWidth", label: "stroke width :", style: {
|
|
111
98
|
label: { fontSize: '11px', fontWeight: 'bold', color: '#232323' },
|
|
112
99
|
input: {
|
|
113
100
|
width: '60%',
|
|
@@ -96,7 +96,7 @@ function MoleculePanelInner({ zones, ranges, molecules: moleculesProp, activeTab
|
|
|
96
96
|
currentDiaIDsToHighlight.length > 0
|
|
97
97
|
? currentDiaIDsToHighlight
|
|
98
98
|
: assignedDiaIDsMerged, setHoverAtom: handleOnAtomHover }, void 0));
|
|
99
|
-
} }, void 0) }, void 0)] }, mol.key)))) : ((0, jsx_runtime_1.jsx)("div", {
|
|
99
|
+
} }, void 0) }, void 0)] }, mol.key)))) : ((0, jsx_runtime_1.jsx)("div", { css: styles.slider, style: { height: '100%' }, onClick: () => openMoleculeEditorHandler(), children: (0, jsx_runtime_1.jsx)("span", { children: "Click to draw molecule" }, void 0) }, void 0)) }, void 0) }, void 0)] }, void 0));
|
|
100
100
|
}
|
|
101
101
|
const MemoizedMoleculePanel = (0, react_2.memo)(MoleculePanelInner);
|
|
102
102
|
const emptyData = { ranges: {}, zones: {} };
|
|
@@ -37,9 +37,6 @@ function PeaksPanelInner({ peaks, info, xDomain, activeTab, preferences, }) {
|
|
|
37
37
|
}, [modal, yesHandler]);
|
|
38
38
|
const settingsPanelHandler = (0, react_2.useCallback)(() => {
|
|
39
39
|
setFlipStatus(!isFlipped);
|
|
40
|
-
if (!isFlipped) {
|
|
41
|
-
settingRef.current.cancelSetting();
|
|
42
|
-
}
|
|
43
40
|
}, [isFlipped]);
|
|
44
41
|
const saveSettingHandler = (0, react_2.useCallback)(() => {
|
|
45
42
|
settingRef.current.saveSetting();
|
|
@@ -88,7 +88,6 @@ const formatFields = [
|
|
|
88
88
|
];
|
|
89
89
|
function PeaksPreferencesInner({ nucleus, preferences, innerRef, }) {
|
|
90
90
|
const alert = (0, Alert_1.useAlert)();
|
|
91
|
-
const [, setSettingsData] = (0, LocalStorage_1.useStateWithLocalStorage)('nmr-general-settings');
|
|
92
91
|
const formRef = (0, react_1.useRef)(null);
|
|
93
92
|
const updateValues = (0, react_1.useCallback)(() => {
|
|
94
93
|
if (nucleus) {
|
|
@@ -103,27 +102,19 @@ function PeaksPreferencesInner({ nucleus, preferences, innerRef, }) {
|
|
|
103
102
|
(0, react_1.useEffect)(() => {
|
|
104
103
|
updateValues();
|
|
105
104
|
}, [updateValues]);
|
|
106
|
-
const saveHandler = (0, react_1.useCallback)((values
|
|
105
|
+
const saveHandler = (0, react_1.useCallback)((values) => {
|
|
107
106
|
preferences.dispatch({
|
|
108
107
|
type: preferencesReducer_1.SET_PANELS_PREFERENCES,
|
|
109
108
|
payload: { key: 'peaks', value: values },
|
|
110
109
|
});
|
|
111
|
-
|
|
112
|
-
alert.success('Peaks preferences saved successfully');
|
|
110
|
+
alert.success('Peaks preferences saved successfully');
|
|
113
111
|
}, [alert, preferences]);
|
|
114
112
|
(0, react_1.useImperativeHandle)(innerRef, () => ({
|
|
115
113
|
saveSetting: () => {
|
|
116
114
|
formRef.current.submitForm();
|
|
117
115
|
},
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
},
|
|
121
|
-
}), [updateValues]);
|
|
122
|
-
const handleSubmit = (0, react_1.useCallback)((values) => {
|
|
123
|
-
saveHandler(values, true);
|
|
124
|
-
setSettingsData(values, 'formatting.panels.peaks');
|
|
125
|
-
}, [saveHandler, setSettingsData]);
|
|
126
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: styles.container, children: (0, jsx_runtime_1.jsx)(FormikForm_1.default, { onSubmit: handleSubmit, ref: formRef, children: nucleus?.map((nucleusLabel) => ((0, jsx_runtime_1.jsxs)("div", { style: styles.groupContainer, children: [(0, jsx_runtime_1.jsx)(IsotopesViewer_1.default, { style: styles.header, value: nucleusLabel }, void 0), formatFields.map((field) => ((0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: field.label, checkControllerName: `${nucleusLabel}.${field.checkController}`, formatControllerName: `${nucleusLabel}.${field.formatController}`, hideFormat: field.formatController === 'deltaPPMFormat' }, field.id)))] }, nucleusLabel))) }, void 0) }, void 0));
|
|
116
|
+
}), []);
|
|
117
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: styles.container, children: (0, jsx_runtime_1.jsx)(FormikForm_1.default, { onSubmit: saveHandler, ref: formRef, children: nucleus?.map((nucleusLabel) => ((0, jsx_runtime_1.jsxs)("div", { style: styles.groupContainer, children: [(0, jsx_runtime_1.jsx)(IsotopesViewer_1.default, { style: styles.header, value: nucleusLabel }, void 0), formatFields.map((field) => ((0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: field.label, checkControllerName: `${nucleusLabel}.${field.checkController}`, formatControllerName: `${nucleusLabel}.${field.formatController}`, hideFormat: field.formatController === 'deltaPPMFormat' }, field.id)))] }, nucleusLabel))) }, void 0) }, void 0));
|
|
127
118
|
}
|
|
128
119
|
const MemoizedPeaksPreferences = (0, react_1.memo)(PeaksPreferencesInner);
|
|
129
120
|
// TODO: remove this hacky use of ref.
|
|
@@ -105,9 +105,6 @@ function RangesTablePanelInner({ ranges, data, info, xDomain, preferences, activ
|
|
|
105
105
|
}, [isFilterActive]);
|
|
106
106
|
const settingsPanelHandler = (0, react_2.useCallback)(() => {
|
|
107
107
|
setFlipStatus(!isFlipped);
|
|
108
|
-
if (!isFlipped) {
|
|
109
|
-
settingRef.current.cancelSetting();
|
|
110
|
-
}
|
|
111
108
|
}, [isFlipped]);
|
|
112
109
|
const saveSettingHandler = (0, react_2.useCallback)(() => {
|
|
113
110
|
settingRef.current.saveSetting();
|
|
@@ -76,7 +76,6 @@ const formatFields = [
|
|
|
76
76
|
];
|
|
77
77
|
function RangesPreferencesInner({ nucleus, preferences, innerRef, }) {
|
|
78
78
|
const alert = (0, Alert_1.useAlert)();
|
|
79
|
-
const [, setSettingsData] = (0, LocalStorage_1.useStateWithLocalStorage)('nmr-general-settings');
|
|
80
79
|
const formRef = (0, react_1.useRef)();
|
|
81
80
|
const updateValues = (0, react_1.useCallback)(() => {
|
|
82
81
|
if (nucleus) {
|
|
@@ -91,31 +90,19 @@ function RangesPreferencesInner({ nucleus, preferences, innerRef, }) {
|
|
|
91
90
|
(0, react_1.useEffect)(() => {
|
|
92
91
|
updateValues();
|
|
93
92
|
}, [updateValues]);
|
|
94
|
-
const
|
|
95
|
-
setSettingsData(values, 'formatting.panels.ranges');
|
|
96
|
-
};
|
|
97
|
-
const saveHandler = (0, react_1.useCallback)((values, showMessage = false) => {
|
|
93
|
+
const saveHandler = (0, react_1.useCallback)((values) => {
|
|
98
94
|
preferences.dispatch({
|
|
99
95
|
type: preferencesReducer_1.SET_PANELS_PREFERENCES,
|
|
100
96
|
payload: { key: 'ranges', value: values },
|
|
101
97
|
});
|
|
102
|
-
|
|
103
|
-
alert.success('ranges preferences saved successfully');
|
|
104
|
-
}
|
|
98
|
+
alert.success('ranges preferences saved successfully');
|
|
105
99
|
}, [alert, preferences]);
|
|
106
100
|
(0, react_1.useImperativeHandle)(innerRef, () => ({
|
|
107
101
|
saveSetting: () => {
|
|
108
102
|
formRef.current.submitForm();
|
|
109
103
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
},
|
|
113
|
-
}), [updateValues]);
|
|
114
|
-
const handleSubmit = (values) => {
|
|
115
|
-
saveHandler(values, true);
|
|
116
|
-
saveToLocalStorgate(values);
|
|
117
|
-
};
|
|
118
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: styles.container, children: (0, jsx_runtime_1.jsx)(FormikForm_1.default, { onSubmit: handleSubmit, ref: formRef, children: nucleus?.map((nucleusLabel) => ((0, jsx_runtime_1.jsxs)("div", { style: styles.groupContainer, children: [(0, jsx_runtime_1.jsx)(IsotopesViewer_1.default, { style: styles.header, value: nucleusLabel }, void 0), formatFields.map((field) => ((0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: field.label, checkControllerName: `${nucleusLabel}.${field.checkController}`, formatControllerName: `${nucleusLabel}.${field.formatController}` }, field.id))), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "J Graph tolerance (Hz) :", style: { label: styles.inputLabel, wrapper: styles.inputWrapper }, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: `${nucleusLabel}.jGraphTolerance`, type: "number" }, void 0) }, void 0)] }, nucleusLabel))) }, void 0) }, void 0));
|
|
104
|
+
}), []);
|
|
105
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: styles.container, children: (0, jsx_runtime_1.jsx)(FormikForm_1.default, { onSubmit: saveHandler, ref: formRef, children: nucleus?.map((nucleusLabel) => ((0, jsx_runtime_1.jsxs)("div", { style: styles.groupContainer, children: [(0, jsx_runtime_1.jsx)(IsotopesViewer_1.default, { style: styles.header, value: nucleusLabel }, void 0), formatFields.map((field) => ((0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: field.label, checkControllerName: `${nucleusLabel}.${field.checkController}`, formatControllerName: `${nucleusLabel}.${field.formatController}` }, field.id))), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "J Graph tolerance (Hz) :", style: { label: styles.inputLabel, wrapper: styles.inputWrapper }, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: `${nucleusLabel}.jGraphTolerance`, type: "number" }, void 0) }, void 0)] }, nucleusLabel))) }, void 0) }, void 0));
|
|
119
106
|
}
|
|
120
107
|
const MemoizedRangesPreferences = (0, react_1.memo)(RangesPreferencesInner);
|
|
121
108
|
// TODO: remove this hacky use of ref.
|
|
@@ -12,10 +12,11 @@ const DispatchContext_1 = require("../../context/DispatchContext");
|
|
|
12
12
|
const ButtonToolTip_1 = __importDefault(require("../../elements/ButtonToolTip"));
|
|
13
13
|
const Alert_1 = require("../../elements/popup/Alert");
|
|
14
14
|
const Modal_1 = require("../../elements/popup/Modal");
|
|
15
|
+
const useCheckToolsVisibility_1 = require("../../hooks/useCheckToolsVisibility");
|
|
15
16
|
const Constants_1 = require("../../reducer/core/Constants");
|
|
16
17
|
const Types_1 = require("../../reducer/types/Types");
|
|
17
18
|
const DefaultPanelHeader_1 = __importDefault(require("../header/DefaultPanelHeader"));
|
|
18
|
-
function SpectraPanelHeaderInner({ data, activeSpectrum, activeTab, displayerMode, spectrums, }) {
|
|
19
|
+
function SpectraPanelHeaderInner({ data, activeSpectrum, activeTab, displayerMode, spectrums, isAutomaticPickingVisible, }) {
|
|
19
20
|
const modal = (0, Modal_1.useModal)();
|
|
20
21
|
const alert = (0, Alert_1.useAlert)();
|
|
21
22
|
const dispatch = (0, DispatchContext_1.useDispatch)();
|
|
@@ -77,11 +78,20 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeTab, displayerMod
|
|
|
77
78
|
hideLoading();
|
|
78
79
|
}, 0);
|
|
79
80
|
}, [dispatch, alert]);
|
|
80
|
-
return ((0, jsx_runtime_1.jsxs)(DefaultPanelHeader_1.default, { onDelete: handleDelete, counter: spectrums?.length, deleteToolTip: "Delete all spectra", children: [(0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Hide all spectra", onClick: hideAllSpectrumsHandler, children: (0, jsx_runtime_1.jsx)(fa_1.FaEyeSlash, {}, void 0) }, void 0), (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Show all spectra", onClick: showAllSpectrumsHandler, children: (0, jsx_runtime_1.jsx)(fa_1.FaEye, {}, void 0) }, void 0), activeSpectrum && activeTab && activeTab.split(',').length > 1 && ((0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Add missing projection", onClick: addMissingProjectionHandler, children: (0, jsx_runtime_1.jsx)(fa_1.FaCreativeCommonsSamplingPlus, {}, void 0) }, void 0)), displayerMode === Constants_1.DISPLAYER_MODE.DM_1D && spectrums.length > 1 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Reset Scale", onClick: resetScaleHandler, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrResetScale, {}, void 0) }, void 0), (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Same Top", onClick: setSameTopHandler, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrSameTop, {}, void 0) }, void 0)] }, void 0)), data && data.length > 0 && ((0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Automatic Ranges/Zones picking for all spectra", onClick: automaticPickingHandler, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrRangePicking, {}, void 0) }, void 0))] }, void 0));
|
|
81
|
+
return ((0, jsx_runtime_1.jsxs)(DefaultPanelHeader_1.default, { onDelete: handleDelete, counter: spectrums?.length, deleteToolTip: "Delete all spectra", children: [(0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Hide all spectra", onClick: hideAllSpectrumsHandler, children: (0, jsx_runtime_1.jsx)(fa_1.FaEyeSlash, {}, void 0) }, void 0), (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Show all spectra", onClick: showAllSpectrumsHandler, children: (0, jsx_runtime_1.jsx)(fa_1.FaEye, {}, void 0) }, void 0), activeSpectrum && activeTab && activeTab.split(',').length > 1 && ((0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Add missing projection", onClick: addMissingProjectionHandler, children: (0, jsx_runtime_1.jsx)(fa_1.FaCreativeCommonsSamplingPlus, {}, void 0) }, void 0)), displayerMode === Constants_1.DISPLAYER_MODE.DM_1D && spectrums.length > 1 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Reset Scale", onClick: resetScaleHandler, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrResetScale, {}, void 0) }, void 0), (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Same Top", onClick: setSameTopHandler, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrSameTop, {}, void 0) }, void 0)] }, void 0)), data && data.length > 0 && isAutomaticPickingVisible && ((0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "Automatic Ranges/Zones picking for all spectra", onClick: automaticPickingHandler, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrRangePicking, {}, void 0) }, void 0))] }, void 0));
|
|
81
82
|
}
|
|
82
83
|
const MemoizedSpectraPanelHeader = (0, react_1.memo)(SpectraPanelHeaderInner);
|
|
83
84
|
function SpectrumsTabs({ spectrums }) {
|
|
84
85
|
const { data, activeSpectrum, activeTab, displayerMode } = (0, ChartContext_1.useChartData)();
|
|
85
|
-
|
|
86
|
+
const isToolVisible = (0, useCheckToolsVisibility_1.useCheckToolsVisibility)();
|
|
87
|
+
const isAutomaticPickingVisible = isToolVisible('hideAutoRangesTool');
|
|
88
|
+
return ((0, jsx_runtime_1.jsx)(MemoizedSpectraPanelHeader, { ...{
|
|
89
|
+
data,
|
|
90
|
+
activeSpectrum,
|
|
91
|
+
activeTab,
|
|
92
|
+
displayerMode,
|
|
93
|
+
spectrums,
|
|
94
|
+
isAutomaticPickingVisible,
|
|
95
|
+
} }, void 0));
|
|
86
96
|
}
|
|
87
97
|
exports.default = SpectrumsTabs;
|
|
@@ -123,9 +123,6 @@ function ZonesPanelInner({ zones, activeTab, xDomain, yDomain }) {
|
|
|
123
123
|
}, [assignmentData, dispatch, modal]);
|
|
124
124
|
const settingsPanelHandler = (0, react_2.useCallback)(() => {
|
|
125
125
|
setFlipStatus(!isFlipped);
|
|
126
|
-
if (!isFlipped) {
|
|
127
|
-
settingRef.current.cancelSetting();
|
|
128
|
-
}
|
|
129
126
|
}, [isFlipped]);
|
|
130
127
|
const saveSettingHandler = (0, react_2.useCallback)(() => {
|
|
131
128
|
settingRef.current.saveSetting();
|
|
@@ -76,7 +76,6 @@ const formatFields = [
|
|
|
76
76
|
];
|
|
77
77
|
function ZonesPreferencesInner({ nucleus, innerRef, }) {
|
|
78
78
|
const alert = (0, Alert_1.useAlert)();
|
|
79
|
-
const [, setSettingsData] = (0, LocalStorage_1.useStateWithLocalStorage)('nmr-general-settings');
|
|
80
79
|
const preferences = (0, PreferencesContext_1.usePreferences)();
|
|
81
80
|
const formRef = (0, react_1.useRef)();
|
|
82
81
|
const updateValues = (0, react_1.useCallback)(() => {
|
|
@@ -92,31 +91,19 @@ function ZonesPreferencesInner({ nucleus, innerRef, }) {
|
|
|
92
91
|
(0, react_1.useEffect)(() => {
|
|
93
92
|
updateValues();
|
|
94
93
|
}, [updateValues]);
|
|
95
|
-
const
|
|
96
|
-
setSettingsData(values, 'formatting.panels.ranges');
|
|
97
|
-
};
|
|
98
|
-
const saveHandler = (0, react_1.useCallback)((values, showMessage = false) => {
|
|
94
|
+
const saveHandler = (0, react_1.useCallback)((values) => {
|
|
99
95
|
preferences.dispatch({
|
|
100
96
|
type: preferencesReducer_1.SET_PANELS_PREFERENCES,
|
|
101
97
|
payload: { key: 'zones', value: values },
|
|
102
98
|
});
|
|
103
|
-
|
|
104
|
-
alert.success('zones preferences saved successfully');
|
|
105
|
-
}
|
|
99
|
+
alert.success('zones preferences saved successfully');
|
|
106
100
|
}, [alert, preferences]);
|
|
107
101
|
(0, react_1.useImperativeHandle)(innerRef, () => ({
|
|
108
102
|
saveSetting: () => {
|
|
109
103
|
formRef.current.submitForm();
|
|
110
104
|
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
-
}), [updateValues]);
|
|
115
|
-
const handleSubmit = (values) => {
|
|
116
|
-
saveHandler(values, true);
|
|
117
|
-
saveToLocalStorgate(values);
|
|
118
|
-
};
|
|
119
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: styles.container, children: (0, jsx_runtime_1.jsx)(FormikForm_1.default, { onSubmit: handleSubmit, ref: formRef, children: nucleus?.map((nucleusLabel) => ((0, jsx_runtime_1.jsxs)("div", { style: styles.groupContainer, children: [(0, jsx_runtime_1.jsx)(IsotopesViewer_1.default, { style: styles.header, value: nucleusLabel }, void 0), formatFields.map((field) => ((0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: field.label, checkControllerName: `${nucleusLabel}.${field.checkController}`, formatControllerName: `${nucleusLabel}.${field.formatController}` }, field.id)))] }, nucleusLabel))) }, void 0) }, void 0));
|
|
105
|
+
}), []);
|
|
106
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: styles.container, children: (0, jsx_runtime_1.jsx)(FormikForm_1.default, { onSubmit: saveHandler, ref: formRef, children: nucleus?.map((nucleusLabel) => ((0, jsx_runtime_1.jsxs)("div", { style: styles.groupContainer, children: [(0, jsx_runtime_1.jsx)(IsotopesViewer_1.default, { style: styles.header, value: nucleusLabel }, void 0), formatFields.map((field) => ((0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: field.label, checkControllerName: `${nucleusLabel}.${field.checkController}`, formatControllerName: `${nucleusLabel}.${field.formatController}` }, field.id)))] }, nucleusLabel))) }, void 0) }, void 0));
|
|
120
107
|
}
|
|
121
108
|
const MemoizedZonesPreferences = (0, react_1.memo)(ZonesPreferencesInner);
|
|
122
109
|
// TODO: remove this hacky use of ref.
|
|
@@ -66,9 +66,6 @@ function DatabasePanelInner({ nucleus, selectedTool }) {
|
|
|
66
66
|
const { item } = (0, analysis_ui_components_1.useAccordionContext)('Database');
|
|
67
67
|
const settingsPanelHandler = (0, react_2.useCallback)(() => {
|
|
68
68
|
setFlipStatus(!isFlipped);
|
|
69
|
-
if (!isFlipped) {
|
|
70
|
-
settingRef.current.cancelSetting();
|
|
71
|
-
}
|
|
72
69
|
}, [isFlipped]);
|
|
73
70
|
const saveSettingHandler = (0, react_2.useCallback)(() => {
|
|
74
71
|
settingRef.current.saveSetting();
|
|
@@ -48,7 +48,6 @@ const styles = {
|
|
|
48
48
|
function DatabasePreferences(props, ref) {
|
|
49
49
|
const preferences = (0, PreferencesContext_1.usePreferences)();
|
|
50
50
|
const alert = (0, Alert_1.useAlert)();
|
|
51
|
-
const [, setSettingsData] = (0, LocalStorage_1.useStateWithLocalStorage)('nmr-general-settings');
|
|
52
51
|
const formRef = (0, react_1.useRef)();
|
|
53
52
|
const updateValues = (0, react_1.useCallback)(() => {
|
|
54
53
|
const databasePreferences = (0, LocalStorage_1.getValue)(preferences, `formatting.panels.database`);
|
|
@@ -57,30 +56,18 @@ function DatabasePreferences(props, ref) {
|
|
|
57
56
|
(0, react_1.useEffect)(() => {
|
|
58
57
|
updateValues();
|
|
59
58
|
}, [updateValues]);
|
|
60
|
-
const
|
|
61
|
-
setSettingsData(values, 'formatting.panels.database');
|
|
62
|
-
};
|
|
63
|
-
const saveHandler = (0, react_1.useCallback)((values, showMessage = false) => {
|
|
59
|
+
const saveHandler = (0, react_1.useCallback)((values) => {
|
|
64
60
|
preferences.dispatch({
|
|
65
61
|
type: preferencesReducer_1.SET_PANELS_PREFERENCES,
|
|
66
62
|
payload: { key: 'database', value: values },
|
|
67
63
|
});
|
|
68
|
-
|
|
69
|
-
alert.success('database preferences saved successfully');
|
|
70
|
-
}
|
|
64
|
+
alert.success('database preferences saved successfully');
|
|
71
65
|
}, [alert, preferences]);
|
|
72
66
|
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
73
67
|
saveSetting: () => {
|
|
74
68
|
formRef.current.submitForm();
|
|
75
69
|
},
|
|
76
|
-
cancelSetting: () => {
|
|
77
|
-
updateValues();
|
|
78
|
-
},
|
|
79
70
|
}));
|
|
80
|
-
|
|
81
|
-
saveHandler(values, true);
|
|
82
|
-
saveToLocalStorage(values);
|
|
83
|
-
};
|
|
84
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: styles.container, children: (0, jsx_runtime_1.jsx)(FormikForm_1.default, { onSubmit: handleSubmit, ref: formRef, children: (0, jsx_runtime_1.jsxs)("div", { style: styles.groupContainer, children: [(0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: "Smiles", checkControllerName: "showSmiles", hideFormat: true }, void 0), (0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: "Solvent", checkControllerName: "showSolvent", hideFormat: true }, void 0), (0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: "Names", checkControllerName: "showNames", hideFormat: true }, void 0), (0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: "Range", checkControllerName: "showRange", hideFormat: true }, void 0), (0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: "\u03B4 (ppm)", checkControllerName: "showDelta", hideFormat: true }, void 0), (0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: "Assignment", checkControllerName: "showAssignment", hideFormat: true }, void 0), (0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: "J (Hz)", checkControllerName: "showCoupling", hideFormat: true }, void 0), (0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: "Multiplicity", checkControllerName: "showMultiplicity", hideFormat: true }, void 0)] }, void 0) }, void 0) }, void 0));
|
|
71
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: styles.container, children: (0, jsx_runtime_1.jsx)(FormikForm_1.default, { onSubmit: saveHandler, ref: formRef, children: (0, jsx_runtime_1.jsxs)("div", { style: styles.groupContainer, children: [(0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: "Smiles", checkControllerName: "showSmiles", hideFormat: true }, void 0), (0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: "Solvent", checkControllerName: "showSolvent", hideFormat: true }, void 0), (0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: "Names", checkControllerName: "showNames", hideFormat: true }, void 0), (0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: "Range", checkControllerName: "showRange", hideFormat: true }, void 0), (0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: "\u03B4 (ppm)", checkControllerName: "showDelta", hideFormat: true }, void 0), (0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: "Assignment", checkControllerName: "showAssignment", hideFormat: true }, void 0), (0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: "J (Hz)", checkControllerName: "showCoupling", hideFormat: true }, void 0), (0, jsx_runtime_1.jsx)(FormikColumnFormatField_1.default, { label: "Multiplicity", checkControllerName: "showMultiplicity", hideFormat: true }, void 0)] }, void 0) }, void 0) }, void 0));
|
|
85
72
|
}
|
|
86
73
|
exports.default = (0, react_1.forwardRef)(DatabasePreferences);
|
|
@@ -213,7 +213,7 @@ function handleBrushEnd(draft, action) {
|
|
|
213
213
|
break;
|
|
214
214
|
}
|
|
215
215
|
if (brushHistory) {
|
|
216
|
-
brushHistory.push({ xDomain:
|
|
216
|
+
brushHistory.push({ xDomain: draft.xDomain, yDomain: draft.yDomain });
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
else {
|
|
@@ -278,6 +278,7 @@ function zoomOut(draft, action) {
|
|
|
278
278
|
switch (zoomType) {
|
|
279
279
|
case Zoom_1.ZoomType.HORIZONTAL: {
|
|
280
280
|
draft.xDomain = draft.originDomain.xDomain;
|
|
281
|
+
zoomHistory.clear();
|
|
281
282
|
break;
|
|
282
283
|
}
|
|
283
284
|
case Zoom_1.ZoomType.VERTICAL:
|
|
@@ -300,34 +301,16 @@ function zoomOut(draft, action) {
|
|
|
300
301
|
}
|
|
301
302
|
else {
|
|
302
303
|
const { xDomain, yDomain, yDomains } = draft.originDomain;
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
const activeSpectrum = draft.tabActiveSpectrum[draft.activeTab.split(',')[1]];
|
|
314
|
-
draft.yDomain = yDomain;
|
|
315
|
-
if (activeSpectrum?.id) {
|
|
316
|
-
draft.yDomains[activeSpectrum.id] = yDomains[activeSpectrum.id];
|
|
317
|
-
}
|
|
318
|
-
break;
|
|
319
|
-
}
|
|
320
|
-
case DimensionLayout_1.LAYOUT.CENTER_2D: {
|
|
321
|
-
const zoomValue = zoomHistory.pop();
|
|
322
|
-
draft.xDomain = zoomValue ? zoomValue.xDomain : xDomain;
|
|
323
|
-
draft.yDomain = zoomValue ? zoomValue.yDomain : yDomain;
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
326
|
-
default:
|
|
327
|
-
draft.xDomain = xDomain;
|
|
328
|
-
draft.yDomain = yDomain;
|
|
329
|
-
draft.yDomains = yDomains;
|
|
330
|
-
break;
|
|
304
|
+
if ([DimensionLayout_1.LAYOUT.TOP_1D, DimensionLayout_1.LAYOUT.LEFT_1D, DimensionLayout_1.LAYOUT.CENTER_2D].includes(trackID)) {
|
|
305
|
+
const zoomValue = zoomHistory.pop();
|
|
306
|
+
draft.xDomain = zoomValue ? zoomValue.xDomain : xDomain;
|
|
307
|
+
draft.yDomain = zoomValue ? zoomValue.yDomain : yDomain;
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
zoomHistory.clear();
|
|
311
|
+
draft.xDomain = xDomain;
|
|
312
|
+
draft.yDomain = yDomain;
|
|
313
|
+
draft.yDomains = yDomains;
|
|
331
314
|
}
|
|
332
315
|
}
|
|
333
316
|
}
|
|
@@ -7,7 +7,8 @@ function zoomHistoryManager(zoomHistory, nucleus) {
|
|
|
7
7
|
const push = preparePush(zoomHistory[nucleus]);
|
|
8
8
|
const pop = preparePop(zoomHistory[nucleus]);
|
|
9
9
|
const getLast = prepareGetLast(zoomHistory[nucleus]);
|
|
10
|
-
|
|
10
|
+
const clear = () => (zoomHistory[nucleus] = []);
|
|
11
|
+
return { historyStack: zoomHistory[nucleus], push, pop, getLast, clear };
|
|
11
12
|
}
|
|
12
13
|
exports.default = zoomHistoryManager;
|
|
13
14
|
function preparePush(historyStack) {
|
|
@@ -7,27 +7,25 @@ exports.preferencesInitialState = exports.SET_PANELS_PREFERENCES = exports.SET_P
|
|
|
7
7
|
const immer_1 = require("immer");
|
|
8
8
|
const merge_1 = __importDefault(require("lodash/merge"));
|
|
9
9
|
const NMRium_1 = require("../NMRium");
|
|
10
|
-
const basic_1 = __importDefault(require("../nmriumMode/basic"));
|
|
11
|
-
const exercise1D_1 = __importDefault(require("../nmriumMode/exercise1D"));
|
|
12
|
-
const process1D_1 = __importDefault(require("../nmriumMode/process1D"));
|
|
13
10
|
const LocalStorage_1 = require("../utility/LocalStorage");
|
|
11
|
+
const workspaces_1 = __importDefault(require("../workspaces"));
|
|
14
12
|
exports.INIT_PREFERENCES = 'INIT_PREFERENCES';
|
|
15
13
|
exports.SET_PREFERENCES = 'SET_PREFERENCES';
|
|
16
14
|
exports.SET_PANELS_PREFERENCES = 'SET_PANELS_PREFERENCES';
|
|
17
|
-
const
|
|
18
|
-
function
|
|
19
|
-
switch (
|
|
20
|
-
case NMRium_1.
|
|
21
|
-
return
|
|
22
|
-
case NMRium_1.
|
|
23
|
-
return
|
|
15
|
+
const LOCAL_STORAGE_VERSION = 3;
|
|
16
|
+
function getPreferencesByWorkspace(workspace) {
|
|
17
|
+
switch (workspace) {
|
|
18
|
+
case NMRium_1.NMRiumWorkspaces.EXERCISE_1D:
|
|
19
|
+
return workspaces_1.default.exercise1D;
|
|
20
|
+
case NMRium_1.NMRiumWorkspaces.PROCESS_1D:
|
|
21
|
+
return workspaces_1.default.process1D;
|
|
24
22
|
default:
|
|
25
|
-
return
|
|
23
|
+
return workspaces_1.default.basic;
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
26
|
exports.preferencesInitialState = {
|
|
29
27
|
basePreferences: {},
|
|
30
|
-
display:
|
|
28
|
+
display: workspaces_1.default.basic.display,
|
|
31
29
|
controllers: {
|
|
32
30
|
mws: { low: 2, high: 20 },
|
|
33
31
|
dimmedSpectraTransparency: 0.1,
|
|
@@ -45,7 +43,15 @@ exports.preferencesInitialState = {
|
|
|
45
43
|
panels: {},
|
|
46
44
|
},
|
|
47
45
|
dispatch: null,
|
|
46
|
+
workspace: 'default',
|
|
48
47
|
};
|
|
48
|
+
function getTruthyObjectValues(data) {
|
|
49
|
+
return JSON.parse(JSON.stringify(data), (key, value) => {
|
|
50
|
+
if (value) {
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
49
55
|
function mapNucleus(draft) {
|
|
50
56
|
if (draft.formatting.nucleus && Array.isArray(draft.formatting.nucleus)) {
|
|
51
57
|
draft.formatting.nucleusByKey = draft.formatting.nucleus.reduce((acc, item) => {
|
|
@@ -56,48 +62,82 @@ function mapNucleus(draft) {
|
|
|
56
62
|
}
|
|
57
63
|
function handleInit(draft, action) {
|
|
58
64
|
const nmrLocalStorageVersion = (0, LocalStorage_1.getLocalStorage)('nmr-local-storage-version', false);
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
let localData = (0, LocalStorage_1.getLocalStorage)('nmr-general-settings');
|
|
66
|
+
// remove old nmr-local-storage-version key
|
|
67
|
+
if (nmrLocalStorageVersion && localData?.version) {
|
|
68
|
+
(0, LocalStorage_1.removeData)('nmr-local-storage-version');
|
|
69
|
+
}
|
|
70
|
+
if (!localData?.version || localData?.version !== LOCAL_STORAGE_VERSION) {
|
|
61
71
|
(0, LocalStorage_1.removeData)('nmr-general-settings');
|
|
62
|
-
(0, LocalStorage_1.storeData)('nmr-local-storage-version', LOCAL_STORGAE_VERSION);
|
|
63
72
|
}
|
|
64
|
-
const localData = (0, LocalStorage_1.getLocalStorage)('nmr-general-settings');
|
|
65
73
|
if (action.payload) {
|
|
66
|
-
const { dispatch,
|
|
67
|
-
draft.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const { dispatch, workspace, ...resProps } = action.payload;
|
|
75
|
+
draft.workspace = workspace;
|
|
76
|
+
const workspacePreferences = getPreferencesByWorkspace(workspace);
|
|
77
|
+
if (!localData ||
|
|
78
|
+
!localData?.workspaces[workspace] ||
|
|
79
|
+
workspacePreferences.version !== localData?.workspaces[workspace]?.version) {
|
|
80
|
+
localData = localData || {};
|
|
81
|
+
localData = {
|
|
82
|
+
version: LOCAL_STORAGE_VERSION,
|
|
83
|
+
workspaces: {
|
|
84
|
+
...localData.workspaces,
|
|
85
|
+
[workspace]: {
|
|
86
|
+
...workspacePreferences,
|
|
87
|
+
controllers: draft.controllers,
|
|
88
|
+
formatting: draft.formatting,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
(0, LocalStorage_1.storeData)('nmr-general-settings', JSON.stringify(localData));
|
|
93
|
+
}
|
|
94
|
+
draft.basePreferences = (0, merge_1.default)({}, workspacePreferences, resProps);
|
|
95
|
+
const hiddenModeFeatures = getTruthyObjectValues(draft.basePreferences.display);
|
|
96
|
+
let hiddenLocalStorageFeatures = {};
|
|
76
97
|
draft.dispatch = dispatch;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
98
|
+
const localStorageModePreferences = localData?.workspaces[workspace] || null;
|
|
99
|
+
if (localStorageModePreferences) {
|
|
100
|
+
Object.entries(localStorageModePreferences).forEach(([k, v]) => {
|
|
101
|
+
if (k === 'display') {
|
|
102
|
+
hiddenLocalStorageFeatures = getTruthyObjectValues(v);
|
|
103
|
+
}
|
|
104
|
+
else if (!['dispatch', 'basePreferences'].includes(k)) {
|
|
80
105
|
draft[k] = (0, merge_1.default)({}, resProps[k] ? resProps[k] : {}, v);
|
|
81
106
|
}
|
|
82
107
|
});
|
|
83
108
|
mapNucleus(draft);
|
|
84
109
|
}
|
|
110
|
+
draft.display = (0, merge_1.default)({}, getPreferencesByWorkspace(NMRium_1.NMRiumWorkspaces.DEFAULT).display, hiddenModeFeatures, hiddenLocalStorageFeatures);
|
|
85
111
|
}
|
|
86
112
|
}
|
|
87
113
|
function handleSetPreferences(draft, action) {
|
|
88
114
|
if (action.payload) {
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
115
|
+
const { controllers, formatting, display } = action.payload;
|
|
116
|
+
let localData = (0, LocalStorage_1.getLocalStorage)('nmr-general-settings');
|
|
117
|
+
localData.workspaces = {
|
|
118
|
+
...localData.workspaces,
|
|
119
|
+
[draft.workspace]: {
|
|
120
|
+
...localData.workspaces[draft.workspace],
|
|
121
|
+
controllers,
|
|
122
|
+
formatting,
|
|
123
|
+
display,
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
(0, LocalStorage_1.storeData)('nmr-general-settings', JSON.stringify(localData));
|
|
127
|
+
draft.controllers = controllers;
|
|
128
|
+
draft.formatting = formatting;
|
|
129
|
+
draft.display.panels = display.panels;
|
|
130
|
+
draft.display.general.hideExperimentalFeatures =
|
|
131
|
+
display.general.hideExperimentalFeatures;
|
|
95
132
|
mapNucleus(draft);
|
|
96
133
|
}
|
|
97
134
|
}
|
|
98
135
|
function handleSetPanelsPreferences(draft, action) {
|
|
99
136
|
if (action.payload) {
|
|
100
137
|
const { key, value } = action.payload;
|
|
138
|
+
let localData = (0, LocalStorage_1.getLocalStorage)('nmr-general-settings');
|
|
139
|
+
localData.workspaces[draft.workspace].formatting.panels[key] = value;
|
|
140
|
+
(0, LocalStorage_1.storeData)('nmr-general-settings', JSON.stringify(localData));
|
|
101
141
|
draft.formatting.panels[key] = value;
|
|
102
142
|
}
|
|
103
143
|
}
|