2020-04-05 22:15:03 +02:00
|
|
|
<template>
|
2020-04-21 16:10:53 +02:00
|
|
|
<div class="app">
|
2020-05-07 19:57:11 +02:00
|
|
|
<v-app id="geotimetracking">
|
|
|
|
<!-- Side navigation menu -->
|
|
|
|
<v-navigation-drawer v-model="drawer" app clipped class="main_accent">
|
|
|
|
<v-list dense>
|
|
|
|
<v-list-item link to="/">
|
|
|
|
<v-list-item-action>
|
|
|
|
<v-icon>mdi-view-dashboard</v-icon>
|
|
|
|
</v-list-item-action>
|
|
|
|
<v-list-item-content>
|
|
|
|
<v-list-item-title>Home</v-list-item-title>
|
|
|
|
</v-list-item-content>
|
|
|
|
</v-list-item>
|
2020-05-21 10:21:32 +02:00
|
|
|
<v-list-item link to="/timerecords" v-bind:class="{'d-none':loggedIn=='false'}">
|
2020-05-07 19:57:11 +02:00
|
|
|
<v-list-item-action>
|
|
|
|
<v-icon>mdi-clock</v-icon>
|
|
|
|
</v-list-item-action>
|
|
|
|
<v-list-item-content>
|
|
|
|
<v-list-item-title>Time Records</v-list-item-title>
|
|
|
|
</v-list-item-content>
|
|
|
|
</v-list-item>
|
2020-05-21 10:21:32 +02:00
|
|
|
<v-list-item link to="/statistics" v-bind:class="{'d-none':loggedIn=='false'}">
|
2020-05-07 19:57:11 +02:00
|
|
|
<v-list-item-action>
|
|
|
|
<v-icon>mdi-chart-bar</v-icon>
|
|
|
|
</v-list-item-action>
|
|
|
|
<v-list-item-content>
|
2020-05-17 17:32:50 +02:00
|
|
|
<v-list-item-title>Statistics</v-list-item-title>
|
2020-05-07 19:57:11 +02:00
|
|
|
</v-list-item-content>
|
|
|
|
</v-list-item>
|
2020-05-28 17:18:05 +02:00
|
|
|
<v-list-item @click="toAccounts" v-bind:class="{'d-none':loggedIn=='false'}">
|
|
|
|
<v-list-item-action>
|
|
|
|
<v-icon>mdi-account-details</v-icon>
|
|
|
|
</v-list-item-action>
|
|
|
|
<v-list-item-content>
|
|
|
|
<v-list-item-title>Accounts</v-list-item-title>
|
|
|
|
</v-list-item-content>
|
|
|
|
</v-list-item>
|
2020-05-07 19:57:11 +02:00
|
|
|
<v-list-item link to="/about">
|
|
|
|
<v-list-item-action>
|
|
|
|
<v-icon>mdi-information-outline</v-icon>
|
|
|
|
</v-list-item-action>
|
|
|
|
<v-list-item-content>
|
|
|
|
<v-list-item-title>About</v-list-item-title>
|
|
|
|
</v-list-item-content>
|
|
|
|
</v-list-item>
|
2020-05-21 10:21:32 +02:00
|
|
|
<v-list-item link to="/users" v-bind:class="{'d-none':loggedIn=='false'}">
|
|
|
|
<v-list-item-action>
|
|
|
|
<v-icon>mdi-account-group</v-icon>
|
|
|
|
</v-list-item-action>
|
|
|
|
<v-list-item-content>
|
2020-05-28 17:18:05 +02:00
|
|
|
<v-list-item-title>Admin</v-list-item-title>
|
2020-05-21 10:21:32 +02:00
|
|
|
</v-list-item-content>
|
|
|
|
</v-list-item>
|
2020-05-07 19:57:11 +02:00
|
|
|
</v-list>
|
|
|
|
</v-navigation-drawer>
|
|
|
|
|
|
|
|
<!-- Top menu bar -->
|
|
|
|
<v-app-bar app clipped-left class="main" elevation="10">
|
|
|
|
<v-app-bar-nav-icon @click.stop="drawer = !drawer" />
|
2020-05-25 12:10:02 +02:00
|
|
|
<v-img @click="forward" src="./assets/logo.svg" max-height="100%" max-width="100" contain></v-img>
|
2020-05-07 19:57:11 +02:00
|
|
|
<v-toolbar-title>Geo Timetracking</v-toolbar-title>
|
|
|
|
<v-spacer></v-spacer>
|
2020-05-19 11:11:07 +02:00
|
|
|
|
2020-05-15 12:40:59 +02:00
|
|
|
<!-- Menu with account icon -->
|
2020-05-28 17:18:05 +02:00
|
|
|
<v-menu
|
|
|
|
v-model="menu"
|
|
|
|
:close-on-content-click="false"
|
|
|
|
:nudge-width="200"
|
|
|
|
offset-y
|
|
|
|
v-if="loggedIn == 'true'"
|
|
|
|
>
|
2020-05-15 12:40:59 +02:00
|
|
|
<template v-slot:activator="{ on }">
|
2020-05-28 17:18:05 +02:00
|
|
|
<v-btn icon v-on="on">
|
2020-05-15 12:40:59 +02:00
|
|
|
<v-icon>mdi-account</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
</template>
|
2020-05-07 19:57:11 +02:00
|
|
|
|
2020-05-15 12:40:59 +02:00
|
|
|
<v-card>
|
|
|
|
<v-list>
|
|
|
|
<v-list-item>
|
|
|
|
<v-list-item-avatar>
|
|
|
|
<img src="https://cdn.vuetifyjs.com/images/john.jpg" alt="John" />
|
|
|
|
</v-list-item-avatar>
|
2020-05-07 19:57:11 +02:00
|
|
|
|
2020-05-15 12:40:59 +02:00
|
|
|
<v-list-item-content>
|
2020-05-28 17:18:05 +02:00
|
|
|
<v-list-item-title>{{fullname}}</v-list-item-title>
|
2020-05-15 12:40:59 +02:00
|
|
|
</v-list-item-content>
|
2020-05-28 17:18:05 +02:00
|
|
|
|
2020-05-18 09:12:41 +02:00
|
|
|
<v-list-item-action></v-list-item-action>
|
2020-05-15 12:40:59 +02:00
|
|
|
</v-list-item>
|
|
|
|
</v-list>
|
2020-05-07 19:57:11 +02:00
|
|
|
|
2020-05-15 12:40:59 +02:00
|
|
|
<v-divider></v-divider>
|
2020-05-07 19:57:11 +02:00
|
|
|
|
2020-05-15 12:40:59 +02:00
|
|
|
<v-list>
|
|
|
|
<v-list-item>
|
|
|
|
<v-list-item-action>
|
2020-05-18 09:12:41 +02:00
|
|
|
<v-switch color="primary" :input-value="login" @change="login= !login"></v-switch>
|
2020-05-15 12:40:59 +02:00
|
|
|
</v-list-item-action>
|
|
|
|
<v-list-item-title>View as Guest</v-list-item-title>
|
|
|
|
</v-list-item>
|
|
|
|
</v-list>
|
2020-05-07 19:57:11 +02:00
|
|
|
|
2020-05-15 12:40:59 +02:00
|
|
|
<v-card-actions>
|
|
|
|
<v-spacer></v-spacer>
|
2020-05-07 19:57:11 +02:00
|
|
|
|
2020-05-15 12:40:59 +02:00
|
|
|
<v-btn text @click="menu = false">Cancel</v-btn>
|
2020-05-19 11:11:07 +02:00
|
|
|
<v-btn color="primary" text @click="logout">Logout</v-btn>
|
2020-05-15 12:40:59 +02:00
|
|
|
</v-card-actions>
|
|
|
|
</v-card>
|
|
|
|
</v-menu>
|
2020-05-28 17:18:05 +02:00
|
|
|
<v-card v-if="loggedIn == 'false'">
|
|
|
|
<!-- Modal -->
|
|
|
|
|
|
|
|
<v-row justify="center">
|
|
|
|
<v-dialog v-model="dialog" width="70%" persistent>
|
|
|
|
<template v-slot:activator="{ on }">
|
|
|
|
<v-btn color="primary" dark v-on="on">Login</v-btn>
|
|
|
|
</template>
|
|
|
|
<v-card class="main">
|
|
|
|
<v-card-actions>
|
|
|
|
<v-spacer></v-spacer>
|
|
|
|
<v-btn icon @click="dialog = false">
|
|
|
|
<v-icon>mdi-window-close</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
</v-card-actions>
|
|
|
|
<SignIn v-on:signIn="signIn" v-on:signUp="signUp" />
|
|
|
|
<p id="loginError"></p>
|
|
|
|
</v-card>
|
|
|
|
</v-dialog>
|
|
|
|
</v-row>
|
|
|
|
</v-card>
|
2020-05-07 19:57:11 +02:00
|
|
|
</v-app-bar>
|
|
|
|
|
|
|
|
<!-- Routed pages are inserted here -->
|
|
|
|
<v-content>
|
|
|
|
<router-view />
|
|
|
|
</v-content>
|
|
|
|
|
|
|
|
<!-- Footer on bottom -->
|
|
|
|
<v-footer app class="main">
|
|
|
|
<span>© 2020 Team TacocaT</span>
|
|
|
|
</v-footer>
|
|
|
|
</v-app>
|
2020-04-05 22:15:03 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2020-04-17 10:15:09 +02:00
|
|
|
<script>
|
2020-05-15 12:40:59 +02:00
|
|
|
import SignIn from "./views/SignIn.vue";
|
2020-05-19 11:11:07 +02:00
|
|
|
import { baseUri } from "./variables.js";
|
|
|
|
|
|
|
|
if (!sessionStorage.getItem("loggedin")) {
|
|
|
|
sessionStorage.setItem("loggedin", false);
|
|
|
|
}
|
|
|
|
|
2020-04-17 10:15:09 +02:00
|
|
|
export default {
|
2020-05-15 12:40:59 +02:00
|
|
|
components: {
|
|
|
|
SignIn
|
|
|
|
},
|
2020-05-07 19:57:11 +02:00
|
|
|
props: {
|
|
|
|
source: String
|
|
|
|
},
|
|
|
|
data: () => ({
|
|
|
|
drawer: null,
|
2020-05-15 12:40:59 +02:00
|
|
|
login: true,
|
|
|
|
dialog: false,
|
2020-05-19 11:11:07 +02:00
|
|
|
menu: false,
|
|
|
|
loggedIn: sessionStorage.getItem("loggedin"),
|
2020-05-28 17:18:05 +02:00
|
|
|
fullname:
|
|
|
|
sessionStorage.getItem("firstname") +
|
|
|
|
" " +
|
|
|
|
sessionStorage.getItem("lastname")
|
2020-05-07 19:57:11 +02:00
|
|
|
}),
|
2020-05-16 20:25:37 +02:00
|
|
|
methods: {
|
2020-05-28 17:18:05 +02:00
|
|
|
forward() {
|
|
|
|
this.$router.push("/");
|
|
|
|
},
|
2020-05-18 09:12:41 +02:00
|
|
|
signIn(loginData) {
|
|
|
|
var xhttp = new XMLHttpRequest();
|
|
|
|
|
|
|
|
xhttp.onreadystatechange = function() {
|
|
|
|
if ((this.status == 200) & (this.readyState == 4)) {
|
|
|
|
sessionStorage.setItem(
|
|
|
|
"jwt",
|
|
|
|
this.getResponseHeader("Authorization")
|
|
|
|
);
|
2020-05-19 11:11:07 +02:00
|
|
|
sessionStorage.setItem("loggedin", true);
|
2020-05-18 09:12:41 +02:00
|
|
|
} else if (this.status != 200 && this.status != 0) {
|
|
|
|
document.getElementById("loginError").innerHTML =
|
|
|
|
"Login not successfull";
|
|
|
|
}
|
|
|
|
};
|
2020-05-28 17:18:05 +02:00
|
|
|
|
2020-05-19 11:11:07 +02:00
|
|
|
xhttp.open("POST", baseUri + "/login", false);
|
2020-05-18 09:12:41 +02:00
|
|
|
xhttp.send(
|
|
|
|
'{"username": "' +
|
|
|
|
loginData.username +
|
|
|
|
'", "password": "' +
|
|
|
|
loginData.password +
|
|
|
|
'"}'
|
|
|
|
);
|
2020-05-28 17:18:05 +02:00
|
|
|
if (sessionStorage.getItem("loggedin") == "true") {
|
|
|
|
sessionStorage.setItem("haveData", true);
|
2020-05-19 11:11:07 +02:00
|
|
|
var whoxhttp = new XMLHttpRequest();
|
2020-05-28 17:18:05 +02:00
|
|
|
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);
|
2020-05-19 11:11:07 +02:00
|
|
|
|
2020-05-28 17:18:05 +02:00
|
|
|
this.fullname =
|
|
|
|
sessionStorage.getItem("firstname") +
|
|
|
|
" " +
|
|
|
|
sessionStorage.getItem("lastname");
|
|
|
|
location.reload();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
whoxhttp.open("GET", baseUri + "/whoami", false);
|
2020-05-19 11:11:07 +02:00
|
|
|
|
2020-05-28 17:18:05 +02:00
|
|
|
whoxhttp.setRequestHeader(
|
|
|
|
"Authorization",
|
|
|
|
sessionStorage.getItem("jwt")
|
|
|
|
);
|
|
|
|
|
|
|
|
whoxhttp.send(null);
|
|
|
|
location.reload();
|
2020-05-19 11:11:07 +02:00
|
|
|
}
|
2020-05-18 09:12:41 +02:00
|
|
|
},
|
|
|
|
signUp(signupData) {
|
|
|
|
var xhttp = new XMLHttpRequest();
|
|
|
|
|
|
|
|
xhttp.onreadystatechange = function() {
|
2020-05-19 11:11:07 +02:00
|
|
|
if ((this.status == 201) & (this.readyState == 4)) {
|
2020-05-18 09:12:41 +02:00
|
|
|
location.reload();
|
|
|
|
} else if (this.status != 201 && this.status != 0) {
|
|
|
|
document.getElementById("loginError").innerHTML =
|
|
|
|
"The username already exist";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
xhttp.open("POST", baseUri + "/sign-up", true);
|
|
|
|
xhttp.setRequestHeader("Content-Type", "application/json");
|
|
|
|
xhttp.send(
|
2020-05-19 11:11:07 +02:00
|
|
|
"{" +
|
2020-05-18 09:12:41 +02:00
|
|
|
'"firstname": "' +
|
|
|
|
signupData.firstname +
|
|
|
|
'", "lastname": "' +
|
|
|
|
signupData.lastname +
|
|
|
|
'", "username": "' +
|
|
|
|
signupData.username +
|
|
|
|
'", "password": "' +
|
|
|
|
signupData.password +
|
|
|
|
'"}'
|
|
|
|
);
|
2020-05-19 11:11:07 +02:00
|
|
|
},
|
2020-05-28 17:18:05 +02:00
|
|
|
logout() {
|
2020-05-19 11:11:07 +02:00
|
|
|
sessionStorage.clear();
|
|
|
|
sessionStorage.setItem("loggedin", false);
|
|
|
|
location.reload();
|
2020-05-28 17:18:05 +02:00
|
|
|
},
|
|
|
|
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");
|
|
|
|
}
|
2020-05-16 20:25:37 +02:00
|
|
|
}
|
|
|
|
},
|
2020-05-18 09:12:41 +02:00
|
|
|
|
2020-05-07 19:57:11 +02:00
|
|
|
created() {
|
|
|
|
this.$vuetify.theme.dark = true;
|
2020-04-17 10:15:09 +02:00
|
|
|
}
|
2020-05-07 19:57:11 +02:00
|
|
|
};
|
2020-04-17 10:15:09 +02:00
|
|
|
</script>
|
2020-04-19 11:35:25 +02:00
|
|
|
|
2020-04-21 14:41:48 +02:00
|
|
|
|
2020-05-07 19:57:11 +02:00
|
|
|
<style scoped>
|
|
|
|
.link {
|
|
|
|
color: #f1f1f1f1;
|
|
|
|
text-decoration: none;
|
2020-04-15 18:38:30 +02:00
|
|
|
}
|
2020-05-07 19:57:11 +02:00
|
|
|
.v-application {
|
2020-05-15 12:40:59 +02:00
|
|
|
font-family: "Montserrat", sans-serif;
|
|
|
|
background-color: var(--v-background-base) !important;
|
2020-04-15 18:38:30 +02:00
|
|
|
}
|
2020-04-05 22:15:03 +02:00
|
|
|
</style>
|