-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from Strexas/MDE/PKFE-31
MDE/PKFE-31
- Loading branch information
Showing
27 changed files
with
1,291 additions
and
108 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
106 changes: 85 additions & 21 deletions
106
...-end/src/features/editor/components/toolbarView/toolbarGroupButtons/applyGroupButtons.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 |
---|---|---|
@@ -1,26 +1,90 @@ | ||
import { ToolbarGroupItem, ToolbarGroupItemProps } from '@/features/editor/components/toolbarView'; | ||
import { useToolbarContext } from '@/features/editor/hooks'; | ||
import { useStatusContext } from '@/hooks'; | ||
import { Deblur as DeblurIcon } from '@mui/icons-material'; | ||
import { useCallback, useMemo } from 'react'; | ||
|
||
import { ToolbarGroupItemProps } from '@/features/editor/components/toolbarView'; | ||
export interface ApplyGroupButtonsProps {} | ||
|
||
const applySpliceAiClick = () => { | ||
console.log('Clicked Apply SpliceAI Button!'); | ||
}; | ||
export const ApplyGroupButtons: React.FC<ApplyGroupButtonsProps> = () => { | ||
const { blockedStateUpdate } = useStatusContext(); | ||
const { saveTo, override, applyTo, applyErrorStateUpdate } = useToolbarContext(); | ||
|
||
const applyCaddClick = () => { | ||
console.log('Clicked Apply CADD Button!'); | ||
}; | ||
const applySpliceAiClick = useCallback(async () => { | ||
if (!applyTo) { | ||
applyErrorStateUpdate('Please select a file'); | ||
return; | ||
} | ||
|
||
blockedStateUpdate(true); | ||
|
||
try { | ||
console.log( | ||
'Clicked Apply SpliceAI Button! Params:\n saveTo:', | ||
saveTo, | ||
'\n override:', | ||
override, | ||
'\n applyTo:', | ||
applyTo | ||
); | ||
|
||
await new Promise((resolve) => setTimeout(resolve, 1000)); // TODO: remove this line | ||
} catch (error) { | ||
console.error('Error applying SpliceAI:', error); | ||
} finally { | ||
blockedStateUpdate(false); | ||
} | ||
}, [saveTo, override, applyTo]); | ||
|
||
const applyCaddClick = useCallback(async () => { | ||
if (!applyTo) { | ||
applyErrorStateUpdate('Please select a file'); | ||
return; | ||
} | ||
|
||
export const ApplyGroupButtons: ToolbarGroupItemProps[] = [ | ||
{ | ||
group: 'apply', | ||
icon: DeblurIcon, | ||
label: 'Apply SpliceAI', | ||
onClick: applySpliceAiClick, | ||
}, | ||
{ | ||
group: 'apply', | ||
icon: DeblurIcon, | ||
label: 'Apply CADD', | ||
onClick: applyCaddClick, | ||
}, | ||
]; | ||
blockedStateUpdate(true); | ||
|
||
try { | ||
console.log( | ||
'Clicked Merge LOVD & ClinVar Button! Params:\n saveTo:', | ||
saveTo, | ||
'\n override:', | ||
override, | ||
'\n applyTo:', | ||
applyTo | ||
); | ||
|
||
await new Promise((resolve) => setTimeout(resolve, 1000)); // TODO: remove this line | ||
} catch (error) { | ||
console.error('Error applying CADD:', error); | ||
} finally { | ||
blockedStateUpdate(false); | ||
} | ||
}, [saveTo, override, applyTo]); | ||
|
||
const buttons: ToolbarGroupItemProps[] = useMemo( | ||
() => [ | ||
{ | ||
group: 'apply', | ||
icon: DeblurIcon, | ||
label: 'Apply SpliceAI', | ||
onClick: applySpliceAiClick, | ||
}, | ||
{ | ||
group: 'apply', | ||
icon: DeblurIcon, | ||
label: 'Apply CADD', | ||
onClick: applyCaddClick, | ||
}, | ||
], | ||
[applySpliceAiClick, applyCaddClick] | ||
); | ||
|
||
return ( | ||
<> | ||
{buttons.map((button, index) => ( | ||
<ToolbarGroupItem key={index} {...button} /> | ||
))} | ||
</> | ||
); | ||
}; |
133 changes: 102 additions & 31 deletions
133
...d/src/features/editor/components/toolbarView/toolbarGroupButtons/downloadGroupButtons.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 |
---|---|---|
@@ -1,36 +1,107 @@ | ||
import { ToolbarGroupItemProps } from '@/features/editor/components/toolbarView'; | ||
|
||
import { ToolbarGroupItem, ToolbarGroupItemProps } from '@/features/editor/components/toolbarView'; | ||
import { useToolbarContext } from '@/features/editor/hooks'; | ||
import { useStatusContext } from '@/hooks'; | ||
import { Download as DownloadIcon } from '@mui/icons-material'; | ||
import { useCallback, useMemo } from 'react'; | ||
|
||
const handleDownloadLovdClick = () => { | ||
console.log('Clicked Download Lovd Button!'); | ||
}; | ||
export interface DownloadGroupButtonsProps {} | ||
|
||
const handleDownloadClinvarClick = () => { | ||
console.log('Clicked Download Clinvar Button!'); | ||
}; | ||
export const DownloadGroupButtons: React.FC<DownloadGroupButtonsProps> = () => { | ||
const { blockedStateUpdate } = useStatusContext(); | ||
const { saveTo, override, gene } = useToolbarContext(); | ||
|
||
const handleDownloadGnomadClick = () => { | ||
console.log('Clicked Download Gnomad Button!'); | ||
}; | ||
const handleDownloadLovdClick = useCallback(async () => { | ||
blockedStateUpdate(true); | ||
|
||
try { | ||
console.log( | ||
'Clicked Download Lovd Button! Params:\n saveTo:', | ||
saveTo, | ||
'\n override:', | ||
override, | ||
'\n gene:', | ||
gene | ||
); | ||
|
||
await new Promise((resolve) => setTimeout(resolve, 1000)); // TODO: remove this line | ||
} catch (error) { | ||
console.error('Error downloading LOVD file:', error); | ||
} finally { | ||
blockedStateUpdate(false); | ||
} | ||
}, [saveTo, override, gene]); | ||
|
||
const handleDownloadClinvarClick = useCallback(async () => { | ||
blockedStateUpdate(true); | ||
|
||
export const DownloadGroupButtons: ToolbarGroupItemProps[] = [ | ||
{ | ||
group: 'download', | ||
icon: DownloadIcon, | ||
label: 'LOVD', | ||
onClick: handleDownloadLovdClick, | ||
}, | ||
{ | ||
group: 'download', | ||
icon: DownloadIcon, | ||
label: 'ClinVar', | ||
onClick: handleDownloadClinvarClick, | ||
}, | ||
{ | ||
group: 'download', | ||
icon: DownloadIcon, | ||
label: 'gnomAD', | ||
onClick: handleDownloadGnomadClick, | ||
}, | ||
]; | ||
try { | ||
console.log( | ||
'Clicked Download Clinvar Button! Params:\n saveTo:', | ||
saveTo, | ||
'\n override:', | ||
override, | ||
'\n gene:', | ||
gene | ||
); | ||
|
||
await new Promise((resolve) => setTimeout(resolve, 1000)); // TODO: remove this line | ||
} catch (error) { | ||
console.error('Error downloading ClinVar file:', error); | ||
} finally { | ||
blockedStateUpdate(false); | ||
} | ||
}, [saveTo, override, gene]); | ||
|
||
const handleDownloadGnomadClick = useCallback(async () => { | ||
blockedStateUpdate(true); | ||
|
||
try { | ||
console.log( | ||
'Clicked Download Gnomad Button! Params:\n saveTo:', | ||
saveTo, | ||
'\n override:', | ||
override, | ||
'\n gene:', | ||
gene | ||
); | ||
|
||
await new Promise((resolve) => setTimeout(resolve, 1000)); // TODO: remove this line | ||
} catch (error) { | ||
console.error('Error downloading gnomAD file:', error); | ||
} finally { | ||
blockedStateUpdate(false); | ||
} | ||
}, [saveTo, override, gene]); | ||
|
||
const buttons: ToolbarGroupItemProps[] = useMemo( | ||
() => [ | ||
{ | ||
group: 'download', | ||
icon: DownloadIcon, | ||
label: 'LOVD', | ||
onClick: handleDownloadLovdClick, | ||
}, | ||
{ | ||
group: 'download', | ||
icon: DownloadIcon, | ||
label: 'ClinVar', | ||
onClick: handleDownloadClinvarClick, | ||
}, | ||
{ | ||
group: 'download', | ||
icon: DownloadIcon, | ||
label: 'gnomAD', | ||
onClick: handleDownloadGnomadClick, | ||
}, | ||
], | ||
[handleDownloadLovdClick, handleDownloadClinvarClick, handleDownloadGnomadClick] | ||
); | ||
|
||
return ( | ||
<> | ||
{buttons.map((button, index) => ( | ||
<ToolbarGroupItem key={index} {...button} /> | ||
))} | ||
</> | ||
); | ||
}; |
3 changes: 3 additions & 0 deletions
3
app/front-end/src/features/editor/components/toolbarView/toolbarGroupButtons/index.ts
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
export { ApplyGroupButtons } from './applyGroupButtons'; | ||
export type { ApplyGroupButtonsProps } from './applyGroupButtons'; | ||
export { DownloadGroupButtons } from './downloadGroupButtons'; | ||
export type { DownloadGroupButtonsProps } from './downloadGroupButtons'; | ||
export { MergeGroupButtons } from './mergeGroupButtons'; | ||
export type { MergeGroupButtonsProps } from './mergeGroupButtons'; |
Oops, something went wrong.