|
|
@@ -3,8 +3,9 @@
|
|
|
<div class="logo" />
|
|
|
<router-link to="/planner" class="appname">BDLG planner</router-link>
|
|
|
<nav class="tabs floating">
|
|
|
+ <router-link class="tab" active-class="selected" to="/planner"> Accueil </router-link>
|
|
|
<router-link class="tab" active-class="selected" to="/planner/evenement">
|
|
|
- Accueil
|
|
|
+ Evenement
|
|
|
</router-link>
|
|
|
<router-link class="tab" active-class="selected" to="/planner/planning">Planning</router-link>
|
|
|
<router-link class="tab" active-class="selected" to="/planner/competences">
|
|
|
@@ -61,7 +62,8 @@ import updatePlanningVersions from "@/mixins/updatePlanningVersions";
|
|
|
import { MutationTypes } from "./store/Mutations";
|
|
|
import dayjs from "dayjs";
|
|
|
import { StateJSON } from "./store/State";
|
|
|
-const APIAdress = "http://localhost:8080/";
|
|
|
+
|
|
|
+const API_URL = process.env.VUE_APP_API_URL;
|
|
|
|
|
|
const keyofEvent: Array<keyof Evenement> = ["name", "uuid", "start", "end"];
|
|
|
export default defineComponent({
|
|
|
@@ -75,23 +77,22 @@ export default defineComponent({
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
+ fetch(`${API_URL}api/evenements`)
|
|
|
+ .then((response) => {
|
|
|
+ if (response.status == 200) {
|
|
|
+ return response.json();
|
|
|
+ } else {
|
|
|
+ throw new Error(response.statusText);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then((data) => this.$store.commit(MutationTypes.refreshSavedPlanning, data));
|
|
|
+
|
|
|
const previousState = window.localStorage.getItem("activeState");
|
|
|
toast({ html: "Bienvenue" });
|
|
|
if (previousState) {
|
|
|
this.importJsonState(JSON.parse(previousState), false);
|
|
|
- this.$router.push({ name: "Main" });
|
|
|
+ if (this.$route.path != "/planner") this.$router.push({ name: "Evenement" });
|
|
|
}
|
|
|
- this.$nextTick(() =>
|
|
|
- fetch(`${APIAdress}api/evenements`)
|
|
|
- .then((response) => {
|
|
|
- if (response.status == 200) {
|
|
|
- return response.json();
|
|
|
- } else {
|
|
|
- throw new Error(response.statusText);
|
|
|
- }
|
|
|
- })
|
|
|
- .then((data) => this.$store.commit(MutationTypes.refreshSavedPlanning, data))
|
|
|
- );
|
|
|
window.onbeforeunload = () => {
|
|
|
this.localSave();
|
|
|
};
|
|
|
@@ -108,12 +109,10 @@ export default defineComponent({
|
|
|
};
|
|
|
// local save
|
|
|
window.localStorage.setItem("activeState", body.content);
|
|
|
- fetch(`${APIAdress}api/evenements/${body.uuid}`, {
|
|
|
+ fetch(`${API_URL}api/evenements/${body.uuid}`, {
|
|
|
method: "PUT",
|
|
|
body: JSON.stringify(body),
|
|
|
- headers: {
|
|
|
- "Content-Type": "application/json",
|
|
|
- },
|
|
|
+ headers: { "Content-Type": "application/json" },
|
|
|
})
|
|
|
.then((response) => {
|
|
|
if (response.status == 200) {
|
|
|
@@ -126,12 +125,10 @@ export default defineComponent({
|
|
|
classes: "error",
|
|
|
displayLength: 5000,
|
|
|
});
|
|
|
- return fetch(`${APIAdress}api/evenements/`, {
|
|
|
+ return fetch(`${API_URL}api/evenements`, {
|
|
|
method: "POST",
|
|
|
body: JSON.stringify(body),
|
|
|
- headers: {
|
|
|
- "Content-Type": "application/json",
|
|
|
- },
|
|
|
+ headers: { "Content-Type": "application/json" },
|
|
|
}).then((response) => {
|
|
|
if (response.status == 200) {
|
|
|
toast({ html: "Données sauvegardées", classes: "success", displayLength: 5000 });
|
|
|
@@ -207,10 +204,10 @@ export default defineComponent({
|
|
|
const options = {
|
|
|
method: "POST",
|
|
|
body: JSON.stringify(body),
|
|
|
- headers: { "Content-type": "application/json; charset=UTF-8" },
|
|
|
+ headers: { "Content-Type": "application/json" },
|
|
|
};
|
|
|
this.optimisationInProgress = true;
|
|
|
- fetch(`${APIAdress}planning/solve`, options)
|
|
|
+ fetch(`${API_URL}planning/solve`, options)
|
|
|
.then((response) => {
|
|
|
if (response.status == 200) {
|
|
|
return response.json();
|
|
|
@@ -358,6 +355,9 @@ export default defineComponent({
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ // Remove past score explanation.
|
|
|
+ this.clearToast();
|
|
|
+ this.$router.push({ name: "Evenement" });
|
|
|
},
|
|
|
},
|
|
|
});
|