diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index cef32c6..b283c84 100644
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -28,6 +28,14 @@
Statistics
+
+
+ mdi-account-details
+
+
+ Accounts
+
+
mdi-information-outline
@@ -41,7 +49,7 @@
mdi-account-group
- Users
+ Admin
@@ -55,9 +63,15 @@
-
+
-
+
mdi-account
@@ -70,10 +84,9 @@
- {{fullname}}
- {{role}}
+ {{fullname}}
-
+
@@ -96,30 +109,28 @@
Logout
-
-
-
-
-
-
-
-
- Login
-
-
-
-
-
- mdi-window-close
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+ Login
+
+
+
+
+
+ mdi-window-close
+
+
+
+
+
+
+
+
@@ -156,15 +167,16 @@ export default {
dialog: false,
menu: false,
loggedIn: sessionStorage.getItem("loggedin"),
- fullname: sessionStorage.getItem("firstname") + " " + sessionStorage.getItem("lastname"),
- role: sessionStorage.getItem("role")
+ fullname:
+ sessionStorage.getItem("firstname") +
+ " " +
+ sessionStorage.getItem("lastname")
}),
methods: {
- forward() {
- this.$router.push("/")
- },
+ forward() {
+ this.$router.push("/");
+ },
signIn(loginData) {
-
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
@@ -174,14 +186,12 @@ export default {
this.getResponseHeader("Authorization")
);
sessionStorage.setItem("loggedin", true);
-
} else if (this.status != 200 && this.status != 0) {
-
document.getElementById("loginError").innerHTML =
"Login not successfull";
}
};
-
+
xhttp.open("POST", baseUri + "/login", false);
xhttp.send(
'{"username": "' +
@@ -190,29 +200,32 @@ export default {
loginData.password +
'"}'
);
- if(sessionStorage.getItem("loggedin")== "true"){
- sessionStorage.setItem("haveData", true);
+ if (sessionStorage.getItem("loggedin") == "true") {
+ sessionStorage.setItem("haveData", true);
var whoxhttp = new XMLHttpRequest();
- whoxhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- var userInformation = JSON.parse(whoxhttp.responseText);
- sessionStorage.setItem("firstname", userInformation.firstname);
- sessionStorage.setItem("lastname", userInformation.lastname);
- sessionStorage.setItem("username", userInformation.username);
- sessionStorage.setItem("role", userInformation.role.name);
-
-
- this.fullname= sessionStorage.getItem("firstname") + " " + sessionStorage.getItem("lastname");
- location.reload();
- }
- };
- whoxhttp.open("GET", baseUri + "/whoami", false);
-
+ whoxhttp.onreadystatechange = function() {
+ if (this.readyState == 4 && this.status == 200) {
+ var userInformation = JSON.parse(whoxhttp.responseText);
+ sessionStorage.setItem("firstname", userInformation.firstname);
+ sessionStorage.setItem("lastname", userInformation.lastname);
+ sessionStorage.setItem("username", userInformation.username);
- whoxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
+ this.fullname =
+ sessionStorage.getItem("firstname") +
+ " " +
+ sessionStorage.getItem("lastname");
+ location.reload();
+ }
+ };
+ whoxhttp.open("GET", baseUri + "/whoami", false);
- whoxhttp.send(null);
- location.reload();
+ whoxhttp.setRequestHeader(
+ "Authorization",
+ sessionStorage.getItem("jwt")
+ );
+
+ whoxhttp.send(null);
+ location.reload();
}
},
signUp(signupData) {
@@ -241,12 +254,48 @@ export default {
'"}'
);
},
- logout(){
+ logout() {
sessionStorage.clear();
sessionStorage.setItem("loggedin", false);
location.reload();
+ },
+ toAccounts() {
+ sessionStorage.setItem(
+ "timeTrackAccountListUser",
+ sessionStorage.getItem("username")
+ );
+ var xhttp = new XMLHttpRequest();
+ xhttp.onreadystatechange = function() {
+ if (this.readyState == 4 && this.status == 200) {
+ var usersInformation = JSON.parse(xhttp.responseText);
+ sessionStorage.setItem(
+ "timeTrackAccountListUserId",
+ usersInformation._links.self.href
+ );
+ }
+ };
+ xhttp.open(
+ "GET",
+ baseUri +
+ "/users/search/byUsername?username=" +
+ sessionStorage.getItem("username"),
+ false
+ );
+
+ xhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
+
+ xhttp.send(null);
+ this.users = JSON.parse(sessionStorage.getItem("users"));
+
+ if (this.$route.path == "/timetrackaccounts" ) {
+
+
+ location.reload();
+
+ }else{
+ this.$router.push("/timetrackaccounts");
+ }
}
-
},
created() {