-
Notifications
You must be signed in to change notification settings - Fork 5
fetch only one estimator #1790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
grzanka
merged 16 commits into
master
from
1771-query-backend-only-for-specific-estimator
Dec 3, 2024
Merged
fetch only one estimator #1790
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0454040
fetch only one estimator
matuszsmig fa10e34
get state of estiamtors order
matuszsmig 06769f4
some changes
matuszsmig a05b3e2
Merge branch 'refs/heads/master' into 1771-query-backend-only-for-spe…
matuszsmig 8776159
use estimators name given from backend
matuszsmig 601f505
little changes
matuszsmig 45f2ef0
fix some bug
matuszsmig c79fb71
delete hard code
matuszsmig e2a0b5a
little changes
matuszsmig b8903ac
Merge branch 'refs/heads/master' into 1771-query-backend-only-for-spe…
matuszsmig 642d065
changes after cr
matuszsmig 5c71aaf
delete fluka condition
matuszsmig 077d5aa
changes after code review
matuszsmig 27afcc7
Merge branch 'refs/heads/master' into 1771-query-backend-only-for-spe…
matuszsmig 704adfc
hope thats all
matuszsmig 9498878
fix problem with loading example
matuszsmig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
77 changes: 77 additions & 0 deletions
77
src/WrapperApp/components/Results/EstimatorTab/EstimatorTab.tsx
This file contains hidden or 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,77 @@ | ||
| import { Box, Card, CardContent, CircularProgress } from '@mui/material'; | ||
|
|
||
| import { generateGraphs } from '../../../../JsRoot/GraphData'; | ||
| import { FullSimulationData } from '../../../../services/ShSimulatorService'; | ||
| import { TabPanel } from '../../Panels/TabPanel'; | ||
| import { EstimatorResults } from '../ResultsPanel'; | ||
| import TablePage0D from '../ResultsTable'; | ||
|
|
||
| interface EstimatorTabProps { | ||
| estimator: EstimatorResults; | ||
| tabsValue: number; | ||
| resultsGeneratedFromProjectFile: boolean; | ||
| groupQuantities: boolean; | ||
| simulation: FullSimulationData; | ||
| } | ||
|
|
||
| const EstimatorTab = ({ | ||
| estimator, | ||
| tabsValue, | ||
| resultsGeneratedFromProjectFile, | ||
| groupQuantities, | ||
| simulation | ||
| }: EstimatorTabProps) => { | ||
| return ( | ||
| <Card | ||
| variant='outlined' | ||
| sx={{ | ||
| 'flexGrow': 1, | ||
| 'margin': '0.5rem', | ||
| 'bgcolor': theme => | ||
| theme.palette.mode === 'dark' ? 'text.disabled' : 'background.paper', | ||
| '& .MuiCardContent-root div': { | ||
| bgcolor: 'transparent', | ||
| backgroundImage: 'none', | ||
| color: 'black' | ||
| } | ||
| }}> | ||
| {!estimator ? ( | ||
| <Box | ||
| sx={{ | ||
| display: 'flex', | ||
| justifyContent: 'center', | ||
| alignItems: 'center', | ||
| height: '100vh' | ||
| }}> | ||
| <CircularProgress /> | ||
| </Box> | ||
| ) : ( | ||
| <CardContent> | ||
| <TabPanel | ||
| key={`tab_panel_${estimator.name}_${tabsValue}`} | ||
| value={tabsValue} | ||
| index={tabsValue} | ||
| persistentIfVisited> | ||
| <Box | ||
| style={{ | ||
| width: '100%', | ||
| display: 'flex', | ||
| flexDirection: 'column' | ||
| }}> | ||
| {estimator.tablePages.length > 0 && ( | ||
| <TablePage0D estimator={estimator}></TablePage0D> | ||
| )} | ||
| {generateGraphs( | ||
| estimator, | ||
| resultsGeneratedFromProjectFile && groupQuantities, | ||
| simulation?.jobId | ||
| )} | ||
| </Box> | ||
| </TabPanel> | ||
| </CardContent> | ||
| )} | ||
| </Card> | ||
| ); | ||
| }; | ||
|
|
||
| export default EstimatorTab; |
125 changes: 125 additions & 0 deletions
125
src/WrapperApp/components/Results/EstimatorsSelect/EstimatorsSelect.tsx
This file contains hidden or 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,125 @@ | ||
| import { Card, CardContent, Tab, Tabs } from '@mui/material'; | ||
| import { SyntheticEvent, useCallback, useEffect, useState } from 'react'; | ||
|
|
||
| import { FullSimulationData, useShSimulation } from '../../../../services/ShSimulatorService'; | ||
|
|
||
| interface EstimatorsTabProps { | ||
| tabsValue: number; | ||
| setTabsValue: (value: number) => void; | ||
| simulation: FullSimulationData; | ||
| setResultsSimulationData: React.Dispatch<React.SetStateAction<FullSimulationData | undefined>>; | ||
| estimatorsTabData: string[]; | ||
| } | ||
|
|
||
| const EstimatorsSelect = ({ | ||
| tabsValue, | ||
| setTabsValue, | ||
| simulation, | ||
| setResultsSimulationData, | ||
| estimatorsTabData | ||
| }: EstimatorsTabProps) => { | ||
| const [controller] = useState(new AbortController()); | ||
|
|
||
| const { getJobResult } = useShSimulation(); | ||
|
|
||
| const handleEstimatorTabChange = useCallback( | ||
| async (id: number) => { | ||
| const currentEstimatorData = simulation.estimators; | ||
| const estimatorExists = | ||
| currentEstimatorData[id] && currentEstimatorData[id].name !== ''; | ||
|
|
||
| if (!estimatorExists) { | ||
| const simulationJobId = simulation.jobId; | ||
|
|
||
| const estimatorData = await getJobResult( | ||
| { | ||
| jobId: simulationJobId, | ||
| estimatorName: estimatorsTabData[id] + '_' | ||
| }, | ||
| controller.signal, | ||
| true | ||
| ); | ||
|
|
||
| const newEstimatorData = estimatorData?.estimators; | ||
|
|
||
| if (newEstimatorData) { | ||
| const newEstimators = [...currentEstimatorData]; | ||
|
|
||
| while (newEstimators.length <= id) { | ||
| newEstimators.push({ | ||
| name: '', | ||
| pages: [] | ||
| }); | ||
| } | ||
|
|
||
| newEstimators[id] = newEstimatorData[0]; | ||
|
|
||
| const newSimulation = { | ||
| ...simulation, | ||
| estimators: newEstimators | ||
| }; | ||
| setResultsSimulationData(newSimulation); | ||
| } | ||
| } | ||
| }, | ||
| [controller.signal, estimatorsTabData, getJobResult, setResultsSimulationData, simulation] | ||
| ); | ||
|
|
||
| useEffect(() => { | ||
| handleEstimatorTabChange(0); | ||
| }, [handleEstimatorTabChange]); | ||
|
|
||
| const handleChange = (_event: SyntheticEvent, newValue: number) => { | ||
| setTabsValue(newValue); | ||
| }; | ||
|
|
||
| return ( | ||
| <Card | ||
| sx={{ | ||
| margin: '0.5rem', | ||
| height: 'min-content', | ||
| overflow: 'unset', | ||
| position: 'sticky', | ||
| top: '8px', | ||
| zIndex: 1 | ||
| }}> | ||
| <CardContent | ||
| sx={{ | ||
| color: theme => | ||
| theme.palette.mode === 'dark' ? 'secondary.contrastText' : 'secondary.dark' | ||
| }}> | ||
| <Tabs | ||
| textColor='inherit' | ||
| sx={{ | ||
| 'flexShrink': 0, | ||
| '& .MuiTabs-indicator': { | ||
| backgroundColor: theme => | ||
| theme.palette.mode === 'dark' | ||
| ? 'secondary.contrastText' | ||
| : 'secondary.dark' | ||
| }, | ||
| '& .MuiButtonBase-root': { | ||
| fontWeight: 'bold' | ||
| } | ||
| }} | ||
| orientation='vertical' | ||
| variant='scrollable' | ||
| value={tabsValue} | ||
| onChange={handleChange}> | ||
| {estimatorsTabData.map((estimatorName, id) => { | ||
| return ( | ||
| <Tab | ||
| key={`tab_${estimatorName}`} | ||
| label={estimatorName} | ||
| value={id} | ||
| onClick={() => handleEstimatorTabChange(id)} | ||
| /> | ||
| ); | ||
| })} | ||
| </Tabs> | ||
| </CardContent> | ||
| </Card> | ||
| ); | ||
| }; | ||
|
|
||
| export default EstimatorsSelect; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.