47 lines
1.2 KiB
Vue
Raw Normal View History

2020-05-21 10:21:32 +02:00
<template>
2020-05-22 13:57:47 +02:00
<v-container fluid>
2020-05-21 10:21:32 +02:00
<div v-bind:key="user.username" v-for="user in users">
<UsersItems v-bind:user="user" v-on:edit-user="edituser" />
</div>
2020-05-22 13:57:47 +02:00
</v-container>
2020-05-21 10:21:32 +02:00
</template>
<script>
import { baseUri } from "../variables.js";
import UsersItems from "./UsersItems.vue";
export default {
components: {
UsersItems
},
data: () => ({
2020-05-24 10:46:03 +02:00
users: JSON.parse(sessionStorage.getItem("users")),
dialog: false
2020-05-21 10:21:32 +02:00
}),
methods: {
2020-05-24 10:46:03 +02:00
edituser(userlink) {
sessionStorage.setItem("edituser", userlink);
window.location.href = "http://localhost:8080/edituser";
2020-05-21 10:21:32 +02:00
}
},
created() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
2020-05-24 10:46:03 +02:00
var usersInformation = JSON.parse(xhttp.responseText);
2020-05-21 10:21:32 +02:00
sessionStorage.setItem(
"users",
JSON.stringify(usersInformation._embedded.users)
);
}
};
xhttp.open("GET", baseUri + "/users", false);
xhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
xhttp.send(null);
this.users = JSON.parse(sessionStorage.getItem("users"));
}
};
</script>