Merge branch 'frontend/timo' into develop

This commit is contained in:
Timo Volkmann 2019-05-14 12:06:59 +02:00
commit 7ccf8fc42e
3 changed files with 96 additions and 67 deletions

View File

@ -199,21 +199,16 @@
this.$store.commit('cacheCollector/RESET_NEW_CACHE'); this.$store.commit('cacheCollector/RESET_NEW_CACHE');
this.$router.push({path: '/overview'}); this.$router.push({path: '/overview'});
}).catch((error) => { }).catch((error) => {
//TODO: Fehlermeldungen
// Error
let msg; let msg;
let title; let title;
if (error.response) { if (error.response) {
// The request was made and the server responded with a status code title = "Bitte Eingaben überprüfen!";
title = "Problem with response!"; msg = error.response.data;
msg = error.response;
} else if (error.request) { } else if (error.request) {
// The request was made but no response was received title = "Verbindungsfehler!";
title = "Problem with request!"; msg = "Es konnte keine Verbindung zum Server aufgebaut werden. Versuchen Sie es später noch einmal!"
msg = "Error occured due to wrong server request!"
console.log(error.request); console.log(error.request);
} else { } else {
// Something happened in setting up the request that triggered an Error
title = "Error"; title = "Error";
msg = error.message; msg = error.message;
console.log('Error', error.message); console.log('Error', error.message);
@ -227,7 +222,24 @@
console.log("POST api/editCache: " + response.statusText); console.log("POST api/editCache: " + response.statusText);
this.$store.commit('cacheCollector/RESET_NEW_CACHE'); this.$store.commit('cacheCollector/RESET_NEW_CACHE');
this.$router.push({path: '/overview'}); this.$router.push({path: '/overview'});
}) }).catch((error) => {
let msg;
let title;
if (error.response) {
title = "Bitte Eingaben überprüfen!";
msg = error.response.data;
} else if (error.request) {
title = "Verbindungsfehler!";
msg = "Es konnte keine Verbindung zum Server aufgebaut werden. Versuchen Sie es später noch einmal!"
console.log(error.request);
} else {
title = "Error";
msg = error.message;
console.log('Error', error.message);
}
console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
})
} }
}, },
}, },

View File

@ -109,29 +109,24 @@
localStorage.setItem('userMail', JSON.stringify(data.email)); localStorage.setItem('userMail', JSON.stringify(data.email));
this.evalAuthentication(); this.evalAuthentication();
this.$router.push({path: `/overview`}) this.$router.push({path: `/overview`})
}) }).catch((error) => {
.catch((error) => { let msg;
let message; let title;
let header = "Fehler: "; if (error.response) {
if (error.response) { title = "Fehler!";
console.log("ERROR RESPONSE"); msg = error.response.data;
// The request was made and the server responded with a status code } else if (error.request) {
// that falls out of the range of 2xx title = "Verbindungsfehler!";
message = error.response.data.error; msg = "Es konnte keine Verbindung zum Server aufgebaut werden. Versuchen Sie es später noch einmal!"
header += error.response.status; console.log(error.request);
} else if (error.request) { } else {
// The request was made but no response was received title = "Error";
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of msg = error.message;
// http.ClientRequest in node.js console.log('Error', error.message);
message = "Anfrage fehlgeschlagen."; }
} else { console.log(error.config);
// Something happened in setting up the request that triggered an Error this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
console.log('Error', error.message); }).finally(() => {
message = error.message;
}
console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: message, title: header, });
}).finally(() => {
this.loading = false; this.loading = false;
this.evalAuthentication(); this.evalAuthentication();
}) })

View File

@ -165,26 +165,22 @@
this.initMap(); this.initMap();
resolve(true); resolve(true);
}).catch((error) => { }).catch((error) => {
let message; let msg;
let header = "Fehler: "; let title;
if (error.response) { if (error.response) {
console.log("ERROR RESPONSE"); title = "Bitte Eingaben überprüfen!";
// The request was made and the server responded with a status code msg = error.response.data;
// that falls out of the range of 2xx
message = error.response.data.error;
header += error.response.status;
} else if (error.request) { } else if (error.request) {
// The request was made but no response was received title = "Verbindungsfehler!";
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of msg = "Es konnte keine Verbindung zum Server aufgebaut werden. Versuchen Sie es später noch einmal!"
// http.ClientRequest in node.js console.log(error.request);
message = "Anfrage fehlgeschlagen.";
} else { } else {
// Something happened in setting up the request that triggered an Error title = "Error";
msg = error.message;
console.log('Error', error.message); console.log('Error', error.message);
message = error.message;
} }
console.log(error.config); console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: message, title: header,}); this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
resolve(true); resolve(true);
}) })
}) })
@ -258,26 +254,22 @@
.then((response) => { .then((response) => {
this.loadData(); this.loadData();
}).catch((error) => { }).catch((error) => {
let message; let msg;
let header = "Fehler: "; let title;
if (error.response) { if (error.response) {
console.log("ERROR RESPONSE"); title = "Fehler!";
// The request was made and the server responded with a status code msg = error.response.data;
// that falls out of the range of 2xx
message = error.response.data.error;
header += error.response.status;
} else if (error.request) { } else if (error.request) {
// The request was made but no response was received title = "Verbindungsfehler!";
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of msg = "Es konnte keine Verbindung zum Server aufgebaut werden. Versuchen Sie es später noch einmal!"
// http.ClientRequest in node.js console.log(error.request);
message = "Anfrage fehlgeschlagen.";
} else { } else {
// Something happened in setting up the request that triggered an Error title = "Error";
msg = error.message;
console.log('Error', error.message); console.log('Error', error.message);
message = error.message;
} }
console.log(error.config); console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: message, title: header,}); this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
}) })
}, },
startCache(cacheID) { startCache(cacheID) {
@ -299,9 +291,24 @@
console.log(response.data); console.log(response.data);
currentStationID = response.data.aktuelleStation.id; currentStationID = response.data.aktuelleStation.id;
this.$router.push({path: `/station/${cacheID}/${currentStationID}`}); this.$router.push({path: `/station/${cacheID}/${currentStationID}`});
}) }).catch((error) => {
.catch((error) => { let msg;
}); let title;
if (error.response) {
title = "Fehler!";
msg = error.response.data;
} else if (error.request) {
title = "Verbindungsfehler!";
msg = "Es konnte keine Verbindung zum Server aufgebaut werden. Versuchen Sie es später noch einmal!"
console.log(error.request);
} else {
title = "Error";
msg = error.message;
console.log('Error', error.message);
}
console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
})
} }
}, },
goToReward(cacheID) { goToReward(cacheID) {
@ -316,9 +323,24 @@
console.log(response.data); console.log(response.data);
currentStationID = response.data.aktuelleStation.id; currentStationID = response.data.aktuelleStation.id;
this.$router.push({path: `/CacheEnd/${params.cacheID}`}); this.$router.push({path: `/CacheEnd/${params.cacheID}`});
}) }).catch((error) => {
.catch((error) => { let msg;
}); let title;
if (error.response) {
title = "Fehler!";
msg = error.response.data;
} else if (error.request) {
title = "Verbindungsfehler!";
msg = "Es konnte keine Verbindung zum Server aufgebaut werden. Versuchen Sie es später noch einmal!"
console.log(error.request);
} else {
title = "Error";
msg = error.message;
console.log('Error', error.message);
}
console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
})
} }
}, },