Skip to content

Commit

Permalink
fix-presigned url
Browse files Browse the repository at this point in the history
  • Loading branch information
BryonLewis committed May 2, 2024
1 parent 829541c commit e46dc76
Showing 1 changed file with 78 additions and 46 deletions.
124 changes: 78 additions & 46 deletions client/src/views/Spectrogram.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<script lang="ts">
import { computed, defineComponent, onMounted, onUnmounted, Ref, ref, watch } from "vue";
import {
computed,
defineComponent,
onMounted,
onUnmounted,
Ref,
ref,
watch,
} from "vue";
import {
getSpecies,
getAnnotations,
Expand Down Expand Up @@ -57,16 +65,22 @@ export default defineComponent({
const recordingInfo = ref(false);
const getAnnotationsList = async (annotationId?: number) => {
const response = await getAnnotations(props.id);
annotations.value = response.data.sort((a, b) => a.start_time - b.start_time);
annotations.value = response.data.sort(
(a, b) => a.start_time - b.start_time
);
const tempResp = await getTemporalAnnotations(props.id);
temporalAnnotations.value = tempResp.data.sort((a, b) => a.start_time - b.start_time);
temporalAnnotations.value = tempResp.data.sort(
(a, b) => a.start_time - b.start_time
);
if (annotationId !== undefined) {
selectedId.value = annotationId;
}
};
const selectedIndex = computed(() => {
if (annotations.value && selectedId.value !== null) {
return annotations.value.findIndex((item) => item.id === selectedId.value);
return annotations.value.findIndex(
(item) => item.id === selectedId.value
);
}
return -1;
});
Expand All @@ -88,18 +102,29 @@ export default defineComponent({
const response = compressed.value
? await getSpectrogramCompressed(props.id)
: await getSpectrogram(props.id);
if (response.data['url']) {
image.value.src = response.data['url'];
if (response.data["url"]) {
const updateHost = `${window.location.protocol}//${window.location.hostname}/`;
const updatedURL = response.data["url"].replace(
"http://127.0.0.1:9000/",
updateHost
);
image.value.src = updatedURL.split("?")[0];
} else {
// TODO Error Out if there is no URL
console.error('No URL found for the spectrogram');
console.error("No URL found for the spectrogram");
}
image.value.onload = () => {
loadedImage.value = true;
};
spectroInfo.value = response.data["spectroInfo"];
annotations.value = response.data["annotations"]?.sort((a, b) => a.start_time - b.start_time) || [];
temporalAnnotations.value = response.data["temporal"]?.sort((a, b) => a.start_time - b.start_time) || [];
annotations.value =
response.data["annotations"]?.sort(
(a, b) => a.start_time - b.start_time
) || [];
temporalAnnotations.value =
response.data["temporal"]?.sort(
(a, b) => a.start_time - b.start_time
) || [];
if (response.data.currentUser) {
currentUser.value = response.data.currentUser;
}
Expand All @@ -116,14 +141,26 @@ export default defineComponent({
selectedId.value = annotationId;
};
const selectedAnnotation = computed(() => {
if (selectedId.value !== null && selectedType.value === 'pulse' && annotations.value) {
const found = annotations.value.findIndex((item) => item.id === selectedId.value);
if (
selectedId.value !== null &&
selectedType.value === "pulse" &&
annotations.value
) {
const found = annotations.value.findIndex(
(item) => item.id === selectedId.value
);
if (found !== -1) {
return annotations.value[found];
}
}
if (selectedId.value !== null && selectedType.value === 'sequence' && temporalAnnotations.value) {
const found = temporalAnnotations.value.findIndex((item) => item.id === selectedId.value);
if (
selectedId.value !== null &&
selectedType.value === "sequence" &&
temporalAnnotations.value
) {
const found = temporalAnnotations.value.findIndex(
(item) => item.id === selectedId.value
);
if (found !== -1) {
return temporalAnnotations.value[found];
}
Expand All @@ -133,9 +170,12 @@ export default defineComponent({
watch(gridEnabled, () => {
toggleLayerVisibility("grid");
});
watch(() => props.id, () => {
loadData();
});
watch(
() => props.id,
() => {
loadData();
}
);
onMounted(() => loadData());
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const parentGeoViewerRef: Ref<any> = ref(null);
Expand Down Expand Up @@ -169,15 +209,23 @@ export default defineComponent({
const otherUsers = computed(() => Object.keys(otherUserAnnotations.value));
const deleteChip = (item: string) => {
selectedUsers.value.splice(selectedUsers.value.findIndex((data) => data === item));
selectedUsers.value.splice(
selectedUsers.value.findIndex((data) => data === item)
);
setSelectedUsers(selectedUsers.value);
};
watch(selectedUsers, () => {
setSelectedUsers(selectedUsers.value);
});
const processSelection = ({id, annotationType}: { id: number, annotationType: 'pulse' | 'sequence'}) => {
const processSelection = ({
id,
annotationType,
}: {
id: number;
annotationType: "pulse" | "sequence";
}) => {
selectedId.value = id;
selectedType.value = annotationType;
};
Expand Down Expand Up @@ -220,23 +268,14 @@ export default defineComponent({

<template>
<v-row>
<v-dialog
v-model="recordingInfo"
width="600"
>
<recording-info-dialog
:id="id"
@close="recordingInfo = false"
/>
<v-dialog v-model="recordingInfo" width="600">

Check warning on line 271 in client/src/views/Spectrogram.vue

View workflow job for this annotation

GitHub Actions / Lint [eslint]

'width' should be on a new line
<recording-info-dialog :id="id" @close="recordingInfo = false" />

Check warning on line 272 in client/src/views/Spectrogram.vue

View workflow job for this annotation

GitHub Actions / Lint [eslint]

'@close' should be on a new line
</v-dialog>
<v-col>
<v-toolbar>
<v-container>
<v-row align="center">
<v-tooltip

bottom
>
<v-tooltip bottom>
<template #activator="{ props: subProps }">
<v-icon
v-bind="subProps"
Expand All @@ -246,11 +285,9 @@ export default defineComponent({
mdi-information-outline
</v-icon>
</template>
<span>
Recording Information
</span>
<span> Recording Information </span>
</v-tooltip>

<v-col cols="2">
<div>
<b>Time:</b>
Expand All @@ -261,10 +298,7 @@ export default defineComponent({
<span v-if="freqRef >= 0">{{ freqRef.toFixed(2) }}KHz</span>
</div>
</v-col>
<v-col
v-if="scaledVals.x > 1 || scaledVals.y > 1"
cols="2"
>
<v-col v-if="scaledVals.x > 1 || scaledVals.y > 1" cols="2">

Check warning on line 301 in client/src/views/Spectrogram.vue

View workflow job for this annotation

GitHub Actions / Lint [eslint]

'cols' should be on a new line
<div>
<b>xScale:</b>
<span v-if="timeRef >= 0">{{ scaledVals.x.toFixed(2) }}x</span>
Expand All @@ -275,18 +309,16 @@ export default defineComponent({
</div>
</v-col>

<v-col
cols="1"
class="px-0"
style="font-size: 20px"
>
<div v-if="annotationState !== '' && annotationState !== 'disabled'">
<v-col cols="1" class="px-0" style="font-size: 20px">

Check warning on line 312 in client/src/views/Spectrogram.vue

View workflow job for this annotation

GitHub Actions / Lint [eslint]

'class' should be on a new line

Check warning on line 312 in client/src/views/Spectrogram.vue

View workflow job for this annotation

GitHub Actions / Lint [eslint]

'style' should be on a new line
<div
v-if="annotationState !== '' && annotationState !== 'disabled'"
>
<b>Mode:</b>
<span> {{ annotationState }}</span>
</div>
</v-col>
<v-col
v-if="otherUsers.length && colorScale"
v-if="otherUsers.length && colorScale"
cols="3"
class="ma-0 pa-0 pt-5"
>
Expand All @@ -309,7 +341,7 @@ export default defineComponent({
text-color="gray"
@click:close="deleteChip(item.value)"
>
{{ item.value.replace(/@.*/, '') }}
{{ item.value.replace(/@.*/, "") }}
</v-chip>
</template>
</v-select>
Expand Down

0 comments on commit e46dc76

Please sign in to comment.