-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRecordingList.vue
More file actions
195 lines (185 loc) · 5.54 KB
/
RecordingList.vue
File metadata and controls
195 lines (185 loc) · 5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<script lang="ts">
import { defineComponent, ref, Ref, onMounted, computed } from 'vue';
import { FileAnnotation, getRecordings, Recording, Species } from '../api/api';
import useState from '@use/useState';
import { EditingRecording } from './UploadRecording.vue';
export default defineComponent({
setup() {
const {
sharedList,
recordingList,
currentUser,
configuration,
showSubmittedRecordings,
myRecordingsDisplay,
sharedRecordingsDisplay,
} = useState();
const editingRecording: Ref<EditingRecording | null> = ref(null);
const fetchRecordings = async () => {
const recordings = await getRecordings();
recordingList.value = recordings.data;
const shared = await getRecordings(true);
sharedList.value = shared.data;
};
onMounted(() => fetchRecordings());
const openPanel = ref(1);
const filtered = ref(true);
const modifiedList = computed(() => {
if (filtered.value) {
return sharedList.value.filter((item) => !item.userMadeAnnotations);
}
return sharedList.value;
});
const userSubmittedAnnotation = (recording: Recording) => {
const userSubmittedAnnotations = recording.fileAnnotations.filter((annotation: FileAnnotation) => (
annotation.owner === currentUser.value && annotation.submitted
));
if (userSubmittedAnnotations.length === 0 || userSubmittedAnnotations[0].species.length === 0) {
return undefined;
}
return userSubmittedAnnotations[0].species.map((specie: Species) => specie.species_code).join(', ');
};
return {
recordingList,
sharedList,
modifiedList,
filtered,
editingRecording,
openPanel,
userSubmittedAnnotation,
configuration,
myRecordingsDisplay,
sharedRecordingsDisplay,
showSubmittedRecordings,
};
},
});
</script>
<template>
<v-expansion-panels v-model="openPanel">
<v-col v-if="configuration.mark_annotations_completed_enabled">
<v-row>
<v-col>
<v-checkbox
v-model="showSubmittedRecordings"
label="Show submitted recordings"
hide-details
/>
</v-col>
</v-row>
</v-col>
<v-expansion-panel>
<v-expansion-panel-title>My Recordings</v-expansion-panel-title>
<v-expansion-panel-text>
<div
v-for="item in myRecordingsDisplay"
:key="`public_${item.id}`"
>
<v-card class="pa-2 my-2">
<v-row dense>
<v-col class="text-left">
<b>Name:</b><router-link
:to="`/recording/${item.id.toString()}/spectrogram`"
>
{{ item.name }}
</router-link>
</v-col>
</v-row>
<v-row dense>
<v-col>
<b>Public:</b>
<v-icon
v-if="item.public"
color="success"
>
mdi-check
</v-icon>
<v-icon
v-else
color="error"
>
mdi-close
</v-icon>
</v-col>
<v-col>
<div>
<b class="pr-1">Annotations:</b>{{ item.userAnnotations }}
</div>
</v-col>
</v-row>
<v-row
v-if="configuration.mark_annotations_completed_enabled && userSubmittedAnnotation(item)"
dense
>
<v-col>
<b>My label: </b>
<span>{{ userSubmittedAnnotation(item) }}</span>
</v-col>
</v-row>
</v-card>
</div>
</v-expansion-panel-text>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-title>Public</v-expansion-panel-title>
<v-expansion-panel-text class="ma-0 pa-0">
<v-switch
v-model="filtered"
label="Filter Annotated"
dense
/>
<div
v-for="item in modifiedList"
:key="`public_${item.id}`"
>
<v-card class="pa-2 my-2">
<v-row dense>
<v-col class="text-left">
<b class="pr-1">Name:</b>
<router-link
:to="`/recording/${item.id.toString()}/spectrogram`"
>
{{ item.name }}
</router-link>
</v-col>
</v-row>
<v-row dense>
<v-col>
<div style="font-size:0.75em">
<b>Owner:</b> {{ item.owner_username }}
</div>
</v-col>
</v-row>
<v-row dense>
<v-col>
<div>
<b>Annotated:</b>
<v-icon
v-if="item.userMadeAnnotations"
color="success"
>
mdi-check
</v-icon>
<v-icon
v-else
color="error"
>
mdi-close
</v-icon>
</div>
</v-col>
</v-row>
</v-card>
</div>
</v-expansion-panel-text>
</v-expansion-panel>
</v-expansion-panels>
</template>
<style scoped>
.v-expansion-panel-text>>> .v-expansion-panel-text__wrap {
padding: 0 !important;
}
.v-expansion-panel-text__wrapper {
padding: 0 !important;
}
</style>