-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replicate spectra Peak picking function in automatic assignment…
… panel it is a clone of the automatic peak picking that is currently in spectra close #1480
- Loading branch information
1 parent
d3d8ad1
commit d8e6180
Showing
3 changed files
with
53 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/component/panels/header/SpectraAutomaticPickingButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { SvgNmrRangePicking } from 'cheminfo-font'; | ||
import { useCallback } from 'react'; | ||
|
||
import { useChartData } from '../../context/ChartContext'; | ||
import { useDispatch } from '../../context/DispatchContext'; | ||
import Button from '../../elements/ButtonToolTip'; | ||
import { useAlert } from '../../elements/popup/Alert'; | ||
import { useCheckToolsVisibility } from '../../hooks/useCheckToolsVisibility'; | ||
import { | ||
AUTO_RANGES_SPECTRA_PICKING, | ||
AUTO_ZONES_SPECTRA_PICKING, | ||
} from '../../reducer/types/Types'; | ||
|
||
export function SpectraAutomaticPickingButton() { | ||
const dispatch = useDispatch(); | ||
const alert = useAlert(); | ||
const { data } = useChartData(); | ||
const isToolVisible = useCheckToolsVisibility(); | ||
|
||
const automaticPickingHandler = useCallback(() => { | ||
void (async () => { | ||
const hideLoading = await alert.showLoading( | ||
'Automatic Ranges/Zones detection for all spectra in progress', | ||
); | ||
setTimeout(() => { | ||
dispatch({ type: AUTO_RANGES_SPECTRA_PICKING }); | ||
dispatch({ type: AUTO_ZONES_SPECTRA_PICKING }); | ||
hideLoading(); | ||
}, 0); | ||
})(); | ||
}, [dispatch, alert]); | ||
|
||
if ( | ||
(Array.isArray(data) && data.length === 0) || | ||
!isToolVisible('autoRangesTool') | ||
) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Button | ||
popupTitle="Automatic Ranges/Zones picking for all spectra" | ||
onClick={automaticPickingHandler} | ||
> | ||
<SvgNmrRangePicking /> | ||
</Button> | ||
); | ||
} |