Format App.vue

This commit is contained in:
Marcel Schwarz 2020-07-21 23:09:16 +02:00
parent cfad59d139
commit 695df651e1

View File

@ -57,7 +57,7 @@
<!-- Top menu bar -->
<v-app-bar app clipped-left class="main" elevation="10">
<v-app-bar-nav-icon @click.stop="drawer = !drawer" />
<v-app-bar-nav-icon @click.stop="drawer = !drawer"/>
<v-img @click="forward" src="./assets/logo.svg" max-height="100%" max-width="100" contain></v-img>
<v-toolbar-title>Geo Timetracking</v-toolbar-title>
<v-spacer></v-spacer>
@ -80,7 +80,7 @@
<v-list>
<v-list-item>
<v-list-item-avatar>
<img src="https://cdn.vuetifyjs.com/images/john.jpg" alt="John" />
<img src="https://cdn.vuetifyjs.com/images/john.jpg" alt="John"/>
</v-list-item-avatar>
<v-list-item-content>
@ -93,7 +93,6 @@
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
@ -104,7 +103,6 @@
</v-menu>
<v-card v-if="loggedIn == 'false'">
<!-- Modal -->
<v-row justify="center">
<v-dialog v-model="dialog" width="70%" persistent>
<template v-slot:activator="{ on }">
@ -117,7 +115,7 @@
<v-icon>mdi-window-close</v-icon>
</v-btn>
</v-card-actions>
<SignIn v-on:signIn="signIn" v-on:signUp="signUp" />
<SignIn v-on:signIn="signIn" v-on:signUp="signUp"/>
<p id="loginError"></p>
</v-card>
</v-dialog>
@ -127,7 +125,7 @@
<!-- Routed pages are inserted here -->
<v-content>
<router-view />
<router-view/>
</v-content>
<!-- Footer on bottom -->
@ -139,14 +137,14 @@
</template>
<script>
import SignIn from "./views/SignIn.vue";
import { baseUri } from "./variables.js";
import SignIn from "./views/SignIn.vue";
import {baseUri} from "./variables.js";
if (!sessionStorage.getItem("loggedin")) {
if (!sessionStorage.getItem("loggedin")) {
sessionStorage.setItem("loggedin", false);
}
}
export default {
export default {
components: {
SignIn
},
@ -158,10 +156,7 @@ export default {
dialog: false,
menu: false,
loggedIn: sessionStorage.getItem("loggedin"),
fullname:
sessionStorage.getItem("firstname") +
" " +
sessionStorage.getItem("lastname")
fullname: sessionStorage.getItem("firstname") + " " + sessionStorage.getItem("lastname")
}),
methods: {
forward() {
@ -170,12 +165,9 @@ export default {
signIn(loginData) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
xhttp.onreadystatechange = function () {
if ((this.status == 200) & (this.readyState == 4)) {
sessionStorage.setItem(
"jwt",
this.getResponseHeader("Authorization")
);
sessionStorage.setItem("jwt", this.getResponseHeader("Authorization"));
sessionStorage.setItem("loggedin", true);
} else if (this.status != 200 && this.status != 0) {
document.getElementById("loginError").innerHTML =
@ -194,7 +186,7 @@ export default {
if (sessionStorage.getItem("loggedin") == "true") {
sessionStorage.setItem("haveData", true);
var whoxhttp = new XMLHttpRequest();
whoxhttp.onreadystatechange = function() {
whoxhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
var userInformation = JSON.parse(whoxhttp.responseText);
sessionStorage.setItem("firstname", userInformation.firstname);
@ -202,20 +194,14 @@ export default {
sessionStorage.setItem("username", userInformation.username);
sessionStorage.setItem("userIDOwn", userInformation.id);
this.fullname =
sessionStorage.getItem("firstname") +
" " +
sessionStorage.getItem("lastname");
this.fullname = sessionStorage.getItem("firstname")
+ " "
+ sessionStorage.getItem("lastname");
location.reload();
}
};
whoxhttp.open("GET", baseUri + "/whoami", false);
whoxhttp.setRequestHeader(
"Authorization",
sessionStorage.getItem("jwt")
);
whoxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
whoxhttp.send(null);
location.reload();
}
@ -223,12 +209,11 @@ export default {
signUp(signupData) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
xhttp.onreadystatechange = function () {
if ((this.status == 201) & (this.readyState == 4)) {
location.reload();
} else if (this.status != 201 && this.status != 0) {
document.getElementById("loginError").innerHTML =
"The username already exist";
document.getElementById("loginError").innerHTML = "The username already exist";
}
};
xhttp.open("POST", baseUri + "/sign-up", true);
@ -252,12 +237,9 @@ export default {
location.reload();
},
toAccounts() {
sessionStorage.setItem(
"timeTrackAccountListUser",
sessionStorage.getItem("username")
);
sessionStorage.setItem("timeTrackAccountListUser", sessionStorage.getItem("username"));
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(
@ -275,35 +257,31 @@ export default {
);
xhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
xhttp.send(null);
this.users = JSON.parse(sessionStorage.getItem("users"));
if (this.$route.path == "/timetrackaccounts" ) {
if (this.$route.path == "/timetrackaccounts") {
location.reload();
}else{
} else {
this.$router.push("/timetrackaccounts");
}
}
},
created() {
this.$vuetify.theme.dark = true;
}
};
};
</script>
<style scoped>
.link {
.link {
color: #f1f1f1f1;
text-decoration: none;
}
.v-application {
}
.v-application {
font-family: "Montserrat", sans-serif;
background-color: var(--v-background-base) !important;
}
}
</style>