Skip to content

Commit

Permalink
adding auth and release info to various api calls (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
havok2063 authored Jan 24, 2025
1 parent 82bcd93 commit f0a264f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/components/ConeSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ async function callApi(ra: string, dec: string, { radius, units }: { radius: num
// turn on loading flag
loading.value = true;
const endpoint = import.meta.env.VITE_API_URL + `/query/cone?ra=${ra}&dec=${dec}&radius=${radius}&units=${units}`
await axios.get(endpoint)
const endpoint = import.meta.env.VITE_API_URL + `/query/cone?ra=${ra}&dec=${dec}&radius=${radius}&units=${units}&release=${store.release}`;
await axios.get(endpoint, {headers: store.get_auth_hdr()})
.then(response => {
// Handle the response data
Expand Down
8 changes: 6 additions & 2 deletions src/components/ParentCatalog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
<script setup lang="ts">
import { ref, defineProps } from 'vue';
import axiosInstance from '@/axios'
import { useAppStore } from '@/store/app'
// get the application state store
const store = useAppStore()
// define which properties are passed in from the parent, i.e. ":xxx"
const props = defineProps<{
Expand Down Expand Up @@ -130,7 +134,7 @@ async function getParentCatalogData() {
// Populate table data with parent catalog info for the given sdssid and catalog name
// resolve the target coordinates using the valis endpoint
const url = `/target/parents/${selected_catalog.value}/${props.sdssid}?catalogid=${props.catalogid}`;
const url = `/target/parents/${selected_catalog.value}/${props.sdssid}?catalogid=${props.catalogid}&release=${store.release}`;
// use local cache if available
// temporary cache per target page load
Expand All @@ -142,7 +146,7 @@ async function getParentCatalogData() {
}
// fetch the parent catalog data
await axiosInstance.get(url)
await axiosInstance.get(url, {headers: store.get_auth_hdr()})
.then((response) => {
// convert response data to an array of objects for the data table; object keys match header field "key"
let data = Object.entries(response.data[0]).map((item)=> ({parameter: item[0], value: item[1]}))
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReleaseSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function get_releases() {
// remove the MPLs and work release
let rels = response.data.filter((rel: string) => !rel.startsWith("M") && !rel.startsWith("W")).reverse()
// remove the older DRs for now; update this to only DR19 once it's available
rels = rels.filter((rel: string) => rel.startsWith("DR") ? parseInt(rel.slice(2)) >= 18 : rel)
rels = rels.filter((rel: string) => rel.startsWith("DR") ? parseInt(rel.slice(2)) >= 19 : rel)
// filter out all IPL except IPL3 from rels
rels = rels.filter((rel: string) => rel.startsWith("IPL") ? rel.endsWith("3") : rel)
// store the releases and check for selection
Expand Down
5 changes: 4 additions & 1 deletion src/components/Solara.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
import axios from 'axios'
import { ref, onMounted, watch } from 'vue'
import { useTheme } from 'vuetify'
import { useAppStore } from '@/store/app'
// get the application state store
const store = useAppStore()
// define which properties are passed in from the parent, i.e. ":xxx"
const props = defineProps<{
Expand All @@ -30,7 +33,7 @@ let valid = ref(false)
let errmsg = ref('')
let theme = useTheme()
let url = ref(import.meta.env.VITE_API_URL + `/solara/embed/?release=IPL3&sdssid=${props.sdssid}&files=${props.files.join()}&theme=${theme.global.name.value}`)
let url = ref(import.meta.env.VITE_API_URL + `/solara/embed/?release=${store.release}&sdssid=${props.sdssid}&files=${props.files.join()}&theme=${theme.global.name.value}`)
console.log('url', url)
async function check_solara() {
Expand Down
4 changes: 2 additions & 2 deletions src/views/Explore.vue
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ function get_hipscat(item) {
async function coneSearch(ra: string, dec: string, radius: number, units: string): Promise<void> {
// perform the cone search API call
const endpoint = `/query/cone?ra=${ra}&dec=${dec}&radius=${radius}&units=${units}`
await axiosInstance.get(endpoint)
const endpoint = `/query/cone?ra=${ra}&dec=${dec}&radius=${radius}&units=${units}&release=${store.release}`
await axiosInstance.get(endpoint, {headers: store.get_auth_hdr()})
.then(response => {
// Handle the response data
// if no results, do nothing
Expand Down
4 changes: 3 additions & 1 deletion src/views/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,10 @@ async function submit_form(this: any) {
[formData.value.ra, formData.value.dec] = extract_coords(formData.value.coords)
console.log('submitting', formData.value)
let hdr1 = {'Content-Type': 'application/json'}
let hdr = {...hdr1, ...store.get_auth_hdr()}
await axiosInstance.post('/query/main',
formData.value, {headers: {'Content-Type': 'application/json'}})
formData.value, {headers: hdr })
.then((response) => {
// handle the initial response
console.log(response)
Expand Down
12 changes: 6 additions & 6 deletions src/views/Target.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,18 @@ let headmeta = [
async function get_target_info() {
console.time('Info Time');
let rel = "IPL3"
//let rel = "IPL3"
// set up API call endpoints
let endpoints = [
`/target/ids/${sdss_id}?release=${rel}`,
`/target/cartons/${sdss_id}?release=${rel}`,
`/target/catalogs/${sdss_id}?release=${rel}`,
`/target/pipelines/${sdss_id}?release=${rel}`
`/target/ids/${sdss_id}?release=${store.release}`,
`/target/cartons/${sdss_id}?release=${store.release}`,
`/target/catalogs/${sdss_id}?release=${store.release}`,
`/target/pipelines/${sdss_id}?release=${store.release}`
]
// await the promises
await Promise.all(endpoints.map((endpoint) => axiosInstance.get(endpoint)))
await Promise.all(endpoints.map((endpoint) => axiosInstance.get(endpoint, {headers: store.get_auth_hdr()})))
.then(([{data: target}, {data: cartons}, {data: catalogs}, {data: pipes}] )=> {
console.log({ target, cartons, catalogs, pipes })
loading.value = false
Expand Down

0 comments on commit f0a264f

Please sign in to comment.