Skip to content

Commit

Permalink
Fix/improve sorting method
Browse files Browse the repository at this point in the history
The similarity sort UI/UX is still unfinished.
  • Loading branch information
mzur committed Jun 25, 2024
1 parent 664a5d4 commit 7777d99
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/resources/assets/js/mixins/largoContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,22 @@ export default {
return [];
},
sortedAnnotations() {
let annotations = this.annotations.slice();
let annotations = this.annotations;
// This will be empty for the default sorting.
if (this.sortingSequence) {
if (this.sortingSequence.length > 0) {
const map = {};
this.sortingSequence.forEach((id, idx) => map[id] = idx);
annotations.forEach((a) => {
// Image annotation IDs are prefixed with 'i', video annotations with
// 'v' to avoid duplicate IDs whe sorting both types of annotations.
map[a.type === VIDEO_ANNOTATION ? ('v' + a.id) : ('i' + a.id)] = a;
});
// Image annotation IDs are prefixed with 'i', video annotations with
// 'v' to avoid duplicate IDs whe sorting both types of annotations.
annotations.sort((a, b) =>
map[a.type === VIDEO_ANNOTATION ? ('v' + a.id) : ('i' + a.id)] -
map[b.type === VIDEO_ANNOTATION ? ('v' + b.id) : ('i' + b.id)]
);
annotations = this.sortingSequence.map(id => map[id]);
}
if (this.sortingDirection === SORT_DIRECTION.ASCENDING) {
return annotations.reverse();
return annotations.slice().reverse();
}
return annotations;
Expand Down Expand Up @@ -405,7 +404,6 @@ export default {
promise = this.querySortByOutlier(labelId)
.then(response => response.body);
} else if (key === SORT_KEY.SIMILARITY) {
console.log(this.similarityReference);
// Skip cacheing for this sorting method.
return this.querySortBySimilarity(labelId, this.similarityReference)
.then(response => response.body);
Expand All @@ -425,6 +423,10 @@ export default {
return sequence;
},
updateSortKey(key) {
if (key !== SORT_KEY.SIMILARITY) {
this.similarityReference = null;
}
const labelId = this.selectedLabel?.id;
this.startLoading();
this.fetchSortingSequence(key, labelId)
Expand Down
1 change: 1 addition & 0 deletions src/resources/views/show/content.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:height="{{config('thumbnails.height')}}"
:selectable="true"
:pinnable="needsSimilarityReference"
:pinned-image="similarityReference"
v-on:select="handleSelectedImageDismiss"
></dismiss-image-grid>
<relabel-image-grid
Expand Down

0 comments on commit 7777d99

Please sign in to comment.