Format TimetrackAccount related things

This commit is contained in:
Marcel Schwarz 2020-07-21 21:59:44 +02:00
parent 286d1c7fda
commit ebd5493e46
3 changed files with 162 additions and 168 deletions

View File

@ -1,5 +1,5 @@
<template > <template>
<v-container id = "createAccountListen"> <v-container id="createAccountListen">
<v-card align-center> <v-card align-center>
<p class="text-center logowhite--text" style="font-size:30pt">Details</p> <p class="text-center logowhite--text" style="font-size:30pt">Details</p>
@ -37,8 +37,9 @@
</v-container> </v-container>
</template> </template>
<script> <script>
import { baseUri } from "../variables"; import {baseUri} from "../variables";
export default {
export default {
name: "CreateTimeTrackAccount", name: "CreateTimeTrackAccount",
data: () => ({ data: () => ({
user: sessionStorage.getItem("timeTrackAccountListUserId"), user: sessionStorage.getItem("timeTrackAccountListUserId"),
@ -52,7 +53,7 @@ export default {
if (this.newname != "" || this.newrevenue != "" || this.newdescription != "") { if (this.newname != "" || this.newrevenue != "" || this.newdescription != "") {
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
var suc; var suc;
xhttp.onreadystatechange = function() { xhttp.onreadystatechange = function () {
if ((this.status == 201) & (this.readyState == 4)) { if ((this.status == 201) & (this.readyState == 4)) {
suc = true; suc = true;
} }
@ -73,7 +74,7 @@ export default {
this.newdescription + this.newdescription +
'"}' '"}'
); );
if (suc == true ) { if (suc == true) {
this.$router.push("/timetrackaccounts"); this.$router.push("/timetrackaccounts");
} }
} }
@ -89,5 +90,5 @@ export default {
} }
}); });
} }
}; };
</script> </script>

View File

@ -1,5 +1,5 @@
<template > <template>
<v-container id = "editAccountListen"> <v-container id="editAccountListen">
<v-card align-center> <v-card align-center>
<div class="text-center ma-3"> <div class="text-center ma-3">
<p class="text-center logowhite--text" style="font-size:30pt">Account to edit:</p> <p class="text-center logowhite--text" style="font-size:30pt">Account to edit:</p>
@ -45,7 +45,7 @@
</template> </template>
<script> <script>
export default { export default {
name: "EditTimeTrackAccount", name: "EditTimeTrackAccount",
data: () => ({ data: () => ({
name: "", name: "",
@ -63,9 +63,9 @@ export default {
if (this.newname != this.name || this.newrevenue != this.revenue || this.newdescription != this.description) { if (this.newname != this.name || this.newrevenue != this.revenue || this.newdescription != this.description) {
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
var suc; var suc;
xhttp.onreadystatechange = function() { xhttp.onreadystatechange = function () {
if ((this.status == 200) & (this.readyState == 4)) { if ((this.status == 200) & (this.readyState == 4)) {
suc =true; suc = true;
} }
}; };
xhttp.open("PATCH", link, false); xhttp.open("PATCH", link, false);
@ -82,8 +82,8 @@ export default {
this.newdescription + this.newdescription +
'"}' '"}'
); );
if(suc ==true){ if (suc == true) {
this.$router.push( "/timetrackaccounts"); this.$router.push("/timetrackaccounts");
} }
} }
}, },
@ -92,7 +92,7 @@ export default {
var accountxhttp = new XMLHttpRequest(); var accountxhttp = new XMLHttpRequest();
var account; var account;
accountxhttp.onreadystatechange = function() { accountxhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
account = JSON.parse(accountxhttp.responseText); account = JSON.parse(accountxhttp.responseText);
} }
@ -125,5 +125,5 @@ export default {
} }
}); });
} }
}; };
</script> </script>

View File

@ -20,10 +20,10 @@
</template> </template>
<script> <script>
import { baseUri} from "../variables.js"; import {baseUri} from "../variables.js";
import TimeTrackAccountItem from "./TimeTrackAccountItem.vue"; import TimeTrackAccountItem from "./TimeTrackAccountItem.vue";
export default { export default {
name: "TimeTrackAccounts", name: "TimeTrackAccounts",
components: { components: {
TimeTrackAccountItem TimeTrackAccountItem
@ -37,27 +37,21 @@ export default {
methods: { methods: {
deleteTimeTrackAccount(selfLink) { deleteTimeTrackAccount(selfLink) {
var accountxhttp = new XMLHttpRequest(); var accountxhttp = new XMLHttpRequest();
accountxhttp.onreadystatechange = function() { accountxhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 204) { if (this.readyState == 4 && this.status == 204) {
location.reload(); location.reload();
} }
}; };
accountxhttp.open("DELETE", selfLink , false); accountxhttp.open("DELETE", selfLink, false);
accountxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
accountxhttp.setRequestHeader(
"Authorization",
sessionStorage.getItem("jwt")
);
accountxhttp.send(null); accountxhttp.send(null);
}, },
editTimeTrackAccount(selfLink) { editTimeTrackAccount(selfLink) {
sessionStorage.setItem("timeTrackAccountEditSelfLink", selfLink); sessionStorage.setItem("timeTrackAccountEditSelfLink", selfLink);
this.$router.push("/edittimetrackaccount");
this.$router.push( "/edittimetrackaccount");
}, },
createTimeTrackAccount() { createTimeTrackAccount() {
this.$router.push( "/createtimetrackaccount"); this.$router.push("/createtimetrackaccount");
} }
}, },
@ -65,7 +59,7 @@ export default {
var accounts; var accounts;
var timeTrackAccountsTMP; var timeTrackAccountsTMP;
var accountxhttp = new XMLHttpRequest(); var accountxhttp = new XMLHttpRequest();
accountxhttp.onreadystatechange = function() { accountxhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
accounts = JSON.parse(accountxhttp.responseText); accounts = JSON.parse(accountxhttp.responseText);
timeTrackAccountsTMP = accounts._embedded.accounts; timeTrackAccountsTMP = accounts._embedded.accounts;
@ -80,12 +74,11 @@ export default {
); );
accountxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt")); accountxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
accountxhttp.send(null); accountxhttp.send(null);
this.timeTrackAccounts = timeTrackAccountsTMP; this.timeTrackAccounts = timeTrackAccountsTMP;
} }
}; };
</script> </script>
<style scoped> <style scoped>