Skip to content

Commit

Permalink
client-side updates
Browse files Browse the repository at this point in the history
  • Loading branch information
BryonLewis committed Dec 2, 2024
1 parent c145a9c commit 1d4a050
Show file tree
Hide file tree
Showing 9 changed files with 335 additions and 214 deletions.
25 changes: 25 additions & 0 deletions bats_ai/core/migrations/0012_alter_annotations_confidence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.1.13 on 2024-12-02 16:31

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('core', '0011_alter_annotations_options_annotations_confidence_and_more'),
]

operations = [
migrations.AlterField(
model_name='annotations',
name='confidence',
field=models.FloatField(
default=1.0,
help_text='A confidence value between 0 and 1.0, default is 1.0.',
validators=[
django.core.validators.MinValueValidator(0.0),
django.core.validators.MaxValueValidator(1.0),
],
),
),
]
36 changes: 32 additions & 4 deletions bats_ai/core/views/recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ class RecordingUploadSchema(Schema):
unusual_occurrences: str = None


class RecordingAnnotationSchema(Schema):
# species: list[SpeciesSchema] | None
comments: str | None = None
model: str | None = None
owner: str
confidence: float
id: int | None = None

@classmethod
def from_orm(cls, obj: RecordingAnnotation, **kwargs):
return cls(
# species=[SpeciesSchema.from_orm(species) for species in obj.species.all()],
owner=obj.owner.username,
confidence=obj.confidence,
comments=obj.comments,
model=obj.model,
id=obj.pk,
)


class AnnotationSchema(Schema):
start_time: int
end_time: int
Expand All @@ -74,7 +94,7 @@ class AnnotationSchema(Schema):
owner_email: str = None

@classmethod
def from_orm(cls, obj, owner_email=None, **kwargs):
def from_orm(cls, obj: Annotations, owner_email=None, **kwargs):
return cls(
start_time=obj.start_time,
end_time=obj.end_time,
Expand Down Expand Up @@ -217,7 +237,10 @@ def get_recordings(request: HttpRequest, public: bool | None = None):
for recording in recordings:
user = User.objects.get(id=recording['owner_id'])
fileAnnotations = RecordingAnnotation.objects.filter(recording=recording['id'])
recording['fileAnnotations'] = fileAnnotations
recording['fileAnnotations'] = [
RecordingAnnotationSchema.from_orm(fileAnnotation).dict()
for fileAnnotation in fileAnnotations
]
recording['owner_username'] = user.username
recording['audio_file_presigned_url'] = default_storage.url(recording['audio_file'])
recording['hasSpectrogram'] = Recording.objects.get(id=recording['id']).has_spectrogram
Expand Down Expand Up @@ -263,8 +286,13 @@ def get_recording(request: HttpRequest, id: int):
recording_id=recording['id'], owner=request.user
).exists()
recording['userMadeAnnotations'] = user_has_annotations
annotations = RecordingAnnotation.objects.filter(recording=id).annotate('confidence')
recording['fileAnnotations'] = annotations
fileAnnotations = RecordingAnnotation.objects.filter(recording=id).order_by(
'confidence'
)
recording['fileAnnotations'] = [
RecordingAnnotationSchema.from_orm(fileAnnotation).dict()
for fileAnnotation in fileAnnotations
]

return recording
else:
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "vue-project-template",
"name": "bat-ai-client",
"version": "0.1.0",
"private": true,
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default defineComponent({
const oauthClient = inject<OAuthClient>("oauthClient");
const router = useRouter();
const route = useRoute();
const { nextShared, sharedList } = useState();
const { nextShared, sharedList, sideTab, } = useState();
const getShared = async () => {
sharedList.value = (await getRecordings(true)).data;
};
Expand Down Expand Up @@ -57,7 +57,7 @@ export default defineComponent({
}
});
return { oauthClient, containsSpectro, loginText, logInOrOut, activeTab, nextShared };
return { oauthClient, containsSpectro, loginText, logInOrOut, activeTab, nextShared, sideTab };
},
});
</script>
Expand Down
74 changes: 38 additions & 36 deletions client/src/components/AnnotationEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,43 +115,45 @@ export default defineComponent({
</v-btn>
</v-row>
</v-card-title>
<v-row>
<SpeciesInfo
:species-list="species"
:selected-species="speciesEdit"
class="my-2"
/>
</v-row>
<v-row>
<v-autocomplete
v-model="speciesEdit"
multiple
closable-chips
chips
:items="speciesList"
label="Species"
@update:model-value="updateAnnotation()"
/>
</v-row>
<v-row>
<v-autocomplete
v-model="type"
multiple
closable-chips
chips
:items="callTypes"
label="Type"
@update:model-value="updateAnnotation()"
/>
</v-row>
<v-card-text>
<v-row>
<SpeciesInfo
:species-list="species"
:selected-species="speciesEdit"
class="my-2"
/>
</v-row>
<v-row>
<v-autocomplete
v-model="speciesEdit"
multiple
closable-chips
chips
:items="speciesList"
label="Species"
@update:model-value="updateAnnotation()"
/>
</v-row>
<v-row>
<v-autocomplete
v-model="type"
multiple
closable-chips
chips
:items="callTypes"
label="Type"
@update:model-value="updateAnnotation()"
/>
</v-row>

<v-row>
<v-textarea
v-model="comments"
label="Comments"
@change="updateAnnotation()"
/>
</v-row>
<v-row>
<v-textarea
v-model="comments"
label="Comments"
@change="updateAnnotation()"
/>
</v-row>
</v-card-text>
</v-card>
</template>

Expand Down
Loading

0 comments on commit 1d4a050

Please sign in to comment.