-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
829541c
commit e46dc76
Showing
1 changed file
with
78 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
|
@@ -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; | ||
}); | ||
|
@@ -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; | ||
} | ||
|
@@ -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]; | ||
} | ||
|
@@ -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); | ||
|
@@ -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; | ||
}; | ||
|
@@ -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"> | ||
<recording-info-dialog :id="id" @close="recordingInfo = false" /> | ||
Check warning on line 272 in client/src/views/Spectrogram.vue
|
||
</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" | ||
|
@@ -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> | ||
|
@@ -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"> | ||
<div> | ||
<b>xScale:</b> | ||
<span v-if="timeRef >= 0">{{ scaledVals.x.toFixed(2) }}x</span> | ||
|
@@ -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
|
||
<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" | ||
> | ||
|
@@ -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> | ||
|