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 >
<v-container id = "createAccountListen">
<template>
<v-container id="createAccountListen">
<v-card align-center>
<p class="text-center logowhite--text" style="font-size:30pt">Details</p>
@ -37,32 +37,33 @@
</v-container>
</template>
<script>
import { baseUri } from "../variables";
export default {
name: "CreateTimeTrackAccount",
data: () => ({
user: sessionStorage.getItem("timeTrackAccountListUserId"),
newname: "",
newrevenue: "",
newdescription: "",
}),
import {baseUri} from "../variables";
methods: {
addAccount() {
if (this.newname != "" || this.newrevenue != "" || this.newdescription != "") {
var xhttp = new XMLHttpRequest();
var suc;
xhttp.onreadystatechange = function() {
if ((this.status == 201) & (this.readyState == 4)) {
suc = true;
}
};
xhttp.open("POST", baseUri + "/accounts", false);
xhttp.setRequestHeader("Content-Type", "application/json");
export default {
name: "CreateTimeTrackAccount",
data: () => ({
user: sessionStorage.getItem("timeTrackAccountListUserId"),
newname: "",
newrevenue: "",
newdescription: "",
}),
xhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
xhttp.send(
"{" +
methods: {
addAccount() {
if (this.newname != "" || this.newrevenue != "" || this.newdescription != "") {
var xhttp = new XMLHttpRequest();
var suc;
xhttp.onreadystatechange = function () {
if ((this.status == 201) & (this.readyState == 4)) {
suc = true;
}
};
xhttp.open("POST", baseUri + "/accounts", false);
xhttp.setRequestHeader("Content-Type", "application/json");
xhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
xhttp.send(
"{" +
'"user": "' +
this.user +
'", "revenue": "' +
@ -72,22 +73,22 @@ export default {
'", "description": "' +
this.newdescription +
'"}'
);
if (suc == true ) {
this.$router.push("/timetrackaccounts");
);
if (suc == true) {
this.$router.push("/timetrackaccounts");
}
}
}
},
},
},
mounted() {
var listen = document.getElementById('createAccountListen');
listen.addEventListener("keyup", e => {
if (e.keyCode === 13) {
e.preventDefault();
mounted() {
var listen = document.getElementById('createAccountListen');
listen.addEventListener("keyup", e => {
if (e.keyCode === 13) {
e.preventDefault();
this.addAccount();
}
});
}
};
</script>
this.addAccount();
}
});
}
};
</script>

View File

@ -1,5 +1,5 @@
<template >
<v-container id = "editAccountListen">
<template>
<v-container id="editAccountListen">
<v-card align-center>
<div class="text-center ma-3">
<p class="text-center logowhite--text" style="font-size:30pt">Account to edit:</p>
@ -45,35 +45,35 @@
</template>
<script>
export default {
name: "EditTimeTrackAccount",
data: () => ({
name: "",
revenue: "",
description: "",
newname: "",
newrevenue: "",
newdescription: "",
}),
export default {
name: "EditTimeTrackAccount",
data: () => ({
name: "",
revenue: "",
description: "",
newname: "",
newrevenue: "",
newdescription: "",
}),
methods: {
editAccount() {
var link = sessionStorage.getItem("timeTrackAccountEditSelfLink");
methods: {
editAccount() {
var link = sessionStorage.getItem("timeTrackAccountEditSelfLink");
if (this.newname != this.name || this.newrevenue != this.revenue || this.newdescription != this.description) {
var xhttp = new XMLHttpRequest();
var suc;
xhttp.onreadystatechange = function() {
if ((this.status == 200) & (this.readyState == 4)) {
suc =true;
}
};
xhttp.open("PATCH", link, false);
xhttp.setRequestHeader("Content-Type", "application/json");
if (this.newname != this.name || this.newrevenue != this.revenue || this.newdescription != this.description) {
var xhttp = new XMLHttpRequest();
var suc;
xhttp.onreadystatechange = function () {
if ((this.status == 200) & (this.readyState == 4)) {
suc = true;
}
};
xhttp.open("PATCH", link, false);
xhttp.setRequestHeader("Content-Type", "application/json");
xhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
xhttp.send(
"{" +
xhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
xhttp.send(
"{" +
'"name": "' +
this.newname +
'", "revenue": "' +
@ -81,49 +81,49 @@ export default {
'", "description": "' +
this.newdescription +
'"}'
);
if(suc ==true){
this.$router.push( "/timetrackaccounts");
);
if (suc == true) {
this.$router.push("/timetrackaccounts");
}
}
}
},
},
},
created() {
var accountxhttp = new XMLHttpRequest();
var account;
created() {
var accountxhttp = new XMLHttpRequest();
var account;
accountxhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
account = JSON.parse(accountxhttp.responseText);
}
};
accountxhttp.open(
"GET",
sessionStorage.getItem("timeTrackAccountEditSelfLink"),
false
);
accountxhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
account = JSON.parse(accountxhttp.responseText);
}
};
accountxhttp.open(
"GET",
sessionStorage.getItem("timeTrackAccountEditSelfLink"),
false
);
accountxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
accountxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
accountxhttp.send(null);
this.name = account.name;
this.revenue = account.revenue;
this.description = account.description;
accountxhttp.send(null);
this.name = account.name;
this.revenue = account.revenue;
this.description = account.description;
this.newname = account.name;
this.newrevenue = account.revenue;
this.newdescription = account.description;
this.newname = account.name;
this.newrevenue = account.revenue;
this.newdescription = account.description;
},
mounted() {
var listen = document.getElementById('editAccountListen');
listen.addEventListener("keyup", e => {
if (e.keyCode === 13) {
e.preventDefault();
},
mounted() {
var listen = document.getElementById('editAccountListen');
listen.addEventListener("keyup", e => {
if (e.keyCode === 13) {
e.preventDefault();
this.editAccount();
}
});
}
};
</script>
this.editAccount();
}
});
}
};
</script>

View File

@ -10,7 +10,7 @@
<v-row>
<v-col cols="6"></v-col>
<v-col cols="1">
<v-btn v-if="loggedIn == 'true'" fab color="primary" @click="createTimeTrackAccount()">
<v-btn v-if="loggedIn == 'true'" fab color="primary" @click="createTimeTrackAccount()">
<v-icon>mdi-plus</v-icon>
</v-btn>
</v-col>
@ -20,73 +20,66 @@
</template>
<script>
import { baseUri} from "../variables.js";
import TimeTrackAccountItem from "./TimeTrackAccountItem.vue";
import {baseUri} from "../variables.js";
import TimeTrackAccountItem from "./TimeTrackAccountItem.vue";
export default {
name: "TimeTrackAccounts",
components: {
TimeTrackAccountItem
},
data() {
return {
timeTrackAccounts: "",
loggedIn: sessionStorage.getItem("loggedin")
};
},
methods: {
deleteTimeTrackAccount(selfLink) {
export default {
name: "TimeTrackAccounts",
components: {
TimeTrackAccountItem
},
data() {
return {
timeTrackAccounts: "",
loggedIn: sessionStorage.getItem("loggedin")
};
},
methods: {
deleteTimeTrackAccount(selfLink) {
var accountxhttp = new XMLHttpRequest();
accountxhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 204) {
location.reload();
}
};
accountxhttp.open("DELETE", selfLink, false);
accountxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
accountxhttp.send(null);
},
editTimeTrackAccount(selfLink) {
sessionStorage.setItem("timeTrackAccountEditSelfLink", selfLink);
this.$router.push("/edittimetrackaccount");
},
createTimeTrackAccount() {
this.$router.push("/createtimetrackaccount");
}
},
created() {
var accounts;
var timeTrackAccountsTMP;
var accountxhttp = new XMLHttpRequest();
accountxhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 204) {
location.reload();
accountxhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
accounts = JSON.parse(accountxhttp.responseText);
timeTrackAccountsTMP = accounts._embedded.accounts;
}
};
accountxhttp.open("DELETE", selfLink , false);
accountxhttp.setRequestHeader(
"Authorization",
sessionStorage.getItem("jwt")
);
accountxhttp.send(null);
},
editTimeTrackAccount(selfLink) {
sessionStorage.setItem("timeTrackAccountEditSelfLink", selfLink);
this.$router.push( "/edittimetrackaccount");
},
createTimeTrackAccount() {
this.$router.push( "/createtimetrackaccount");
}
},
created() {
var accounts;
var timeTrackAccountsTMP;
var accountxhttp = new XMLHttpRequest();
accountxhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
accounts = JSON.parse(accountxhttp.responseText);
timeTrackAccountsTMP = accounts._embedded.accounts;
}
};
accountxhttp.open(
"GET",
baseUri +
accountxhttp.open(
"GET",
baseUri +
"/accounts/search/findByUsername?username=" +
sessionStorage.getItem("timeTrackAccountListUser"),
false
);
false
);
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>
<style scoped>
</style>
</style>