REST Service for POPCORN - ILIAS
alex
2025-06-03 fd94c517909211b0079a225f1c438a07f96289cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<script setup>
 
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
const users = reactive({
   total: 0,
   offset: 0,
   limit: 10,
   data: [],
})
const limit = 24
const error = ref(null)
 
onMounted(init)
 
/////////////////////////////////////////////////////////////////////////
 
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) {
      Object.assign(users,data)
   }
   else {
      error.value = `ERROR: ${res.status}`
   }
}
 
function go (offset) {
   console.log("go", offset)
   return init(offset)
}
 
</script>
 
<template>
 
   <div>
 
      <h1>
         ILIAS Users
<!--         <small>{{users.offset}} - {{users.offset+users.data.length}} von {{users.total}}</small>-->
      </h1>
      <p>{{ userId }}</p>
      <p v-if="error">{{ error }}</p>
 
      <div class="users">
 
         <Pagination :offset="users.offset" :limit="users.limit" :total="users.total" @go="go" />
 
         <table class="w100p">
            <thead>
               <tr>
                  <th>usr_id</th>
                  <th>login</th>
                  <th>firstname</th>
                  <th>lastname</th>
                  <th>gender</th>
<!--                  <th>email</th>-->
                  <th>institution</th>
                  <th>department</th>
               </tr>
            </thead>
            <tbody>
               <tr v-for="user in users.data">
                  <td>
                     <RouterLink :to="`/ui/user/${user.usr_id}`">
                        {{user.usr_id}}
                     </RouterLink>
                  </td>
                  <td>{{user.login}}</td>
                  <td>{{user.firstname}}</td>
                  <td>{{user.lastname}}</td>
                  <td>{{user.gender}}</td>
<!--                  <td>{{ user.email}}</td>-->
                  <td>{{user.institution}}</td>
                  <td>{{user.department}}</td>
               </tr>
            </tbody>
         </table>
      </div>
 
<!--      <pre>{{ users }}</pre>-->
   </div>
 
</template>
 
<style scoped>
 
</style>