Skip to content

Commit

Permalink
RecentSources widget: UI fix (#101)
Browse files Browse the repository at this point in the history
* fix display of recent sources widget, pin skyportal to 101984d9057cb62944decedfa560dffb5d755bef

* slightly better display for SourceStatus.jsx

* update github action artifact version

* add missing change to artifact action update

* add missing change to artifact action update (logs)
  • Loading branch information
Theodlz authored Dec 4, 2024
1 parent 292ef22 commit 117e683
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 82 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/test_api_and_frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -247,22 +247,22 @@ jobs:
PYTHONPATH=. python baselayer/tools/test_frontend.py --xml --headless 'skyportal/tests/external'
- name: Upload logs
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: logs
name: logs-${{ matrix.test_subset }}
path: patched_skyportal/log

- name: Upload test post-mortem reports
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: test-results
name: test-results-${{ matrix.test_subset }}
path: patched_skyportal/test-results

- name: Upload generated plots
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: generated-plots
name: generated-plots-${{ matrix.test_subset }}
path: patched_skyportal/skyportal/tests/data/*_expected.png
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ geckodriver.log
patched_skyportal
previous_skyportal
icare.yaml
.DS_Store
62 changes: 25 additions & 37 deletions extensions/skyportal/static/js/components/widget/RecentSources.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ import SearchIcon from "@mui/icons-material/Search";
import InputAdornment from "@mui/material/InputAdornment";

import { showNotification } from "baselayer/components/Notifications";
import { ra_to_hours, dec_to_dms } from "../../units";
import { dec_to_dms, ra_to_hours } from "../../units";
import * as profileActions from "../../ducks/profile";
import WidgetPrefsDialog from "./WidgetPrefsDialog";

import SourceStatus from "./SourceStatus";

dayjs.extend(relativeTime);
dayjs.extend(utc);

const confirmed_classes = ['Kilonova', 'GRB', 'GW Counterpart', 'GW Candidate', 'Supernova']
const rejected_classes = ['Not Kilonova', 'Not GRB', 'Not GW Counterpart', 'Not GW Candidate', 'Not Supernova']
const not_confirmed_classes = ["I-care", "Not I-care"]
const obs_classes = ['GO GRANDMA', 'STOP GRANDMA', 'GO GRANDMA (HIGH PRIORITY)']

export const useSourceListStyles = makeStyles((theme) => ({
stampContainer: {
display: "contents",
Expand Down Expand Up @@ -125,22 +131,6 @@ export const useSourceListStyles = makeStyles((theme) => ({
theme.palette.mode === "light" ? theme.palette.secondary.light : null,
},
},
confirmed: {
background: "#03c04a!important",
},
rejected: {
background: "#ff0000!important",
},
not_confirmed: {
// grey background
background: "#e0e0e0!important",
},
go: {
background: "#03c04a!important",
},
stop: {
background: "#ff0000!important",
},
root: {
"& .MuiOutlinedInput-root": {
"& fieldset": {
Expand Down Expand Up @@ -172,6 +162,22 @@ export const useSourceListStyles = makeStyles((theme) => ({
marginLeft: theme.spacing(2),
},
},
confirmed: {
background: "#03c04a!important",
},
rejected: {
background: "#ff0000!important",
},
not_confirmed: {
// grey background
background: "#e0e0e0!important",
},
go: {
background: "#03c04a!important",
},
stop: {
background: "#ff0000!important",
},
}));

const defaultPrefs = {
Expand Down Expand Up @@ -309,21 +315,16 @@ const RecentSourcesList = ({
return <div>No recent sources available.</div>;
}

const confirmed_classes = ['Kilonova', 'GRB', 'GW Counterpart', 'GW Candidate', 'Supernova']
const rejected_classes = ['Not Kilonova', 'Not GRB', 'Not GW Counterpart', 'Not GW Candidate', 'Not Supernova']
const not_confirmed_classes = ["I-care", "Not I-care"]
const obs_classes = ['GO GRANDMA', 'STOP GRANDMA', 'GO GRANDMA (HIGH PRIORITY)']

return (
<div className={styles.sourceListContainer}>
<ul className={styles.sourceList}>
{sources.map((source) => {
let recentSourceName = `${source.obj_id}`;
let classification = null;
let grandma_source_classification = "I-care";
let confirmed_or_rejected = 'not_confirmed';
let grandma_obs_classification = null;
let obs_status = null;
let classification = null;
if (source.classifications.length > 0) {
// Display the most recent non-zero probability class
const filteredClasses = source.classifications?.filter(
Expand Down Expand Up @@ -421,19 +422,6 @@ const RecentSourcesList = ({
<Chip className={styles[obs_status]} size="small" label={grandma_obs_classification} key={grandma_obs_classification}/>
)}
</span>
<span>
{`\u03B1, \u03B4: ${ra_to_hours(
source.ra
)} ${dec_to_dms(source.dec)}`}
</span>
<Link
to={`/source/${source.obj_id}`}
className={styles.sourceName}
>
<span className={styles.sourceNameLink}>
{recentSourceName}
</span>
</Link>
{classification && (
<span className={styles.classification}>
{classification}
Expand All @@ -457,7 +445,6 @@ const RecentSourcesList = ({
<span style={{ textAlign: "right" }}>
{dayjs().to(dayjs.utc(`${source.created_at}Z`))}
</span>
<SourceStatus source={source} />
{displayTNS && source?.tns_name?.length > 0 && (
<div
style={{
Expand Down Expand Up @@ -490,6 +477,7 @@ const RecentSourcesList = ({
/>
</div>
)}
<SourceStatus source={source} />
</div>
</div>
</div>
Expand Down
73 changes: 39 additions & 34 deletions extensions/skyportal/static/js/components/widget/SourceStatus.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ import { useDispatch, useSelector } from "react-redux";

import * as sourcestatus from "../../ducks/sourcestatus";
import { fetchRecentSources } from "../../ducks/recentSources";
import DialogTitle from "@mui/material/DialogTitle";
import Divider from "@mui/material/Divider";
import IconButton from "@mui/material/IconButton";
import Tooltip from "@mui/material/Tooltip";
import CloseIcon from '@mui/icons-material/Close';
import EditIcon from '@mui/icons-material/Edit';

const confirmed_classes = ['Kilonova', 'GRB', 'GW Counterpart', 'GW Candidate', 'Supernova']
const rejected_classes = ['Not Kilonova', 'Not GRB', 'Not GW Counterpart', 'Not GW Candidate', 'Not Supernova']
const not_defined = ["I-care", "Not I-care"]
const obs_status = ["GO GRANDMA", "STOP GRANDMA", "GO GRANDMA (HIGH PRIORITY)"]
const obs_status = ["GO GRANDMA (HIGH PRIORITY)", "GO GRANDMA", "STOP GRANDMA"]

const SourceStatus = ({ source }) => {
const [open, setOpen] = useState(false);
Expand Down Expand Up @@ -94,23 +100,31 @@ const SourceStatus = ({ source }) => {


return (
<div>
<Button
variant="outlined"
size="small"
onClick={() => setOpen(true)}
>
Update Status
</Button>
<Dialog open={open}>
<div key={source.obj_id}>
<Tooltip title="Edit Grandma Source Status" placement="left">
<IconButton
variant="outlined"
size="small"
onClick={() => setOpen(true)}
>
<EditIcon fontSize="small" />
</IconButton>
</Tooltip>
<Dialog open={open} onClose={() => setOpen(false)} maxWidth="md" fullWidth>
<DialogTitle disableTypography style={ {display: 'flex', justifyContent: 'space-between', alignItems: 'center', height: '4rem'} }>
<h3>Edit Grandma Source Status</h3>
<IconButton onClick={() => setOpen(false)}>
<CloseIcon />
</IconButton>
</DialogTitle>
<Divider />
<DialogContent>
<div style={ {display: 'grid', gridTemplateColumns: '1fr 1fr', gridGap: '1rem'} }>
<div style={ {display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(260px, 1fr))', gridGap: '1rem'} }>
<div>
<h3>
Classification Status of {source?.obj_id}
Classification Status
</h3>
<div style={ {display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gridGap: '1rem'} }>

{confirmed_classes.map((c) => (
<Button
key={c}
Expand Down Expand Up @@ -150,33 +164,24 @@ const SourceStatus = ({ source }) => {
</div>
<div>
<h3>
Source Observation Status
Observation Status
</h3>
<div style={ {display: 'grid', gridTemplateColumns: '1fr', gridGap: '1rem'} }>
{obs_status.map((c) => (
<Button
key={c}
variant="outlined"
size="small"
onClick={() => {
changeSourceObsStatus(c);
}}
>
{c}
</Button>
))}
<Button
key={c}
variant="outlined"
size="small"
onClick={() => {
changeSourceObsStatus(c);
}}
>
{c}
</Button>
))}
</div>
</div>
</div>
<Button
variant="contained"
color="primary"
onClick={() => {
setOpen(false);
}}
>
Close
</Button>
</DialogContent>
</Dialog>
</div>
Expand Down
4 changes: 0 additions & 4 deletions extensions/skyportal/static/js/ducks/sourcestatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ export const REFRESH_SOURCE = "skyportal/REFRESH_SOURCE";

const ADD_CLASSIFICATION = "skyportal/ADD_CLASSIFICATION";

const DELETE_CLASSIFICATION = "skyportal/DELETE_CLASSIFICATION";

const UPDATE_SOURCE = "skyportal/UPDATE_SOURCE";

export function updateStatus(formData) {
return API.POST(`/api/classification`, ADD_CLASSIFICATION, formData);
}
Expand Down
2 changes: 1 addition & 1 deletion skyportal

0 comments on commit 117e683

Please sign in to comment.