From d70351c84732844b76b7f1992b60114619eb6381 Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Tue, 03 Jun 2025 10:55:14 +0000
Subject: [PATCH] adding Pagination.vue

---
 vue/src/pages/Users.vue |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/vue/src/pages/Users.vue b/vue/src/pages/Users.vue
index 0fae2d8..8e3b0e6 100644
--- a/vue/src/pages/Users.vue
+++ b/vue/src/pages/Users.vue
@@ -2,6 +2,7 @@
 
 import {onMounted, reactive, ref} from "vue"
 import {useRoute} from "vue-router"
+import Pagination from "../components/Pagination.vue"
 
 const route = useRoute()
 const userId = route.params.userId
@@ -18,8 +19,8 @@
 
 /////////////////////////////////////////////////////////////////////////
 
-async function init () {
-   const res = await fetch(`/api/users?limit=${limit}&token=jiuGfr432898D90290kjfsldkfn3hh8F`)
+async function init (offset = 0) {
+   const res = await fetch(`/api/users?offset=${offset}&limit=${limit}&token=jiuGfr432898D90290kjfsldkfn3hh8F`)
    const data = await res.json()
    console.log(data)
    if (res.status === 200) {
@@ -28,6 +29,11 @@
    else {
       error.value = `ERROR: ${res.status}`
    }
+}
+
+function go (offset) {
+   console.log("go", offset)
+   return init(offset)
 }
 
 </script>
@@ -39,17 +45,17 @@
       <h1>
          Users
          <small>
-            {{users.offset}} - {{users.offset+users.limit}} von {{users.total}}
+            {{users.offset}} - {{users.offset+users.data.length}} von {{users.total}}
          </small>
       </h1>
       <p>{{ userId }}</p>
       <p v-if="error">{{ error }}</p>
 
-      <div class="user">
+      <div class="users">
 
+         <Pagination :offset="users.offset" :limit="users.limit" :total="users.total" @go="go" />
 
-
-         <table class="">
+         <table class="w100p">
             <thead>
                <tr>
                   <th>usr_id</th>
@@ -57,7 +63,7 @@
                   <th>firstname</th>
                   <th>lastname</th>
                   <th>gender</th>
-                  <th>email</th>
+<!--                  <th>email</th>-->
                   <th>institution</th>
                   <th>department</th>
                </tr>
@@ -73,7 +79,7 @@
                   <td>{{user.firstname}}</td>
                   <td>{{user.lastname}}</td>
                   <td>{{user.gender}}</td>
-                  <td>{{user.email}}</td>
+<!--                  <td>{{ user.email}}</td>-->
                   <td>{{user.institution}}</td>
                   <td>{{user.department}}</td>
                </tr>

--
Gitblit v1.8.0