REST Service for POPCORN - ILIAS
alex
2025-10-23 1eb86629227181c4c05c8a34100f7e54a57574a8
vue/src/pages/Kurse.vue
@@ -3,79 +3,92 @@
import {onMounted, reactive, ref} from "vue"
import {useRoute} from "vue-router"
import Pagination from "../components/Pagination.vue"
import {routerBase} from "@/lib/api"
import {getKurse, routerBase} from "@/lib/api"
document.title = 'Kurse | globus-ilias-rest'
const route = useRoute()
const kurse = ref([])
const error = ref(null)
onMounted(init)
/////////////////////////////////////////////////////////////////////////
async function init (offset = 0) {
   const res = await fetch(`/api/kurs?token=jiuGfr432898D90290kjfsldkfn3hh8F`)
   const data = await res.json()
   console.log(data)
   if (res.status === 200) {
      kurse.value = data
   }
   else {
      error.value = `ERROR: ${res.status}`
   }
async function init(offset = 0) {
  const data = await getKurse()
  console.log(data)
  kurse.value = data
}
function go (offset) {
   console.log("go", offset)
   return init(offset)
function go(offset) {
  console.log("go", offset)
  return init(offset)
}
</script>
<template>
   <div>
  <div>
      <h1>
         ILIAS Kurse
<!--         <small>{{users.offset}} - {{users.offset+users.data.length}} von {{users.total}}</small>-->
      </h1>
      <p v-if="error">{{ error }}</p>
    <h1>
      ILIAS Kurse
      <small>({{ kurse?.length }})</small>
    </h1>
    <p v-if="error">{{ error }}</p>
      <div class="kurse">
    <div class="kurse">
         <table class="w100p" v-if="kurse">
            <thead>
               <tr>
                  <th>usr_id</th>
                  <th>obj_id</th>
                  <th>title</th>
                  <th>description</th>
                  <th>type</th>
               </tr>
            </thead>
            <tbody>
               <tr v-for="kurs in kurse">
                  <td>
                     <RouterLink :to="`${routerBase}/ui/kurs/${kurs.ref_id}`">
                        {{kurs.ref_id}}
                     </RouterLink>
                  </td>
                  <td>{{kurs.obj_id}}</td>
                  <td>{{kurs.title}}</td>
                  <td>{{kurs.description}}</td>
                  <td>{{kurs.type}}</td>
               </tr>
            </tbody>
         </table>
      </div>
      <table class="w100p" v-if="kurse">
        <thead>
        <tr>
          <th>usr_id</th>
          <th>obj_id</th>
          <th>title</th>
          <th>description</th>
          <th>type</th>
          <th>offline</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="kurs in kurse">
          <td>
            <RouterLink :to="`${routerBase}/ui/kurs/${kurs.ref_id}`">
              {{ kurs.ref_id }}
            </RouterLink>
          </td>
          <td>{{ kurs.obj_id }}</td>
          <td>{{ kurs.title }}</td>
          <td>{{ kurs.description }}</td>
          <td>{{ kurs.type }}</td>
          <td>
            <div :class="{red:kurs.offline===1,green:kurs.offline===0}">
              {{ kurs.offline }}
            </div>
          </td>
        </tr>
        </tbody>
      </table>
    </div>
<!--      <pre>{{ kurse }}</pre>-->
    <!--      <pre>{{ kurse }}</pre>-->
   </div>
  </div>
</template>
<style scoped>
<style scoped lang="stylus">
//
//.red
//  max-width 2ch
//  text-align center;
//  background-color red;
//  color white
//  font-weight bold
//
//.green
//  color green
</style>