From 6a42650c401d04f425444133b843874446f7d235 Mon Sep 17 00:00:00 2001 From: Tim Zieger Date: Wed, 3 Jun 2020 16:32:36 +0200 Subject: [PATCH] Cleanup frontend code --- frontend/src/App.vue | 11 +- frontend/src/router/index.js | 32 +----- frontend/src/views/CreateTimerecord.vue | 15 +-- frontend/src/views/EditTimeTrackAccount.vue | 13 ++- frontend/src/views/EditTimerecord.vue | 21 ++-- frontend/src/views/Home.vue | 16 +-- frontend/src/views/Info.vue | 17 --- frontend/src/views/Login.vue | 81 -------------- frontend/src/views/Register.vue | 111 -------------------- frontend/src/views/TimeTrackAccounts.vue | 22 ++-- frontend/src/views/profile.vue | 27 ----- 11 files changed, 38 insertions(+), 328 deletions(-) delete mode 100644 frontend/src/views/Info.vue delete mode 100644 frontend/src/views/Login.vue delete mode 100644 frontend/src/views/Register.vue delete mode 100644 frontend/src/views/profile.vue diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 6b373e9..12e3a8c 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -93,14 +93,6 @@ - - - - - - View as Guest - - @@ -162,8 +154,7 @@ export default { source: String }, data: () => ({ - drawer: null, - login: true, + drawer: null, dialog: false, menu: false, loggedIn: sessionStorage.getItem("loggedin"), diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index e282cd8..7f4d377 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -1,13 +1,9 @@ import Vue from "vue"; import VueRouter from "vue-router"; import Home from "../views/Home.vue"; -import Profile from "../views/profile.vue"; import missing from "../views/missing.vue"; -import Info from "../views/Info.vue"; import TimeRecords from "../views/TimeRecords.vue"; import About from "../views/About.vue"; -import Login from "../views/Login.vue"; -import Register from "../views/Register.vue"; import StatisticOverview from "../views/StatisticOverview.vue"; import Users from "../views/Users.vue"; import EditUser from "../views/EditUser.vue"; @@ -29,33 +25,7 @@ const routes = [ name: "TimeRecords", component: TimeRecords }, - { - path: "/login", - name: "Login", - component: Login - }, - { - path: "/register", - name: "Register", - component: Register - }, - { - path: "/profile/:id", - name: "Profile", - component: Profile, - children: [ - { - path: 'info', - name: 'Info', - component: Info - } - ] - }, - { - path: "/profile", - name: "ProfileMain", - component: Profile - }, + { path: "/about", name: "About", diff --git a/frontend/src/views/CreateTimerecord.vue b/frontend/src/views/CreateTimerecord.vue index f962e22..beff96a 100644 --- a/frontend/src/views/CreateTimerecord.vue +++ b/frontend/src/views/CreateTimerecord.vue @@ -156,8 +156,8 @@ export default { menutime2: false, menu: false, menu2: false, - types: [ "PAID" ,"BREAK"], - accounts: "", + types: [ "PAID" ,"BREAK"], + accounts: "", user: sessionStorage.getItem("timeTrackAccountListUserId"), newstartdate: "", newenddate: "", @@ -172,10 +172,7 @@ export default { accountxhttp.onreadystatechange = function() { if ((this.status == 200) & (this.readyState == 4)) { - //account = - account = JSON.parse(accountxhttp.responseText); - account = account._links.self.href; } }; @@ -196,12 +193,7 @@ export default { ); accountxhttp.send(null); - if ( - this.newstartdate != "" && - this.newenddate != "" && - this.newdate != "" && - account != "" - ) { + if (this.newstartdate != "" && this.newenddate != "" && this.newdate != "" && account != "") { var xhttp = new XMLHttpRequest(); var suc; this.newstartdate = this.newstartdate + "T" + this.timestart; @@ -213,7 +205,6 @@ export default { }; xhttp.open("POST", baseUri + "/records", false); xhttp.setRequestHeader("Content-Type", "application/json"); - xhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt")); xhttp.send( "{" + diff --git a/frontend/src/views/EditTimeTrackAccount.vue b/frontend/src/views/EditTimeTrackAccount.vue index 104a264..77e93ac 100644 --- a/frontend/src/views/EditTimeTrackAccount.vue +++ b/frontend/src/views/EditTimeTrackAccount.vue @@ -51,7 +51,6 @@ export default { name: "", revenue: "", description: "", - newname: "", newrevenue: "", newdescription: "", @@ -90,23 +89,23 @@ export default { }, }, created() { - var userxhttp = new XMLHttpRequest(); + var accountxhttp = new XMLHttpRequest(); var account; - userxhttp.onreadystatechange = function() { + accountxhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { - account = JSON.parse(userxhttp.responseText); + account = JSON.parse(accountxhttp.responseText); } }; - userxhttp.open( + accountxhttp.open( "GET", sessionStorage.getItem("timeTrackAccountEditSelfLink"), false ); - userxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt")); + accountxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt")); - userxhttp.send(null); + accountxhttp.send(null); this.name = account.name; this.revenue = account.revenue; this.description = account.description; diff --git a/frontend/src/views/EditTimerecord.vue b/frontend/src/views/EditTimerecord.vue index 932530c..2e3d8c5 100644 --- a/frontend/src/views/EditTimerecord.vue +++ b/frontend/src/views/EditTimerecord.vue @@ -145,8 +145,7 @@ export default { types: [ "PAID" ,"BREAK"], type: "", stardate: "", - enddate: "", - + enddate: "", newtype: "", newstartdate: new Date().toISOString().substr(0, 10), newenddate: new Date().toISOString().substr(0, 10) @@ -156,11 +155,7 @@ export default { editRecord() { var link = sessionStorage.getItem("timeRecordEditSelfLink"); - if ( - this.newname != this.name || - this.newstartdate != this.startdate || - this.newenddate != this.enddate - ) { + if (this.newname != this.name || this.newstartdate != this.startdate || this.newenddate != this.enddate) { this.newstartdate = this.newstartdate + "T" + this.timestart; this.newenddate = this.newenddate + "T" + this.timeend; var xhttp = new XMLHttpRequest(); @@ -191,23 +186,23 @@ export default { } }, created() { - var userxhttp = new XMLHttpRequest(); + var recordxhttp = new XMLHttpRequest(); var record; - userxhttp.onreadystatechange = function() { + recordxhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { - record = JSON.parse(userxhttp.responseText); + record = JSON.parse(recordxhttp.responseText); } }; - userxhttp.open( + recordxhttp.open( "GET", sessionStorage.getItem("timeRecordEditSelfLink"), false ); - userxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt")); + recordxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt")); - userxhttp.send(null); + recordxhttp.send(null); this.type = record.type; this.startdate = record.startdate; diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue index b47f8f6..6acc371 100644 --- a/frontend/src/views/Home.vue +++ b/frontend/src/views/Home.vue @@ -72,7 +72,7 @@ - - diff --git a/frontend/src/views/Login.vue b/frontend/src/views/Login.vue deleted file mode 100644 index f905d15..0000000 --- a/frontend/src/views/Login.vue +++ /dev/null @@ -1,81 +0,0 @@ - - - - - diff --git a/frontend/src/views/Register.vue b/frontend/src/views/Register.vue deleted file mode 100644 index 2c2ff32..0000000 --- a/frontend/src/views/Register.vue +++ /dev/null @@ -1,111 +0,0 @@ - - - - - diff --git a/frontend/src/views/TimeTrackAccounts.vue b/frontend/src/views/TimeTrackAccounts.vue index 567631d..1b13120 100644 --- a/frontend/src/views/TimeTrackAccounts.vue +++ b/frontend/src/views/TimeTrackAccounts.vue @@ -36,20 +36,20 @@ export default { }, methods: { deleteTimeTrackAccount(selfLink) { - var userxhttp = new XMLHttpRequest(); - userxhttp.onreadystatechange = function() { + var accountxhttp = new XMLHttpRequest(); + accountxhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 204) { location.reload(); } }; - userxhttp.open("DELETE", selfLink , false); + accountxhttp.open("DELETE", selfLink , false); - userxhttp.setRequestHeader( + accountxhttp.setRequestHeader( "Authorization", sessionStorage.getItem("jwt") ); - userxhttp.send(null); + accountxhttp.send(null); }, editTimeTrackAccount(selfLink) { sessionStorage.setItem("timeTrackAccountEditSelfLink", selfLink); @@ -64,14 +64,14 @@ export default { created() { var accounts; var timeTrackAccountsTMP; - var userxhttp = new XMLHttpRequest(); - userxhttp.onreadystatechange = function() { + var accountxhttp = new XMLHttpRequest(); + accountxhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { - accounts = JSON.parse(userxhttp.responseText); + accounts = JSON.parse(accountxhttp.responseText); timeTrackAccountsTMP = accounts._embedded.accounts; } }; - userxhttp.open( + accountxhttp.open( "GET", baseUri + "/accounts/search/findByUsername?username=" + @@ -79,9 +79,9 @@ export default { false ); - userxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt")); + accountxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt")); - userxhttp.send(null); + accountxhttp.send(null); this.timeTrackAccounts = timeTrackAccountsTMP; } diff --git a/frontend/src/views/profile.vue b/frontend/src/views/profile.vue deleted file mode 100644 index 3355b07..0000000 --- a/frontend/src/views/profile.vue +++ /dev/null @@ -1,27 +0,0 @@ - - - - -