Format User related stuff
This commit is contained in:
parent
ebd5493e46
commit
3321f4a58a
@ -1,11 +1,9 @@
|
||||
<template >
|
||||
<template>
|
||||
<v-container>
|
||||
<v-card align-center>
|
||||
<div class="text-center ma-3">
|
||||
<p class="text-center logowhite--text" style="font-size:30pt">User to edit:</p>
|
||||
<p class="text-center logowhite--text" style="font-size:30pt">{{username}}</p>
|
||||
|
||||
|
||||
</div>
|
||||
</v-card>
|
||||
<v-card align-center>
|
||||
@ -73,8 +71,9 @@
|
||||
</v-container>
|
||||
</template>
|
||||
<script>
|
||||
import { baseUri} from "../variables";
|
||||
export default {
|
||||
import {baseUri} from "../variables";
|
||||
|
||||
export default {
|
||||
name: "Edituser",
|
||||
data: () => ({
|
||||
firstname: "",
|
||||
@ -92,15 +91,13 @@ export default {
|
||||
var suc;
|
||||
if (this.firstname != "" && this.lastname != "") {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
|
||||
xhttp.onreadystatechange = function() {
|
||||
xhttp.onreadystatechange = function () {
|
||||
if ((this.status == 200) & (this.readyState == 4)) {
|
||||
suc= true;
|
||||
suc = true;
|
||||
}
|
||||
};
|
||||
xhttp.open("PATCH", link, false);
|
||||
xhttp.setRequestHeader("Content-Type", "application/json");
|
||||
|
||||
xhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
|
||||
xhttp.send(
|
||||
"{" +
|
||||
@ -110,43 +107,35 @@ export default {
|
||||
this.lastname +
|
||||
'"}'
|
||||
);
|
||||
if(suc == true ){
|
||||
if (suc == true) {
|
||||
this.$router.push("/users");
|
||||
}
|
||||
} else if (this.firstname != "") {
|
||||
var xhttpfirst = new XMLHttpRequest();
|
||||
|
||||
xhttpfirst.onreadystatechange = function() {
|
||||
xhttpfirst.onreadystatechange = function () {
|
||||
if ((this.status == 200) & (this.readyState == 4)) {
|
||||
suc = true;
|
||||
}
|
||||
};
|
||||
xhttpfirst.open("PATCH", link, false);
|
||||
xhttpfirst.setRequestHeader("Content-Type", "application/json");
|
||||
xhttpfirst.setRequestHeader(
|
||||
"Authorization",
|
||||
sessionStorage.getItem("jwt")
|
||||
);
|
||||
xhttpfirst.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
|
||||
xhttpfirst.send("{" + '"firstname": "' + this.firstname + '"}');
|
||||
if(suc == true ){
|
||||
if (suc == true) {
|
||||
this.$router.push("/users");
|
||||
}
|
||||
} else if (this.lastname != "") {
|
||||
var xhttplast = new XMLHttpRequest();
|
||||
|
||||
xhttplast.onreadystatechange = function() {
|
||||
xhttplast.onreadystatechange = function () {
|
||||
if ((this.status == 200) & (this.readyState == 4)) {
|
||||
suc = true;
|
||||
}
|
||||
};
|
||||
xhttplast.open("PATCH", link, false);
|
||||
xhttplast.setRequestHeader("Content-Type", "application/json");
|
||||
xhttplast.setRequestHeader(
|
||||
"Authorization",
|
||||
sessionStorage.getItem("jwt")
|
||||
);
|
||||
xhttplast.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
|
||||
xhttplast.send("{" + '"lastname": "' + this.lastname + '"}');
|
||||
if(suc == true ){
|
||||
if (suc == true) {
|
||||
this.$router.push("/users");
|
||||
}
|
||||
} else {
|
||||
@ -158,14 +147,11 @@ export default {
|
||||
var link = sessionStorage.getItem("edituser");
|
||||
if (this.longitude != "" && this.latitude != "" && this.radius) {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
|
||||
xhttp.onreadystatechange = function() {
|
||||
xhttp.onreadystatechange = function () {
|
||||
if ((this.status == 201) & (this.readyState == 4)) {
|
||||
var location = JSON.parse(xhttp.responseText);
|
||||
sessionStorage.setItem("locationlink", location._links.self.href);
|
||||
} else if(this.readyState == 4 ){
|
||||
|
||||
|
||||
} else if (this.readyState == 4) {
|
||||
numericerror = true;
|
||||
document.getElementById("locationnotcomplete").innerHTML = "Only numeric values are allowed";
|
||||
}
|
||||
@ -185,22 +171,17 @@ export default {
|
||||
'"}'
|
||||
);
|
||||
|
||||
|
||||
if (numericerror == false) {
|
||||
|
||||
var xhttpadd = new XMLHttpRequest();
|
||||
var suc;
|
||||
xhttpadd.onreadystatechange = function() {
|
||||
xhttpadd.onreadystatechange = function () {
|
||||
if ((this.status == 200) & (this.readyState == 4)) {
|
||||
suc = true;
|
||||
}
|
||||
};
|
||||
xhttpadd.open("PATCH", link, false);
|
||||
xhttpadd.setRequestHeader("Content-Type", "application/json");
|
||||
xhttpadd.setRequestHeader(
|
||||
"Authorization",
|
||||
sessionStorage.getItem("jwt")
|
||||
);
|
||||
xhttpadd.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
|
||||
xhttpadd.send(
|
||||
"{" +
|
||||
'"location": "' +
|
||||
@ -220,7 +201,7 @@ export default {
|
||||
},
|
||||
created() {
|
||||
var userxhttp = new XMLHttpRequest();
|
||||
userxhttp.onreadystatechange = function() {
|
||||
userxhttp.onreadystatechange = function () {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
var username = JSON.parse(userxhttp.responseText);
|
||||
sessionStorage.setItem(
|
||||
@ -229,14 +210,10 @@ export default {
|
||||
);
|
||||
}
|
||||
};
|
||||
userxhttp.open("GET",sessionStorage.getItem("edituser"), false);
|
||||
|
||||
userxhttp.open("GET", sessionStorage.getItem("edituser"), false);
|
||||
userxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
|
||||
|
||||
userxhttp.send(null);
|
||||
this.username = sessionStorage.getItem("usernameedit");
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
</script>
|
@ -1,7 +1,8 @@
|
||||
<template>
|
||||
<v-container fluid>
|
||||
<div v-bind:key="user.username" v-for="user in users">
|
||||
<UsersItems v-bind:user="user" v-on:edit-user="edituser" v-on:del-user="deluser" v-on:show-accounts="showAccounts"/>
|
||||
<UsersItems v-bind:user="user" v-on:edit-user="edituser" v-on:del-user="deluser"
|
||||
v-on:show-accounts="showAccounts"/>
|
||||
</div>
|
||||
<v-row>
|
||||
<v-col cols="5"></v-col>
|
||||
@ -21,9 +22,10 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { baseUri} from "../variables.js";
|
||||
import UsersItems from "./UsersItems.vue";
|
||||
export default {
|
||||
import {baseUri} from "../variables.js";
|
||||
import UsersItems from "./UsersItems.vue";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
UsersItems
|
||||
},
|
||||
@ -36,31 +38,23 @@ export default {
|
||||
}),
|
||||
methods: {
|
||||
edituser(userlink) {
|
||||
|
||||
sessionStorage.setItem("edituser", userlink);
|
||||
|
||||
this.$router.push( "/edituser");
|
||||
this.$router.push("/edituser");
|
||||
},
|
||||
deluser(selfLink){
|
||||
deluser(selfLink) {
|
||||
var userxhttp = new XMLHttpRequest();
|
||||
userxhttp.onreadystatechange = function() {
|
||||
userxhttp.onreadystatechange = function () {
|
||||
if (this.readyState == 4 && this.status == 204) {
|
||||
location.reload();
|
||||
}
|
||||
};
|
||||
userxhttp.open("DELETE", selfLink , false);
|
||||
|
||||
userxhttp.setRequestHeader(
|
||||
"Authorization",
|
||||
sessionStorage.getItem("jwt")
|
||||
);
|
||||
|
||||
userxhttp.open("DELETE", selfLink, false);
|
||||
userxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
|
||||
userxhttp.send(null);
|
||||
},
|
||||
showAccounts(username, uid) {
|
||||
sessionStorage.setItem("timeTrackAccountListUser", username);
|
||||
sessionStorage.setItem("timeTrackAccountListUserId", uid);
|
||||
|
||||
this.$router.push("/timetrackaccounts");
|
||||
},
|
||||
nextPage() {
|
||||
@ -81,17 +75,14 @@ export default {
|
||||
}
|
||||
sessionStorage.removeItem("page");
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function() {
|
||||
xhttp.onreadystatechange = function () {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
var usersInformation = JSON.parse(xhttp.responseText);
|
||||
sessionStorage.setItem(
|
||||
"users",
|
||||
JSON.stringify(usersInformation._embedded.users)
|
||||
);
|
||||
sessionStorage.setItem("users", JSON.stringify(usersInformation._embedded.users));
|
||||
userLinks = usersInformation._links;
|
||||
}
|
||||
};
|
||||
xhttp.open("GET", baseUri + "/users?page=" +this.page, false);
|
||||
xhttp.open("GET", baseUri + "/users?page=" + this.page, false);
|
||||
|
||||
xhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
|
||||
|
||||
@ -104,5 +95,5 @@ export default {
|
||||
}
|
||||
this.users = JSON.parse(sessionStorage.getItem("users"));
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
@ -5,10 +5,9 @@
|
||||
<v-row no-gutters align="center">
|
||||
<v-col cols="1">
|
||||
<v-avatar>
|
||||
<img src="https://cdn.vuetifyjs.com/images/john.jpg" alt="John" />
|
||||
<img src="https://cdn.vuetifyjs.com/images/john.jpg" alt="John"/>
|
||||
</v-avatar>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="3">
|
||||
<v-card color="background" elevation="0">
|
||||
<pre><v-icon color="primary">mdi-account</v-icon>{{" " + user.username}}</pre>
|
||||
@ -26,12 +25,7 @@
|
||||
</v-row>
|
||||
</v-list-item-content>
|
||||
<v-list-item-action>
|
||||
<v-speed-dial
|
||||
v-model="fab"
|
||||
transition="slide-x-reverse-transition"
|
||||
direction="left"
|
||||
open-on-hover
|
||||
>
|
||||
<v-speed-dial v-model="fab" transition="slide-x-reverse-transition" direction="left" open-on-hover>
|
||||
<template v-slot:activator>
|
||||
<v-btn v-model="fab" color="background" elevation="0" dark fab>
|
||||
<v-icon v-if="fab">mdi-close</v-icon>
|
||||
@ -54,7 +48,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
export default {
|
||||
name: "UsersItems",
|
||||
props: ["user"],
|
||||
data: () => ({
|
||||
@ -64,16 +58,15 @@ export default {
|
||||
getUid(hrefTmp) {
|
||||
var parts = hrefTmp.split("/");
|
||||
return parts[4];
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.v-card {
|
||||
.v-card {
|
||||
border-color: #131313 !important;
|
||||
border-width: 3px !important;
|
||||
border-radius: 10000px !important;
|
||||
}
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user