From 06db9e572371c99895f6e4e80dd53c4f3b33a0b4 Mon Sep 17 00:00:00 2001 From: Amar Bolkan Date: Tue, 1 Dec 2020 14:14:34 +0100 Subject: [PATCH 01/61] Set default position of map to Wedel coordinates --- config/config.development.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.development.js b/config/config.development.js index 79c6eb6..d4a0fac 100644 --- a/config/config.development.js +++ b/config/config.development.js @@ -6,7 +6,7 @@ var SYSTEM_URL = "http://localhost:8000"; var API_ROOT = SYSTEM_URL + "/api"; var GBFS_URL = SYSTEM_URL + "/gbfs/gbfs.json"; -var DEFAULT_LOCATION = [48.3984, 9.9908]; +var DEFAULT_LOCATION = [53.5823813, 9.7137465]; var DEFAULT_ZOOM = 15; var I18N_MESSAGE_OVERRIDE = {}; From 538223ba3ceb25d96cb0fc1f7a95e5b3626f0839 Mon Sep 17 00:00:00 2001 From: Amar Bolkan Date: Tue, 1 Dec 2020 14:18:17 +0100 Subject: [PATCH 02/61] Add Costum login button, which accesses the cykel admin login page and redirects back to voorwiel --- src/components/Login.vue | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/Login.vue b/src/components/Login.vue index b3c964d..4099569 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -50,6 +50,15 @@ fetch(url) .then(r => r.json()) .then(data => { + // Adding Costum Login Button + let costum_login = { + "name": "Costum Login", + "provider": "AZV", + "auth_url" : "http://localhost:8000/admin/login/?next=localhost:8080" + }; + // Add this entry to the list of displayed buttons + data.push(costum_login); + this.providers = data; this.loading = false; }) From 2439be682b0a97778edce9a3791f4abd9d1c2c27 Mon Sep 17 00:00:00 2001 From: Amar Bolkan Date: Tue, 1 Dec 2020 15:02:47 +0100 Subject: [PATCH 03/61] Check TODO --- src/App.vue | 1 + src/store/index.js | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/App.vue b/src/App.vue index f226fcc..8a12cfa 100644 --- a/src/App.vue +++ b/src/App.vue @@ -91,6 +91,7 @@ }, methods: { logout() { + this.$store.dispatch("LOGOUT"); } }, diff --git a/src/store/index.js b/src/store/index.js index d4c5163..0eb4f6c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -71,6 +71,7 @@ export default new Vuex.Store({ .get('/user') .then( response => { + console.log(response.data); commit("SET_USER", { user: response.data }); }, err => { @@ -163,11 +164,19 @@ export default new Vuex.Store({ }, mutations: { CLEAR_USER: (state) => { - state.authToken = null; - state.user = undefined; - state.rents = []; - state.lock = []; - localStorage.removeItem(LS_AUTH_TOKEN_KEY); + + if (state.user.username === "costum_login") + { + console.log("Im logged in as costum_user") + } + else + { + state.authToken = null; + state.user = undefined; + state.rents = []; + state.lock = []; + localStorage.removeItem(LS_AUTH_TOKEN_KEY); + } }, SET_USER: (state, { user }) => { state.user = user; From ac6e35b3008a8fb7d940c47dfa60d102b4dc4032 Mon Sep 17 00:00:00 2001 From: Amar Bolkan Date: Thu, 3 Dec 2020 17:39:01 +0100 Subject: [PATCH 04/61] Custom Login funktion hinzugefuegt. --- src/components/CustomLogin.vue | 107 +++++++++++++++++++++++++++++++++ src/components/Login.vue | 13 ++-- src/i18n/messages.json | 8 ++- src/router/index.js | 3 + src/store/index.js | 39 +++++++++++- 5 files changed, 156 insertions(+), 14 deletions(-) create mode 100644 src/components/CustomLogin.vue diff --git a/src/components/CustomLogin.vue b/src/components/CustomLogin.vue new file mode 100644 index 0000000..d72dfe4 --- /dev/null +++ b/src/components/CustomLogin.vue @@ -0,0 +1,107 @@ + + + + diff --git a/src/components/Login.vue b/src/components/Login.vue index 4099569..9b7b369 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -18,6 +18,10 @@ + + {{ "Custom Login" }} + + @@ -50,15 +54,6 @@ fetch(url) .then(r => r.json()) .then(data => { - // Adding Costum Login Button - let costum_login = { - "name": "Costum Login", - "provider": "AZV", - "auth_url" : "http://localhost:8000/admin/login/?next=localhost:8080" - }; - // Add this entry to the list of displayed buttons - data.push(costum_login); - this.providers = data; this.loading = false; }) diff --git a/src/i18n/messages.json b/src/i18n/messages.json index bc460cb..3f5666a 100644 --- a/src/i18n/messages.json +++ b/src/i18n/messages.json @@ -23,7 +23,9 @@ }, "login": { "login-with": "Login with", - "configerror": "Cannot load login configuration" + "configerror": "Cannot load login configuration", + "username" : "Username", + "password" : "Password" }, "about": { "title": "About", @@ -68,7 +70,9 @@ }, "login": { "login-with": "Einloggen mit", - "configerror": "Laden der Login-Konfiguration fehlgeschlagen" + "configerror": "Laden der Login-Konfiguration fehlgeschlagen", + "username" : "Benutzername", + "password" : "Passwort" }, "about": { "title": "Über", diff --git a/src/router/index.js b/src/router/index.js index 8c38fcb..1ab6e0b 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -12,6 +12,8 @@ import Support from '../components/Support'; import VehicleDetail from '../components/VehicleDetail'; import StationDetail from '../components/StationDetail'; +import CustomLogin from '../components/CustomLogin'; + const NoOpComponent = Vue.component('no-op', { functional: true, render () { return null; } @@ -22,6 +24,7 @@ const router = new VueRouter({ routes: [ { path: '/', component: NoOpComponent }, { path: '/login', name: 'login', component: Login }, + { path: '/login/custom', name: 'customLogin', component: CustomLogin }, { path: '/login/return', component: LoginReturn }, { path: '/rent', name: 'rent', component: Rent, meta: { requiresAuth: true }, props: (route) => { if (route.query && route.query.id) { diff --git a/src/store/index.js b/src/store/index.js index 0eb4f6c..72a1e13 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -164,12 +164,45 @@ export default new Vuex.Store({ }, mutations: { CLEAR_USER: (state) => { - + if (state.user.username === "costum_login") { - console.log("Im logged in as costum_user") + // TODO clean up + // Invalidate the logged-in user in cykel + // TODO implement the cykel logout + console.log(state); + console.log(state.authToken) + console.log(localStorage) +/* const headers = { + Cookie: "" + } + fetch('https://jsonplaceholder.typicode.com/todos', { + method: 'POST', + body: JSON.stringify(todo), + headers: + }) + .then(response => response.json()) + .then(json => { + console.log(json); + }); + + fetch("http://localhost:8000/admin/logout/") + .then(async response => { + const data = await response.text(); + console.log(data) + // check for error response + /*if (!response.ok) { + // get error message from body or default to response statusText + const error = (data && data.message) || response.statusText; + return Promise.reject(error); + } + }) + .catch(error => { + console.log(error); + console.log("There was an error, during logout!"); + });*/ } - else + { state.authToken = null; state.user = undefined; From a80d7475cba8e97876705177258627faaca549df Mon Sep 17 00:00:00 2001 From: Amar Bolkan Date: Fri, 4 Dec 2020 13:29:47 +0100 Subject: [PATCH 05/61] cleaned up --- src/components/CustomLogin.vue | 1 - src/store/index.js | 46 +++------------------------------- 2 files changed, 3 insertions(+), 44 deletions(-) diff --git a/src/components/CustomLogin.vue b/src/components/CustomLogin.vue index d72dfe4..aed23f6 100644 --- a/src/components/CustomLogin.vue +++ b/src/components/CustomLogin.vue @@ -72,7 +72,6 @@ import axios from 'axios'; methods: { authenticate() { let params = new URLSearchParams(location.search); - console.log(params) if (params.get('redirect')) { sessionStorage.setItem('redirect', params.get('redirect')); } diff --git a/src/store/index.js b/src/store/index.js index 72a1e13..e378d2c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -13,7 +13,7 @@ const axiosWithAuth = function (state) { } const getCurrentPosition = (options) => { - if (navigator.geolocation) { + if (navigator.geolocation) { return new Promise( (resolve, reject) => { let timeout = options.timeout || 5000; @@ -25,7 +25,8 @@ const getCurrentPosition = (options) => { options); } ) - } + } + return Promise.reject(); } @@ -164,52 +165,11 @@ export default new Vuex.Store({ }, mutations: { CLEAR_USER: (state) => { - - if (state.user.username === "costum_login") - { - // TODO clean up - // Invalidate the logged-in user in cykel - // TODO implement the cykel logout - console.log(state); - console.log(state.authToken) - console.log(localStorage) -/* const headers = { - Cookie: "" - } - fetch('https://jsonplaceholder.typicode.com/todos', { - method: 'POST', - body: JSON.stringify(todo), - headers: - }) - .then(response => response.json()) - .then(json => { - console.log(json); - }); - - fetch("http://localhost:8000/admin/logout/") - .then(async response => { - const data = await response.text(); - console.log(data) - // check for error response - /*if (!response.ok) { - // get error message from body or default to response statusText - const error = (data && data.message) || response.statusText; - return Promise.reject(error); - } - }) - .catch(error => { - console.log(error); - console.log("There was an error, during logout!"); - });*/ - } - - { state.authToken = null; state.user = undefined; state.rents = []; state.lock = []; localStorage.removeItem(LS_AUTH_TOKEN_KEY); - } }, SET_USER: (state, { user }) => { state.user = user; From 5e5d4555b3b7e6438d739c9ece22329470bdf9cc Mon Sep 17 00:00:00 2001 From: Amar Bolkan Date: Fri, 4 Dec 2020 15:00:01 +0100 Subject: [PATCH 06/61] Added choosable return locations. Currently hardcoded --- src/components/Rent.vue | 32 ++++++++++++++++++++++++++++++-- src/store/index.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/src/components/Rent.vue b/src/components/Rent.vue index bf20f65..38bf6c5 100644 --- a/src/components/Rent.vue +++ b/src/components/Rent.vue @@ -50,6 +50,18 @@ {{ $t('message.rent.renting-for') }} + + +
+ +

+

Selected return location: {{ selectedReturnLocation }}

+
+
+
{{ $t('message.rent.finish-rent') }} @@ -65,6 +77,9 @@ import TickingTime from "./TickingTime.vue"; import RentLock from "./RentLock.vue"; + //TODO delete later + import Vue from 'vue' + export default { components: { TickingTime, RentLock }, props: ['bikeId'], @@ -88,7 +103,14 @@ mdi: { lock: mdiLock, lockOpenVariant: mdiLockOpenVariant - } + }, + // TODO delete later + choosableLocations :[ + {name : "Altstadt", id: 1}, + {name : "Fock-Straße", id: 2}, + {name : "Bahnhof", id: 3} + ], + selectedReturnLocation : null } }, computed: { @@ -106,6 +128,7 @@ endRent(rentId) { this.rentError = ''; this.loadingRents.push(rentId); + Vue.prototype.$selectedReturnLocation = this.selectedReturnLocation this.$store.dispatch("END_RENT", rentId) .catch(err => { this.rentError = err; @@ -114,7 +137,12 @@ this.loadingRents.splice(index, 1); } }); - } + }, + // TODO delete later + changeReturnLocation (event) { + this.selectedReturnLocation = event.target.options[event.target.options.selectedIndex].text + console.log(this.selectedReturnLocation) + } }, mounted() { this.bikenumber = this.bikeId; diff --git a/src/store/index.js b/src/store/index.js index e378d2c..ca709bb 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -126,9 +126,40 @@ export default new Vuex.Store({ let data = {}; if (location && location.coords && location.coords.accuracy < 50) { + data['lat'] = location.coords.latitude; data['lng'] = location.coords.longitude; } + + console.log(Vue.prototype.$selectedReturnLocation) + + // TODO delete + let lat = 0.0; + let lng = 0.0; + switch(Vue.prototype.$selectedReturnLocation) + { + case "Altstadt" : + lat = 53.583435 + lng = 9.698574 + break; + case "Fock-Straße": + lat = 53.580897 + lng = 9.703375999999999 + break; + case "Bahnhof": + lat = 53.581697 + lng = 9.703375999999999 + break; + default : + console.log("No location selected") + lat = 53.581697 + lng = 9.703675999999999 + break; + } + + data['lat'] = lat ; + data['lng'] = lng; + try { let finish_url = state.rents.find((el) => el.id == rentId).finish_url; From 5250ecdaa21a958adad2c60ef8bfcb333ecfb2f3 Mon Sep 17 00:00:00 2001 From: Amar Bolkan Date: Tue, 8 Dec 2020 11:54:10 +0100 Subject: [PATCH 07/61] Added selectable return location, when renting bikes --- src/components/CustomLogin.vue | 2 +- src/components/Rent.vue | 51 +++++++++++++++++++++++++--------- src/store/index.js | 30 ++------------------ 3 files changed, 41 insertions(+), 42 deletions(-) diff --git a/src/components/CustomLogin.vue b/src/components/CustomLogin.vue index aed23f6..174fcea 100644 --- a/src/components/CustomLogin.vue +++ b/src/components/CustomLogin.vue @@ -77,7 +77,7 @@ import axios from 'axios'; } try { // TODO relative path - let auth_url = "http://localhost:8000/api-token-auth/"; + let auth_url = this.$appConfig.API_ROOT + '/auth/token'; axios.post( auth_url, { username : this.username, diff --git a/src/components/Rent.vue b/src/components/Rent.vue index 38bf6c5..9169d52 100644 --- a/src/components/Rent.vue +++ b/src/components/Rent.vue @@ -55,10 +55,10 @@


-

Selected return location: {{ selectedReturnLocation }}

+

Selected return location: {{ selectedStation }}

@@ -77,8 +77,10 @@ import TickingTime from "./TickingTime.vue"; import RentLock from "./RentLock.vue"; + //TODO delete later import Vue from 'vue' + import axios from 'axios'; export default { components: { TickingTime, RentLock }, @@ -104,18 +106,18 @@ lock: mdiLock, lockOpenVariant: mdiLockOpenVariant }, - // TODO delete later - choosableLocations :[ - {name : "Altstadt", id: 1}, - {name : "Fock-Straße", id: 2}, - {name : "Bahnhof", id: 3} - ], - selectedReturnLocation : null + availableStations :[], + selectedStation : null, + lng: null, + lat: null } }, computed: { ...mapState(['rents']) }, + created() { + this.fetchStations(); + }, methods: { startRent() { this.loading = true; @@ -128,7 +130,8 @@ endRent(rentId) { this.rentError = ''; this.loadingRents.push(rentId); - Vue.prototype.$selectedReturnLocation = this.selectedReturnLocation + Vue.prototype.$returnLng = this.lng + Vue.prototype.$returnLat = this.lat this.$store.dispatch("END_RENT", rentId) .catch(err => { this.rentError = err; @@ -138,11 +141,33 @@ } }); }, - // TODO delete later changeReturnLocation (event) { - this.selectedReturnLocation = event.target.options[event.target.options.selectedIndex].text - console.log(this.selectedReturnLocation) + this.selectedStation = event.target.options[event.target.options.selectedIndex].text + + for (var index in this.availableStations) + { + if (this.availableStations[index].name === this.selectedStation) + { + this.lng = this.availableStations[index].location.lng; + this.lat = this.availableStations[index].location.lat; + break; + } } + }, + fetchStations() { + + let url = this.$appConfig.API_ROOT + '/stations/locations'; + axios.post(url) + .then( response => response.data) + .then( data => { + console.log(data) + this.availableStations = data + }) + .catch( + console.log("Error") + // TODO Fehlerbehandlung einfügen + ) + } }, mounted() { this.bikenumber = this.bikeId; diff --git a/src/store/index.js b/src/store/index.js index ca709bb..87a88fe 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -131,34 +131,8 @@ export default new Vuex.Store({ data['lng'] = location.coords.longitude; } - console.log(Vue.prototype.$selectedReturnLocation) - - // TODO delete - let lat = 0.0; - let lng = 0.0; - switch(Vue.prototype.$selectedReturnLocation) - { - case "Altstadt" : - lat = 53.583435 - lng = 9.698574 - break; - case "Fock-Straße": - lat = 53.580897 - lng = 9.703375999999999 - break; - case "Bahnhof": - lat = 53.581697 - lng = 9.703375999999999 - break; - default : - console.log("No location selected") - lat = 53.581697 - lng = 9.703675999999999 - break; - } - - data['lat'] = lat ; - data['lng'] = lng; + data['lat'] = Vue.prototype.$returnLat; + data['lng'] = Vue.prototype.$returnLng; try { From 655f7952dbbd42bebebdbab28c06303203b7dd28 Mon Sep 17 00:00:00 2001 From: mlange304 Date: Tue, 8 Dec 2020 12:05:43 +0100 Subject: [PATCH 08/61] Textbox for Error Message --- src/components/CustomLogin.vue | 136 +++++++++++++++++---------------- 1 file changed, 72 insertions(+), 64 deletions(-) diff --git a/src/components/CustomLogin.vue b/src/components/CustomLogin.vue index aed23f6..a5466fe 100644 --- a/src/components/CustomLogin.vue +++ b/src/components/CustomLogin.vue @@ -1,17 +1,16 @@ From 03f70b261fb29a1aa11278bee3eb0d70ffa99e58 Mon Sep 17 00:00:00 2001 From: Amar Bolkan Date: Tue, 8 Dec 2020 13:23:47 +0100 Subject: [PATCH 09/61] Changed CustomLogin URL to relativ path --- src/components/CustomLogin.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/CustomLogin.vue b/src/components/CustomLogin.vue index a5466fe..a0f3584 100644 --- a/src/components/CustomLogin.vue +++ b/src/components/CustomLogin.vue @@ -84,7 +84,7 @@ export default { } try { // TODO relative path - let auth_url = "http://localhost:8000/api-token-auth/"; + let auth_url = this.$appConfig.API_ROOT + '/auth/token'; axios .post(auth_url, { From 85c2a72c538abbe4a62fcd6d0c8cbf8726996967 Mon Sep 17 00:00:00 2001 From: Amar Bolkan Date: Tue, 8 Dec 2020 13:28:38 +0100 Subject: [PATCH 10/61] Todo entfernt --- src/components/CustomLogin.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/CustomLogin.vue b/src/components/CustomLogin.vue index a0f3584..24baada 100644 --- a/src/components/CustomLogin.vue +++ b/src/components/CustomLogin.vue @@ -83,7 +83,6 @@ export default { sessionStorage.setItem("redirect", params.get("redirect")); } try { - // TODO relative path let auth_url = this.$appConfig.API_ROOT + '/auth/token'; axios From c928a55de70ba8728c0ec6a65726226dfd1f963f Mon Sep 17 00:00:00 2001 From: mlange304 Date: Wed, 9 Dec 2020 12:50:10 +0100 Subject: [PATCH 11/61] =?UTF-8?q?messages.json=20f=C3=BCr=20custom=20login?= =?UTF-8?q?=20aktualisiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 6 +++--- src/components/CustomLogin.vue | 13 +++++++------ src/i18n/messages.json | 6 ++++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/App.vue b/src/App.vue index 8a12cfa..ed30a3c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -9,8 +9,8 @@ - - + + {{ $t('message.app.login') }} {{ mdi.login }} @@ -48,7 +48,7 @@ {{ mdi.helpCircleOutline }} -