Skip to content

Commit

Permalink
works 1 way. but with so many fiddles i dont fully grasp how it works
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-stokes committed Nov 28, 2023
1 parent cb15b68 commit 4f73cd6
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/main/webui/src/targets/New.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import "./aladin.component.css";
// It is declared for the typescript checker to understand it.
declare var A: any;

// NOTE ABS: Aladin seems to be the global holder for the object that we can
// manipulate. This is different to NGOT, but at this point, ill buy anything.
declare var Aladin: any;

// the initial config for the aladin viewer.
const initialConfig = {
cooFrame: 'ICRS',
Expand Down Expand Up @@ -50,7 +54,6 @@ const initialConfig = {
* @constructor
*/
const TargetForm = (props: FormPropsType<newTargetData>): ReactElement => {
let aladin: any;
const form = useForm({
initialValues: props.initialValues ?? {
TargetName: "",
Expand Down Expand Up @@ -102,16 +105,12 @@ const TargetForm = (props: FormPropsType<newTargetData>): ReactElement => {
form.setFieldValue('SelectedEpoch', data.epoch!);
form.values.searching = false;

// acquire the aladin object.
console.log("outside aladin");
if (aladin !== null) {
console.log("inside aladin");
// @ts-ignore
Aladin.prototype.gotoRaDec(data.raDegrees, data.decDegrees);
console.log("complete aladin");
}
// acquire the aladin object and set it.
Aladin?.gotoRaDec(data.raDegrees, data.decDegrees);
})
.catch(() => notFound());
.catch((reason: any) => {
console.error(reason);
notFound()});
}

/**
Expand Down Expand Up @@ -222,7 +221,7 @@ const TargetForm = (props: FormPropsType<newTargetData>): ReactElement => {

// When the import has succeeded we store the aladin js instance
// into its component
aladin = A.aladin('#aladin-lite-div', initialConfig);
Aladin = A.aladin('#aladin-lite-div', initialConfig);

// add the catalog.
const catalogue = A.catalog({
Expand All @@ -232,7 +231,7 @@ const TargetForm = (props: FormPropsType<newTargetData>): ReactElement => {
});

// is not null, created from javascript.
aladin.addCatalog(catalogue);
Aladin.addCatalog(catalogue);

// add the overlay.
const overlay = A.graphicOverlay({
Expand All @@ -241,7 +240,7 @@ const TargetForm = (props: FormPropsType<newTargetData>): ReactElement => {
});

// is not null, created from javascript.
aladin.addOverlay(overlay);
Aladin.addOverlay(overlay);
})
}});

Expand Down

0 comments on commit 4f73cd6

Please sign in to comment.