From 33a46fa0445275005f6cb565faffa879601c5425 Mon Sep 17 00:00:00 2001 From: hamed musallam Date: Mon, 29 Apr 2024 20:26:30 +0200 Subject: [PATCH] refactor: move axis preferences to general settings chore: update to nmr-load-save version 0.31.0 refactor: 'Formatting' tab preferences and rename it to 'Nuclei' refactor: formatting object in the workspace and the predefined workspaces --- package-lock.json | 26 +- .../EventsTrackers/KeysListenerTracker.tsx | 14 +- .../hooks/useFormatNumberByNucleus.ts | 35 +- src/component/hooks/usePanelPreferences.ts | 4 +- .../modal/setting/GeneralSettings.tsx | 8 +- .../settings-tabs/FormattingTabContent.tsx | 150 ----- .../settings-tabs/NucleiTabContent.tsx | 187 ++++++ .../modal/setting/settingsValidation.ts | 126 ++-- .../SpectraPanel/SpectraPreferences.tsx | 69 +- .../reducer/actions/DomainActions.ts | 28 +- .../preferences/actions/analyzeSpectra.ts | 8 +- .../preferences/actions/matrixGeneration.ts | 6 +- .../actions/setPanelsPreferences.ts | 2 +- .../preferences/actions/setPreferences.ts | 6 +- .../panelsPreferencesDefaultValues.ts | 5 +- .../utilities/mapNucleiFormatting.ts | 15 - src/component/utility/PreferencesHelper.ts | 4 +- src/component/workspaces/exercise.ts | 52 +- src/component/workspaces/prediction.ts | 344 +++++----- src/component/workspaces/simulation.ts | 72 +- .../workspaces/workspaceDefaultProperties.ts | 21 +- src/demo/views/BenchtopNMRWorkspace.tsx | 67 +- src/demo/views/CustomWorkspace.tsx | 113 ++-- src/demo/views/SnapshotView.tsx | 618 +++++++++--------- src/demo/views/Teaching.tsx | 14 +- 25 files changed, 970 insertions(+), 1024 deletions(-) delete mode 100644 src/component/modal/setting/settings-tabs/FormattingTabContent.tsx create mode 100644 src/component/modal/setting/settings-tabs/NucleiTabContent.tsx delete mode 100644 src/component/reducer/preferences/utilities/mapNucleiFormatting.ts diff --git a/package-lock.json b/package-lock.json index ef759b4b6..f9394d369 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4781,16 +4781,16 @@ } }, "node_modules/brukerconverter": { - "version": "6.3.9", - "resolved": "https://registry.npmjs.org/brukerconverter/-/brukerconverter-6.3.9.tgz", - "integrity": "sha512-rmzadrmIbBiv4Ihh4G4fTSqXAEM+Z2ai402hAt2KK/AQWRXl9hYzXPpKubYt1Z8qWaqcG2dkvoOmb/yuKGiVOg==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/brukerconverter/-/brukerconverter-7.0.0.tgz", + "integrity": "sha512-GJczqQleVXtJL7DSeNMvSXmE7JuTQdhSjs4Wc3qM78uJJNKn3pBD73YW2pbCyuf4aelTvnxFJq67F+9850JgUQ==", "dependencies": { - "cheminfo-types": "^1.7.2", + "cheminfo-types": "^1.7.3", "filelist-utils": "^1.11.0", "iobuffer": "^5.3.2", "is-any-array": "^2.0.1", - "jcampconverter": "^9.6.1", - "ml-spectra-processing": "^14.1.1" + "jcampconverter": "^9.6.4", + "ml-spectra-processing": "^14.3.0" } }, "node_modules/builtin-modules": { @@ -10344,27 +10344,27 @@ } }, "node_modules/nmr-load-save": { - "version": "0.30.1-pre.1714163234", - "resolved": "https://registry.npmjs.org/nmr-load-save/-/nmr-load-save-0.30.1-pre.1714163234.tgz", - "integrity": "sha512-maCstN05kPIyT++W7XqmBCA+A2fcqtwWlhN6XivxADtnQ0Ss5Hku1awXFz0tHZZog5WHO8eghZq09JcC0F/4BA==", + "version": "0.31.0", + "resolved": "https://registry.npmjs.org/nmr-load-save/-/nmr-load-save-0.31.0.tgz", + "integrity": "sha512-2Hhu2WoODYAyvBJX/8mtlxgfgYmxf8/AyKszKk5bPUQctLK77woIv0mMmaiuXeEupE3a1JcHHu2SoDoX+r40Aw==", "dependencies": { "@lukeed/uuid": "^2.0.1", "@types/lodash.merge": "^4.6.9", - "brukerconverter": "^6.3.8", + "brukerconverter": "^7.0.0", "cheminfo-types": "^1.7.3", "convert-to-jcamp": "^5.4.10", "filelist-utils": "^1.11.0", - "gyromagnetic-ratio": "^1.1.1", + "gyromagnetic-ratio": "^1.2.0", "is-any-array": "^2.0.1", "jcampconverter": "^9.6.4", "jeolconverter": "^1.0.3", "lodash.merge": "^4.6.2", - "ml-spectra-processing": "^14.2.2", + "ml-spectra-processing": "^14.3.0", "nmr-correlation": "^2.3.3", "nmr-processing": "^12.2.0", "nmredata": "^0.9.9", "openchemlib": "^8.9.0", - "openchemlib-utils": "^5.12.1", + "openchemlib-utils": "^5.16.3", "sdf-parser": "^6.0.1", "varian-converter": "^1.0.0" } diff --git a/src/component/EventsTrackers/KeysListenerTracker.tsx b/src/component/EventsTrackers/KeysListenerTracker.tsx index ba033713f..6950d0081 100644 --- a/src/component/EventsTrackers/KeysListenerTracker.tsx +++ b/src/component/EventsTrackers/KeysListenerTracker.tsx @@ -12,7 +12,6 @@ import { useModal } from '../elements/popup/Modal'; import { HighlightEventSource, useHighlightData } from '../highlight/index'; import { useCheckToolsVisibility } from '../hooks/useCheckToolsVisibility'; import useExport from '../hooks/useExport'; -import { usePanelPreferences } from '../hooks/usePanelPreferences'; import useToolsFunctions from '../hooks/useToolsFunctions'; import SaveAsModal from '../modal/SaveAsModal'; import { options } from '../toolbar/ToolTypes'; @@ -33,7 +32,10 @@ function KeysListenerTracker(props: KeysListenerTrackerProps) { }, } = useChartData(); const dispatch = useDispatch(); - const { dispatch: dispatchPreferences } = usePreferences(); + const { + dispatch: dispatchPreferences, + current: { nuclei }, + } = usePreferences(); const toaster = useToaster(); const modal = useModal(); const openLoader = useLoader(); @@ -51,7 +53,6 @@ function KeysListenerTracker(props: KeysListenerTrackerProps) { const isToolVisible = useCheckToolsVisibility(); const { highlight, remove } = useHighlightData(); - const { axisDomain } = usePanelPreferences('spectra', activeTab); const mouseIsOverDisplayer = useRef(false); useEffect(() => { @@ -445,7 +446,10 @@ function KeysListenerTracker(props: KeysListenerTrackerProps) { if (e.shiftKey) { switch (e.key) { case 'F': { - dispatch({ type: 'SET_AXIS_DOMAIN', payload: { axisDomain } }); + dispatch({ + type: 'SET_AXIS_DOMAIN', + payload: { nucleiPreferences: nuclei }, + }); break; } default: @@ -470,12 +474,12 @@ function KeysListenerTracker(props: KeysListenerTrackerProps) { [ alignSpectraVerticallyHandler, allow1DTool, - axisDomain, changeDisplayViewModeHandler, dispatch, handleChangeOption, handleFullZoomOut, isToolVisible, + nuclei, openLoader, openSaveAsDialog, saveAsJSONHandler, diff --git a/src/component/hooks/useFormatNumberByNucleus.ts b/src/component/hooks/useFormatNumberByNucleus.ts index 1b5e62b1f..3d9958710 100644 --- a/src/component/hooks/useFormatNumberByNucleus.ts +++ b/src/component/hooks/useFormatNumberByNucleus.ts @@ -6,7 +6,8 @@ import { formatNumber } from '../utility/formatNumber'; export type ReturnFunction = ( value?: number | string, - formatKey?: string, + // eslint-disable-next-line @typescript-eslint/ban-types + formatKey?: 'ppmFormat' | 'hzFormat' | (string & {}), prefix?: string, suffix?: string, ) => string; @@ -15,22 +16,26 @@ export function useFormatNumberByNucleus(nucleus?: string[]): ReturnFunction[]; export function useFormatNumberByNucleus(nucleus?: string): ReturnFunction; export function useFormatNumberByNucleus(nucleus?: string | string[]) { const preferences = usePreferences(); - const nucleusByKey = lodashGet(preferences.current, `formatting.nuclei`, { - ppm: '0.0', - hz: '0.0', - }); + const nucleiPreferences = lodashGet(preferences.current, `nuclei`, []); return useMemo(() => { function formatFun(n: string) { - return (value: any, formatKey = 'ppm', prefix = '', suffix = '') => { - return formatNumber( - value, - nucleusByKey?.[n.toLowerCase()]?.[formatKey], - { - prefix, - suffix, - }, - ); + const preferences = nucleiPreferences?.find( + ({ nucleus }) => nucleus.toLowerCase() === n.toLowerCase(), + ) || { + ppmFormat: '0.0', + hzFormat: '0.0', + }; + return ( + value: any, + formatKey = 'ppmFormat', + prefix = '', + suffix = '', + ) => { + return formatNumber(value, preferences[formatKey], { + prefix, + suffix, + }); }; } @@ -45,5 +50,5 @@ export function useFormatNumberByNucleus(nucleus?: string | string[]) { } else { throw new Error('nuclus must be string or array of string'); } - }, [nucleus, nucleusByKey]); + }, [nucleiPreferences, nucleus]); } diff --git a/src/component/hooks/usePanelPreferences.ts b/src/component/hooks/usePanelPreferences.ts index e116b660a..487d1eb0a 100644 --- a/src/component/hooks/usePanelPreferences.ts +++ b/src/component/hooks/usePanelPreferences.ts @@ -21,8 +21,6 @@ import { } from '../reducer/preferences/panelsPreferencesDefaultValues'; import { getValue } from '../utility/LocalStorage'; -const basePath = 'formatting.panels'; - type Panel = | 'spectra' | 'peaks' @@ -82,7 +80,7 @@ function getPanelPreferences( nucleus?: string, returnOnlyNucleusPreferences = false, ) { - const panelPath = `${basePath}.${panelKey}`; + const panelPath = `panels.${panelKey}`; let path = panelPath; if (nucleus) { diff --git a/src/component/modal/setting/GeneralSettings.tsx b/src/component/modal/setting/GeneralSettings.tsx index 4cf6d1aa1..37a9a1171 100644 --- a/src/component/modal/setting/GeneralSettings.tsx +++ b/src/component/modal/setting/GeneralSettings.tsx @@ -34,10 +34,10 @@ import PredefinedWorkspaces from '../../workspaces'; import WorkspaceItem from './WorkspaceItem'; import DatabasesTabContent from './settings-tabs/DatabasesTabContent'; import DisplayTabContent from './settings-tabs/DisplayTabContent'; -import FormattingTabContent from './settings-tabs/FormattingTabContent'; import GeneralTabContent from './settings-tabs/GeneralTabContent'; import ImportationFiltersTabContent from './settings-tabs/ImportationFiltersTabContent'; import InfoBlockTabContent from './settings-tabs/InfoBlockTabContent'; +import NucleiTabContent from './settings-tabs/NucleiTabContent'; import OnLoadProcessingTabContent from './settings-tabs/OnLoadProcessingTabContent'; import SpectraColorsTabContent from './settings-tabs/SpectraColorsTabContent'; import ToolsTabContent from './settings-tabs/ToolsTabContent'; @@ -361,11 +361,7 @@ function GeneralSettingsModal({ height }: GeneralSettingsModalProps) { panel={} /> - } - /> + } /> -
- - - - - - - - - - - {nucleiList?.map((key, index) => { - const num = index + 1; - return ( - - - - - - - - ); - })} - -
#Nucleus δ (ppm)Coupling (Hz) -
- {num} - {' '} - - - - - - - - deleteHandler(key)} - > - - - {nucleiList.length === index + 1 && ( - - - - )} -
-
- - ); -} - -export default FormattingTabContent; diff --git a/src/component/modal/setting/settings-tabs/NucleiTabContent.tsx b/src/component/modal/setting/settings-tabs/NucleiTabContent.tsx new file mode 100644 index 000000000..438fa795a --- /dev/null +++ b/src/component/modal/setting/settings-tabs/NucleiTabContent.tsx @@ -0,0 +1,187 @@ +import { useFormikContext } from 'formik'; +import { NucleiPreferences } from 'nmr-load-save'; +import { CSSProperties, useCallback, useMemo } from 'react'; +import { FaPlus, FaTimes } from 'react-icons/fa'; + +import Button from '../../../elements/Button'; +import { GroupPane } from '../../../elements/GroupPane'; +import ReactTable, { Column } from '../../../elements/ReactTable/ReactTable'; +import FormikInput from '../../../elements/formik/FormikInput'; + +const styles: Record<'input' | 'column', CSSProperties> = { + input: { + width: '100%', + }, + column: { + padding: '2px', + }, +}; + +function NucleiTabContent() { + const { values, setFieldValue } = useFormikContext(); + + const fields = (values as any)?.nuclei || []; + + const addHandler = useCallback( + (data: readonly any[], index: number) => { + let columns: NucleiPreferences[] = []; + const emptyField: NucleiPreferences = { + nucleus: '', + ppmFormat: '0.00', + hzFormat: '0.00', + }; + if (data && Array.isArray(data)) { + columns = [...data.slice(0, index), emptyField, ...data.slice(index)]; + } else { + columns.push(emptyField); + } + void setFieldValue('nuclei', columns); + }, + [setFieldValue], + ); + + const deleteHandler = useCallback( + (data, index: number) => { + const _fields = data.filter((_, columnIndex) => columnIndex !== index); + void setFieldValue('nuclei', _fields); + }, + [setFieldValue], + ); + + const COLUMNS: Array> = useMemo( + () => [ + { + Header: '#', + style: { width: '25px', ...styles.column }, + accessor: (_, index) => index + 1, + }, + { + Header: 'Nucleus', + style: { padding: 0, ...styles.column }, + Cell: ({ row }) => { + return ( + + ); + }, + }, + { + Header: 'δ (ppm)', + style: { padding: 0, ...styles.column }, + Cell: ({ row }) => { + return ( + + ); + }, + }, + { + Header: 'Coupling (Hz)', + style: { padding: 0, ...styles.column }, + Cell: ({ row }) => { + return ( + + ); + }, + }, + { + Header: 'Axis from', + style: { padding: 0, ...styles.column }, + Cell: ({ row }) => { + return ( + + ); + }, + }, + { + Header: 'Axis to', + style: { padding: 0, ...styles.column }, + Cell: ({ row }) => { + return ( + + ); + }, + }, + + { + Header: '', + style: { width: '70px', ...styles.column }, + id: 'add-button', + Cell: ({ data, row }) => { + return ( +
+ addHandler(data, row.index + 1)} + > + + + deleteHandler(data, row.index)} + > + + +
+ ); + }, + }, + ], + [addHandler, deleteHandler], + ); + + return ( +
+ { + return ( + addHandler(fields, 0)} + /> + ); + }} + > + + +
+ ); +} + +function FieldsBlockHeader({ onAdd, text }) { + return ( +
+

{text}

+ + + Add nuclei preferences + +
+ ); +} + +export default NucleiTabContent; diff --git a/src/component/modal/setting/settingsValidation.ts b/src/component/modal/setting/settingsValidation.ts index 3ccfe8d45..c1387a50f 100644 --- a/src/component/modal/setting/settingsValidation.ts +++ b/src/component/modal/setting/settingsValidation.ts @@ -1,71 +1,51 @@ -import { Workspace } from 'nmr-load-save'; -import { - array, - lazy, - object, - string, - ValidationError, - type ObjectShape, - number, -} from 'yup'; +import { array, object, string, ValidationError, number } from 'yup'; -const formattingElementValidation = (obj: Workspace): ObjectShape => { - return Object.fromEntries( - Object.keys(obj.formatting.nuclei).map((key) => [ - key, - object().shape({ - name: string().trim().required('Nucleus is a required field'), - ppm: string().trim().required('PPM format is a required field'), - hz: string().trim().required('Hz format is a required field'), - }), - ]), - ); -}; - -const formattingValidation = (obj: Workspace) => - object().shape({ - nuclei: object() - .shape(formattingElementValidation(obj)) - .test( - 'Unique', - 'Nuclei need te be unique', - function check(nuclei: Record) { - const nucleusFrequencies: Record< - string, - { value: number; fields: string[] } - > = {}; - for (const key of Object.keys(nuclei)) { - const _key = nuclei[key].name?.toLowerCase() || ''; - if (_key) { - if (nucleusFrequencies[_key]) { - ++nucleusFrequencies[_key].value; - nucleusFrequencies[_key].fields.push(key); - } else { - nucleusFrequencies[_key] = { value: 1, fields: [key] }; - } - } - } +const nucleiValidation = array() + .of( + object().shape({ + nucleus: string().trim().required('Nucleus is a required field'), + ppmFormat: string().trim().required('PPM format is a required field'), + hzFormat: string().trim().required('Hz format is a required field'), + }), + ) + .test('Unique', 'Nuclei need te be unique', function check(nuclei) { + if (!nuclei) return true; - const errors: ValidationError[] = []; - for (const key in nucleusFrequencies) { - const { value, fields } = nucleusFrequencies[key]; - if (value > 1) { - for (const field of fields) { - errors.push( - new ValidationError( - `${key} nucleus must te be unique`, - nuclei[key].name, - // eslint-disable-next-line no-invalid-this - `${this.path}.${field}.name`, - ), - ); - } - } - } + const nucleusFrequencies: Record< + string, + { value: number; fieldsIndexes: number[] } + > = {}; + let index = 0; + for (const nucleiPreferences of nuclei) { + const key = nucleiPreferences.nucleus?.toLowerCase() || ''; + if (key) { + if (nucleusFrequencies[key]) { + ++nucleusFrequencies[key].value; + nucleusFrequencies[key].fieldsIndexes.push(index); + } else { + nucleusFrequencies[key] = { value: 1, fieldsIndexes: [index] }; + } + } + index++; + } - return new ValidationError(errors); - }, - ), + const errors: ValidationError[] = []; + for (const key in nucleusFrequencies) { + const { value, fieldsIndexes } = nucleusFrequencies[key]; + if (value > 1) { + for (const index of fieldsIndexes) { + errors.push( + new ValidationError( + `${key} nucleus must te be unique`, + nuclei[index].nucleus, + // eslint-disable-next-line no-invalid-this + `${this.path}.${index}.name`, + ), + ); + } + } + } + return new ValidationError(errors); }); const databasesValidation = object().shape({ @@ -103,12 +83,10 @@ const generalValidation = object({ dimmedSpectraOpacity: number().required(), }); -export const validation: any = lazy((obj: Workspace) => - object().shape({ - formatting: formattingValidation(obj), - databases: databasesValidation, - infoBlock: infoBlockValidation, - general: generalValidation, - spectraColors: spectraColorsSchemaValidation, - }), -); +export const validation: any = object().shape({ + nuclei: nucleiValidation, + databases: databasesValidation, + infoBlock: infoBlockValidation, + general: generalValidation, + spectraColors: spectraColorsSchemaValidation, +}); diff --git a/src/component/panels/SpectraPanel/SpectraPreferences.tsx b/src/component/panels/SpectraPanel/SpectraPreferences.tsx index b4634b0db..37dcf7181 100644 --- a/src/component/panels/SpectraPanel/SpectraPreferences.tsx +++ b/src/component/panels/SpectraPanel/SpectraPreferences.tsx @@ -1,4 +1,3 @@ -import styled from '@emotion/styled'; import { Formik, FormikProps } from 'formik'; import { PanelsPreferences, Workspace } from 'nmr-load-save'; import { @@ -14,10 +13,7 @@ import * as Yup from 'yup'; import { useChartData } from '../../context/ChartContext'; import { usePreferences } from '../../context/PreferencesContext'; import { GroupPane, GroupPaneStyle } from '../../elements/GroupPane'; -import { InputStyle } from '../../elements/Input'; -import Label from '../../elements/Label'; import { Scroller } from '../../elements/Scroller'; -import FormikInput from '../../elements/formik/FormikInput'; import useNucleus from '../../hooks/useNucleus'; import { usePanelPreferencesByNuclei } from '../../hooks/usePanelPreferences'; import { convertPathArrayToString } from '../../utility/convertPathArrayToString'; @@ -39,10 +35,6 @@ const groupPaneStyle: GroupPaneStyle = { }, }; -const inputStyle: InputStyle = { - input: { padding: '5px' }, -}; - function validationColumns(obj) { const validationObject = {}; for (const key of Object.keys(obj.nuclei)) { @@ -67,7 +59,7 @@ function validationColumns(obj) { } const spectraPreferencesValidation: any = Yup.lazy( - (obj: Workspace['formatting']['panels']['spectra']) => + (obj: Workspace['panels']['spectra']) => Yup.object().shape({ nuclei: Yup.object().shape(validationColumns(obj)), }), @@ -191,7 +183,6 @@ function SpectraPreferences(props, ref: any) { datalist={datalist} /> - ))} @@ -201,62 +192,4 @@ function SpectraPreferences(props, ref: any) { ); } -interface AxisPreferencesProps { - nucleus: string; -} - -const Container = styled.div` - display: flex; -`; - -function AxisPreferences(props: AxisPreferencesProps) { - const { nucleus } = props; - - if (nucleus.split(',').length === 1) { - return ( - - - - ); - } - - return ( - <> - - - - - - - - ); -} - -interface AxisFieldsProps extends AxisPreferencesProps { - axis: 'x' | 'y'; -} - -function AxisFields(props: AxisFieldsProps) { - const { nucleus, axis } = props; - - return ( - - - - - ); -} - export default memo(forwardRef(SpectraPreferences)); diff --git a/src/component/reducer/actions/DomainActions.ts b/src/component/reducer/actions/DomainActions.ts index a0053c55a..2847505c3 100644 --- a/src/component/reducer/actions/DomainActions.ts +++ b/src/component/reducer/actions/DomainActions.ts @@ -1,7 +1,7 @@ import type { NmrData2DFt, NmrData2DFid } from 'cheminfo-types'; import { extent } from 'd3'; import { Draft } from 'immer'; -import { Spectrum1D, Spectrum2D, XYAxisDomain } from 'nmr-load-save'; +import { Spectrum1D, Spectrum2D, NucleiPreferences } from 'nmr-load-save'; import { get1DDataXY } from '../../../data/data1d/Spectrum1D/get1DDataXY'; import { isSpectrum2D } from '../../../data/data2d/Spectrum2D'; @@ -14,7 +14,7 @@ import { ActionType } from '../types/ActionType'; type SetAxisDomainAction = ActionType< 'SET_AXIS_DOMAIN', - { axisDomain?: XYAxisDomain } + { nucleiPreferences: NucleiPreferences[] } >; type SetXDomainAction = ActionType< 'SET_X_DOMAIN', @@ -278,11 +278,33 @@ function handleSetYDomain(draft: Draft, action: SetYDomainAction) { } //action function handleSetAxisDomain(draft: Draft, action: SetAxisDomainAction) { - const { axisDomain: { x, y } = {} } = action.payload; + const { nucleiPreferences } = action.payload; const { originDomain: { xDomain, yDomain }, displayerMode, + view: { + spectra: { activeTab }, + }, } = draft; + + const axisDomain: { + x?: { from?: number; to?: number }; + y?: { from?: number; to?: number }; + } = {}; + + const [xNucleus, yNucleus] = activeTab?.split(',') || []; + + for (const nuclei of nucleiPreferences) { + const { nucleus, axisFrom, axisTo } = nuclei; + if (nucleus?.toLowerCase() === xNucleus?.toLowerCase()) { + axisDomain.x = { from: axisFrom, to: axisTo }; + } + if (nucleus?.toLowerCase() === yNucleus?.toLowerCase()) { + axisDomain.y = { from: axisFrom, to: axisTo }; + } + } + + const { x, y } = axisDomain; const x1 = x?.from ?? xDomain[0]; const x2 = x?.to ?? xDomain[1]; const y1 = y?.from ?? yDomain[0]; diff --git a/src/component/reducer/preferences/actions/analyzeSpectra.ts b/src/component/reducer/preferences/actions/analyzeSpectra.ts index 761d47258..7a8e5048b 100644 --- a/src/component/reducer/preferences/actions/analyzeSpectra.ts +++ b/src/component/reducer/preferences/actions/analyzeSpectra.ts @@ -17,7 +17,7 @@ export function analyzeSpectra( action: AnalyzeSpectraAction, ) { const currentWorkspacePreferences = getActiveWorkspace(draft); - const panels = currentWorkspacePreferences.formatting.panels; + const panels = currentWorkspacePreferences.panels; const { start, end, nucleus, columnKey } = action.payload; if (!panels.multipleSpectraAnalysis) { @@ -41,7 +41,7 @@ export function changeAnalysisColumnValueKey( ) { const { columnKey, valueKey, nucleus } = action.payload; const currentWorkspacePreferences = getActiveWorkspace(draft); - const panels = currentWorkspacePreferences.formatting.panels; + const panels = currentWorkspacePreferences.panels; MultipleAnalysis.changeColumnValueKey( panels.multipleSpectraAnalysis as any, @@ -56,7 +56,7 @@ export function deleteAnalysisColumn( ) { const { columnKey, nucleus } = action.payload; const currentWorkspacePreferences = getActiveWorkspace(draft); - const panels = currentWorkspacePreferences.formatting.panels; + const panels = currentWorkspacePreferences.panels; MultipleAnalysis.deleteSpectraAnalysis( panels.multipleSpectraAnalysis as any, columnKey, @@ -72,7 +72,7 @@ export function setSpectraAnalysisPanelsPreferences( const currentWorkspacePreferences = getActiveWorkspace(draft); const { nucleus, data } = action.payload; - const panels = currentWorkspacePreferences.formatting.panels; + const panels = currentWorkspacePreferences.panels; if (!panels?.multipleSpectraAnalysis) { panels.multipleSpectraAnalysis = diff --git a/src/component/reducer/preferences/actions/matrixGeneration.ts b/src/component/reducer/preferences/actions/matrixGeneration.ts index f42dbcacf..4ffddf7fa 100644 --- a/src/component/reducer/preferences/actions/matrixGeneration.ts +++ b/src/component/reducer/preferences/actions/matrixGeneration.ts @@ -14,7 +14,7 @@ function addExclusionZone( ) { const { zone, range, nucleus } = action.payload; const currentWorkspacePreferences = getActiveWorkspace(draft); - const panels = currentWorkspacePreferences.formatting.panels; + const panels = currentWorkspacePreferences.panels; const exclusionZone = { id: v4(), @@ -42,7 +42,7 @@ function addExclusionZone( function deleteExclusionZone(draft: Draft, action) { const { zone, nucleus } = action.payload; const currentWorkspacePreferences = getActiveWorkspace(draft); - const panels = currentWorkspacePreferences.formatting.panels; + const panels = currentWorkspacePreferences.panels; if (panels.matrixGeneration?.[nucleus]) { const options: MatrixOptions = panels.matrixGeneration[nucleus]; @@ -55,7 +55,7 @@ function deleteExclusionZone(draft: Draft, action) { function setMatrixGenerationOptions(draft: Draft, action) { const { options, nucleus } = action.payload; const currentWorkspacePreferences = getActiveWorkspace(draft); - const panels = currentWorkspacePreferences.formatting.panels; + const panels = currentWorkspacePreferences.panels; panels.matrixGeneration = { ...panels.matrixGeneration, [nucleus]: options }; } diff --git a/src/component/reducer/preferences/actions/setPanelsPreferences.ts b/src/component/reducer/preferences/actions/setPanelsPreferences.ts index cf905853e..972218831 100644 --- a/src/component/reducer/preferences/actions/setPanelsPreferences.ts +++ b/src/component/reducer/preferences/actions/setPanelsPreferences.ts @@ -8,7 +8,7 @@ export function setPanelsPreferences(draft: Draft, action) { const currentWorkspacePreferences = getActiveWorkspace(draft); const { key, value } = action.payload; - const panels = currentWorkspacePreferences.formatting.panels; + const panels = currentWorkspacePreferences.panels; if (value?.nuclei) { const { nuclei, ...commonPreferences } = value; diff --git a/src/component/reducer/preferences/actions/setPreferences.ts b/src/component/reducer/preferences/actions/setPreferences.ts index 241e7df4b..5b2cc75fe 100644 --- a/src/component/reducer/preferences/actions/setPreferences.ts +++ b/src/component/reducer/preferences/actions/setPreferences.ts @@ -4,19 +4,17 @@ import cloneDeep from 'lodash/cloneDeep'; import { getLocalStorage, storeData } from '../../../utility/LocalStorage'; import { PreferencesState } from '../preferencesReducer'; import { getActiveWorkspace } from '../utilities/getActiveWorkspace'; -import { mapNucleiFormatting } from '../utilities/mapNucleiFormatting'; export function setPreferences(draft: Draft, action) { const localData = getLocalStorage('nmr-general-settings'); const currentWorkspacePreferences = getActiveWorkspace(draft); if (action.payload) { - const { formatting, ...restPreferences } = action.payload; + const preferences = action.payload; draft.workspaces[draft.workspace.current] = { ...currentWorkspacePreferences, - ...restPreferences, - formatting: mapNucleiFormatting(formatting), + ...preferences, }; } diff --git a/src/component/reducer/preferences/panelsPreferencesDefaultValues.ts b/src/component/reducer/preferences/panelsPreferencesDefaultValues.ts index 8f2da95a9..858f160f4 100644 --- a/src/component/reducer/preferences/panelsPreferencesDefaultValues.ts +++ b/src/component/reducer/preferences/panelsPreferencesDefaultValues.ts @@ -1,7 +1,7 @@ import { MultipleSpectraAnalysisPreferences, PanelsPreferences, - SpectraNucleusPreferences, + SpectraPreferences, } from 'nmr-load-save'; import { is2DNucleus } from '../../utility/nucleusToString'; @@ -13,8 +13,7 @@ function getPreferences(data: T, nucleus?: string) { const getSpectraDefaultValues = ( nucleus?: string, ): PanelsPreferences['spectra'] => { - const preferences: SpectraNucleusPreferences = { - axisDomain: {}, + const preferences: SpectraPreferences = { columns: [ { name: 'visible', diff --git a/src/component/reducer/preferences/utilities/mapNucleiFormatting.ts b/src/component/reducer/preferences/utilities/mapNucleiFormatting.ts deleted file mode 100644 index 3e582a7db..000000000 --- a/src/component/reducer/preferences/utilities/mapNucleiFormatting.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Formatting } from 'nmr-load-save'; - -export function mapNucleiFormatting(formatting: Formatting): Formatting { - const { nuclei, ...res } = formatting; - - return { - nuclei: Object.fromEntries( - Object.keys(nuclei).map((key) => [ - nuclei[key].name.trim().toLowerCase(), - nuclei[key], - ]), - ), - ...res, - }; -} diff --git a/src/component/utility/PreferencesHelper.ts b/src/component/utility/PreferencesHelper.ts index adc6be82c..9a661aa6b 100644 --- a/src/component/utility/PreferencesHelper.ts +++ b/src/component/utility/PreferencesHelper.ts @@ -3,8 +3,8 @@ import { getLocalStorage, getValue } from './LocalStorage'; function GetPreference(preferences, key) { const localData = getLocalStorage('nmr-general-settings'); const val = - getValue(preferences, `formatting.panels.[${key}]`) || - getValue(localData, `formatting.panels.[${key}]`); + getValue(preferences, `panels.[${key}]`) || + getValue(localData, `panels.[${key}]`); return val; } diff --git a/src/component/workspaces/exercise.ts b/src/component/workspaces/exercise.ts index 53838b5ad..70c4827c3 100644 --- a/src/component/workspaces/exercise.ts +++ b/src/component/workspaces/exercise.ts @@ -38,33 +38,31 @@ export const exercise: InnerWorkspace = { popupLoggingLevel: 'error', invert: false, }, - formatting: { - nuclei: {}, - panels: { - integrals: { - nuclei: { - '1H': { - showSerialNumber: true, - relative: { show: true, format: '0.00' }, - absolute: { show: false, format: '0.00' }, - from: { show: true, format: '0.00' }, - to: { show: true, format: '0.00' }, - color: 'black', - strokeWidth: 1, - showKind: false, - showDeleteAction: true, - }, - '13C': { - showSerialNumber: true, - relative: { show: true, format: '0.00' }, - absolute: { show: false, format: '0.00' }, - from: { show: true, format: '0.00' }, - to: { show: true, format: '0.00' }, - color: 'black', - strokeWidth: 1, - showKind: false, - showDeleteAction: true, - }, + nuclei: [], + panels: { + integrals: { + nuclei: { + '1H': { + showSerialNumber: true, + relative: { show: true, format: '0.00' }, + absolute: { show: false, format: '0.00' }, + from: { show: true, format: '0.00' }, + to: { show: true, format: '0.00' }, + color: 'black', + strokeWidth: 1, + showKind: false, + showDeleteAction: true, + }, + '13C': { + showSerialNumber: true, + relative: { show: true, format: '0.00' }, + absolute: { show: false, format: '0.00' }, + from: { show: true, format: '0.00' }, + to: { show: true, format: '0.00' }, + color: 'black', + strokeWidth: 1, + showKind: false, + showDeleteAction: true, }, }, }, diff --git a/src/component/workspaces/prediction.ts b/src/component/workspaces/prediction.ts index e2545b12e..939ce4942 100644 --- a/src/component/workspaces/prediction.ts +++ b/src/component/workspaces/prediction.ts @@ -48,179 +48,177 @@ export const prediction: InnerWorkspace = { fftDimension2: true, }, }, - formatting: { - nuclei: {}, - panels: { - spectra: { - nuclei: { - '1H,1H': { - columns: [ - { - name: 'visible', - label: '', - description: 'Show/Hide Spectrum', - visible: true, - }, - { - label: 'Spectrum Name', - jpath: ['info', 'name'], - visible: true, - }, - { - label: 'Frequency', - description: 'frequency', - jpath: ['info', 'baseFrequency'], - visible: true, - }, - { - label: 'Solvent', - jpath: ['info', 'solvent'], - visible: false, - }, - { - jpath: ['info', 'pulseSequence'], - label: 'Pulse', - visible: true, - }, - { - jpath: ['info', 'experiment'], - label: 'Experiment', - visible: true, - }, - { - name: 'color', - label: '', - description: 'Spectrum Color', - visible: true, - }, - ], - }, - '1H,13C': { - columns: [ - { - name: 'visible', - label: '', - description: 'Show/Hide Spectrum', - visible: true, - }, - { - label: 'Spectrum Name', - jpath: ['info', 'name'], - visible: true, - }, - { - label: 'Frequency', - description: 'frequency', - jpath: ['info', 'baseFrequency'], - visible: true, - }, - { - label: 'Solvent', - jpath: ['info', 'solvent'], - visible: false, - }, - { - jpath: ['info', 'pulseSequence'], - label: 'Pulse', - visible: true, - }, - { - jpath: ['info', 'experiment'], - label: 'Experiment', - visible: true, - }, - { - name: 'color', - label: '', - description: 'Spectrum Color', - visible: true, - }, - ], - }, - '1H': { - columns: [ - { - name: 'visible', - label: '', - description: 'Show/Hide Spectrum', - visible: true, - }, - { - label: 'Spectrum Name', - jpath: ['info', 'name'], - visible: true, - }, - { - label: 'Frequency', - description: 'frequency', - jpath: ['info', 'baseFrequency'], - visible: true, - }, - { - label: 'Solvent', - jpath: ['info', 'solvent'], - visible: false, - }, - { - jpath: ['info', 'pulseSequence'], - label: 'Pulse', - visible: true, - }, - { - jpath: ['info', 'experiment'], - label: 'Experiment', - visible: true, - }, - { - name: 'color', - label: '', - description: 'Spectrum Color', - visible: true, - }, - ], - }, - '13C': { - columns: [ - { - name: 'visible', - label: '', - description: 'Show/Hide Spectrum', - visible: true, - }, - { - label: 'Spectrum Name', - jpath: ['info', 'name'], - visible: true, - }, - { - label: 'Frequency', - description: 'frequency', - jpath: ['info', 'baseFrequency'], - visible: true, - }, - { - label: 'Solvent', - jpath: ['info', 'solvent'], - visible: false, - }, - { - jpath: ['info', 'pulseSequence'], - label: 'Pulse', - visible: true, - }, - { - jpath: ['info', 'experiment'], - label: 'Experiment', - visible: true, - }, - { - name: 'color', - label: '', - description: 'Spectrum Color', - visible: true, - }, - ], - }, + nuclei: [], + panels: { + spectra: { + nuclei: { + '1H,1H': { + columns: [ + { + name: 'visible', + label: '', + description: 'Show/Hide Spectrum', + visible: true, + }, + { + label: 'Spectrum Name', + jpath: ['info', 'name'], + visible: true, + }, + { + label: 'Frequency', + description: 'frequency', + jpath: ['info', 'baseFrequency'], + visible: true, + }, + { + label: 'Solvent', + jpath: ['info', 'solvent'], + visible: false, + }, + { + jpath: ['info', 'pulseSequence'], + label: 'Pulse', + visible: true, + }, + { + jpath: ['info', 'experiment'], + label: 'Experiment', + visible: true, + }, + { + name: 'color', + label: '', + description: 'Spectrum Color', + visible: true, + }, + ], + }, + '1H,13C': { + columns: [ + { + name: 'visible', + label: '', + description: 'Show/Hide Spectrum', + visible: true, + }, + { + label: 'Spectrum Name', + jpath: ['info', 'name'], + visible: true, + }, + { + label: 'Frequency', + description: 'frequency', + jpath: ['info', 'baseFrequency'], + visible: true, + }, + { + label: 'Solvent', + jpath: ['info', 'solvent'], + visible: false, + }, + { + jpath: ['info', 'pulseSequence'], + label: 'Pulse', + visible: true, + }, + { + jpath: ['info', 'experiment'], + label: 'Experiment', + visible: true, + }, + { + name: 'color', + label: '', + description: 'Spectrum Color', + visible: true, + }, + ], + }, + '1H': { + columns: [ + { + name: 'visible', + label: '', + description: 'Show/Hide Spectrum', + visible: true, + }, + { + label: 'Spectrum Name', + jpath: ['info', 'name'], + visible: true, + }, + { + label: 'Frequency', + description: 'frequency', + jpath: ['info', 'baseFrequency'], + visible: true, + }, + { + label: 'Solvent', + jpath: ['info', 'solvent'], + visible: false, + }, + { + jpath: ['info', 'pulseSequence'], + label: 'Pulse', + visible: true, + }, + { + jpath: ['info', 'experiment'], + label: 'Experiment', + visible: true, + }, + { + name: 'color', + label: '', + description: 'Spectrum Color', + visible: true, + }, + ], + }, + '13C': { + columns: [ + { + name: 'visible', + label: '', + description: 'Show/Hide Spectrum', + visible: true, + }, + { + label: 'Spectrum Name', + jpath: ['info', 'name'], + visible: true, + }, + { + label: 'Frequency', + description: 'frequency', + jpath: ['info', 'baseFrequency'], + visible: true, + }, + { + label: 'Solvent', + jpath: ['info', 'solvent'], + visible: false, + }, + { + jpath: ['info', 'pulseSequence'], + label: 'Pulse', + visible: true, + }, + { + jpath: ['info', 'experiment'], + label: 'Experiment', + visible: true, + }, + { + name: 'color', + label: '', + description: 'Spectrum Color', + visible: true, + }, + ], }, }, }, diff --git a/src/component/workspaces/simulation.ts b/src/component/workspaces/simulation.ts index 1c594a805..9bea3f354 100644 --- a/src/component/workspaces/simulation.ts +++ b/src/component/workspaces/simulation.ts @@ -31,43 +31,41 @@ export const simulation: InnerWorkspace = { zoom: true, }, }, - formatting: { - nuclei: {}, - panels: { - spectra: { - nuclei: { - '1H': { - columns: [ - { - name: 'visible', - label: '', - description: 'Show/Hide Spectrum', - visible: true, - }, - { - label: 'Spectrum Name', - jpath: ['info', 'name'], - visible: true, - }, - { - label: 'Frequency', - description: 'frequency', - jpath: ['info', 'originFrequency'], - visible: true, - }, - { - jpath: ['info', 'nucleus'], - label: 'Experiment', - visible: true, - }, - { - name: 'color', - label: '', - description: 'Spectrum Color', - visible: true, - }, - ], - }, + nuclei: [], + panels: { + spectra: { + nuclei: { + '1H': { + columns: [ + { + name: 'visible', + label: '', + description: 'Show/Hide Spectrum', + visible: true, + }, + { + label: 'Spectrum Name', + jpath: ['info', 'name'], + visible: true, + }, + { + label: 'Frequency', + description: 'frequency', + jpath: ['info', 'originFrequency'], + visible: true, + }, + { + jpath: ['info', 'nucleus'], + label: 'Experiment', + visible: true, + }, + { + name: 'color', + label: '', + description: 'Spectrum Color', + visible: true, + }, + ], }, }, }, diff --git a/src/component/workspaces/workspaceDefaultProperties.ts b/src/component/workspaces/workspaceDefaultProperties.ts index 97b6d0ee6..522dff7c8 100644 --- a/src/component/workspaces/workspaceDefaultProperties.ts +++ b/src/component/workspaces/workspaceDefaultProperties.ts @@ -66,17 +66,16 @@ export const workspaceDefaultProperties: Required = { popupLoggingLevel: 'error', invert: false, }, - formatting: { - nuclei: { - '1h': { name: '1H', ppm: '0.00', hz: '0.00' }, - '13c': { name: '13C', ppm: '0.00', hz: '0.00' }, - '15n': { name: '15N', ppm: '0.00', hz: '0.00' }, - '19f': { name: '19F', ppm: '0.00', hz: '0.00' }, - '29si': { name: '29Si', ppm: '0.00', hz: '0.00' }, - '31p': { name: '31P', ppm: '0.00', hz: '0.00' }, - }, - panels: {}, - }, + nuclei: [ + { nucleus: '1H', ppmFormat: '0.00', hzFormat: '0.00' }, + { nucleus: '13C', ppmFormat: '0.00', hzFormat: '0.00' }, + { nucleus: '15N', ppmFormat: '0.00', hzFormat: '0.00' }, + { nucleus: '19F', ppmFormat: '0.00', hzFormat: '0.00' }, + { nucleus: '29Si', ppmFormat: '0.00', hzFormat: '0.00' }, + { nucleus: '31P', ppmFormat: '0.00', hzFormat: '0.00' }, + ], + panels: {}, + databases: { defaultDatabase: '', data: [ diff --git a/src/demo/views/BenchtopNMRWorkspace.tsx b/src/demo/views/BenchtopNMRWorkspace.tsx index 0c9b8050c..08e70387d 100644 --- a/src/demo/views/BenchtopNMRWorkspace.tsx +++ b/src/demo/views/BenchtopNMRWorkspace.tsx @@ -108,41 +108,39 @@ const customWorkspaces: CustomWorkspaces = { popupLoggingLevel: 'error', invert: false, }, - formatting: { - nuclei: { - '1h': { - name: '1H', - ppm: '0.00', - hz: '0.00', - }, - '13c': { - name: '13C', - ppm: '0.00', - hz: '0.00', - }, - '15n': { - name: '15N', - ppm: '0.00', - hz: '0.00', - }, - '19f': { - name: '19F', - ppm: '0.00', - hz: '0.00', - }, - '29si': { - name: '29Si', - ppm: '0.00', - hz: '0.00', - }, - '31p': { - name: '31P', - ppm: '0.00', - hz: '0.00', - }, + nuclei: [ + { + nucleus: '1H', + ppmFormat: '0.00', + hzFormat: '0.00', }, - panels: {}, - }, + { + nucleus: '13C', + ppmFormat: '0.00', + hzFormat: '0.00', + }, + { + nucleus: '15N', + ppmFormat: '0.00', + hzFormat: '0.00', + }, + { + nucleus: '19F', + ppmFormat: '0.00', + hzFormat: '0.00', + }, + { + nucleus: '29Si', + ppmFormat: '0.00', + hzFormat: '0.00', + }, + { + nucleus: '31P', + ppmFormat: '0.00', + hzFormat: '0.00', + }, + ], + panels: {}, databases: { defaultDatabase: '', data: [ @@ -307,7 +305,6 @@ const customWorkspaces: CustomWorkspaces = { version: 2, label: 'Simple NMR analysis', visible: true, - source: 'predefined', }, }; diff --git a/src/demo/views/CustomWorkspace.tsx b/src/demo/views/CustomWorkspace.tsx index 30edb0bc9..511077ee2 100644 --- a/src/demo/views/CustomWorkspace.tsx +++ b/src/demo/views/CustomWorkspace.tsx @@ -55,18 +55,18 @@ const customWorkspaces: CustomWorkspaces = { verticalSplitterCloseThreshold: 600, spectraRendering: 'auto', loggingLevel: 'info', + invert: false, + popupLoggingLevel: 'info', }, - formatting: { - nuclei: { - '1h': { name: '1H', ppm: '0.00', hz: '0.00' }, - '13c': { name: '13C', ppm: '0.00', hz: '0.00' }, - '15n': { name: '15N', ppm: '0.00', hz: '0.00' }, - '19f': { name: '19F', ppm: '0.00', hz: '0.00' }, - '29si': { name: '29Si', ppm: '0.00', hz: '0.00' }, - '31p': { name: '31P', ppm: '0.00', hz: '0.00' }, - }, - panels: {}, - }, + nuclei: [ + { nucleus: '1H', ppmFormat: '0.00', hzFormat: '0.00' }, + { nucleus: '13C', ppmFormat: '0.00', hzFormat: '0.00' }, + { nucleus: '15N', ppmFormat: '0.00', hzFormat: '0.00' }, + { nucleus: '19F', ppmFormat: '0.00', hzFormat: '0.00' }, + { nucleus: '29Si', ppmFormat: '0.00', hzFormat: '0.00' }, + { nucleus: '31P', ppmFormat: '0.00', hzFormat: '0.00' }, + ], + panels: {}, databases: { defaultDatabase: '', data: [ @@ -117,50 +117,53 @@ const customWorkspaces: CustomWorkspaces = { ], }, onLoadProcessing: { - '1H': [ - { - name: 'digitalFilter', - label: 'Digital Filter', - value: {}, - flag: true, - }, - { name: 'apodization', label: 'Apodization', value: {}, flag: false }, - { name: 'zeroFilling', label: 'Zero Filling', value: {}, flag: true }, - { - name: 'fft', - label: 'Fast fourier transform', - value: {}, - flag: true, - }, - { - name: 'phaseCorrection', - label: 'Phase correction', - value: {}, - flag: true, - }, - ], - '13C': [ - { - name: 'digitalFilter', - label: 'Digital Filter', - value: {}, - flag: true, - }, - { name: 'apodization', label: 'Apodization', value: {}, flag: true }, - { name: 'zeroFilling', label: 'Zero Filling', value: {}, flag: true }, - { - name: 'fft', - label: 'Fast fourier transform', - value: {}, - flag: true, - }, - { - name: 'phaseCorrection', - label: 'Phase correction', - value: {}, - flag: true, - }, - ], + autoProcessing: true, + filters: { + '1H': [ + { + name: 'digitalFilter', + label: 'Digital Filter', + value: {}, + flag: true, + }, + { name: 'apodization', label: 'Apodization', value: {}, flag: false }, + { name: 'zeroFilling', label: 'Zero Filling', value: {}, flag: true }, + { + name: 'fft', + label: 'Fast fourier transform', + value: {}, + flag: true, + }, + { + name: 'phaseCorrection', + label: 'Phase correction', + value: {}, + flag: true, + }, + ], + '13C': [ + { + name: 'digitalFilter', + label: 'Digital Filter', + value: {}, + flag: true, + }, + { name: 'apodization', label: 'Apodization', value: {}, flag: true }, + { name: 'zeroFilling', label: 'Zero Filling', value: {}, flag: true }, + { + name: 'fft', + label: 'Fast fourier transform', + value: {}, + flag: true, + }, + { + name: 'phaseCorrection', + label: 'Phase correction', + value: {}, + flag: true, + }, + ], + }, }, label: 'Metabolomics', version: 1, diff --git a/src/demo/views/SnapshotView.tsx b/src/demo/views/SnapshotView.tsx index 310fee18c..2584c3cb5 100644 --- a/src/demo/views/SnapshotView.tsx +++ b/src/demo/views/SnapshotView.tsx @@ -95,275 +95,268 @@ const customWorkspaces: CustomWorkspaces = { verticalSplitterCloseThreshold: 600, spectraRendering: 'auto', loggingLevel: 'info', + invert: false, + popupLoggingLevel: 'info', }, - formatting: { - nuclei: { - '1h': { - name: '1H', - ppm: '0.00', - hz: '0.00', - }, - '13c': { - name: '13C', - ppm: '0.00', - hz: '0.00', - }, - '15n': { - name: '15N', - ppm: '0.00', - hz: '0.00', - }, - '19f': { - name: '19F', - ppm: '0.00', - hz: '0.00', - }, - '29si': { - name: '29Si', - ppm: '0.00', - hz: '0.00', - }, - '31p': { - name: '31P', - ppm: '0.00', - hz: '0.00', - }, + nuclei: [ + { + nucleus: '1H', + ppmFormat: '0.00', + hzFormat: '0.00', }, - panels: { - spectra: { - nuclei: { - '1H': { - columns: [ - { - name: 'visible', - label: '', - description: 'Show/Hide Spectrum', - visible: true, - }, - { - name: 'name', - label: 'Spectrum Name', - description: 'Spectrum Name', - jpath: ['info', 'name'], - visible: true, - }, - { - name: 'solvent', - label: 'Solvent', - description: 'Solvent', - jpath: ['info', 'solvent'], - visible: false, - }, - { - jpath: ['info', 'pulseSequence'], - label: 'Pulse', - visible: false, - }, - { - jpath: ['info', 'experiment'], - label: 'Experiment', - visible: true, - }, - { - name: 'color', - label: '', - description: 'Spectrum Color', - visible: true, - }, - ], - }, - '1H,1H': { - columns: [ - { - name: 'visible', - label: '', - description: 'Show/Hide Spectrum', - visible: true, - }, - { - name: 'name', - label: 'Spectrum Name', - description: 'Spectrum Name', - jpath: ['info', 'name'], - visible: true, - }, - { - name: 'solvent', - label: 'Solvent', - description: 'Solvent', - jpath: ['info', 'solvent'], - visible: false, - }, - { - jpath: ['info', 'pulseSequence'], - label: 'Pulse', - visible: false, - }, - { - jpath: ['info', 'experiment'], - label: 'Experiment', - visible: true, - }, - { - name: 'color', - label: '', - description: 'Spectrum Color', - visible: true, - }, - ], - }, - '1H,13C': { - columns: [ - { - name: 'visible', - label: '', - description: 'Show/Hide Spectrum', - visible: true, - }, - { - name: 'name', - label: 'Spectrum Name', - description: 'Spectrum Name', - jpath: ['info', 'name'], - visible: true, - }, - { - name: 'solvent', - label: 'Solvent', - description: 'Solvent', - jpath: ['info', 'solvent'], - visible: false, - }, - { - jpath: ['info', 'pulseSequence'], - label: 'Pulse', - visible: false, - }, - { - jpath: ['info', 'experiment'], - label: 'Experiment', - visible: true, - }, - { - name: 'color', - label: '', - description: 'Spectrum Color', - visible: true, - }, - ], - }, - '13C': { - columns: [ - { - name: 'visible', - label: '', - description: 'Show/Hide Spectrum', - visible: true, - }, - { - name: 'name', - label: 'Spectrum Name', - description: 'Spectrum Name', - jpath: ['info', 'name'], - visible: true, - }, - { - name: 'solvent', - label: 'Solvent', - description: 'Solvent', - jpath: ['info', 'solvent'], - visible: false, - }, - { - jpath: ['info', 'pulseSequence'], - label: 'Pulse', - visible: false, - }, - { - jpath: ['info', 'experiment'], - label: 'Experiment', - visible: true, - }, - { - name: 'color', - label: '', - description: 'Spectrum Color', - visible: true, - }, - ], - }, + { + nucleus: '13C', + ppmFormat: '0.00', + hzFormat: '0.00', + }, + { + nucleus: '15N', + ppmFormat: '0.00', + hzFormat: '0.00', + }, + { + nucleus: '19F', + ppmFormat: '0.00', + hzFormat: '0.00', + }, + { + nucleus: '29Si', + ppmFormat: '0.00', + hzFormat: '0.00', + }, + { + nucleus: '31P', + ppmFormat: '0.00', + hzFormat: '0.00', + }, + ], + panels: { + spectra: { + nuclei: { + '1H': { + columns: [ + { + name: 'visible', + label: '', + description: 'Show/Hide Spectrum', + visible: true, + }, + { + label: 'Spectrum Name', + description: 'Spectrum Name', + jpath: ['info', 'name'], + visible: true, + }, + { + label: 'Solvent', + description: 'Solvent', + jpath: ['info', 'solvent'], + visible: false, + }, + { + jpath: ['info', 'pulseSequence'], + label: 'Pulse', + visible: false, + }, + { + jpath: ['info', 'experiment'], + label: 'Experiment', + visible: true, + }, + { + name: 'color', + label: '', + description: 'Spectrum Color', + visible: true, + }, + ], }, - }, - ranges: { - nuclei: { - '1H': { - from: { - show: false, - format: '0.00', + '1H,1H': { + columns: [ + { + name: 'visible', + label: '', + description: 'Show/Hide Spectrum', + visible: true, }, - to: { - show: false, - format: '0.00', + { + label: 'Spectrum Name', + description: 'Spectrum Name', + jpath: ['info', 'name'], + visible: true, }, - absolute: { - show: false, - format: '0.00', + { + label: 'Solvent', + description: 'Solvent', + jpath: ['info', 'solvent'], + visible: false, }, - relative: { - show: true, - format: '0.00', + { + jpath: ['info', 'pulseSequence'], + label: 'Pulse', + visible: false, }, - deltaPPM: { - show: true, - format: '0.00', + { + jpath: ['info', 'experiment'], + label: 'Experiment', + visible: true, }, - deltaHz: { - show: false, - format: '0.00', + { + name: 'color', + label: '', + description: 'Spectrum Color', + visible: true, }, - coupling: { - show: false, - format: '0.00', + ], + }, + '1H,13C': { + columns: [ + { + name: 'visible', + label: '', + description: 'Show/Hide Spectrum', + visible: true, }, - jGraphTolerance: 0.2, - showKind: false, - }, - '13C': { - from: { - show: false, - format: '0.00', + { + label: 'Spectrum Name', + description: 'Spectrum Name', + jpath: ['info', 'name'], + visible: true, + }, + { + label: 'Solvent', + description: 'Solvent', + jpath: ['info', 'solvent'], + visible: false, }, - to: { - show: false, - format: '0.00', + { + jpath: ['info', 'pulseSequence'], + label: 'Pulse', + visible: false, }, - absolute: { - show: false, - format: '0.00', + { + jpath: ['info', 'experiment'], + label: 'Experiment', + visible: true, }, - relative: { - show: true, - format: '0.00', + { + name: 'color', + label: '', + description: 'Spectrum Color', + visible: true, }, - deltaPPM: { - show: true, - format: '0.00', + ], + }, + '13C': { + columns: [ + { + name: 'visible', + label: '', + description: 'Show/Hide Spectrum', + visible: true, + }, + { + label: 'Spectrum Name', + description: 'Spectrum Name', + jpath: ['info', 'name'], + visible: true, + }, + { + label: 'Solvent', + description: 'Solvent', + jpath: ['info', 'solvent'], + visible: false, }, - deltaHz: { - show: false, - format: '0.00', + { + jpath: ['info', 'pulseSequence'], + label: 'Pulse', + visible: false, }, - coupling: { - show: true, - format: '0.00', + { + jpath: ['info', 'experiment'], + label: 'Experiment', + visible: true, }, - jGraphTolerance: 2, - showKind: true, + { + name: 'color', + label: '', + description: 'Spectrum Color', + visible: true, + }, + ], + }, + }, + }, + ranges: { + nuclei: { + '1H': { + from: { + show: false, + format: '0.00', + }, + to: { + show: false, + format: '0.00', + }, + absolute: { + show: false, + format: '0.00', + }, + relative: { + show: true, + format: '0.00', }, + deltaPPM: { + show: true, + format: '0.00', + }, + deltaHz: { + show: false, + format: '0.00', + }, + coupling: { + show: false, + format: '0.00', + }, + jGraphTolerance: 0.2, + showKind: false, + }, + '13C': { + from: { + show: false, + format: '0.00', + }, + to: { + show: false, + format: '0.00', + }, + absolute: { + show: false, + format: '0.00', + }, + relative: { + show: true, + format: '0.00', + }, + deltaPPM: { + show: true, + format: '0.00', + }, + deltaHz: { + show: false, + format: '0.00', + }, + coupling: { + show: true, + format: '0.00', + }, + jGraphTolerance: 2, + showKind: true, }, }, }, }, + databases: { defaultDatabase: '', data: [ @@ -412,70 +405,73 @@ const customWorkspaces: CustomWorkspaces = { ], }, onLoadProcessing: { - '1H': [ - { - name: 'digitalFilter', - label: 'Digital Filter', - value: {}, - flag: true, - }, - { - name: 'apodization', - label: 'Apodization', - value: {}, - flag: false, - }, - { - name: 'zeroFilling', - label: 'Zero Filling', - value: {}, - flag: true, - }, - { - name: 'fft', - label: 'Fast fourier transform', - value: {}, - flag: true, - }, - { - name: 'phaseCorrection', - label: 'Phase correction', - value: {}, - flag: true, - }, - ], - '13C': [ - { - name: 'digitalFilter', - label: 'Digital Filter', - value: {}, - flag: true, - }, - { - name: 'apodization', - label: 'Apodization', - value: {}, - flag: true, - }, - { - name: 'zeroFilling', - label: 'Zero Filling', - value: {}, - flag: true, - }, - { - name: 'fft', - label: 'Fast fourier transform', - value: {}, - flag: true, - }, - { - name: 'phaseCorrection', - label: 'Phase correction', - value: {}, - flag: true, - }, - ], + autoProcessing: true, + filters: { + '1H': [ + { + name: 'digitalFilter', + label: 'Digital Filter', + value: {}, + flag: true, + }, + { + name: 'apodization', + label: 'Apodization', + value: {}, + flag: false, + }, + { + name: 'zeroFilling', + label: 'Zero Filling', + value: {}, + flag: true, + }, + { + name: 'fft', + label: 'Fast fourier transform', + value: {}, + flag: true, + }, + { + name: 'phaseCorrection', + label: 'Phase correction', + value: {}, + flag: true, + }, + ], + '13C': [ + { + name: 'digitalFilter', + label: 'Digital Filter', + value: {}, + flag: true, + }, + { + name: 'apodization', + label: 'Apodization', + value: {}, + flag: true, + }, + { + name: 'zeroFilling', + label: 'Zero Filling', + value: {}, + flag: true, + }, + { + name: 'fft', + label: 'Fast fourier transform', + value: {}, + flag: true, + }, + { + name: 'phaseCorrection', + label: 'Phase correction', + value: {}, + flag: true, + }, + ], + }, }, label: 'Snapshots', version: 1, diff --git a/src/demo/views/Teaching.tsx b/src/demo/views/Teaching.tsx index 8c08bc192..5679075d6 100644 --- a/src/demo/views/Teaching.tsx +++ b/src/demo/views/Teaching.tsx @@ -82,12 +82,14 @@ export default function Teaching(props) {