6
0
Răsfoiți Sursa

added the showing of the pages in the paginated view and fixed the counting of the returned files

Dimitri Korsch 3 ani în urmă
părinte
comite
cea1bd07e6

+ 6 - 4
pycs/frontend/endpoints/projects/ListProjectFiles.py

@@ -38,17 +38,19 @@ class ListProjectFiles(View):
                 files = collection.get_files(offset=start, limit=length).all()
 
         else:
-            count = project.files.count()
-
 
             with_annotations = request.args.get("only_with_annotations")
-
             kwargs = dict(with_annotations=None)
 
             if with_annotations is not None:
                 kwargs["with_annotations"] = with_annotations == "1"
 
-            files = project.get_files(offset=start, limit=length, **kwargs).all()
+            # first get all files without specific limit
+            files = project.get_files(**kwargs)
+            # get the count of those
+            count = files.count()
+            # finally, limit to the desired offset and number of files
+            files = files.offset(start).limit(length).all()
 
         # return files
         return jsonify({

+ 4 - 4
webui/src/components/media/paginated-media.vue

@@ -25,14 +25,14 @@
       </div>
     </div>
 
-    <div v-if="!inline" class="pagination">
-      <div class="button" :class="{clickable: page > 1}" @click="prevPage">
+    <div class="pagination">
+      <div v-if="!inline" class="button" :class="{clickable: page > 1}" @click="prevPage">
         &lt;
       </div>
       <div class="text">
-        {{ page }} / {{ pageCount }}
+        Page {{ page }} / {{ pageCount }}
       </div>
-      <div class="button" :class="{clickable: page < pageCount}" @click="nextPage">
+      <div v-if="!inline" class="button" :class="{clickable: page < pageCount}" @click="nextPage">
         &gt;
       </div>
     </div>