Fixed axios base url

This commit is contained in:
neviyn 2018-09-26 11:36:06 +01:00
parent d1d3b35699
commit 56f8c19520
6 changed files with 39 additions and 11 deletions

View File

@ -12,7 +12,7 @@ import "pc-bootstrap4-datetimepicker/build/css/bootstrap-datetimepicker.css";
import Icon from "vue-awesome/components/Icon"; import Icon from "vue-awesome/components/Icon";
Vue.config.productionTip = false; Vue.config.productionTip = false;
axios.defaults.baseUrl = "http://localhost:8090/api"; axios.defaults.baseURL = "/api";
Vue.use(VueAxios, axios); Vue.use(VueAxios, axios);
Vue.use(BootstrapVue); Vue.use(BootstrapVue);
Vue.use(datePicker); Vue.use(datePicker);

View File

@ -92,7 +92,7 @@ export default {
mounted() { mounted() {
this.resetStore(); this.resetStore();
Vue.axios Vue.axios
.get("/api/site/all") .get("/site/all")
.then(response => { .then(response => {
this.siteOptions = response.data; this.siteOptions = response.data;
this.loaded = true; this.loaded = true;
@ -125,7 +125,7 @@ export default {
]), ]),
getTutors: function() { getTutors: function() {
if (this.site != null) { 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.tutorOptions = response.data;
this.loadingTutors = false; this.loadingTutors = false;
}); });

View File

@ -40,7 +40,7 @@ export default {
var form = document.getElementById("submission-form"); var form = document.getElementById("submission-form");
if (form.checkValidity()) { if (form.checkValidity()) {
Vue.axios Vue.axios
.post("/api/site", this.siteName) .post("/site", this.siteName)
.then(response => { .then(response => {
this.alertVariant = "success"; this.alertVariant = "success";
this.alertText = "Successfully added " + response.data.name; this.alertText = "Successfully added " + response.data.name;

View File

@ -8,6 +8,9 @@
<b-form-group horizontal label="Tutor Name"> <b-form-group horizontal label="Tutor Name">
<b-form-input v-model="tutorName" type="text" style="text-align:center;" /> <b-form-input v-model="tutorName" type="text" style="text-align:center;" />
</b-form-group> </b-form-group>
<b-form-group horizontal label="Password">
<b-form-input v-model="submissionPassword" type="password" style="text-align:center;" />
</b-form-group>
<b-button type="submit" size="lg" variant="primary">Submit</b-button> <b-button type="submit" size="lg" variant="primary">Submit</b-button>
</b-form> </b-form>
<br /> <br />
@ -29,12 +32,13 @@ export default {
dismissSecs: 5, dismissSecs: 5,
dismissCountDown: 0, dismissCountDown: 0,
alertVariant: "info", alertVariant: "info",
alertText: "" alertText: "",
submissionPassword: ""
}; };
}, },
mounted() { mounted() {
Vue.axios Vue.axios
.get("/api/site/all") .get("/site/all")
.then(response => { .then(response => {
this.siteOptions = response.data; this.siteOptions = response.data;
}) })
@ -54,9 +58,15 @@ export default {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
var form = document.getElementById("submission-form"); var form = document.getElementById("submission-form");
let axiosConfig = {
auth: {
username: "test",
password: this.submissionPassword
}
};
if (form.checkValidity()) { if (form.checkValidity()) {
Vue.axios Vue.axios
.post("/api/tutor", { .post("/tutor", {
siteId: this.siteSelection, siteId: this.siteSelection,
name: this.tutorName name: this.tutorName
}) })
@ -70,7 +80,7 @@ export default {
this.alertText = "Failed to add Tutor"; this.alertText = "Failed to add Tutor";
this.showAlert(); this.showAlert();
console.log(error); console.log(error);
}); }, axiosConfig);
} }
} }
} }

View File

@ -198,7 +198,7 @@ export default {
}); });
if (form.checkValidity()) { if (form.checkValidity()) {
Vue.axios Vue.axios
.post("/api/observation", { .post("/observation", {
siteId: this.site, siteId: this.site,
tutorIds: this.tutors, tutorIds: this.tutors,
observed: this.description, observed: this.description,

View File

@ -12,6 +12,11 @@
</div> </div>
</b-modal> </b-modal>
<b-row> <b-row>
<b-col>
<b-form-group label="Site">
<b-form-select v-model="siteSelection" :options="siteOptions" style="text-align:center;" />
</b-form-group>
</b-col>
<b-col> <b-col>
<b-form-group label="From"> <b-form-group label="From">
<date-picker v-model="startDate" :config="dateOptions" /> <date-picker v-model="startDate" :config="dateOptions" />
@ -44,13 +49,15 @@ export default {
dateOptions: { dateOptions: {
format: "DD/MM/YYYY", format: "DD/MM/YYYY",
useCurrent: false useCurrent: false
} },
siteSelection: null,
siteOptions: null
}; };
}, },
methods: { methods: {
getAllTimeAverage: function() { getAllTimeAverage: function() {
Vue.axios Vue.axios
.get("/api/observation/average/all/chartjs") .get("/observation/average/all/chartjs")
.then(response => { .then(response => {
this.chartData = response.data; this.chartData = response.data;
}) })
@ -63,6 +70,17 @@ export default {
}, },
mounted() { mounted() {
this.getAllTimeAverage(); 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();
});
} }
}; };
</script> </script>