5 files modified
3 files deleted
| | |
| | | <script setup> |
| | | |
| | | import {apiTokenValid, deleteApiToken} from "../lib/api" |
| | | import {apiTokenValid, deleteApiToken, routerBase} from "../lib/api" |
| | | |
| | | </script> |
| | | |
| | | <template> |
| | |
| | | <div class="header"> |
| | | <div>Globus-ILIAS-REST</div> |
| | | <div>|</div> |
| | | <RouterLink :to="`/ui/user`">Users</RouterLink> |
| | | <RouterLink :to="`/ui/kurs`">Courses</RouterLink> |
| | | <RouterLink :to="`${routerBase}/ui/user`">Users</RouterLink> |
| | | <RouterLink :to="`${routerBase}/ui/kurs`">Courses</RouterLink> |
| | | <div style="flex-grow: 1" /> |
| | | <div v-if="apiTokenValid"> |
| | | <button type="button" @click="deleteApiToken()">logout</button> |
| | |
| | | |
| | | export const apiBase = import.meta.env.VITE_API_BASE |
| | | export const iliasBase = import.meta.env.VITE_ILIAS_BASE |
| | | export const routerBase = import.meta.env.VITE_ROUTER_BASE |
| | | |
| | | /////// KURS //////////////////////////////////////////////////////////////// |
| | | |
| | |
| | | return await resKurs.json() |
| | | } |
| | | |
| | | /////// USER //////////////////////////////////////////////////////////////// |
| | | |
| | | export async function getUsers (offset, limit) { |
| | | const res = await fetch(`${apiBase}/users?offset=${offset}&limit=${limit}&token=${apiToken.value}`) |
| | | return res.json() |
| | | } |
| | | |
| | | export async function getUser (userId) { |
| | | const res = await fetch(`${apiBase}/user/userid/${userId}?token=${apiToken.value}`) |
| | | return await res.json() |
| | | } |
| | |
| | | |
| | | import {useRoute} from 'vue-router' |
| | | import {onMounted, reactive, ref} from "vue" |
| | | import {iliasBase} from "../lib/api" |
| | | import {getUser, iliasBase} from "../lib/api" |
| | | import LinkExtern from "../components/LinkExtern.vue" |
| | | |
| | | const route = useRoute() |
| | |
| | | ///////////////////////////////////////////////////////////////////////// |
| | | |
| | | async function init () { |
| | | const res = await fetch(`/api/user/userid/${userId}?token=jiuGfr432898D90290kjfsldkfn3hh8F`) |
| | | const data = await res.json() |
| | | const data = await getUser(userId) |
| | | console.log(data) |
| | | if (res.status === 200) { |
| | | user.value = data |
| | | } |
| | | else { |
| | | error.value = `ERROR: ${res.status}` |
| | | } |
| | | } |
| | | |
| | | </script> |
| | |
| | | <template> |
| | | |
| | | <div> |
| | | <h1> |
| | | <h1>asdf |
| | | User {{ userId }} |
| | | <small class="ml-05">{{ user?.firstname }} {{ user?.lastname }}</small> |
| | | </h1> |
| | |
| | | import {onMounted, reactive, ref} from "vue" |
| | | import {useRoute} from "vue-router" |
| | | import Pagination from "../components/Pagination.vue" |
| | | import {getUsers} from "@/lib/api" |
| | | |
| | | const route = useRoute() |
| | | const userId = route.params.userId |
| | |
| | | ///////////////////////////////////////////////////////////////////////// |
| | | |
| | | async function init (offset = 0) { |
| | | const res = await fetch(`/api/users?offset=${offset}&limit=${limit}&token=jiuGfr432898D90290kjfsldkfn3hh8F`) |
| | | const data = await res.json() |
| | | // const res = await fetch(`/api/users?offset=${offset}&limit=${limit}&token=jiuGfr432898D90290kjfsldkfn3hh8F`) |
| | | // const data = await res.json() |
| | | const data = await getUsers(offset, limit) |
| | | console.log(data) |
| | | if (res.status === 200) { |
| | | Object.assign(users,data) |
| | | } |
| | | else { |
| | | error.value = `ERROR: ${res.status}` |
| | | } |
| | | } |
| | | |
| | | function go (offset) { |
| | |
| | | |
| | | |
| | | const routes = [ |
| | | { path: `/`, redirect: "/user" }, |
| | | { path: `/`, redirect: "/ui/user" }, |
| | | { path: `/ui/user`, component: Users }, |
| | | { path: `/ui/user/:userId`, component: UserDetail }, |
| | | { path: `/ui/kurs`, component: Kurse }, |