From 56f8c19520edc769b915609d3b754127e7fa29d5 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Wed, 26 Sep 2018 11:36:06 +0100 Subject: [PATCH] Fixed axios base url --- frontend/src/main.js | 2 +- frontend/src/views/Home.vue | 4 ++-- frontend/src/views/NewSite.vue | 2 +- frontend/src/views/NewTutor.vue | 18 ++++++++++++++---- frontend/src/views/Observation.vue | 2 +- frontend/src/views/Stats.vue | 22 ++++++++++++++++++++-- 6 files changed, 39 insertions(+), 11 deletions(-) diff --git a/frontend/src/main.js b/frontend/src/main.js index a02ace2..b85c515 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -12,7 +12,7 @@ import "pc-bootstrap4-datetimepicker/build/css/bootstrap-datetimepicker.css"; import Icon from "vue-awesome/components/Icon"; Vue.config.productionTip = false; -axios.defaults.baseUrl = "http://localhost:8090/api"; +axios.defaults.baseURL = "/api"; Vue.use(VueAxios, axios); Vue.use(BootstrapVue); Vue.use(datePicker); diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue index 64d749a..1e0b548 100644 --- a/frontend/src/views/Home.vue +++ b/frontend/src/views/Home.vue @@ -92,7 +92,7 @@ export default { mounted() { this.resetStore(); Vue.axios - .get("/api/site/all") + .get("/site/all") .then(response => { this.siteOptions = response.data; this.loaded = true; @@ -125,7 +125,7 @@ export default { ]), getTutors: function() { if (this.site != null) { - Vue.axios.get("/api/site/" + this.site + "/tutors").then(response => { + Vue.axios.get("/site/" + this.site + "/tutors").then(response => { this.tutorOptions = response.data; this.loadingTutors = false; }); diff --git a/frontend/src/views/NewSite.vue b/frontend/src/views/NewSite.vue index bb775e9..59128ca 100644 --- a/frontend/src/views/NewSite.vue +++ b/frontend/src/views/NewSite.vue @@ -40,7 +40,7 @@ export default { var form = document.getElementById("submission-form"); if (form.checkValidity()) { Vue.axios - .post("/api/site", this.siteName) + .post("/site", this.siteName) .then(response => { this.alertVariant = "success"; this.alertText = "Successfully added " + response.data.name; diff --git a/frontend/src/views/NewTutor.vue b/frontend/src/views/NewTutor.vue index 00368a6..1989fff 100644 --- a/frontend/src/views/NewTutor.vue +++ b/frontend/src/views/NewTutor.vue @@ -8,6 +8,9 @@ + + + Submit
@@ -29,12 +32,13 @@ export default { dismissSecs: 5, dismissCountDown: 0, alertVariant: "info", - alertText: "" + alertText: "", + submissionPassword: "" }; }, mounted() { Vue.axios - .get("/api/site/all") + .get("/site/all") .then(response => { this.siteOptions = response.data; }) @@ -54,9 +58,15 @@ export default { e.preventDefault(); e.stopPropagation(); var form = document.getElementById("submission-form"); + let axiosConfig = { + auth: { + username: "test", + password: this.submissionPassword + } + }; if (form.checkValidity()) { Vue.axios - .post("/api/tutor", { + .post("/tutor", { siteId: this.siteSelection, name: this.tutorName }) @@ -70,7 +80,7 @@ export default { this.alertText = "Failed to add Tutor"; this.showAlert(); console.log(error); - }); + }, axiosConfig); } } } diff --git a/frontend/src/views/Observation.vue b/frontend/src/views/Observation.vue index dcfc9a5..1e8ba7d 100644 --- a/frontend/src/views/Observation.vue +++ b/frontend/src/views/Observation.vue @@ -198,7 +198,7 @@ export default { }); if (form.checkValidity()) { Vue.axios - .post("/api/observation", { + .post("/observation", { siteId: this.site, tutorIds: this.tutors, observed: this.description, diff --git a/frontend/src/views/Stats.vue b/frontend/src/views/Stats.vue index 5538f05..dc4d9aa 100644 --- a/frontend/src/views/Stats.vue +++ b/frontend/src/views/Stats.vue @@ -12,6 +12,11 @@ + + + + + @@ -44,13 +49,15 @@ export default { dateOptions: { format: "DD/MM/YYYY", useCurrent: false - } + }, + siteSelection: null, + siteOptions: null }; }, methods: { getAllTimeAverage: function() { Vue.axios - .get("/api/observation/average/all/chartjs") + .get("/observation/average/all/chartjs") .then(response => { this.chartData = response.data; }) @@ -63,6 +70,17 @@ export default { }, mounted() { this.getAllTimeAverage(); + Vue.axios + .get("/site/all") + .then(response => { + this.siteOptions = response.data; + this.loaded = true; + }) + .catch(error => { + this.errorStatus = error.response.status; + this.errorMessage = error.response.data; + this.$refs.errorModal.show(); + }); } };