From 281ee2526708e11aadb8c7182ef28d701ef38d3d Mon Sep 17 00:00:00 2001 From: Martin Zurowietz Date: Fri, 10 Jan 2025 09:28:50 +0100 Subject: [PATCH] Fix largo sorting for edge case --- src/public/assets/scripts/main.js | 2 +- src/public/mix-manifest.json | 2 +- src/resources/assets/js/mixins/largoContainer.vue | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/public/assets/scripts/main.js b/src/public/assets/scripts/main.js index d5f5874..e7d10a6 100644 --- a/src/public/assets/scripts/main.js +++ b/src/public/assets/scripts/main.js @@ -1 +1 @@ -(()=>{"use strict";var t,e={255:()=>{var t="imageAnnotation",e="videoAnnotation";function n(t,e,n,i,s,o,a,r){var l,u="function"==typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=n,u._compiled=!0),i&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),a?(l=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),s&&s.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},u._ssrRegister=l):s&&(l=r?function(){s.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:s),l)if(u.functional){u._injectStyles=l;var c=u.render;u.render=function(t,e){return l.call(e),c(t,e)}}else{var d=u.beforeCreate;u.beforeCreate=d?[].concat(d,l):[l]}return{exports:t,options:u}}const i=n({computed:{id:function(){return this.image.id},uuid:function(){return this.image.uuid},type:function(){return this.image.type},patchPrefix:function(){return this.uuid[0]+this.uuid[1]+"/"+this.uuid[2]+this.uuid[3]+"/"+this.uuid},urlTemplate:function(){return biigle.$require("largo.patchUrlTemplate")}},methods:{getThumbnailUrl:function(){return this.type===e?this.urlTemplate.replace(":prefix",this.patchPrefix).replace(":id","v-".concat(this.id)):this.urlTemplate.replace(":prefix",this.patchPrefix).replace(":id",this.id)}},created:function(){this.type===t?this.showAnnotationRoute=biigle.$require("largo.showImageAnnotationRoute"):this.showAnnotationRoute=biigle.$require("largo.showVideoAnnotationRoute")}},undefined,undefined,!1,null,null,null).exports;const s=n({mixins:[i],props:{_id:{type:String,required:!0},_uuid:{type:String,required:!0},label:{type:Object,required:!0},emptySrc:{type:String,required:!0},_urlTemplate:{type:String,required:!0}},data:function(){return{url:""}},computed:{title:function(){return"Example annotation for label "+this.label.name},src:function(){return this.url||this.emptySrc},image:function(){return{id:this._id,uuid:this._uuid,type:t}},urlTemplate:function(){return this._urlTemplate}},methods:{showEmptyImage:function(){this.url=""}},created:function(){this.url=this.getThumbnailUrl()}},undefined,undefined,!1,null,null,null).exports,o=Vue.resource("api/v1/volumes{/id}/largo",{},{queryImageAnnotations:{method:"GET",url:"api/v1/volumes{/id}/image-annotations/filter/label{/label_id}"},queryVideoAnnotations:{method:"GET",url:"api/v1/volumes{/id}/video-annotations/filter/label{/label_id}"},queryExampleAnnotations:{method:"GET",url:"api/v1/volumes{/id}/image-annotations/examples{/label_id}"},sortAnnotationsByOutlier:{method:"GET",url:"api/v1/volumes{/id}/annotations/sort/outliers{/label_id}"},sortAnnotationsBySimilarity:{method:"GET",url:"api/v1/volumes{/id}/annotations/sort/similarity"}});var a=biigle.$require("echo"),r=biigle.$require("events"),l=biigle.$require("messages").handleErrorResponse,u=biigle.$require("volumes.components.imageGrid"),c=biigle.$require("volumes.components.imageGridImage"),d=biigle.$require("annotations.components.labelsTabPlugins"),h=biigle.$require("labelTrees.components.labelTrees"),m=biigle.$require("core.mixins.loader"),g=biigle.$require("messages"),f=biigle.$require("core.components.powerToggle"),p=biigle.$require("core.models.Settings"),b=biigle.$require("annotations.components.settingsTabPlugins"),v=biigle.$require("core.components.sidebar"),y=biigle.$require("core.components.sidebarTab"),S=biigle.$require("core.keyboard");const w=n({mixins:[m],components:{annotationPatch:s},props:{label:{default:null},volumeId:{type:Number,required:!0},count:{type:Number,default:3}},data:function(){return{exampleLabel:null,exampleAnnotations:[],cache:{},shown:!0}},computed:{isShown:function(){return this.shown&&null!==this.label},hasExamples:function(){return this.exampleLabel&&this.exampleAnnotations&&Object.keys(this.exampleAnnotations).length>0}},methods:{parseResponse:function(t){return t.data},setExampleAnnotations:function(t){(!t[0].hasOwnProperty("annotations")||Object.keys(t[0].annotations).length0){var n={};t.forEach((function(t){n[t.type===e?"v"+t.id:"i"+t.id]=t})),t=this.sortingSequence.map((function(t){return n[t]}))}return this.sortingDirection===E?t.slice().reverse():t},allAnnotations:function(){var t=[];for(var e in this.annotationsCache)this.annotationsCache.hasOwnProperty(e)&&(t=t.concat(this.annotationsCache[e]));return t},hasNoAnnotations:function(){return this.selectedLabel&&!this.loading&&0===this.annotations.length},dismissedAnnotations:function(){return this.allAnnotations.filter((function(t){return t.dismissed}))},annotationsWithNewLabel:function(){return this.dismissedAnnotations.filter((function(t){return!!t.newLabel}))},hasDismissedAnnotations:function(){return this.dismissedAnnotations.length>0},dismissedImageAnnotationsToSave:function(){return this.packDismissedToSave(this.dismissedAnnotations.filter((function(e){return e.type===t})))},dismissedVideoAnnotationsToSave:function(){return this.packDismissedToSave(this.dismissedAnnotations.filter((function(t){return t.type===e})))},changedImageAnnotationsToSave:function(){return this.packChangedToSave(this.annotationsWithNewLabel.filter((function(e){return e.type===t})))},changedVideoAnnotationsToSave:function(){return this.packChangedToSave(this.annotationsWithNewLabel.filter((function(t){return t.type===e})))},toDeleteCount:function(){return this.dismissedAnnotations.length-this.annotationsWithNewLabel.length},saveButtonClass:function(){return this.forceChange?"btn-danger":"btn-success"},sortingIsActive:function(){return this.isInDismissStep&&(this.sortingKey!==k||this.sortingDirection!==R)},imagesPinnable:function(){return this.needsSimilarityReference||this.sortingKey===B}},methods:{getAnnotations:function(t){var e,n,i=this;this.annotationsCache.hasOwnProperty(t.id)?e=Vue.Promise.resolve():(Vue.set(this.annotationsCache,t.id,[]),this.startLoading(),e=this.queryAnnotations(t).then((function(e){return i.gotAnnotations(t,e)}),l)),this.sortingKey===B?n=this.resetSorting():this.sortingIsActive?(this.sortingSequence=[],n=this.updateSortKey(this.sortingKey)):n=Vue.Promise.resolve(),Vue.Promise.all([e,n]).finally(this.finishLoading)},gotAnnotations:function(n,i){var s=i[0].data,o=i[1].data,a=[];s&&(a=a.concat(this.initAnnotations(n,s,t))),o&&(a=a.concat(this.initAnnotations(n,o,e))),a=a.sort((function(t,e){return e.id-t.id})),Vue.set(this.annotationsCache,n.id,a)},initAnnotations:function(t,e,n){return Object.keys(e).map((function(i){return{id:i,uuid:e[i],label_id:t.id,dismissed:!1,newLabel:null,type:n}}))},handleSelectedLabel:function(t){this.selectedLabel=t,this.isInDismissStep&&this.getAnnotations(t)},handleDeselectedLabel:function(){this.selectedLabel=null},handleSelectedImageDismiss:function(t,e){t.dismissed?(t.dismissed=!1,t.newLabel=null):(t.dismissed=!0,e.shiftKey&&this.lastSelectedImage?this.dismissAllImagesBetween(t,this.lastSelectedImage):this.lastSelectedImage=t)},goToRelabel:function(){this.step=1,this.lastSelectedImage=null},goToDismiss:function(){this.step=0,this.lastSelectedImage=null,this.selectedLabel&&this.getAnnotations(this.selectedLabel)},handleSelectedImageRelabel:function(t,e){t.newLabel?this.selectedLabel&&t.newLabel.id!==this.selectedLabel.id?t.newLabel=this.selectedLabel:t.newLabel=null:this.selectedLabel&&(t.newLabel=this.selectedLabel,e.shiftKey&&this.lastSelectedImage?this.relabelAllImagesBetween(t,this.lastSelectedImage):this.lastSelectedImage=t)},save:function(){var t=this;if(!this.loading){if(this.toDeleteCount>0){for(var e;null!==e&&parseInt(e,10)!==this.toDeleteCount;)e=prompt("This might delete ".concat(this.toDeleteCount," annotation(s). Please enter the number to continue."));if(null===e)return}this.startLoading(),this.performSave({dismissed_image_annotations:this.dismissedImageAnnotationsToSave,changed_image_annotations:this.changedImageAnnotationsToSave,dismissed_video_annotations:this.dismissedVideoAnnotationsToSave,changed_video_annotations:this.changedVideoAnnotationsToSave,force:this.forceChange}).then((function(e){return t.waitForSessionId=e.body.id}),(function(e){t.finishLoading(),l(e)}))}},handleSessionSaved:function(t){if(t.id==this.waitForSessionId){for(var e in this.finishLoading(),g.success("Saved. You can now start a new re-evaluation session."),this.step=0,this.annotationsCache)this.annotationsCache.hasOwnProperty(e)&&delete this.annotationsCache[e];for(var n in this.sortingSequenceCache)this.sortingSequenceCache.hasOwnProperty(n)&&delete this.sortingSequenceCache[n];this.handleSelectedLabel(this.selectedLabel)}},handleSessionFailed:function(t){t.id==this.waitForSessionId&&(this.finishLoading(),g.danger("There was an unexpected error."))},dismissAllImagesBetween:function(t,e){var n=this.sortedAnnotations.indexOf(t),i=this.sortedAnnotations.indexOf(e);if(i=0;n--)e.hasOwnProperty(t[n].label_id)?e[t[n].label_id].push(t[n].id):e[t[n].label_id]=[t[n].id];return e},packChangedToSave:function(t){for(var e={},n=t.length-1;n>=0;n--)e.hasOwnProperty(t[n].newLabel.id)?e[t[n].newLabel.id].push(t[n].id):e[t[n].newLabel.id]=[t[n].id];return e},initializeEcho:function(){a.getInstance().private("user-".concat(this.user.id)).listen(".Biigle\\Modules\\Largo\\Events\\LargoSessionSaved",this.handleSessionSaved).listen(".Biigle\\Modules\\Largo\\Events\\LargoSessionFailed",this.handleSessionFailed)},updateShowOutlines:function(t){this.showAnnotationOutlines=t},updateSortDirection:function(t){this.sortingDirection=t},fetchSortingSequence:function(t,e){var n,i,s,o=this,a=null===(n=this.sortingSequenceCache)||void 0===n||null===(i=n[e])||void 0===i?void 0:i[t];if(a)return Vue.Promise.resolve(a);if(this.selectedLabel)if(t===P)s=this.querySortByOutlier(e).then((function(t){return t.body}));else{if(t===B)return this.querySortBySimilarity(e,this.similarityReference).then((function(t){return t.body}));s=Vue.Promise.resolve([])}else s=Vue.Promise.resolve([]);return s.then((function(n){return o.putSortingSequenceToCache(t,e,n)}))},putSortingSequenceToCache:function(t,e,n){return this.sortingSequenceCache[e]||Vue.set(this.sortingSequenceCache,e,{}),this.sortingSequenceCache[e][t]=n,n},updateSortKey:function(t){var e,n=this;t!==B&&(this.similarityReference=null,this.pinnedImage=null);var i=null===(e=this.selectedLabel)||void 0===e?void 0:e.id;return this.startLoading(),this.fetchSortingSequence(t,i).then((function(e){n.sortingKey=t,n.sortingSequence=e,t===B&&(n.needsSimilarityReference=!1,n.pinnedImage=n.similarityReference)})).catch((function(t){n.handleErrorResponse(t),n.similarityReference=null})).finally(this.finishLoading)},handleInitSimilaritySort:function(){this.sortingKey!==B&&(this.needsSimilarityReference=!0)},handleCancelSimilaritySort:function(){this.needsSimilarityReference=!1},handlePinImage:function(t){var e;(null===(e=this.pinnedImage)||void 0===e?void 0:e.id)===t.id?this.resetSorting():this.imagesPinnable&&(this.similarityReference=t,this.updateSortKey(B))},resetSorting:function(){var t=this;return this.updateSortKey(k).then((function(){return t.sortingDirection=R}))}},watch:{annotations:function(t){r.$emit("annotations-count",t.length)},dismissedAnnotations:function(t){r.$emit("dismissed-annotations-count",t.length)},step:function(t){r.$emit("step",t)},selectedLabel:function(){this.isInDismissStep&&this.$refs.dismissGrid.setOffset(0)}},created:function(){var t=this;this.user=biigle.$require("largo.user"),window.addEventListener("beforeunload",(function(e){if(t.hasDismissedAnnotations)return e.preventDefault(),e.returnValue="","This page is asking you to confirm that you want to leave - data you have entered may not be saved."})),this.initializeEcho()}},undefined,undefined,!1,null,null,null).exports;const j=n({mixins:[V],components:{catalogImageGrid:C},data:function(){return{labelTrees:[]}},methods:{queryAnnotations:function(t){var e=I.queryImageAnnotations({id:t.id}),n=I.queryVideoAnnotations({id:t.id});return Vue.Promise.all([e,n])},showOutlines:function(){this.showAnnotationOutlines=!0},hideOutlines:function(){this.showAnnotationOutlines=!1}},created:function(){var t=biigle.$require("annotationCatalog.labelTree");this.labelTrees=[t],this.showAnnotationOutlines=!1}},undefined,undefined,!1,null,null,null).exports;const G=n({mixins:[V],data:function(){return{volumeId:null,labelTrees:[],mediaType:""}},methods:{queryAnnotations:function(t){var e,n;return"image"===this.mediaType?(e=o.queryImageAnnotations({id:this.volumeId,label_id:t.id}),n=Vue.Promise.resolve([])):(e=Vue.Promise.resolve([]),n=o.queryVideoAnnotations({id:this.volumeId,label_id:t.id})),Vue.Promise.all([e,n])},performSave:function(t){return o.save({id:this.volumeId},t)},querySortByOutlier:function(t){return o.sortAnnotationsByOutlier({id:this.volumeId,label_id:t}).then(this.parseSortingQuery)},querySortBySimilarity:function(t,e){return o.sortAnnotationsBySimilarity({id:this.volumeId,label_id:t,annotation_id:e.id}).then(this.parseSortingQuery)},parseSortingQuery:function(t){return"image"===this.mediaType?t.body=t.body.map((function(t){return"i"+t})):t.body=t.body.map((function(t){return"v"+t})),t}},created:function(){this.volumeId=biigle.$require("largo.volumeId"),this.labelTrees=biigle.$require("largo.labelTrees"),this.mediaType=biigle.$require("largo.mediaType")}},undefined,undefined,!1,null,null,null).exports;const K=n({data:function(){return{step:0,count:0,dismissedCount:0}},computed:{shownCount:function(){return this.isInDismissStep?this.count:this.dismissedCount},isInDismissStep:function(){return 0===this.step},isInRelabelStep:function(){return 1===this.step}},methods:{updateStep:function(t){this.step=t},updateCount:function(t){this.count=t},updateDismissedCount:function(t){this.dismissedCount=t}},created:function(){r.$on("annotations-count",this.updateCount),r.$on("dismissed-annotations-count",this.updateDismissedCount),r.$on("step",this.updateStep)}},undefined,undefined,!1,null,null,null).exports,U=Vue.resource("api/v1/projects{/id}/largo",{},{queryImageAnnotations:{method:"GET",url:"api/v1/projects{/id}/image-annotations/filter/label{/label_id}"},queryVideoAnnotations:{method:"GET",url:"api/v1/projects{/id}/video-annotations/filter/label{/label_id}"},sortAnnotationsByOutlier:{method:"GET",url:"api/v1/projects{/id}/annotations/sort/outliers{/label_id}"},sortAnnotationsBySimilarity:{method:"GET",url:"api/v1/projects{/id}/annotations/sort/similarity"}});const N=n({mixins:[V],data:function(){return{projectId:null,labelTrees:[]}},methods:{queryAnnotations:function(t){var e=U.queryImageAnnotations({id:this.projectId,label_id:t.id}),n=U.queryVideoAnnotations({id:this.projectId,label_id:t.id});return Vue.Promise.all([e,n])},performSave:function(t){return U.save({id:this.projectId},t)},querySortByOutlier:function(t){return U.sortAnnotationsByOutlier({id:this.projectId,label_id:t})},querySortBySimilarity:function(e,n){var i={id:this.projectId,label_id:e};return n.type===t?i.image_annotation_id=n.id:i.video_annotation_id=n.id,U.sortAnnotationsBySimilarity(i)}},created:function(){this.projectId=biigle.$require("largo.projectId"),this.labelTrees=biigle.$require("largo.labelTrees")}},undefined,undefined,!1,null,null,null).exports;biigle.$mount("annotation-catalog-container",j),biigle.$mount("largo-container",G),biigle.$mount("largo-title",K),biigle.$mount("project-largo-container",N)},307:()=>{}},n={};function i(t){var s=n[t];if(void 0!==s)return s.exports;var o=n[t]={exports:{}};return e[t](o,o.exports,i),o.exports}i.m=e,t=[],i.O=(e,n,s,o)=>{if(!n){var a=1/0;for(c=0;c=o)&&Object.keys(i.O).every((t=>i.O[t](n[l])))?n.splice(l--,1):(r=!1,o0&&t[c-1][2]>o;c--)t[c]=t[c-1];t[c]=[n,s,o]},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t={355:0,392:0};i.O.j=e=>0===t[e];var e=(e,n)=>{var s,o,[a,r,l]=n,u=0;if(a.some((e=>0!==t[e]))){for(s in r)i.o(r,s)&&(i.m[s]=r[s]);if(l)var c=l(i)}for(e&&e(n);ui(255)));var s=i.O(void 0,[392],(()=>i(307)));s=i.O(s)})(); \ No newline at end of file +(()=>{"use strict";var t,e={255:()=>{var t="imageAnnotation",e="videoAnnotation";function n(t,e,n,i,s,o,a,r){var l,u="function"==typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=n,u._compiled=!0),i&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),a?(l=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),s&&s.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},u._ssrRegister=l):s&&(l=r?function(){s.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:s),l)if(u.functional){u._injectStyles=l;var c=u.render;u.render=function(t,e){return l.call(e),c(t,e)}}else{var d=u.beforeCreate;u.beforeCreate=d?[].concat(d,l):[l]}return{exports:t,options:u}}const i=n({computed:{id:function(){return this.image.id},uuid:function(){return this.image.uuid},type:function(){return this.image.type},patchPrefix:function(){return this.uuid[0]+this.uuid[1]+"/"+this.uuid[2]+this.uuid[3]+"/"+this.uuid},urlTemplate:function(){return biigle.$require("largo.patchUrlTemplate")}},methods:{getThumbnailUrl:function(){return this.type===e?this.urlTemplate.replace(":prefix",this.patchPrefix).replace(":id","v-".concat(this.id)):this.urlTemplate.replace(":prefix",this.patchPrefix).replace(":id",this.id)}},created:function(){this.type===t?this.showAnnotationRoute=biigle.$require("largo.showImageAnnotationRoute"):this.showAnnotationRoute=biigle.$require("largo.showVideoAnnotationRoute")}},undefined,undefined,!1,null,null,null).exports;const s=n({mixins:[i],props:{_id:{type:String,required:!0},_uuid:{type:String,required:!0},label:{type:Object,required:!0},emptySrc:{type:String,required:!0},_urlTemplate:{type:String,required:!0}},data:function(){return{url:""}},computed:{title:function(){return"Example annotation for label "+this.label.name},src:function(){return this.url||this.emptySrc},image:function(){return{id:this._id,uuid:this._uuid,type:t}},urlTemplate:function(){return this._urlTemplate}},methods:{showEmptyImage:function(){this.url=""}},created:function(){this.url=this.getThumbnailUrl()}},undefined,undefined,!1,null,null,null).exports,o=Vue.resource("api/v1/volumes{/id}/largo",{},{queryImageAnnotations:{method:"GET",url:"api/v1/volumes{/id}/image-annotations/filter/label{/label_id}"},queryVideoAnnotations:{method:"GET",url:"api/v1/volumes{/id}/video-annotations/filter/label{/label_id}"},queryExampleAnnotations:{method:"GET",url:"api/v1/volumes{/id}/image-annotations/examples{/label_id}"},sortAnnotationsByOutlier:{method:"GET",url:"api/v1/volumes{/id}/annotations/sort/outliers{/label_id}"},sortAnnotationsBySimilarity:{method:"GET",url:"api/v1/volumes{/id}/annotations/sort/similarity"}});var a=biigle.$require("echo"),r=biigle.$require("events"),l=biigle.$require("messages").handleErrorResponse,u=biigle.$require("volumes.components.imageGrid"),c=biigle.$require("volumes.components.imageGridImage"),d=biigle.$require("annotations.components.labelsTabPlugins"),h=biigle.$require("labelTrees.components.labelTrees"),m=biigle.$require("core.mixins.loader"),g=biigle.$require("messages"),f=biigle.$require("core.components.powerToggle"),p=biigle.$require("core.models.Settings"),b=biigle.$require("annotations.components.settingsTabPlugins"),v=biigle.$require("core.components.sidebar"),y=biigle.$require("core.components.sidebarTab"),S=biigle.$require("core.keyboard");const w=n({mixins:[m],components:{annotationPatch:s},props:{label:{default:null},volumeId:{type:Number,required:!0},count:{type:Number,default:3}},data:function(){return{exampleLabel:null,exampleAnnotations:[],cache:{},shown:!0}},computed:{isShown:function(){return this.shown&&null!==this.label},hasExamples:function(){return this.exampleLabel&&this.exampleAnnotations&&Object.keys(this.exampleAnnotations).length>0}},methods:{parseResponse:function(t){return t.data},setExampleAnnotations:function(t){(!t[0].hasOwnProperty("annotations")||Object.keys(t[0].annotations).length0},dismissedImageAnnotationsToSave:function(){return this.packDismissedToSave(this.dismissedAnnotations.filter((function(e){return e.type===t})))},dismissedVideoAnnotationsToSave:function(){return this.packDismissedToSave(this.dismissedAnnotations.filter((function(t){return t.type===e})))},changedImageAnnotationsToSave:function(){return this.packChangedToSave(this.annotationsWithNewLabel.filter((function(e){return e.type===t})))},changedVideoAnnotationsToSave:function(){return this.packChangedToSave(this.annotationsWithNewLabel.filter((function(t){return t.type===e})))},toDeleteCount:function(){return this.dismissedAnnotations.length-this.annotationsWithNewLabel.length},saveButtonClass:function(){return this.forceChange?"btn-danger":"btn-success"},sortingIsActive:function(){return this.isInDismissStep&&(this.sortingKey!==k||this.sortingDirection!==R)},imagesPinnable:function(){return this.needsSimilarityReference||this.sortingKey===B}},methods:{getAnnotations:function(t){var e,n,i=this;this.annotationsCache.hasOwnProperty(t.id)?e=Vue.Promise.resolve():(Vue.set(this.annotationsCache,t.id,[]),this.startLoading(),e=this.queryAnnotations(t).then((function(e){return i.gotAnnotations(t,e)}),l)),this.sortingKey===B?n=this.resetSorting():this.sortingIsActive?(this.sortingSequence=[],n=this.updateSortKey(this.sortingKey)):n=Vue.Promise.resolve(),Vue.Promise.all([e,n]).finally(this.finishLoading)},gotAnnotations:function(n,i){var s=i[0].data,o=i[1].data,a=[];s&&(a=a.concat(this.initAnnotations(n,s,t))),o&&(a=a.concat(this.initAnnotations(n,o,e))),a=a.sort((function(t,e){return e.id-t.id})),Vue.set(this.annotationsCache,n.id,a)},initAnnotations:function(t,e,n){return Object.keys(e).map((function(i){return{id:i,uuid:e[i],label_id:t.id,dismissed:!1,newLabel:null,type:n}}))},handleSelectedLabel:function(t){this.selectedLabel=t,this.isInDismissStep&&this.getAnnotations(t)},handleDeselectedLabel:function(){this.selectedLabel=null},handleSelectedImageDismiss:function(t,e){t.dismissed?(t.dismissed=!1,t.newLabel=null):(t.dismissed=!0,e.shiftKey&&this.lastSelectedImage?this.dismissAllImagesBetween(t,this.lastSelectedImage):this.lastSelectedImage=t)},goToRelabel:function(){this.step=1,this.lastSelectedImage=null},goToDismiss:function(){this.step=0,this.lastSelectedImage=null,this.selectedLabel&&this.getAnnotations(this.selectedLabel)},handleSelectedImageRelabel:function(t,e){t.newLabel?this.selectedLabel&&t.newLabel.id!==this.selectedLabel.id?t.newLabel=this.selectedLabel:t.newLabel=null:this.selectedLabel&&(t.newLabel=this.selectedLabel,e.shiftKey&&this.lastSelectedImage?this.relabelAllImagesBetween(t,this.lastSelectedImage):this.lastSelectedImage=t)},save:function(){var t=this;if(!this.loading){if(this.toDeleteCount>0){for(var e;null!==e&&parseInt(e,10)!==this.toDeleteCount;)e=prompt("This might delete ".concat(this.toDeleteCount," annotation(s). Please enter the number to continue."));if(null===e)return}this.startLoading(),this.performSave({dismissed_image_annotations:this.dismissedImageAnnotationsToSave,changed_image_annotations:this.changedImageAnnotationsToSave,dismissed_video_annotations:this.dismissedVideoAnnotationsToSave,changed_video_annotations:this.changedVideoAnnotationsToSave,force:this.forceChange}).then((function(e){return t.waitForSessionId=e.body.id}),(function(e){t.finishLoading(),l(e)}))}},handleSessionSaved:function(t){if(t.id==this.waitForSessionId){for(var e in this.finishLoading(),g.success("Saved. You can now start a new re-evaluation session."),this.step=0,this.annotationsCache)this.annotationsCache.hasOwnProperty(e)&&delete this.annotationsCache[e];for(var n in this.sortingSequenceCache)this.sortingSequenceCache.hasOwnProperty(n)&&delete this.sortingSequenceCache[n];this.handleSelectedLabel(this.selectedLabel)}},handleSessionFailed:function(t){t.id==this.waitForSessionId&&(this.finishLoading(),g.danger("There was an unexpected error."))},dismissAllImagesBetween:function(t,e){var n=this.sortedAnnotations.indexOf(t),i=this.sortedAnnotations.indexOf(e);if(i=0;n--)e.hasOwnProperty(t[n].label_id)?e[t[n].label_id].push(t[n].id):e[t[n].label_id]=[t[n].id];return e},packChangedToSave:function(t){for(var e={},n=t.length-1;n>=0;n--)e.hasOwnProperty(t[n].newLabel.id)?e[t[n].newLabel.id].push(t[n].id):e[t[n].newLabel.id]=[t[n].id];return e},initializeEcho:function(){a.getInstance().private("user-".concat(this.user.id)).listen(".Biigle\\Modules\\Largo\\Events\\LargoSessionSaved",this.handleSessionSaved).listen(".Biigle\\Modules\\Largo\\Events\\LargoSessionFailed",this.handleSessionFailed)},updateShowOutlines:function(t){this.showAnnotationOutlines=t},updateSortDirection:function(t){this.sortingDirection=t},fetchSortingSequence:function(t,e){var n,i,s,o=this,a=null===(n=this.sortingSequenceCache)||void 0===n||null===(i=n[e])||void 0===i?void 0:i[t];if(a)return Vue.Promise.resolve(a);if(this.selectedLabel)if(t===P)s=this.querySortByOutlier(e).then((function(t){return t.body}));else{if(t===B)return this.querySortBySimilarity(e,this.similarityReference).then((function(t){return t.body}));s=Vue.Promise.resolve([])}else s=Vue.Promise.resolve([]);return s.then((function(n){return o.putSortingSequenceToCache(t,e,n)}))},putSortingSequenceToCache:function(t,e,n){return this.sortingSequenceCache[e]||Vue.set(this.sortingSequenceCache,e,{}),this.sortingSequenceCache[e][t]=n,n},updateSortKey:function(t){var e,n=this;t!==B&&(this.similarityReference=null,this.pinnedImage=null);var i=null===(e=this.selectedLabel)||void 0===e?void 0:e.id;return this.startLoading(),this.fetchSortingSequence(t,i).then((function(e){n.sortingKey=t,n.sortingSequence=e,t===B&&(n.needsSimilarityReference=!1,n.pinnedImage=n.similarityReference)})).catch((function(t){n.handleErrorResponse(t),n.similarityReference=null})).finally(this.finishLoading)},handleInitSimilaritySort:function(){this.sortingKey!==B&&(this.needsSimilarityReference=!0)},handleCancelSimilaritySort:function(){this.needsSimilarityReference=!1},handlePinImage:function(t){var e;(null===(e=this.pinnedImage)||void 0===e?void 0:e.id)===t.id?this.resetSorting():this.imagesPinnable&&(this.similarityReference=t,this.updateSortKey(B))},resetSorting:function(){var t=this;return this.updateSortKey(k).then((function(){return t.sortingDirection=R}))}},watch:{annotations:function(t){r.$emit("annotations-count",t.length)},dismissedAnnotations:function(t){r.$emit("dismissed-annotations-count",t.length)},step:function(t){r.$emit("step",t)},selectedLabel:function(){this.isInDismissStep&&this.$refs.dismissGrid.setOffset(0)}},created:function(){var t=this;this.user=biigle.$require("largo.user"),window.addEventListener("beforeunload",(function(e){if(t.hasDismissedAnnotations)return e.preventDefault(),e.returnValue="","This page is asking you to confirm that you want to leave - data you have entered may not be saved."})),this.initializeEcho()}},undefined,undefined,!1,null,null,null).exports;const j=n({mixins:[V],components:{catalogImageGrid:C},data:function(){return{labelTrees:[]}},methods:{queryAnnotations:function(t){var e=I.queryImageAnnotations({id:t.id}),n=I.queryVideoAnnotations({id:t.id});return Vue.Promise.all([e,n])},showOutlines:function(){this.showAnnotationOutlines=!0},hideOutlines:function(){this.showAnnotationOutlines=!1}},created:function(){var t=biigle.$require("annotationCatalog.labelTree");this.labelTrees=[t],this.showAnnotationOutlines=!1}},undefined,undefined,!1,null,null,null).exports;const K=n({mixins:[V],data:function(){return{volumeId:null,labelTrees:[],mediaType:""}},methods:{queryAnnotations:function(t){var e,n;return"image"===this.mediaType?(e=o.queryImageAnnotations({id:this.volumeId,label_id:t.id}),n=Vue.Promise.resolve([])):(e=Vue.Promise.resolve([]),n=o.queryVideoAnnotations({id:this.volumeId,label_id:t.id})),Vue.Promise.all([e,n])},performSave:function(t){return o.save({id:this.volumeId},t)},querySortByOutlier:function(t){return o.sortAnnotationsByOutlier({id:this.volumeId,label_id:t}).then(this.parseSortingQuery)},querySortBySimilarity:function(t,e){return o.sortAnnotationsBySimilarity({id:this.volumeId,label_id:t,annotation_id:e.id}).then(this.parseSortingQuery)},parseSortingQuery:function(t){return"image"===this.mediaType?t.body=t.body.map((function(t){return"i"+t})):t.body=t.body.map((function(t){return"v"+t})),t}},created:function(){this.volumeId=biigle.$require("largo.volumeId"),this.labelTrees=biigle.$require("largo.labelTrees"),this.mediaType=biigle.$require("largo.mediaType")}},undefined,undefined,!1,null,null,null).exports;const G=n({data:function(){return{step:0,count:0,dismissedCount:0}},computed:{shownCount:function(){return this.isInDismissStep?this.count:this.dismissedCount},isInDismissStep:function(){return 0===this.step},isInRelabelStep:function(){return 1===this.step}},methods:{updateStep:function(t){this.step=t},updateCount:function(t){this.count=t},updateDismissedCount:function(t){this.dismissedCount=t}},created:function(){r.$on("annotations-count",this.updateCount),r.$on("dismissed-annotations-count",this.updateDismissedCount),r.$on("step",this.updateStep)}},undefined,undefined,!1,null,null,null).exports,U=Vue.resource("api/v1/projects{/id}/largo",{},{queryImageAnnotations:{method:"GET",url:"api/v1/projects{/id}/image-annotations/filter/label{/label_id}"},queryVideoAnnotations:{method:"GET",url:"api/v1/projects{/id}/video-annotations/filter/label{/label_id}"},sortAnnotationsByOutlier:{method:"GET",url:"api/v1/projects{/id}/annotations/sort/outliers{/label_id}"},sortAnnotationsBySimilarity:{method:"GET",url:"api/v1/projects{/id}/annotations/sort/similarity"}});const N=n({mixins:[V],data:function(){return{projectId:null,labelTrees:[]}},methods:{queryAnnotations:function(t){var e=U.queryImageAnnotations({id:this.projectId,label_id:t.id}),n=U.queryVideoAnnotations({id:this.projectId,label_id:t.id});return Vue.Promise.all([e,n])},performSave:function(t){return U.save({id:this.projectId},t)},querySortByOutlier:function(t){return U.sortAnnotationsByOutlier({id:this.projectId,label_id:t})},querySortBySimilarity:function(e,n){var i={id:this.projectId,label_id:e};return n.type===t?i.image_annotation_id=n.id:i.video_annotation_id=n.id,U.sortAnnotationsBySimilarity(i)}},created:function(){this.projectId=biigle.$require("largo.projectId"),this.labelTrees=biigle.$require("largo.labelTrees")}},undefined,undefined,!1,null,null,null).exports;biigle.$mount("annotation-catalog-container",j),biigle.$mount("largo-container",K),biigle.$mount("largo-title",G),biigle.$mount("project-largo-container",N)},307:()=>{}},n={};function i(t){var s=n[t];if(void 0!==s)return s.exports;var o=n[t]={exports:{}};return e[t](o,o.exports,i),o.exports}i.m=e,t=[],i.O=(e,n,s,o)=>{if(!n){var a=1/0;for(c=0;c=o)&&Object.keys(i.O).every((t=>i.O[t](n[l])))?n.splice(l--,1):(r=!1,o0&&t[c-1][2]>o;c--)t[c]=t[c-1];t[c]=[n,s,o]},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t={355:0,392:0};i.O.j=e=>0===t[e];var e=(e,n)=>{var s,o,[a,r,l]=n,u=0;if(a.some((e=>0!==t[e]))){for(s in r)i.o(r,s)&&(i.m[s]=r[s]);if(l)var c=l(i)}for(e&&e(n);ui(255)));var s=i.O(void 0,[392],(()=>i(307)));s=i.O(s)})(); \ No newline at end of file diff --git a/src/public/mix-manifest.json b/src/public/mix-manifest.json index 7de6090..8fe95a5 100644 --- a/src/public/mix-manifest.json +++ b/src/public/mix-manifest.json @@ -1,4 +1,4 @@ { - "/assets/scripts/main.js": "/assets/scripts/main.js?id=a5c13da60fe45f14eb11719e28a8f378", + "/assets/scripts/main.js": "/assets/scripts/main.js?id=e905f62357d0ef81ac20e94395510a2a", "/assets/styles/main.css": "/assets/styles/main.css?id=68a88f330c08af97df1d47c207ea8ccb" } diff --git a/src/resources/assets/js/mixins/largoContainer.vue b/src/resources/assets/js/mixins/largoContainer.vue index f8c24a9..e61ca9a 100644 --- a/src/resources/assets/js/mixins/largoContainer.vue +++ b/src/resources/assets/js/mixins/largoContainer.vue @@ -85,8 +85,7 @@ export default { return annotations; } - // This will be empty for the default sorting. - if (this.sortingSequence.length > 0) { + if (this.sortingKey !== SORT_KEY.ANNOTATION_ID) { const map = {}; annotations.forEach((a) => { // Image annotation IDs are prefixed with 'i', video annotations with