Skip to content

FIREFLY-1935: Alert Viewer#1917

Merged
kpuriIpac merged 1 commit intodevfrom
FIREFLY-1935-alert-viewer
Mar 26, 2026
Merged

FIREFLY-1935: Alert Viewer#1917
kpuriIpac merged 1 commit intodevfrom
FIREFLY-1935-alert-viewer

Conversation

@kpuriIpac
Copy link
Copy Markdown
Contributor

@kpuriIpac kpuriIpac commented Mar 3, 2026

Ticket: https://jira.ipac.caltech.edu/browse/FIREFLY-1935

  • Implement Alert Viewer template
  • Improved server side logic by adding a search processor based on feedback
  • The processor retrieves & downloads the file, and then uses the existing AlertAnalyzer, then returns the parts (2 tables and 3 images) back to client as JSON
    • each JSON entry also includes the file location, in case we support multiple (more than one) files later
  • This in turn simplifies the client-side code inside AlertUploadPanel
  • Using the same viewerId and only one call to MultiImageViewer for images now
  • ToDo: some basic cleanup left to do including fixing heights of the 2 tables
  • Note: The search processor currently only supports URLs, but I have some commented out code (marked with a todo) ready to accept Alert IDs as well. This should be pretty easy to enable once we have working examples of Alert IDs (and the service to call with those IDs).

Test build: Alert Viewer: https://fireflydev.ipac.caltech.edu/firefly-1935-alert-viewer/firefly/alertviewer

@kpuriIpac kpuriIpac self-assigned this Mar 3, 2026
@kpuriIpac kpuriIpac force-pushed the FIREFLY-1935-alert-viewer branch 6 times, most recently from 41c2af3 to cf5a5a3 Compare March 11, 2026 22:27
@kpuriIpac kpuriIpac requested a review from loitly March 11, 2026 22:30
Copy link
Copy Markdown
Contributor

@loitly loitly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UI still needs some polishing, which is expected. Moving the logic to the server side is a good improvement. I think we should talk offline to fully flesh out what the new interface should look like.
@robyww should review the multiProduct changes.

Comment thread src/firefly/html/alertviewer.html Outdated
<title>Alert Viewer</title>

<script>
var pOpts = window.firefly && window.firefly.options || {};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used.

}}>

{/* Top: tables */}
<Box sx={{display: 'flex', flex: '1 1 0%', gap: 1, p: 1, overflow: 'hidden', minHeight: 0, minWidth: 0,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is Box with display=flex used throughout? Would it be easier to use Stack?

isFromURL={true}
canDragDrop={false}
fileAnalysis={onLoading}
uploadParams={{analyzerId: 'alert'}} //triggers server alert analyzer
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly what I had in mind, but I could be wrong. Let's talk offline.

onChange: (ev) => onUrlChange(ev, viewProps, fireValueChange),
value: viewProps.displayValue,
onUrlAnalysis: (value) => doUrlAnalysis(value, fireValueChange, fileType, viewProps.fileAnalysis)
onUrlAnalysis: (value) => doUrlAnalysis(value, fireValueChange, fileType, viewProps.fileAnalysis, viewProps.uploadParams)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could be done without having to change FileUpload.

@kpuriIpac kpuriIpac force-pushed the FIREFLY-1935-alert-viewer branch 3 times, most recently from ddc105d to 97be20a Compare March 19, 2026 20:32
@kpuriIpac kpuriIpac marked this pull request as ready for review March 19, 2026 20:33
@kpuriIpac kpuriIpac requested a review from robyww March 19, 2026 20:55
@robyww
Copy link
Copy Markdown
Contributor

robyww commented Mar 20, 2026

@kpuriIpac I brought up the test. The alert tab does not appear to be enabled.

@kpuriIpac
Copy link
Copy Markdown
Contributor Author

Copy link
Copy Markdown
Contributor

@robyww robyww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Mostly UI feedback with a couple of code comments. I will look at the code more on Monday.)

UI Feedback:

  • I think you should use the DockLayoutPanel for the three views. I think it is pretty each to use since it does layout this way by default. See line 67 of ResultsPanel.jsx
  • pad the right side table down so it better aligns with the left side table
  • remove Scroll Images: Create a prompt on MultiViewStandardToolbar to disable this features. The toolbar get all the props passed to MultiImageViewer.

Comment on lines +51 to +52
? {flex: '1 1 0%', minHeight: 0, height: '100%', maxWidth: '100%', overflow: 'hidden'}
: {width: '100%', height: '100%'};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprise this change was necessary.

)}
</Box>

<Box sx={{flex: '1 1 0%', overflow: 'hidden', minHeight: 0, minWidth: 0}}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also I wee you adding minHeight:0, minWidth: 0. I don't see why this is necessary.


return (
<Stack width={1} alignItems='center'>
<Stack ml={0} mt={4} spacing={3} sx={{position: 'relative'}}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ml=0?
also since youu are declaring a sx you should put the style in there.

viewerId={ALERT.IMG_VIEWER}
insideFlex={true}
forceRowSize={1}
Toolbar={MultiViewStandardToolbar}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the prop for MultiViewStandardToolbar here

@kpuriIpac kpuriIpac force-pushed the FIREFLY-1935-alert-viewer branch 6 times, most recently from 518377d to 0a657fa Compare March 24, 2026 01:06
@kpuriIpac
Copy link
Copy Markdown
Contributor Author

@robyww I implemented the feedback, using DockLayoutPanel now, and cleaned up the styling a lot (unnecessary use of Box, some minHeight / minWidth - lot of it left over from my initial work & testing to make the layout work, but not really required).

One UI bug that I tried to fix today but couldn't: When you expand images (full screen) and Close the expanded mode, the images don't render (but you still see the images toolbar). If you interact with either the toolbar or either one of the tables, the images show up again. Trying to put in a fix for this soon. But otherwise the code is ready for review. Test build updated.

Copy link
Copy Markdown
Contributor

@robyww robyww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks really good! After you address my comments I think it is ready to merge.

Code

I left several clean up comments. They should be quick to address.

UI

  • I think the top right is 1 pixel too high
  • The tab should be call Alert not Upload
  • AlertIDDialog.jsx title should be Recent Alerts
  • The working mask needs to be cleaned up. It is offset.

Comment on lines +54 to +59
if (!imageViewerId || !dataProductsState) return;
const pv= getActivePlotView(visRoot());
if (!pv || !hasImageCubes(pv) || cubeIdx<0) return;
showingStatus.oldWhatToShow= whatToShow;
showingStatus.cubeSet= false;
}, [whatToShow,cubeIdx]);
}, [whatToShow,cubeIdx,dataProductsState]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to add dataProductsState here. This effect should be fine if it is undefined.

Also making it dependent on dataProductsState means the effect will run too much in the normal use case.

const newPrimeIdx= convertHDUIdxToImageIdx(pv,hduIdx,cubeIdx) ?? 0;
if (primeIdx!==newPrimeIdx) dispatchChangePrimePlot({plotId:pv.plotId,primeIdx:newPrimeIdx});
}, [table,primeIdx,cubeIdx]);
}, [table,primeIdx,cubeIdx,dataProductsState]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

}

return (
<Stack direction='row' flexGrow={1} overflow='hidden'>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think the overflow is necessary here

function EmptySlot({label}) {
return (
<Sheet variant='outlined'
sx={{height: 1, display: 'flex', alignItems: 'center', justifyContent: 'center', gcolor: 'background.level1'}}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have never seen this? should this be here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this was a typo, also not needed. Removed.


return (
<Stack width={1} alignItems='center'>
<Stack spacing={3} sx={{position: 'relative', mt: 4}}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

often position: 'relative' is used when there is an absolute inside of it. It does not appear to be necessary.

File tmpFits = File.createTempFile("alert-", ".fits");
FileInfo fileInfo = URLDownload.getDataToFile(serviceUrl, tmpFits);
*/
FileInfo fileInfo = LockingRetrieve.downloadWithCacheMsg(source);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should check the status in fileInfo

@kpuriIpac
Copy link
Copy Markdown
Contributor Author

kpuriIpac commented Mar 24, 2026

@robyww I added a fix for images not rendering when closing expanded mode:

  • closing expanded mode led to image plots coming back with stale plot sizing, I think. The image plots did not get an updated viewDim, so the tiles stayed blank until any interaction triggered a layout refresh.
  • I thought about checking to see if a fix was possible in ImageViewerLayout when we call dispatchUpdateViewSize, but I think that is working like it's supposed to (which is why we don't see this problem elsewhere on firefly)
    • The reason I think this happened here is because alert viewer renders MultiImageViewer directly in our custom results view, and may be missing an extra layout refresh that happens for standard Firefly images (like for TriView as an example)
  • The useEffect i added fixes that by running when the results view returns to default mode (after closing expanded mode) and explicitly calling dispatchUpdateViewSize(plotId, width, height)

Test build updated to test this fix: https://fireflydev.ipac.caltech.edu/firefly-1935-alert-viewer/firefly

I will address the rest of the feedback now.

}
},
menu: [
{label:'Upload', action: 'AlertUpload', path:'/upload'},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line should have primary: true

@kpuriIpac kpuriIpac force-pushed the FIREFLY-1935-alert-viewer branch from e2711a3 to e85ac0d Compare March 25, 2026 19:23
@kpuriIpac
Copy link
Copy Markdown
Contributor Author

@robyww I addressed the rest of your feedback (including the one in useStoreConnector we discussed on slack). Can you take a look? (I was also unsure about the fileInfo status check in the java file, let me know if what I added is what you meant). Test build is also updated. I think the masking is still a little off, will fix before merging.

Copy link
Copy Markdown
Contributor

@robyww robyww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Remove the ExpanededView stuff and it is ready to merge.

Comment on lines +98 to +102
if (expanded !== LO_VIEW.none) {
return (
<ExpandedView expanded={expanded}/>
);
}
Copy link
Copy Markdown
Contributor

@robyww robyww Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be removed. It is not being used

);
}

function ExpandedView({expanded}) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove ExpandedView. It is not being used.

Comment on lines +44 to +53
const nState = stateGetter(cState); // if getter returns oldState then no state update
if (nState===cState || comparator(cState, nState)) return; // comparator might be overridden, use === first for efficiency
cState = nState;
if (markAsTransition) {
startTransition(() =>{
setter(cState);
});
}
else {
setter(cState);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@kpuriIpac kpuriIpac force-pushed the FIREFLY-1935-alert-viewer branch from 81311c4 to 59418f3 Compare March 26, 2026 17:53
@kpuriIpac kpuriIpac force-pushed the FIREFLY-1935-alert-viewer branch from 59418f3 to d77417f Compare March 26, 2026 18:29
@kpuriIpac kpuriIpac merged commit 6e888d5 into dev Mar 26, 2026
@kpuriIpac kpuriIpac deleted the FIREFLY-1935-alert-viewer branch March 26, 2026 18:30
@robyww robyww added this to the 2026.1 milestone Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants