From c24428b52feeb4b9cfbafac2541e40e9a891b428 Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Sun, 08 Jun 2025 16:34:04 +0000
Subject: [PATCH] fixing current count

---
 vue/src/components/Pagination.vue |    4 +++-
 settings.default.json             |    2 +-
 vue/src/pages/Users.vue           |    2 +-
 lib/search.js                     |    5 ++++-
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/search.js b/lib/search.js
index d6b3d76..1f08c51 100644
--- a/lib/search.js
+++ b/lib/search.js
@@ -89,7 +89,10 @@
       users = JSON.parse(users)
    }
    else {
-      // TODO zweite möglichkeit "readFromApi" implementieren
+      console.log("~~~ reading users from DB ... ~~~")
+      const db = require("./db")
+      const {data} = await db.getUsers(0, 100000)
+      users = data
    }
 
    for (const user of users) {
diff --git a/settings.default.json b/settings.default.json
index c262127..a9dd7f3 100644
--- a/settings.default.json
+++ b/settings.default.json
@@ -9,7 +9,7 @@
       "password": "paaa322ss"
    },
    "search": {
-      "readFromFile": true,
+      "readFromFile": false,
       "file": "users-local.json"
    }
 }
diff --git a/vue/src/components/Pagination.vue b/vue/src/components/Pagination.vue
index 69fc0e5..02c85b0 100644
--- a/vue/src/components/Pagination.vue
+++ b/vue/src/components/Pagination.vue
@@ -10,6 +10,7 @@
    total: Number,
    offset: Number,
    limit: Number,
+   current: Number,
 })
 
 const emit = defineEmits(["go"])
@@ -70,9 +71,10 @@
 
    <div class="pagination">
       <div class="pagination-buttons">
+<!--         <pre>&#45;&#45;{{current}}&#45;&#45;</pre>-->
          <input type="button" @click="goStart()" class="start" value="«">
          <input type="button" @click="goPrev()" class="prev" value="‹">
-         <span class="current">{{ offset }} - {{ offset + limit }} / {{ total }}</span>
+         <span class="current">{{ offset }} - {{ offset + current }} / {{ total }}</span>
          <input type="button" @click="goNext()" class="next" value="›">
          <input type="button" @click="goEnd()" class="end" value="»">
          <KeyboardToggle :initial="false" @toggle="toggleKeyboard" style="color: #666" />
diff --git a/vue/src/pages/Users.vue b/vue/src/pages/Users.vue
index 2d3c225..eb21ccf 100644
--- a/vue/src/pages/Users.vue
+++ b/vue/src/pages/Users.vue
@@ -73,7 +73,7 @@
                   <div style="transform:scale(1.4); font-weight: bold;">&times;</div>
                </button>
             </div>
-            <Pagination :offset="users.offset" :limit="users.limit" :total="users.total" @go="go" />
+            <Pagination :offset="users.offset" :limit="users.limit" :total="users.total" :current="users.data.length" @go="go" />
          </div>
 
          <table class="w100p">

--
Gitblit v1.8.0