diff --git a/browse-next/src/components/CardTable.vue b/browse-next/src/components/CardTable.vue index a6ac6b57..025895ae 100644 --- a/browse-next/src/components/CardTable.vue +++ b/browse-next/src/components/CardTable.vue @@ -51,7 +51,7 @@ v-bind="{ cell, row: sortedItems[rowIndex] }" > diff --git a/browse-next/src/components/RecordingViewLabels.vue b/browse-next/src/components/RecordingViewLabels.vue index fd8604b2..fe066692 100644 --- a/browse-next/src/components/RecordingViewLabels.vue +++ b/browse-next/src/components/RecordingViewLabels.vue @@ -9,7 +9,13 @@ import { CurrentUser } from "@models/LoggedInUser"; import type { TagId } from "@typedefs/api/common"; import CardTable from "@/components/CardTable.vue"; import { DateTime } from "luxon"; -import { RecordingLabels } from "@/consts"; +import { + AudioRecordingLabels, + CameraRecordingLabels, + CommonRecordingLabels, +} from "@/consts"; +import type { RecordingLabel } from "@typedefs/api/group"; +import { RecordingType } from "@typedefs/api/consts.ts"; const props = withDefaults( defineProps<{ @@ -28,7 +34,7 @@ const tableItems = computed>( return (props.recording?.tags || []).map( (tag: ApiRecordingTagResponse) => ({ label: - labels.find((label) => label.value === tag.detail)?.text || + labels.value.find((label) => label.value === tag.detail)?.text || tag.detail, by: tag.taggerName || (tag.automatic ? "Cacophony AI" : "-"), when: DateTime.fromJSDate(new Date(tag.createdAt)).toRelative({ @@ -41,31 +47,54 @@ const tableItems = computed>( } ); -interface Label { - text: string; - value: string; - description: string; -} - // TODO - Group-level defined labels created by group admin. -const labels: Label[] = RecordingLabels.map(({ text, description, value }) => ({ - text, - description, - value: (value || text).toLowerCase(), -})); + +const cameraLabels = computed(() => { + return [...CommonRecordingLabels, ...CameraRecordingLabels].map( + ({ text, description, value }) => ({ + text: text, + description, + value: (value || text).toLowerCase(), + }) + ); +}); +const audioLabels = computed(() => { + return [...CommonRecordingLabels, ...AudioRecordingLabels].map( + ({ text, description, value }) => + ({ + text: text, + description, + value: (value || text).toLowerCase(), + } as RecordingLabel) + ); +}); + +const labels = computed(() => { + if (recordingTypeIsAudio.value) { + return audioLabels.value; + } + return cameraLabels.value; +}); + +const recordingTypeIsAudio = computed(() => { + if (props.recording) { + return props.recording.type === RecordingType.Audio; + } + return false; +}); const unusedLabels = computed(() => { // Filter out labels that have already been added - return labels.filter( + return labels.value.filter( (label) => !props.recording?.tags.some((tag) => tag.detail === label.value) ); }); const selectedLabel = ref(""); -const labelToAdd = computed