diff --git a/client/src/components/AnnotationEditor.vue b/client/src/components/AnnotationEditor.vue index 1245061..5321a3a 100644 --- a/client/src/components/AnnotationEditor.vue +++ b/client/src/components/AnnotationEditor.vue @@ -28,13 +28,13 @@ export default defineComponent({ emits: ['update:annotation', 'delete:annotation'], setup(props, { emit }) { const speciesList = computed(() => { - return props.species.map((item) => (item.common_name)); + return props.species.map((item) => (item.species_code || item.common_name)).sort(); }); - const speciesEdit: Ref = ref( props.annotation?.species?.map((item) => item.common_name) || []); + const speciesEdit: Ref = ref( props.annotation?.species?.map((item) => item.species_code || item.common_name) || []); const comments: Ref = ref(props.annotation?.comments || ''); watch(() => props.annotation, () => { if (props.annotation?.species) { - speciesEdit.value = props.annotation.species.map((item) => item.common_name); + speciesEdit.value = props.annotation.species.map((item) => item.species_code || item.common_name); } if (props.annotation?.comments) { comments.value = props.annotation.comments; @@ -91,7 +91,7 @@ export default defineComponent({ - , default: null, }, - mode: { - type: String as PropType<'creation' | 'editing' | 'disabled'>, - required: true, - } }, emits: ['select'], setup(props) { @@ -58,7 +54,7 @@ export default defineComponent({ Annotations Addmdi-plus diff --git a/client/src/components/SpectrogramViewer.vue b/client/src/components/SpectrogramViewer.vue index 17d7e2b..4681b79 100644 --- a/client/src/components/SpectrogramViewer.vue +++ b/client/src/components/SpectrogramViewer.vue @@ -48,7 +48,6 @@ export default defineComponent({ "selected", "geoViewerRef", "hoverData", - "set-mode", ], setup(props, { emit }) { const containerRef: Ref = ref(); @@ -221,7 +220,6 @@ export default defineComponent({ @update:annotation="updateAnnotation($event)" @create:annotation="createAnnotation($event)" @set-cursor="setCursor($event)" - @set-mode="$emit('set-mode', $event)" />
{ // Will handle clicking, selecting and editing here if (type === "update:mode") { - emit("set-mode", data.mode); setAnnotationState(data.mode); } if (type === "update:cursor") { @@ -263,7 +262,7 @@ export default defineComponent({ editAnnotationLayer.getMode() === "disabled" && props.selectedId === null ) { - emit("set-mode", "disabled"); + annotationState.value === 'disabled'; editAnnotationLayer.featureLayer.clear(); } }); diff --git a/client/src/use/useState.ts b/client/src/use/useState.ts index 888ba4e..1ef1b21 100644 --- a/client/src/use/useState.ts +++ b/client/src/use/useState.ts @@ -9,7 +9,7 @@ const colorScale: Ref | undefined> = ref( const selectedUsers: Ref = ref([]); const currentUser: Ref = ref(''); -type AnnotationState = "" | "editing" | "creating"; +type AnnotationState = "" | "editing" | "creating" | "disabled"; export default function useState() { const setAnnotationState = (state: AnnotationState) => { annotationState.value = state; diff --git a/client/src/views/Spectrogram.vue b/client/src/views/Spectrogram.vue index e08be3e..b023ce1 100644 --- a/client/src/views/Spectrogram.vue +++ b/client/src/views/Spectrogram.vue @@ -38,6 +38,7 @@ export default defineComponent({ setSelectedUsers, createColorScale, currentUser, + annotationState, } = useState(); const image: Ref = ref(new Image()); const spectroInfo: Ref = ref(); @@ -49,7 +50,6 @@ export default defineComponent({ const loadedImage = ref(false); const compressed = ref(false); const gridEnabled = ref(false); - const mode: Ref<"creation" | "editing" | "disabled"> = ref("disabled"); const getAnnotationsList = async (annotationId?: number) => { const response = await getAnnotations(props.id); annotations.value = response.data.sort((a, b) => a.start_time - b.start_time); @@ -128,10 +128,6 @@ export default defineComponent({ }; watch(compressed, () => loadData()); - const setMode = (newMode: "creation" | "editing" | "disabled") => { - mode.value = newMode; - }; - const keyboardEvent = (e: KeyboardEvent) => { if (e.key === "ArrowDown") { selectNextIndex(1); @@ -158,6 +154,7 @@ export default defineComponent({ }); return { + annotationState, compressed, loadedImage, image, @@ -168,7 +165,6 @@ export default defineComponent({ getAnnotationsList, setParentGeoViewer, setHoverData, - setMode, toggleLayerVisibility, speciesList, selectedAnnotation, @@ -177,7 +173,6 @@ export default defineComponent({ layerVisibility, timeRef, freqRef, - mode, // Other user selection otherUserAnnotations, otherUsers, @@ -193,123 +188,128 @@ export default defineComponent({ - - -
- Time: - {{ timeRef.toFixed(0) }}ms -
-
- Frequency: - {{ freqRef.toFixed(2) }}KHz -
-
- - Mode: - {{ mode }} - - - + + +
+ Time: + {{ timeRef.toFixed(0) }}ms +
+
+ Frequency: + {{ freqRef.toFixed(2) }}KHz +
+
+ +
+ Mode: + {{ annotationState }} +
+
+ -