Ver código fonte

added appropriate sorting of images and fixed some UI stuff

Dimitri Korsch 3 anos atrás
pai
commit
14c8cb013c

+ 1 - 1
pycs/database/Collection.py

@@ -58,7 +58,7 @@ class Collection(NamedBaseModel):
 
         # pylint: disable=import-outside-toplevel, cyclic-import
         from pycs.database.File import File
-        return self.files.filter(*filters).order_by(File.id).offset(offset).limit(limit)
+        return self.files.filter(*filters).order_by(File.path).offset(offset).limit(limit)
 
     # pylint: disable=too-many-arguments
     @commit_on_return

+ 16 - 8
pycs/database/File.py

@@ -66,6 +66,7 @@ class File(NamedBaseModel):
         "created",
         "path",
         "frames",
+        "has_annotations",
         "fps",
         "project_id",
         "collection_id",
@@ -76,6 +77,11 @@ class File(NamedBaseModel):
         """ filename consisting of a name and an extension """
         return f"{self.name}{self.extension}"
 
+    @property
+    def has_annotations(self):
+        """ check if there are any referenced results """
+        return self.results.count() != 0
+
     @property
     def absolute_path(self) -> str:
         """ returns an absolute of the file """
@@ -143,8 +149,9 @@ class File(NamedBaseModel):
         :return: another file or None
         """
 
-        return self._get_another_file(File.id > self.id)\
-            .order_by(File.id).first()
+        res = self._get_another_file(File.path > self.path)\
+            .order_by(File.path)
+        return res.first()
 
 
     def previous(self) -> T.Optional[File]:
@@ -155,8 +162,9 @@ class File(NamedBaseModel):
         """
 
         # pylint: disable=no-member
-        return self._get_another_file(File.id < self.id)\
-            .order_by(File.id.desc()).first()
+        res = self._get_another_file(File.path < self.path)\
+            .order_by(File.path.desc())
+        return res.first()
 
 
     def next_in_collection(self) -> T.Optional[File]:
@@ -166,8 +174,8 @@ class File(NamedBaseModel):
         :return: another file or None
         """
         return self._get_another_file(
-            File.id > self.id, File.collection_id == self.collection_id)\
-            .order_by(File.id).first()
+            File.path > self.path, File.collection_id == self.collection_id)\
+            .order_by(File.path).first()
 
 
     def previous_in_collection(self) -> T.Optional[File]:
@@ -179,8 +187,8 @@ class File(NamedBaseModel):
 
         # pylint: disable=no-member
         return self._get_another_file(
-            File.id < self.id, File.collection_id == self.collection_id)\
-            .order_by(File.id.desc()).first()
+            File.path < self.path, File.collection_id == self.collection_id)\
+            .order_by(File.path.desc()).first()
 
 
     def result(self, identifier: int) -> T.Optional[Result]:

+ 1 - 1
pycs/database/Project.py

@@ -301,7 +301,7 @@ class Project(NamedBaseModel):
         :return: iterator of files
         """
 
-        return self.files.filter(*filters).order_by(File.id).offset(offset).limit(limit)
+        return self.files.filter(*filters).order_by(File.path).offset(offset).limit(limit)
 
     def _files_without_results(self):
         """

+ 1 - 0
pycs/frontend/endpoints/data/GetPreviousAndNextFile.py

@@ -18,6 +18,7 @@ class GetPreviousAndNextFile(View):
 
         # get previous and next
         result = {
+            'current': file,
             'previous': file.previous(),
             'next': file.next(),
             'previousInCollection': file.previous_in_collection(),

+ 0 - 1
webui/src/components/media/annotation-box.vue

@@ -37,7 +37,6 @@ export default {
   ],
   computed: {
     labelName: function () {
-      console.log(this.box)
       if (!this.box || !this.box.label_id)
         return false;
       for (let label of this.labels) {

+ 3 - 3
webui/src/components/media/media-control.vue

@@ -82,7 +82,7 @@ export default {
   methods: {
     keypressEvent: function (event) {
       switch (event.key) {
-        case 'w':
+        case 'y':
           this.$refs.previousPage.click();
           break;
         case 'a':
@@ -91,7 +91,7 @@ export default {
         case 'd':
           this.$refs.nextElement.click();
           break;
-        case 's':
+        case 'c':
           this.$refs.nextPage.click();
           break;
       }
@@ -144,4 +144,4 @@ select {
   max-width: 15rem;
   margin: 0 1rem;
 }
-</style>
+</style>

+ 18 - 6
webui/src/components/media/paginated-media.vue

@@ -2,19 +2,23 @@
   <div class="paginated-media">
     <div class="media" ref="media">
       <div v-for="image in images"
-           v-bind:key="image.identifier"
+           v-bind:key="image.path"
            class="image"
            @click="$emit('click', image)">
         <img :alt="image.name" :src="image.src">
 
-        <div v-if="current && current.identifier === image.identifier"
+        <div v-if="current && current.path === image.path"
              class="active"/>
 
         <div v-if="deletable"
              class="delete"
              @click="deleteElement(image)">
+
           <img alt="remove" src="@/assets/icons/x-circle.svg">
         </div>
+        <div v-if="image.has_annotations" class="annotated">
+          <img alt="annotated" src="@/assets/icons/tag.svg">
+        </div>
       </div>
     </div>
 
@@ -98,10 +102,10 @@ export default {
       // edited file is in the current image list
       if (this.filter !== false) {
         for (let image of this.images) {
-          if (image.identifier === file.identifier) {
+          if (image.path === file.path) {
             this.get(() => {
               // click the first image if the current shown was removed
-              if (this.current.identifier === file.identifier) {
+              if (this.current.path === file.path) {
                 this.$emit('click', this.images[0]);
               }
             });
@@ -201,9 +205,9 @@ export default {
       if (this.images.length === 0)
         return;
 
-      if (this.current.identifier < this.images[0].identifier)
+      if (this.current.path < this.images[0].path)
         this.prevPage(this.findCurrent);
-      else if (this.current.identifier > this.images[this.images.length - 1].identifier)
+      else if (this.current.path > this.images[this.images.length - 1].path)
         this.nextPage(this.findCurrent);
     }
   },
@@ -299,6 +303,14 @@ export default {
   filter: invert(1);
 }
 
+.media .annotated {
+  position: absolute;
+  top: 0.15rem;
+  left: 0.15rem;
+
+  padding: 0.3rem 0.3rem 0.3rem;
+}
+
 .media .delete img {
   width: 1rem;
   height: 1rem;

+ 0 - 2
webui/src/components/other/LabelTreeView.vue

@@ -43,7 +43,6 @@ export default {
   components: {EditableHeadline},
   props: ['label', 'indent', 'targetable'],
   data: function () {
-    console.log(this.label)
     return {
       untouched: true,
       target: false,
@@ -71,7 +70,6 @@ export default {
     },
     removeLabel: function () {
       // TODO then / error
-      console.log(this.label)
       let id = this.label.identifier;
       this.$root.socket.post(`/projects/${this.$root.project.identifier}/labels/${id}/remove`, {remove: true});
     },