nmrium 0.28.0 → 0.29.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/database/DatabaseSpectrum.js +9 -6
- package/lib/component/1d/database/ResurrectedDatabaseRanges.js +8 -6
- package/lib/component/2d/Contours.js +8 -8
- package/lib/component/context/PreferencesContext.d.ts +0 -2
- package/lib/component/elements/CheckBox.js +1 -1
- package/lib/component/elements/CheckBoxCell.d.ts +3 -0
- package/lib/component/elements/CheckBoxCell.js +8 -0
- package/lib/component/elements/formik/FormikCheckBox.d.ts +2 -1
- package/lib/component/elements/formik/FormikCheckBox.js +4 -2
- package/lib/component/header/BaseLineCorrectionPanel.js +6 -5
- package/lib/component/hooks/useActiveSpectrumStyleOptions.js +1 -1
- package/lib/component/hooks/useCheckToolsVisibility.js +1 -1
- package/lib/component/modal/changeSum/ChangeSumModal.js +2 -2
- package/lib/component/modal/setting/DatabasesTabContent.js +3 -3
- package/lib/component/modal/setting/DisplayTabContent.d.ts +1 -5
- package/lib/component/modal/setting/DisplayTabContent.js +5 -14
- package/lib/component/modal/setting/GeneralSettings.js +19 -12
- package/lib/component/modal/setting/GeneralTabContent.d.ts +3 -0
- package/lib/component/modal/setting/{ControllersTabContent.js → GeneralTabContent.js} +3 -3
- package/lib/component/modal/setting/ToolsTabContent.d.ts +3 -0
- package/lib/component/modal/setting/ToolsTabContent.js +100 -0
- package/lib/component/panels/Panels.js +7 -4
- package/lib/component/panels/databasePanel/DatabasePanel.js +2 -2
- package/lib/component/reducer/actions/FiltersActions.js +11 -8
- package/lib/component/reducer/preferences/actions/addWorkspace.js +2 -2
- package/lib/component/reducer/preferences/actions/initPreferences.js +4 -4
- package/lib/component/reducer/preferences/actions/removeWorkspace.js +1 -1
- package/lib/component/reducer/preferences/actions/setPanelsPreferences.js +1 -1
- package/lib/component/reducer/preferences/actions/setPreferences.js +13 -16
- package/lib/component/reducer/preferences/actions/setWorkspace.js +1 -1
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +2 -44
- package/lib/component/reducer/preferences/preferencesReducer.js +0 -3
- package/lib/component/reducer/preferences/{utilites → utilities}/checkKeysExists.d.ts +0 -0
- package/lib/component/reducer/preferences/{utilites → utilities}/checkKeysExists.js +0 -0
- package/lib/component/reducer/preferences/{utilites → utilities}/filterObject.d.ts +0 -0
- package/lib/component/reducer/preferences/{utilites → utilities}/filterObject.js +0 -0
- package/lib/component/reducer/preferences/{utilites → utilities}/flatObject.d.ts +0 -0
- package/lib/component/reducer/preferences/{utilites → utilities}/flatObject.js +0 -0
- package/lib/component/reducer/preferences/{utilites → utilities}/getActiveWorkspace.d.ts +2 -1
- package/lib/component/reducer/preferences/{utilites → utilities}/getActiveWorkspace.js +0 -0
- package/lib/component/reducer/preferences/{utilites → utilities}/getPreferencesByWorkspace.d.ts +2 -1
- package/lib/component/reducer/preferences/utilities/getPreferencesByWorkspace.js +6 -0
- package/lib/component/reducer/preferences/{utilites → utilities}/mapNucleiFormatting.d.ts +0 -0
- package/lib/component/reducer/preferences/{utilites → utilities}/mapNucleiFormatting.js +0 -0
- package/lib/component/utility/Evaluate.js +1 -0
- package/lib/component/workspaces/Workspace.d.ts +12 -8
- package/lib/component/workspaces/basic.d.ts +2 -2
- package/lib/component/workspaces/basic.js +18 -39
- package/lib/component/workspaces/embedded.d.ts +2 -2
- package/lib/component/workspaces/embedded.js +19 -12
- package/lib/component/workspaces/exercise.d.ts +2 -2
- package/lib/component/workspaces/exercise.js +4 -33
- package/lib/component/workspaces/index.d.ts +5 -5
- package/lib/component/workspaces/prediction.d.ts +2 -2
- package/lib/component/workspaces/prediction.js +19 -16
- package/lib/component/workspaces/process1D.d.ts +2 -2
- package/lib/component/workspaces/process1D.js +12 -18
- package/lib/component/workspaces/workspaceDefaultProperties.d.ts +2 -0
- package/lib/component/workspaces/workspaceDefaultProperties.js +71 -0
- package/lib/data/data1d/MultipleAnalysis.js +1 -0
- package/lib/data/data1d/Spectrum1D/convertDataToFloat64Array.js +1 -1
- package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +11 -12
- package/lib/data/data1d/database.js +3 -10
- package/lib/data/data1d/filter1d/autoPhaseCorrection.js +1 -1
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +14 -10
- package/lib/types/PanelPreferencesType.d.ts +1 -7
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/database/DatabaseSpectrum.js +9 -6
- package/lib-cjs/component/1d/database/ResurrectedDatabaseRanges.js +8 -6
- package/lib-cjs/component/2d/Contours.js +8 -8
- package/lib-cjs/component/elements/CheckBox.js +1 -1
- package/lib-cjs/component/elements/CheckBoxCell.js +15 -0
- package/lib-cjs/component/elements/formik/FormikCheckBox.js +4 -2
- package/lib-cjs/component/header/BaseLineCorrectionPanel.js +6 -5
- package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +1 -1
- package/lib-cjs/component/hooks/useCheckToolsVisibility.js +1 -1
- package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +2 -2
- package/lib-cjs/component/modal/setting/DatabasesTabContent.js +3 -3
- package/lib-cjs/component/modal/setting/DisplayTabContent.js +5 -14
- package/lib-cjs/component/modal/setting/GeneralSettings.js +19 -12
- package/lib-cjs/component/modal/setting/{ControllersTabContent.js → GeneralTabContent.js} +3 -3
- package/lib-cjs/component/modal/setting/ToolsTabContent.js +105 -0
- package/lib-cjs/component/panels/Panels.js +7 -4
- package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +2 -2
- package/lib-cjs/component/reducer/actions/FiltersActions.js +11 -8
- package/lib-cjs/component/reducer/preferences/actions/addWorkspace.js +2 -2
- package/lib-cjs/component/reducer/preferences/actions/initPreferences.js +4 -4
- package/lib-cjs/component/reducer/preferences/actions/removeWorkspace.js +1 -1
- package/lib-cjs/component/reducer/preferences/actions/setPanelsPreferences.js +1 -1
- package/lib-cjs/component/reducer/preferences/actions/setPreferences.js +16 -16
- package/lib-cjs/component/reducer/preferences/actions/setWorkspace.js +1 -1
- package/lib-cjs/component/reducer/preferences/preferencesReducer.js +0 -3
- package/lib-cjs/component/reducer/preferences/{utilites → utilities}/checkKeysExists.js +0 -0
- package/lib-cjs/component/reducer/preferences/{utilites → utilities}/filterObject.js +0 -0
- package/lib-cjs/component/reducer/preferences/{utilites → utilities}/flatObject.js +0 -0
- package/lib-cjs/component/reducer/preferences/{utilites → utilities}/getActiveWorkspace.js +0 -0
- package/lib-cjs/component/reducer/preferences/{utilites → utilities}/getPreferencesByWorkspace.js +3 -1
- package/lib-cjs/component/reducer/preferences/{utilites → utilities}/mapNucleiFormatting.js +0 -0
- package/lib-cjs/component/utility/Evaluate.js +1 -0
- package/lib-cjs/component/workspaces/basic.js +18 -39
- package/lib-cjs/component/workspaces/embedded.js +19 -12
- package/lib-cjs/component/workspaces/exercise.js +4 -33
- package/lib-cjs/component/workspaces/prediction.js +19 -16
- package/lib-cjs/component/workspaces/process1D.js +12 -18
- package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +74 -0
- package/lib-cjs/data/data1d/MultipleAnalysis.js +1 -0
- package/lib-cjs/data/data1d/Spectrum1D/convertDataToFloat64Array.js +1 -1
- package/lib-cjs/data/data1d/Spectrum1D/initiateDatum1D.js +11 -12
- package/lib-cjs/data/data1d/database.js +3 -10
- package/lib-cjs/data/data1d/filter1d/autoPhaseCorrection.js +1 -1
- package/lib-cjs/data/data2d/Spectrum2D/initiateDatum2D.js +14 -10
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +15 -14
- package/lib/component/modal/setting/ControllersTabContent.d.ts +0 -3
- package/lib/component/reducer/preferences/actions/resetPreferences.d.ts +0 -3
- package/lib/component/reducer/preferences/actions/resetPreferences.js +0 -14
- package/lib/component/reducer/preferences/utilites/getPreferencesByWorkspace.js +0 -4
- package/lib-cjs/component/reducer/preferences/actions/resetPreferences.js +0 -18
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export const workspaceDefaultProperties = {
|
|
2
|
+
display: {
|
|
3
|
+
general: {
|
|
4
|
+
disableMultipletAnalysis: false,
|
|
5
|
+
hideSetSumFromMolecule: false,
|
|
6
|
+
hideGeneralSettings: false,
|
|
7
|
+
experimentalFeatures: { display: false },
|
|
8
|
+
hidePanelOnLoad: false,
|
|
9
|
+
},
|
|
10
|
+
panels: {
|
|
11
|
+
spectraPanel: { display: false, open: false },
|
|
12
|
+
informationPanel: { display: false, open: false },
|
|
13
|
+
integralsPanel: { display: false, open: false },
|
|
14
|
+
rangesPanel: { display: false, open: false },
|
|
15
|
+
structuresPanel: { display: false, open: false },
|
|
16
|
+
filtersPanel: { display: false, open: false },
|
|
17
|
+
zonesPanel: { display: false, open: false },
|
|
18
|
+
automaticAssignmentPanel: { display: false, open: false },
|
|
19
|
+
databasePanel: { display: false, open: false },
|
|
20
|
+
multipleSpectraAnalysisPanel: { display: false, open: false },
|
|
21
|
+
peaksPanel: { display: false, open: false },
|
|
22
|
+
predictionPanel: { display: false, open: false },
|
|
23
|
+
summaryPanel: { display: false, open: false },
|
|
24
|
+
},
|
|
25
|
+
toolBarButtons: {
|
|
26
|
+
baselineCorrectionTool: false,
|
|
27
|
+
exclusionZonesTool: false,
|
|
28
|
+
exportAs: false,
|
|
29
|
+
FFTTool: false,
|
|
30
|
+
import: false,
|
|
31
|
+
integralTool: false,
|
|
32
|
+
multipleSpectraAnalysisTool: false,
|
|
33
|
+
phaseCorrectionTool: false,
|
|
34
|
+
rangePickingTool: false,
|
|
35
|
+
realImaginary: false,
|
|
36
|
+
slicingTool: false,
|
|
37
|
+
spectraCenterAlignments: false,
|
|
38
|
+
spectraStackAlignments: false,
|
|
39
|
+
zeroFillingTool: false,
|
|
40
|
+
zonePickingTool: false,
|
|
41
|
+
zoomOutTool: false,
|
|
42
|
+
zoomTool: false,
|
|
43
|
+
peakTool: false,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
general: {
|
|
47
|
+
dimmedSpectraTransparency: 0.1,
|
|
48
|
+
},
|
|
49
|
+
formatting: {
|
|
50
|
+
nuclei: {
|
|
51
|
+
'1h': { name: '1H', ppm: '0.00', hz: '0.00' },
|
|
52
|
+
'13c': { name: '13C', ppm: '0.00', hz: '0.00' },
|
|
53
|
+
'15n': { name: '15N', ppm: '0.00', hz: '0.00' },
|
|
54
|
+
'19f': { name: '19F', ppm: '0.00', hz: '0.00' },
|
|
55
|
+
'29si': { name: '29Si', ppm: '0.00', hz: '0.00' },
|
|
56
|
+
'31p': { name: '31P', ppm: '0.00', hz: '0.00' },
|
|
57
|
+
},
|
|
58
|
+
panels: {},
|
|
59
|
+
},
|
|
60
|
+
databases: {
|
|
61
|
+
defaultDatabase: '',
|
|
62
|
+
data: [
|
|
63
|
+
{
|
|
64
|
+
key: 'toc',
|
|
65
|
+
label: 'Toc',
|
|
66
|
+
url: 'https://data.cheminfo.org/nmr/database/toc.json',
|
|
67
|
+
enabled: true,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
};
|
|
@@ -179,6 +179,7 @@ function calculate(columns, data, formula = '') {
|
|
|
179
179
|
const params = variables.map((key) => data[key] ? data[key][columns[key].valueKey] : null);
|
|
180
180
|
let result;
|
|
181
181
|
try {
|
|
182
|
+
// eslint-disable-next-line no-new-func
|
|
182
183
|
result = new Function(...variables, `return ${formula}`)(...params);
|
|
183
184
|
}
|
|
184
185
|
catch (e) {
|
|
@@ -9,34 +9,33 @@ import { initiateRanges } from './ranges/initiateRanges';
|
|
|
9
9
|
export function initiateDatum1D(options, usedColors = {}) {
|
|
10
10
|
const datum = {};
|
|
11
11
|
datum.id = options.id || generateID();
|
|
12
|
-
datum.source =
|
|
12
|
+
datum.source = {
|
|
13
13
|
jcampURL: null,
|
|
14
14
|
file: {
|
|
15
15
|
binary: null,
|
|
16
16
|
name: '',
|
|
17
17
|
extension: '',
|
|
18
18
|
},
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
...options.source,
|
|
20
|
+
};
|
|
21
|
+
datum.display = {
|
|
21
22
|
name: options.display?.name ? options.display.name : generateID(),
|
|
22
23
|
...getColor(options, usedColors),
|
|
23
24
|
isVisible: true,
|
|
24
25
|
isPeaksMarkersVisible: true,
|
|
25
26
|
isRealSpectrumVisible: true,
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
...options.display,
|
|
28
|
+
};
|
|
29
|
+
datum.info = {
|
|
28
30
|
nucleus: '1H',
|
|
29
31
|
isFid: false,
|
|
30
32
|
isComplex: false,
|
|
31
33
|
dimension: 1,
|
|
32
|
-
|
|
34
|
+
...options.info,
|
|
35
|
+
};
|
|
33
36
|
datum.originalInfo = datum.info;
|
|
34
|
-
datum.meta =
|
|
35
|
-
datum.data =
|
|
36
|
-
x: [],
|
|
37
|
-
re: [],
|
|
38
|
-
im: [],
|
|
39
|
-
}, convertDataToFloat64Array(options.data));
|
|
37
|
+
datum.meta = { ...options.meta };
|
|
38
|
+
datum.data = convertDataToFloat64Array(options.data);
|
|
40
39
|
datum.originalData = datum.data;
|
|
41
40
|
datum.filters = Object.assign([], options.filters); //array of object {name: "FilterName", options: FilterOptions = {value | object} }
|
|
42
41
|
datum.peaks = initiatePeaks(options, datum);
|
|
@@ -45,26 +45,19 @@ function prepareGetSolvents(data) {
|
|
|
45
45
|
function prepareMoleculesDB(array) {
|
|
46
46
|
let moleculesDB = new MoleculesDB(OCL);
|
|
47
47
|
for (let entry of array) {
|
|
48
|
-
//@ts-expect-error property will be defined in next release of nmr-processing
|
|
49
48
|
if (entry.ocl) {
|
|
50
49
|
try {
|
|
51
|
-
const molecule = OCL.Molecule.fromIDCode(
|
|
52
|
-
//@ts-expect-error
|
|
53
|
-
entry.ocl.idCode,
|
|
54
|
-
//@ts-expect-error property will be defined in next release of nmr-processing
|
|
50
|
+
const molecule = OCL.Molecule.fromIDCode(entry.ocl.idCode,
|
|
51
|
+
//@ts-expect-error types will be fixed in next release of openchemlib
|
|
55
52
|
entry.ocl.coordinates);
|
|
56
53
|
moleculesDB.pushEntry(molecule, entry, {}, {
|
|
57
|
-
//@ts-expect-error property will be defined in next release of nmr-processing
|
|
58
54
|
idCode: entry.ocl.idCode,
|
|
59
|
-
//@ts-expect-error property will be defined in next release of nmr-processing
|
|
60
55
|
index: entry.ocl.index,
|
|
61
56
|
});
|
|
62
57
|
}
|
|
63
58
|
catch (e) {
|
|
64
59
|
// eslint-disable-next-line no-console
|
|
65
|
-
console.log(`Could not parse idCode: ${JSON.stringify(
|
|
66
|
-
//@ts-expect-error property will be defined in next release of nmr-processing
|
|
67
|
-
entry.ocl)}`, e);
|
|
60
|
+
console.log(`Could not parse idCode: ${JSON.stringify(entry.ocl)}`, e);
|
|
68
61
|
}
|
|
69
62
|
}
|
|
70
63
|
else if (entry.smiles) {
|
|
@@ -29,7 +29,7 @@ export function isApplicable(datum1D) {
|
|
|
29
29
|
return false;
|
|
30
30
|
}
|
|
31
31
|
export function reduce(previousValue, newValue) {
|
|
32
|
-
let reduced =
|
|
32
|
+
let reduced = { ...previousValue };
|
|
33
33
|
for (const k in reduced) {
|
|
34
34
|
reduced[k] += newValue[k];
|
|
35
35
|
}
|
|
@@ -5,10 +5,11 @@ import Processing2D, { defaultContourOptions } from '../Processing2D';
|
|
|
5
5
|
export function initiateDatum2D(options, usedColors = {}) {
|
|
6
6
|
const datum = {};
|
|
7
7
|
datum.id = options.id || generateID();
|
|
8
|
-
datum.source =
|
|
8
|
+
datum.source = {
|
|
9
9
|
jcampURL: null,
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
...options.source,
|
|
11
|
+
};
|
|
12
|
+
datum.display = {
|
|
12
13
|
name: options.display?.name ? options.display.name : generateID(),
|
|
13
14
|
...getColor(options, usedColors),
|
|
14
15
|
isPositiveVisible: true,
|
|
@@ -16,26 +17,29 @@ export function initiateDatum2D(options, usedColors = {}) {
|
|
|
16
17
|
isVisible: true,
|
|
17
18
|
contourOptions: defaultContourOptions,
|
|
18
19
|
dimension: 2,
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
...options.display,
|
|
21
|
+
};
|
|
22
|
+
datum.info = {
|
|
21
23
|
nucleus: ['1H', '1H'],
|
|
22
24
|
isFt: true,
|
|
23
25
|
isFid: false,
|
|
24
26
|
isComplex: false,
|
|
25
27
|
dimension: 2,
|
|
26
|
-
|
|
28
|
+
...options.info,
|
|
29
|
+
};
|
|
27
30
|
datum.originalInfo = datum.info;
|
|
28
|
-
datum.meta =
|
|
29
|
-
datum.data =
|
|
31
|
+
datum.meta = { ...options.meta };
|
|
32
|
+
datum.data = {
|
|
30
33
|
z: [],
|
|
31
34
|
minX: 0,
|
|
32
35
|
minY: 0,
|
|
33
36
|
maxX: 0,
|
|
34
37
|
maxY: 0,
|
|
35
|
-
|
|
38
|
+
...options.data,
|
|
39
|
+
};
|
|
36
40
|
datum.originalData = datum.data;
|
|
37
41
|
datum.filters = Object.assign([], options.filters);
|
|
38
|
-
datum.zones =
|
|
42
|
+
datum.zones = { values: [], options: {}, ...options.zones };
|
|
39
43
|
datum.processingController = new Processing2D(datum.data, datum.display.contourOptions);
|
|
40
44
|
//reapply filters after load the original data
|
|
41
45
|
FiltersManager.reapplyFilters(datum);
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
interface
|
|
1
|
+
export interface PanelPreferencesType {
|
|
2
2
|
display: boolean;
|
|
3
3
|
open?: boolean;
|
|
4
|
-
hidden?: false;
|
|
5
4
|
}
|
|
6
|
-
interface HiddenPanelOptions {
|
|
7
|
-
hidden: true;
|
|
8
|
-
}
|
|
9
|
-
export declare type PanelPreferencesType = PanelOptions | HiddenPanelOptions;
|
|
10
|
-
export {};
|
package/lib/versionInfo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default { version: 'v0.
|
|
1
|
+
export default { version: 'v0.29.0' };
|
|
@@ -14,6 +14,7 @@ const highlight_1 = require("../../highlight");
|
|
|
14
14
|
const usePanelPreferences_1 = require("../../hooks/usePanelPreferences");
|
|
15
15
|
const SpinnerContext_1 = require("../../loader/SpinnerContext");
|
|
16
16
|
const FileUtility_1 = require("../../utility/FileUtility");
|
|
17
|
+
const PathBuilder_1 = require("../../utility/PathBuilder");
|
|
17
18
|
const scale_1 = require("../utilities/scale");
|
|
18
19
|
function DatabaseSpectrum() {
|
|
19
20
|
const { displayerKey, height, verticalAlign, yDomain, margin } = (0, ChartContext_1.useChartData)();
|
|
@@ -41,13 +42,15 @@ function DatabaseSpectrum() {
|
|
|
41
42
|
setLoading(false);
|
|
42
43
|
const spectrum = spectra?.[0] || null;
|
|
43
44
|
if (spectrum) {
|
|
45
|
+
const pathBuilder = new PathBuilder_1.PathBuilder();
|
|
46
|
+
const finalScaleX = scaleX();
|
|
47
|
+
const finalScaleY = scaleY();
|
|
44
48
|
const { x, re: y } = spectrum.data;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
setPath(path);
|
|
49
|
+
pathBuilder.moveTo(finalScaleX(x[0]), finalScaleY(y[0]));
|
|
50
|
+
for (let i = 1; i < x.length; i++) {
|
|
51
|
+
pathBuilder.lineTo(finalScaleX(x[i]), finalScaleY(y[i]));
|
|
52
|
+
}
|
|
53
|
+
setPath(pathBuilder.toString());
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
catch (e) {
|
|
@@ -11,6 +11,7 @@ const ScaleContext_1 = require("../../context/ScaleContext");
|
|
|
11
11
|
const highlight_1 = require("../../highlight");
|
|
12
12
|
const usePanelPreferences_1 = require("../../hooks/usePanelPreferences");
|
|
13
13
|
const useSpectrum_1 = __importDefault(require("../../hooks/useSpectrum"));
|
|
14
|
+
const PathBuilder_1 = require("../../utility/PathBuilder");
|
|
14
15
|
const scale_1 = require("../utilities/scale");
|
|
15
16
|
const emptyData = { info: { originFrequency: 400 } };
|
|
16
17
|
function ResurrectedDatabaseRanges() {
|
|
@@ -50,13 +51,14 @@ function ResurrectedDatabaseRanges() {
|
|
|
50
51
|
verticalAlign,
|
|
51
52
|
yDomain,
|
|
52
53
|
});
|
|
54
|
+
const finalScaleX = scaleX();
|
|
53
55
|
const paths = spectra.map(({ data: { x, y }, from, to }) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
return { path, from, to };
|
|
56
|
+
const pathBuilder = new PathBuilder_1.PathBuilder();
|
|
57
|
+
pathBuilder.moveTo(finalScaleX(x[0]), scaleY(y[0]));
|
|
58
|
+
for (let i = 1; i < x.length; i++) {
|
|
59
|
+
pathBuilder.lineTo(finalScaleX(x[i]), scaleY(y[i]));
|
|
60
|
+
}
|
|
61
|
+
return { path: pathBuilder.toString(), from, to };
|
|
60
62
|
}, []);
|
|
61
63
|
return ((0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, className: "resurrected-database-ranges", width: "100%", height: "100%", children: paths.map(({ path, from, to }, index) => (
|
|
62
64
|
// eslint-disable-next-line react/no-array-index-key
|
|
@@ -21,26 +21,26 @@ function ContoursPaths({ id: spectrumID, sign, color, datum, }) {
|
|
|
21
21
|
function buildContourPath(data) {
|
|
22
22
|
const _scaleX = (0, scale_1.get2DXScale)({ margin, width, xDomain });
|
|
23
23
|
const _scaleY = (0, scale_1.get2DYScale)({ margin, height, yDomain });
|
|
24
|
-
const
|
|
24
|
+
const pathBuilder = new PathBuilder_1.PathBuilder();
|
|
25
25
|
for (const element of data) {
|
|
26
26
|
if (element.lines) {
|
|
27
27
|
const lines = element.lines;
|
|
28
28
|
if (lines.length < 1e6) {
|
|
29
29
|
for (let i = 0; i < lines.length; i += 4) {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
pathBuilder.moveTo(_scaleX(lines[i] + xShift), _scaleY(lines[i + 1] + yShift));
|
|
31
|
+
pathBuilder.lineTo(_scaleX(lines[i + 2] + xShift), _scaleY(lines[i + 3] + yShift));
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
-
|
|
36
|
+
pathBuilder.moveTo(_scaleX(element[0].x + xShift), _scaleY(element[0].y + yShift));
|
|
37
37
|
for (let j = 1; j < element.length; j++) {
|
|
38
|
-
|
|
38
|
+
pathBuilder.lineTo(_scaleX(element[j].x + xShift), _scaleY(element[j].y + yShift));
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
return
|
|
42
|
+
pathBuilder.closePath();
|
|
43
|
+
return pathBuilder.toString();
|
|
44
44
|
}
|
|
45
45
|
const data = (0, react_1.useMemo)(() => {
|
|
46
46
|
return (0, get_1.default)(contours, `${spectrumID}.${sign}`, []);
|
|
@@ -51,7 +51,7 @@ function ContoursPaths({ id: spectrumID, sign, color, datum, }) {
|
|
|
51
51
|
return ((0, jsx_runtime_1.jsx)("path", { fill: "none", "data-test-id": "spectrum-line", stroke: color, strokeWidth: "1", style: {
|
|
52
52
|
opacity: isActive
|
|
53
53
|
? 1
|
|
54
|
-
: (0, get_1.default)(preferences.current, '
|
|
54
|
+
: (0, get_1.default)(preferences.current, 'general.dimmedSpectraTransparency', 0.1),
|
|
55
55
|
}, d: path }));
|
|
56
56
|
}
|
|
57
57
|
function ContoursInner({ data, displayerKey }) {
|
|
@@ -9,6 +9,6 @@ const CheckBox = (0, react_1.forwardRef)((props, ref) => {
|
|
|
9
9
|
setCheck(!checked);
|
|
10
10
|
onChange(e);
|
|
11
11
|
}, [checked, onChange]);
|
|
12
|
-
return ((0, jsx_runtime_1.jsx)("input", { ref: ref, type: "checkbox", name: name, id: name, onChange: handleCheck,
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)("input", { ref: ref, type: "checkbox", name: name, id: name, onChange: handleCheck, checked: checkProps, disabled: disabled, style: style }));
|
|
13
13
|
});
|
|
14
14
|
exports.default = CheckBox;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
exports.CheckBoxCell = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const FormikCheckBox_1 = __importDefault(require("./formik/FormikCheckBox"));
|
|
9
|
+
function CheckBoxCell(props) {
|
|
10
|
+
const { name, ...otherProps } = props;
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)(FormikCheckBox_1.default, { style: {
|
|
12
|
+
container: { display: 'block', margin: '0 auto', width: 'fit-content' },
|
|
13
|
+
}, name: props.name, ...otherProps }, props.name));
|
|
14
|
+
}
|
|
15
|
+
exports.CheckBoxCell = CheckBoxCell;
|
|
@@ -9,9 +9,11 @@ const get_1 = __importDefault(require("lodash/get"));
|
|
|
9
9
|
const react_1 = require("react");
|
|
10
10
|
const CheckBox_1 = __importDefault(require("../CheckBox"));
|
|
11
11
|
function FormikCheckBox(props) {
|
|
12
|
-
const { label, name, onChange = () => null, className = 'checkbox', reverse = false, style = { container: {}, label: {}, checkbox: {} }, ...resProps } = props;
|
|
12
|
+
const { label, name, onChange = () => null, className = 'checkbox', reverse = false, style = { container: {}, label: {}, checkbox: {} }, defaultValue, ...resProps } = props;
|
|
13
13
|
const { values, setFieldValue } = (0, formik_1.useFormikContext)();
|
|
14
|
-
const value = reverse
|
|
14
|
+
const value = reverse
|
|
15
|
+
? !(0, get_1.default)(values, name, defaultValue)
|
|
16
|
+
: (0, get_1.default)(values, name, defaultValue);
|
|
15
17
|
const changeHandler = (0, react_1.useCallback)((e) => {
|
|
16
18
|
e.persist();
|
|
17
19
|
onChange(e);
|
|
@@ -34,6 +34,7 @@ const DispatchContext_1 = require("../context/DispatchContext");
|
|
|
34
34
|
const ActionButtons_1 = __importDefault(require("../elements/ActionButtons"));
|
|
35
35
|
const Label_1 = __importDefault(require("../elements/Label"));
|
|
36
36
|
const Select_1 = __importDefault(require("../elements/Select"));
|
|
37
|
+
const FormikCheckBox_1 = __importDefault(require("../elements/formik/FormikCheckBox"));
|
|
37
38
|
const FormikForm_1 = __importDefault(require("../elements/formik/FormikForm"));
|
|
38
39
|
const FormikInput_1 = __importDefault(require("../elements/formik/FormikInput"));
|
|
39
40
|
const FormikOnChange_1 = __importDefault(require("../elements/formik/FormikOnChange"));
|
|
@@ -55,7 +56,7 @@ function BaseLineCorrectionPanel() {
|
|
|
55
56
|
const formRef = (0, react_1.useRef)();
|
|
56
57
|
const algorithmRef = (0, react_1.useRef)();
|
|
57
58
|
const [algorithm, setAlgorithm] = (0, react_1.useState)('polynomial');
|
|
58
|
-
const handleApplyFilter = (0, react_1.useCallback)((values,
|
|
59
|
+
const handleApplyFilter = (0, react_1.useCallback)((values, triggerSource = 'apply') => {
|
|
59
60
|
let options = {};
|
|
60
61
|
switch (algorithm) {
|
|
61
62
|
case 'airpls':
|
|
@@ -74,7 +75,7 @@ function BaseLineCorrectionPanel() {
|
|
|
74
75
|
break;
|
|
75
76
|
}
|
|
76
77
|
dispatch({
|
|
77
|
-
type:
|
|
78
|
+
type: triggerSource === 'onChange'
|
|
78
79
|
? Types_1.CALCULATE_BASE_LINE_CORRECTION_FILTER
|
|
79
80
|
: Types_1.APPLY_BASE_LINE_CORRECTION_FILTER,
|
|
80
81
|
options,
|
|
@@ -110,12 +111,12 @@ function BaseLineCorrectionPanel() {
|
|
|
110
111
|
const validation = Yup.object().shape({
|
|
111
112
|
degree: Yup.number().integer().min(1).max(6).required(),
|
|
112
113
|
});
|
|
113
|
-
return { validation, initialValue: { degree: 3 } };
|
|
114
|
+
return { livePreview: true, validation, initialValue: { degree: 3 } };
|
|
114
115
|
}
|
|
115
116
|
default:
|
|
116
|
-
return { validation: {}, initialValue: {} };
|
|
117
|
+
return { livePreview: true, validation: {}, initialValue: {} };
|
|
117
118
|
}
|
|
118
119
|
}, [algorithm]);
|
|
119
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: styles.container, children: [(0, jsx_runtime_1.jsx)("span", { style: styles.label, children: "Algorithm: " }), (0, jsx_runtime_1.jsx)(Select_1.default, { ref: algorithmRef, data: getAlgorithmsList(), style: { marginLeft: 10, marginRight: 10 }, defaultValue: "polynomial", onChange: changeAlgorithmHandler }), (0, jsx_runtime_1.jsxs)(FormikForm_1.default, { ref: formRef, onSubmit: (values) => handleApplyFilter(values), initialValues: formData.initialValue, validationSchema: formData.validation, children: [algorithm && algorithm === 'airpls' && ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex' }, children: [(0, jsx_runtime_1.jsx)(Label_1.default, { title: "maxIterations:", children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "maxIterations", debounceTime: 250 }) }), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "tolerance:", style: { label: { padding: '0 5px' } }, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "tolerance", debounceTime: 250 }) })] })), algorithm && ['autoPolynomial', 'polynomial'].includes(algorithm) && ((0, jsx_runtime_1.jsx)(Label_1.default, { title: "degree [ 1 - 6 ]:", children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "degree", min: 1, max: 6, style: { inputWrapper: { height: '100%' } }, debounceTime: 250 }) })), (0, jsx_runtime_1.jsx)(FormikOnChange_1.default, { onChange: (values) => handleApplyFilter(values,
|
|
120
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: styles.container, children: [(0, jsx_runtime_1.jsx)("span", { style: styles.label, children: "Algorithm: " }), (0, jsx_runtime_1.jsx)(Select_1.default, { ref: algorithmRef, data: getAlgorithmsList(), style: { marginLeft: 10, marginRight: 10 }, defaultValue: "polynomial", onChange: changeAlgorithmHandler }), (0, jsx_runtime_1.jsxs)(FormikForm_1.default, { ref: formRef, onSubmit: (values) => handleApplyFilter(values), initialValues: { ...formData.initialValue, livePreview: true }, validationSchema: formData.validation, children: [algorithm && algorithm === 'airpls' && ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex' }, children: [(0, jsx_runtime_1.jsx)(Label_1.default, { title: "maxIterations:", children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "maxIterations", debounceTime: 250 }) }), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "tolerance:", style: { label: { padding: '0 5px' } }, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "tolerance", debounceTime: 250 }) })] })), algorithm && ['autoPolynomial', 'polynomial'].includes(algorithm) && ((0, jsx_runtime_1.jsx)(Label_1.default, { title: "degree [ 1 - 6 ]:", children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "degree", min: 1, max: 6, style: { inputWrapper: { height: '100%' } }, debounceTime: 250 }) })), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "live preview ", style: { label: { padding: '0 5px' } }, children: (0, jsx_runtime_1.jsx)(FormikCheckBox_1.default, { name: "livePreview" }) }), (0, jsx_runtime_1.jsx)(FormikOnChange_1.default, { onChange: (values) => handleApplyFilter(values, 'onChange') })] }, JSON.stringify(formData.initialValue)), (0, jsx_runtime_1.jsx)(ActionButtons_1.default, { onDone: () => formRef.current.submitForm(), onCancel: handleCancelFilter })] }));
|
|
120
121
|
}
|
|
121
122
|
exports.default = BaseLineCorrectionPanel;
|
|
@@ -14,7 +14,7 @@ function useActiveSpectrumStyleOptions(id) {
|
|
|
14
14
|
const isActive = activeSpectrum === null ? true : id === activeSpectrum.id;
|
|
15
15
|
const opacity = isActive
|
|
16
16
|
? 1
|
|
17
|
-
: (0, get_1.default)(preferences.current, '
|
|
17
|
+
: (0, get_1.default)(preferences.current, 'general.dimmedSpectraTransparency', 0.1);
|
|
18
18
|
return { isActive, opacity };
|
|
19
19
|
}, [activeSpectrum, id, preferences]);
|
|
20
20
|
}
|
|
@@ -9,6 +9,6 @@ const react_1 = require("react");
|
|
|
9
9
|
const PreferencesContext_1 = require("../context/PreferencesContext");
|
|
10
10
|
function useCheckToolsVisibility() {
|
|
11
11
|
const preferences = (0, PreferencesContext_1.usePreferences)();
|
|
12
|
-
return (0, react_1.useCallback)((toolKey) => (0, get_1.default)(preferences.current, `display.toolBarButtons.${toolKey}`,
|
|
12
|
+
return (0, react_1.useCallback)((toolKey) => (0, get_1.default)(preferences.current, `display.toolBarButtons.${toolKey}`, false), [preferences]);
|
|
13
13
|
}
|
|
14
14
|
exports.useCheckToolsVisibility = useCheckToolsVisibility;
|
|
@@ -102,7 +102,7 @@ function ChangeSumModal({ onSave, onClose, header, sumOptions, }) {
|
|
|
102
102
|
(0, react_2.useEffect)(() => {
|
|
103
103
|
if (sumOptions?.sumAuto &&
|
|
104
104
|
!general?.hideSetSumFromMolecule &&
|
|
105
|
-
!panels?.structuresPanel?.
|
|
105
|
+
!panels?.structuresPanel?.display) {
|
|
106
106
|
setActiveOption(SumSetOptions.Auto);
|
|
107
107
|
const { mf, moleculeKey: key } = sumOptions;
|
|
108
108
|
formRef.current.setValues({
|
|
@@ -151,6 +151,6 @@ function ChangeSumModal({ onSave, onClose, header, sumOptions, }) {
|
|
|
151
151
|
return (
|
|
152
152
|
// <div css={modalContainer}>
|
|
153
153
|
(0, jsx_runtime_1.jsxs)("div", { css: [ModalStyle_1.ModalStyles, styles], children: [(0, jsx_runtime_1.jsxs)("div", { className: "header handle", children: [(0, jsx_runtime_1.jsx)("span", { children: header }), (0, jsx_runtime_1.jsx)(CloseButton_1.default, { onClick: onClose })] }), (0, jsx_runtime_1.jsx)("div", { className: "tab-content", children: (0, jsx_runtime_1.jsx)(FormikForm_1.default, { ref: formRef, onSubmit: saveHandler, initialValues: { sum: null, molecule: null }, validationSchema: validationSchema, children: (0, jsx_runtime_1.jsxs)(Tabs_1.default, { activeTab: setOption, onClick: onTabChangeHandler, children: [!general?.hideSetSumFromMolecule &&
|
|
154
|
-
!panels?.structuresPanel?.
|
|
154
|
+
!panels?.structuresPanel?.display && ((0, jsx_runtime_1.jsx)(Tab_1.default, { tablabel: "Auto", tabid: SumSetOptions.Auto, children: (0, jsx_runtime_1.jsx)(SelectMolecule_1.default, { name: "molecule" }) })), (0, jsx_runtime_1.jsx)(Tab_1.default, { tablabel: "Manual", tabid: SumSetOptions.Manual, children: (0, jsx_runtime_1.jsx)("div", { className: "manual-container", children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: "sum", type: "number", placeholder: "Enter the new value", onKeyDown: handleKeyDown }) }) })] }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "footer-container", children: (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => formRef.current.submitForm(), className: "btn", children: "Set" }) })] }));
|
|
155
155
|
}
|
|
156
156
|
exports.default = ChangeSumModal;
|
|
@@ -12,8 +12,8 @@ const generateID_1 = __importDefault(require("../../../data/utilities/generateID
|
|
|
12
12
|
const Button_1 = __importDefault(require("../../elements/Button"));
|
|
13
13
|
const FormikCheckBox_1 = __importDefault(require("../../elements/formik/FormikCheckBox"));
|
|
14
14
|
const FormikInput_1 = __importDefault(require("../../elements/formik/FormikInput"));
|
|
15
|
+
const getPreferencesByWorkspace_1 = require("../../reducer/preferences/utilities/getPreferencesByWorkspace");
|
|
15
16
|
const isGoogleDocument_1 = require("../../utility/isGoogleDocument");
|
|
16
|
-
const workspaces_1 = __importDefault(require("../../workspaces"));
|
|
17
17
|
const style = {
|
|
18
18
|
table: {
|
|
19
19
|
width: '100%',
|
|
@@ -54,8 +54,8 @@ function DatabasesTabContent({ currentWorkspace }) {
|
|
|
54
54
|
setFieldValue('databases.data', [...databases.data, newDatabase]);
|
|
55
55
|
}, [databases, setFieldValue]);
|
|
56
56
|
const resetDatabaseHandler = (0, react_1.useCallback)(() => {
|
|
57
|
-
const
|
|
58
|
-
|
|
57
|
+
const workSpaceDisplayPreferences = (0, getPreferencesByWorkspace_1.getPreferencesByWorkspace)(currentWorkspace);
|
|
58
|
+
const database = workSpaceDisplayPreferences.databases.data;
|
|
59
59
|
setFieldValue('databases.data', database);
|
|
60
60
|
}, [currentWorkspace, setFieldValue]);
|
|
61
61
|
return ((0, jsx_runtime_1.jsxs)("fieldset", { onClick: (e) => {
|
|
@@ -4,10 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
8
7
|
const react_1 = require("react");
|
|
8
|
+
const CheckBoxCell_1 = require("../../elements/CheckBoxCell");
|
|
9
9
|
const ReactTable_1 = __importDefault(require("../../elements/ReactTable/ReactTable"));
|
|
10
|
-
const FormikCheckBox_1 = __importDefault(require("../../elements/formik/FormikCheckBox"));
|
|
11
10
|
const LIST = [
|
|
12
11
|
{
|
|
13
12
|
label: 'Spectra selection panel',
|
|
@@ -67,12 +66,7 @@ const LIST = [
|
|
|
67
66
|
hideOpenOption: true,
|
|
68
67
|
},
|
|
69
68
|
];
|
|
70
|
-
function
|
|
71
|
-
return ((0, jsx_runtime_1.jsx)(FormikCheckBox_1.default, { style: {
|
|
72
|
-
container: { display: 'block', margin: '0 auto', width: 'fit-content' },
|
|
73
|
-
}, className: "checkbox-element", name: props.name }, props.name));
|
|
74
|
-
}
|
|
75
|
-
function DisplayTabContent({ preferences }) {
|
|
69
|
+
function DisplayTabContent() {
|
|
76
70
|
const COLUMNS = (0, react_1.useMemo)(() => [
|
|
77
71
|
{
|
|
78
72
|
index: 1,
|
|
@@ -88,17 +82,14 @@ function DisplayTabContent({ preferences }) {
|
|
|
88
82
|
{
|
|
89
83
|
index: 2,
|
|
90
84
|
Header: 'Active',
|
|
91
|
-
Cell: ({ row }) => ((0, jsx_runtime_1.jsx)(CheckBoxCell, { name: `display.${row.original.name}.display
|
|
85
|
+
Cell: ({ row }) => ((0, jsx_runtime_1.jsx)(CheckBoxCell_1.CheckBoxCell, { name: `display.${row.original.name}.display`, defaultValue: false })),
|
|
92
86
|
},
|
|
93
87
|
{
|
|
94
88
|
index: 3,
|
|
95
89
|
Header: 'Open on load',
|
|
96
|
-
Cell: ({ row }) => !row.original.hideOpenOption ? ((0, jsx_runtime_1.jsx)(CheckBoxCell, { name: `display.${row.original.name}.open
|
|
90
|
+
Cell: ({ row }) => !row.original.hideOpenOption ? ((0, jsx_runtime_1.jsx)(CheckBoxCell_1.CheckBoxCell, { name: `display.${row.original.name}.open`, defaultValue: false })) : ((0, jsx_runtime_1.jsx)("div", {})),
|
|
97
91
|
},
|
|
98
92
|
], []);
|
|
99
|
-
|
|
100
|
-
return LIST.filter((item) => (0, get_1.default)(preferences, `${item.name}.hidden`) !== true);
|
|
101
|
-
}, [preferences]);
|
|
102
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: { width: '100%', overflow: 'hidden' }, children: (0, jsx_runtime_1.jsx)(ReactTable_1.default, { columns: COLUMNS, data: data }) }));
|
|
93
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { width: '100%', overflow: 'hidden' }, children: (0, jsx_runtime_1.jsx)(ReactTable_1.default, { columns: COLUMNS, data: LIST }) }));
|
|
103
94
|
}
|
|
104
95
|
exports.default = DisplayTabContent;
|
|
@@ -32,17 +32,20 @@ const react_1 = require("@emotion/react");
|
|
|
32
32
|
const react_2 = require("react");
|
|
33
33
|
const PreferencesContext_1 = require("../../context/PreferencesContext");
|
|
34
34
|
const ActionButtons_1 = __importDefault(require("../../elements/ActionButtons"));
|
|
35
|
+
const Button_1 = __importDefault(require("../../elements/Button"));
|
|
35
36
|
const CloseButton_1 = __importDefault(require("../../elements/CloseButton"));
|
|
36
37
|
const Tab_1 = __importDefault(require("../../elements/Tab/Tab"));
|
|
37
38
|
const Tabs_1 = __importStar(require("../../elements/Tab/Tabs"));
|
|
38
39
|
const DropDownButton_1 = __importDefault(require("../../elements/dropDownButton/DropDownButton"));
|
|
39
40
|
const FormikForm_1 = __importDefault(require("../../elements/formik/FormikForm"));
|
|
40
41
|
const Alert_1 = require("../../elements/popup/Alert");
|
|
42
|
+
const getPreferencesByWorkspace_1 = require("../../reducer/preferences/utilities/getPreferencesByWorkspace");
|
|
41
43
|
const ModalStyle_1 = require("../ModalStyle");
|
|
42
|
-
const ControllersTabContent_1 = __importDefault(require("./ControllersTabContent"));
|
|
43
44
|
const DatabasesTabContent_1 = __importDefault(require("./DatabasesTabContent"));
|
|
44
45
|
const DisplayTabContent_1 = __importDefault(require("./DisplayTabContent"));
|
|
45
46
|
const FormattingTabContent_1 = __importDefault(require("./FormattingTabContent"));
|
|
47
|
+
const GeneralTabContent_1 = __importDefault(require("./GeneralTabContent"));
|
|
48
|
+
const ToolsTabContent_1 = __importDefault(require("./ToolsTabContent"));
|
|
46
49
|
const WorkspaceItem_1 = __importDefault(require("./WorkspaceItem"));
|
|
47
50
|
const settingsValidation_1 = require("./settingsValidation");
|
|
48
51
|
const styles = (0, react_1.css) `
|
|
@@ -119,8 +122,8 @@ const styles = (0, react_1.css) `
|
|
|
119
122
|
}
|
|
120
123
|
`;
|
|
121
124
|
function GeneralSettings({ onClose }) {
|
|
122
|
-
const [activeTab, setActiveTab] = (0, react_2.useState)('
|
|
123
|
-
const { dispatch, ...preferences } = (0, PreferencesContext_1.usePreferences)();
|
|
125
|
+
const [activeTab, setActiveTab] = (0, react_2.useState)('general');
|
|
126
|
+
const { dispatch, current: currentWorkspace, ...preferences } = (0, PreferencesContext_1.usePreferences)();
|
|
124
127
|
const alert = (0, Alert_1.useAlert)();
|
|
125
128
|
const refForm = (0, react_2.useRef)();
|
|
126
129
|
const workspaces = (0, PreferencesContext_1.useWorkspacesList)();
|
|
@@ -132,19 +135,21 @@ function GeneralSettings({ onClose }) {
|
|
|
132
135
|
},
|
|
133
136
|
]);
|
|
134
137
|
}, [workspaces]);
|
|
135
|
-
const handleSave = (
|
|
138
|
+
const handleSave = () => {
|
|
136
139
|
refForm.current.submitForm();
|
|
137
|
-
}
|
|
138
|
-
const handleReset = (
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
};
|
|
141
|
+
const handleReset = () => {
|
|
142
|
+
const workSpaceDisplayPreferences = (0, getPreferencesByWorkspace_1.getPreferencesByWorkspace)(preferences.workspace.current);
|
|
143
|
+
refForm.current.setValues(workSpaceDisplayPreferences);
|
|
144
|
+
};
|
|
145
|
+
const handleClose = () => {
|
|
141
146
|
onClose?.();
|
|
142
|
-
}
|
|
143
|
-
const submitHandler = (
|
|
147
|
+
};
|
|
148
|
+
const submitHandler = (values) => {
|
|
144
149
|
dispatch({ type: 'SET_PREFERENCES', payload: values });
|
|
145
150
|
alert.success('Settings saved successfully');
|
|
146
151
|
onClose?.();
|
|
147
|
-
}
|
|
152
|
+
};
|
|
148
153
|
const tabChangeHandler = (0, react_2.useCallback)((tab) => {
|
|
149
154
|
setActiveTab(tab.tabid);
|
|
150
155
|
}, []);
|
|
@@ -176,6 +181,8 @@ function GeneralSettings({ onClose }) {
|
|
|
176
181
|
const renderItem = (0, react_2.useCallback)((item) => {
|
|
177
182
|
return ((0, jsx_runtime_1.jsx)(WorkspaceItem_1.default, { item: item, onSave: addWorkSpaceHandler, onDelete: deleteWorkSpaceHandler }));
|
|
178
183
|
}, [addWorkSpaceHandler, deleteWorkSpaceHandler]);
|
|
179
|
-
return ((0, jsx_runtime_1.jsxs)("div", { css: [ModalStyle_1.ModalStyles, styles], children: [(0, jsx_runtime_1.jsxs)("div", { className: "header handle", children: [(0, jsx_runtime_1.jsx)("span", { children: "General Settings" }), (0, jsx_runtime_1.jsx)(CloseButton_1.default, { onClick: onClose, className: "close-bt" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "workspace-container", children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: "Workspace : " }), (0, jsx_runtime_1.jsx)(DropDownButton_1.default, { data: workspacesList, renderItem: renderItem, selectedKey: preferences?.workspace.current, onSelect: ChangeWorkspaceHandler })
|
|
184
|
+
return ((0, jsx_runtime_1.jsxs)("div", { css: [ModalStyle_1.ModalStyles, styles], children: [(0, jsx_runtime_1.jsxs)("div", { className: "header handle", children: [(0, jsx_runtime_1.jsx)("span", { children: "General Settings" }), (0, jsx_runtime_1.jsx)(CloseButton_1.default, { onClick: onClose, className: "close-bt" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "workspace-container", children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: "Workspace : " }), (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.Danger, { fill: "outline", size: "xSmall", onClick: handleReset, style: {
|
|
185
|
+
marginLeft: '10px',
|
|
186
|
+
}, children: "Reset workspace settings" })] }), (0, jsx_runtime_1.jsx)("div", { className: "main-content", children: (0, jsx_runtime_1.jsx)(FormikForm_1.default, { ref: refForm, initialValues: currentWorkspace, validationSchema: settingsValidation_1.validation, onSubmit: submitHandler, 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, { tablabel: "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, { tablabel: "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, { tablabel: "Display", 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, { tablabel: "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, { tablabel: "Databases", tabid: "databases", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(DatabasesTabContent_1.default, { currentWorkspace: preferences.workspace.current }) }) })] }) }, JSON.stringify(currentWorkspace)) }), (0, jsx_runtime_1.jsx)("div", { className: "footer-container", children: (0, jsx_runtime_1.jsx)(ActionButtons_1.default, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: handleSave, doneLabel: "Save", onCancel: handleClose }) })] }));
|
|
180
187
|
}
|
|
181
188
|
exports.default = GeneralSettings;
|