diff --git a/src/component/loader/DropZone.tsx b/src/component/loader/DropZone.tsx index ee9f70effa..72bf126bdb 100644 --- a/src/component/loader/DropZone.tsx +++ b/src/component/loader/DropZone.tsx @@ -14,6 +14,7 @@ import { LoaderProvider } from '../context/LoaderContext'; import { useLogger } from '../context/LoggerContext'; import { usePreferences } from '../context/PreferencesContext'; import { useAlert } from '../elements/popup/Alert'; +import useCheckExperimentalFeature from '../hooks/useCheckExperimentalFeature'; import { useCheckToolsVisibility } from '../hooks/useCheckToolsVisibility'; import { useMetaInformationImportationModal } from '../modal/metaImportation/index'; @@ -59,6 +60,7 @@ function DropZone(props) { const openImportMetaInformationModal = useMetaInformationImportationModal(); const alert = useAlert(); const { logger } = useLogger(); + const experimentalFeatures = useCheckExperimentalFeature(); async function loadFilesHandler(files) { try { @@ -73,13 +75,14 @@ function DropZone(props) { if (metaFile) { parseMetaFileResult = await parseMetaFile(metaFile); } - const { nmrLoaders: sourceSelector } = preferences.current; const { nmriumState, containsNmrium } = await readDropFiles( fileCollection, { sourceSelector, logger: logger.child({ context: 'nmr-processing' }), + onLoadProcessing: current.onLoadProcessing, + experimentalFeatures, }, ); @@ -97,7 +100,6 @@ function DropZone(props) { payload: { nmriumState, containsNmrium, - onLoadProcessing: current.onLoadProcessing, parseMetaFileResult, }, }); diff --git a/src/component/modal/setting/settings-tabs/OnLoadProcessingTabContent.tsx b/src/component/modal/setting/settings-tabs/OnLoadProcessingTabContent.tsx index a2fef2737d..fd0d74180f 100644 --- a/src/component/modal/setting/settings-tabs/OnLoadProcessingTabContent.tsx +++ b/src/component/modal/setting/settings-tabs/OnLoadProcessingTabContent.tsx @@ -7,22 +7,40 @@ import { TabItem, Tabs } from 'react-science/ui'; import { Nucleus } from '../../../../data/types/common/Nucleus'; import { CheckBoxCell } from '../../../elements/CheckBoxCell'; import IsotopesViewer from '../../../elements/IsotopesViewer'; +import Label from '../../../elements/Label'; import ReactTable from '../../../elements/ReactTable/ReactTable'; import { CustomColumn } from '../../../elements/ReactTable/utility/addCustomColumn'; +import FormikCheckBox from '../../../elements/formik/FormikCheckBox'; function OnLoadProcessingTabContent() { const { values } = useFormikContext(); - const [activeTab, setActiveTab] = useState('1H'); + const isExperimentalFeatures = + values.display?.general?.experimentalFeatures?.display || false; - const tabItems: TabItem[] = Object.keys(values?.onLoadProcessing || {}).map( + return ( +
+ + {isExperimentalFeatures && } +
+ ); +} + +function AutoProcessingFilters() { + const { values } = useFormikContext(); + const [activeTab, setActiveTab] = useState('1H'); + const autoProcessingFilters = values?.onLoadProcessing?.filters || {}; + const tabItems: TabItem[] = Object.keys(autoProcessingFilters).map( (nucleus) => ({ id: nucleus, title: , content: ( - + ), }), ); @@ -55,7 +73,7 @@ function FiltersTable({ data, nucleus }) { Header: 'Enable', Cell: ({ row }) => ( ), diff --git a/src/component/reducer/actions/LoadActions.ts b/src/component/reducer/actions/LoadActions.ts index 335bd7c97b..7eaa6c9aeb 100644 --- a/src/component/reducer/actions/LoadActions.ts +++ b/src/component/reducer/actions/LoadActions.ts @@ -2,12 +2,7 @@ import { Draft } from 'immer'; import lodashMerge from 'lodash/merge'; import lodashMergeWith from 'lodash/mergeWith'; import { buildCorrelationData, CorrelationData } from 'nmr-correlation'; -import { - Spectrum, - OnLoadProcessing, - ViewState, - NmriumState, -} from 'nmr-load-save'; +import { Spectrum, ViewState, NmriumState } from 'nmr-load-save'; import { ParseResult } from 'papaparse'; import { initiateDatum1D } from '../../../data/data1d/Spectrum1D'; @@ -17,7 +12,6 @@ import * as MoleculeManager from '../../../data/molecules/MoleculeManager'; import { linkMetaWithSpectra } from '../../../data/parseMeta/linkMetaWithSpectra'; import { UsedColors } from '../../../types/UsedColors'; import { DefaultTolerance } from '../../panels/SummaryPanel/CorrelationTable/Constants'; -import nucleusToString from '../../utility/nucleusToString'; import { getDefaultViewState, getInitialState, State } from '../Reducer'; import { ActionType } from '../types/ActionType'; @@ -32,7 +26,6 @@ interface InitiateProps { interface InputProps extends InitiateProps { containsNmrium?: boolean; usedColors?: UsedColors; - onLoadProcessing?: OnLoadProcessing; parseMetaFileResult?: ParseResult | null; resetSourceObject?: boolean; } @@ -87,23 +80,15 @@ function setCorrelation(draft: Draft, correlations: CorrelationData) { } } -function setData( - draft: Draft, - input: InputProps, - options: { - autoOnLoadProcessing?: boolean; - } = {}, -) { +function setData(draft: Draft, input: InputProps) { const { nmriumState: { data, view }, - onLoadProcessing = { autoProcessing: true }, parseMetaFileResult = null, } = input || { nmriumState: { data: { spectra: [], molecules: [], correlations: {} } }, multipleAnalysis: {}, }; - const { autoOnLoadProcessing = true } = options; const { source, spectra = [], @@ -133,9 +118,6 @@ function setData( draft.data = draft.data.concat( initSpectra(spectra, { usedColors: draft.usedColors, - onLoadProcessing: autoOnLoadProcessing - ? onLoadProcessing - : { autoProcessing: true }, molecules: draft.molecules, }), ); @@ -155,19 +137,15 @@ function initSpectra( inputSpectra: Spectrum[], options: { usedColors: UsedColors; - onLoadProcessing: OnLoadProcessing; molecules: StateMoleculeExtended[]; }, ) { const spectra: any = []; - const { usedColors, onLoadProcessing, molecules } = options; + const { usedColors, molecules } = options; for (const spectrum of inputSpectra) { const { info } = spectrum; if (info.dimension === 1) { - const filters = onLoadProcessing?.[nucleusToString(info.nucleus)] || []; - spectra.push( - initiateDatum1D(spectrum, { usedColors, filters, molecules }), - ); + spectra.push(initiateDatum1D(spectrum, { usedColors, molecules })); } else if (info.dimension === 2) { spectra.push(initiateDatum2D({ ...spectrum }, { usedColors })); } @@ -197,10 +175,9 @@ function initData( action: LoadDropFilesAction | InitiateAction, options: { forceInitialize?: boolean; - autoOnLoadProcessing?: boolean; } = {}, ) { - const { forceInitialize = false, autoOnLoadProcessing = true } = options; + const { forceInitialize = false } = options; const { nmriumState: { data, view }, @@ -209,7 +186,7 @@ function initData( const viewState = view as ViewState; if (data?.spectra?.length || forceInitialize) { const state = getInitialState(); - setData(state, action.payload, { autoOnLoadProcessing }); + setData(state, action.payload); setActiveTab(state, { tab: viewState?.spectra?.activeTab || '' }); state.width = draft.width; state.height = draft.height; @@ -236,7 +213,6 @@ function handleSetIsLoading(draft: Draft, action: SetIsLoadingAction) { function handleInitiate(draft: Draft, action: InitiateAction) { return initData(draft, action, { forceInitialize: true, - autoOnLoadProcessing: false, }); } @@ -251,7 +227,7 @@ function handleLoadDropFiles(draft: Draft, action: LoadDropFilesAction) { } = payload; if (containsNmrium) { - return initData(draft, action, { autoOnLoadProcessing: false }); + return initData(draft, action); } else { setData(draft, payload); setActiveTab(draft); diff --git a/src/data/data1d/Spectrum1D/initiateDatum1D.ts b/src/data/data1d/Spectrum1D/initiateDatum1D.ts index d2a838bb4d..ce7fb735d2 100644 --- a/src/data/data1d/Spectrum1D/initiateDatum1D.ts +++ b/src/data/data1d/Spectrum1D/initiateDatum1D.ts @@ -1,6 +1,6 @@ import { v4 } from '@lukeed/uuid'; import { Spectrum1D } from 'nmr-load-save'; -import { BaseFilter, FiltersManager, Filters } from 'nmr-processing'; +import { FiltersManager } from 'nmr-processing'; import { UsedColors } from '../../../types/UsedColors'; import { initiateFilters } from '../../initiateFilters'; @@ -15,7 +15,6 @@ import { initiateRanges } from './ranges/initiateRanges'; export interface InitiateDatum1DOptions { usedColors?: UsedColors; - filters?: any[]; molecules?: StateMoleculeExtended[]; } @@ -23,7 +22,7 @@ export function initiateDatum1D( spectrum: any, options: InitiateDatum1DOptions = {}, ): Spectrum1D { - const { usedColors = {}, filters = [], molecules = [] } = options; + const { usedColors = {}, molecules = [] } = options; const { integrals, ranges, ...restSpectrum } = spectrum; const spectrumObj: Spectrum1D = { ...restSpectrum }; @@ -82,40 +81,5 @@ export function initiateDatum1D( //reapply filters after load the original data FiltersManager.reapplyFilters(spectrumObj); - preprocessing(spectrumObj, filters); - return spectrumObj; } - -function preprocessing(datum, onLoadFilters: BaseFilter[] = []) { - if (datum.info.isFid) { - if (onLoadFilters?.length === 0) { - FiltersManager.applyFilter(datum, [ - { - name: Filters.digitalFilter.id, - value: {}, - isDeleteAllow: false, - }, - ]); - } else { - const filters: BaseFilter[] = []; - - for (let filter of onLoadFilters) { - if ( - (!datum.info?.digitalFilter && - filter.name === Filters.digitalFilter.id) || - !filter.flag - ) { - continue; - } - if (filter.name === Filters.digitalFilter.id) { - filter = { ...filter, isDeleteAllow: false }; - } - - filters.push(filter); - } - - FiltersManager.applyFilter(datum, filters); - } - } -}