Skip to content

Commit e325ba4

Browse files
committed
Adds survey management and user access control to Aladin
Implements survey selection and management features alongside user group access control for surveys and catalogs. Introduces a new context for handling surveys and integrates a control panel for selecting and displaying survey information. Enhances user experience by providing feedback on the current survey selection while ensuring that only authorized users can access specific surveys and catalogs. Improves code organization by encapsulating survey-related logic within dedicated components. Relates to user feedback on survey accessibility and usability. Closed #71
1 parent e1e8cd8 commit e325ba4

File tree

8 files changed

+460
-90
lines changed

8 files changed

+460
-90
lines changed

frontend/components/Aladin/AladinContext.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import { createContext, useContext } from 'react';
88
export const AladinContext = createContext({
99
containerRef: null,
1010
aladinRef: null,
11+
surveysRef: {},
1112
catalogsRef: {},
1213
isReady: false,
14+
currentSurveyId: null,
1315
setFoV: () => { },
1416
setTarget: () => { },
15-
setSurvey: () => { },
16-
createSurvey: () => { },
17-
addCatalog: () => { },
17+
setImageSurvey: () => { },
1818
toggleCatalogVisibility: () => { },
1919
addMarker: () => { },
2020
});

frontend/components/Aladin/CatalogControls/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export default function CatalogControls() {
2121
{catalogsRef.current && Object.keys(catalogsRef.current).length > 0 && (
2222
Object.keys(catalogsRef.current).map(key => {
2323
const catalog = catalogsRef.current[key];
24-
console.log(catalog)
2524
return (
2625
<CatalogListItem key={`catalog-list-item-${catalog.name.replace(/ /g, "-")}`} catalog={catalog} />
2726
)

frontend/components/Aladin/Controls.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,16 @@
11
'use client';
22

3-
import { useAladinContext } from './AladinContext';
4-
import { Button, Typography } from '@mui/material';
5-
import Box from '@mui/material/Box';
63
import Stack from '@mui/material/Stack';
4+
import Divider from '@mui/material/Divider';
5+
import SurveyControls from '@/components/Aladin/SurveyControls';
76
import CatalogControls from '@/components/Aladin/CatalogControls';
87

98
export default function Controls() {
10-
const { isReady, setFoV, setTarget, addMarker } = useAladinContext();
11-
12-
const handleGotoM42 = () => {
13-
setTarget('M42');
14-
setFoV(1.0);
15-
addMarker(83.82208, -5.39111, { popupTitle: 'Orion Nebula' });
16-
};
179

1810
return (
1911
<Stack spacing={2} m={2}>
20-
<Typography variant="h6">Surveys</Typography>
21-
<Button variant="contained" disabled={!isReady} onClick={handleGotoM42}>
22-
DES DR2 IRG
23-
</Button>
24-
<Button variant="contained" disabled={!isReady} onClick={handleGotoM42}>
25-
LSST DP0.2 IRG
26-
</Button>
27-
<hr></hr>
12+
<SurveyControls />
13+
<Divider />
2814
<CatalogControls />
2915
</Stack>
3016

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types'
3+
import ListItem from '@mui/material/ListItem';
4+
import ListItemButton from '@mui/material/ListItemButton';
5+
import ListItemIcon from '@mui/material/ListItemIcon';
6+
import ListItemText from '@mui/material/ListItemText';
7+
import CheckIcon from '@mui/icons-material/Check';
8+
9+
import { useAladinContext } from '@/components/Aladin/AladinContext';
10+
11+
export default function SurveyListItem({ survey }) {
12+
const { setImageSurvey, currentSurveyId } = useAladinContext();
13+
14+
const handleToggle = (event) => {
15+
setImageSurvey(survey.id);
16+
};
17+
18+
return (
19+
<React.Fragment>
20+
<ListItem
21+
key={`survey-option-${survey.id}`}
22+
disablePadding
23+
>
24+
<ListItemButton
25+
selected={currentSurveyId === survey.id}
26+
onClick={handleToggle}
27+
>
28+
<ListItemIcon>
29+
{currentSurveyId === survey.id && (<CheckIcon />)}
30+
</ListItemIcon>
31+
<ListItemText primary={survey.name} />
32+
</ListItemButton>
33+
</ListItem>
34+
35+
</React.Fragment>
36+
)
37+
}
38+
39+
SurveyListItem.propTypes = {
40+
survey: PropTypes.object.isRequired,
41+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use client';
2+
3+
import { useAladinContext } from '@/components/Aladin/AladinContext';
4+
import { Typography } from '@mui/material';
5+
import Stack from '@mui/material/Stack';
6+
import List from '@mui/material/List';
7+
import SurveyListItem from './SurveyListItem';
8+
9+
export default function SurveyControls() {
10+
const { surveysRef } = useAladinContext();
11+
12+
return (
13+
<Stack spacing={2}>
14+
<Typography variant="h6">Surveys</Typography>
15+
<List
16+
sx={{
17+
width: '100%',
18+
}}
19+
component="nav"
20+
>
21+
{surveysRef.current && Object.keys(surveysRef.current).length > 0 && (
22+
Object.keys(surveysRef.current).map(key => {
23+
const survey = surveysRef.current[key];
24+
console.log(survey)
25+
return (
26+
<SurveyListItem key={`survey-list-item-${survey.id}`} survey={survey} />
27+
)
28+
}))
29+
}
30+
</List>
31+
</Stack>
32+
33+
);
34+
}

frontend/components/Aladin/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default function Aladin({ userGroups = [] }) {
1717
showCooGridControl: true,
1818
showContextMenu: true,
1919
showSettingsControl: true,
20+
reticleColor: '#41b332'
2021
}}
2122
userGroups={userGroups}
2223
>
@@ -30,7 +31,6 @@ export default function Aladin({ userGroups = [] }) {
3031
</div>
3132
<div style={{
3233
width: '300px',
33-
// padding: '1rem',
3434
background: '#eee'
3535
}}>
3636
<Controls />

0 commit comments

Comments
 (0)