|
|
@@ -52,7 +52,7 @@ import {
|
|
|
} from "@/models/SolverInput";
|
|
|
import updatePlanningVersions from "@/mixins/updatePlanningVersions";
|
|
|
import importJsonState from "@/mixins/ImportJsonState";
|
|
|
-import { MutationTypes } from "@/views/Mutations";
|
|
|
+import { MutationTypes } from "@/store/Mutations";
|
|
|
import { EvenementStateJSON } from "@/store/State";
|
|
|
import Header, { HeaderLink } from "@/components/Utils/Header.vue";
|
|
|
import cFooter from "@/components/Utils/Footer.vue";
|
|
|
@@ -73,7 +73,6 @@ export default defineComponent({
|
|
|
mixins: [updatePlanningVersions, importJsonState],
|
|
|
data() {
|
|
|
return {
|
|
|
- stompClient: Stomp.over(new SockJS("/ws")),
|
|
|
optimisationInProgress: false,
|
|
|
explanation: "",
|
|
|
showExplanation: false,
|
|
|
@@ -82,6 +81,9 @@ export default defineComponent({
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
+ stompClient(): Stomp.Client | null {
|
|
|
+ return this.$store.state.stompClient;
|
|
|
+ },
|
|
|
showFooter(): boolean {
|
|
|
return this.$route.name != "Planning";
|
|
|
},
|
|
|
@@ -94,19 +96,20 @@ export default defineComponent({
|
|
|
},
|
|
|
watch: {
|
|
|
uuid(val: string, old: string) {
|
|
|
- if (old && this.stompClient.connected) this.stompClient.unsubscribe("/planning/" + old);
|
|
|
+ if (old && this.stompClient?.connected) this.stompClient.unsubscribe("/planning/" + old);
|
|
|
this.subscribe(val);
|
|
|
},
|
|
|
},
|
|
|
beforeMount() {
|
|
|
- this.stompClient.connect(
|
|
|
+ this.$store.commit(MutationTypes.setStompClient, Stomp.over(new SockJS("/ws")));
|
|
|
+ this.stompClient?.connect(
|
|
|
{},
|
|
|
() => {
|
|
|
- this.stompClient.subscribe("/toast", (msg) => {
|
|
|
+ this.stompClient?.subscribe("/toast", (msg) => {
|
|
|
var content = JSON.parse(msg.body) as { text: string; type: string };
|
|
|
toast({ html: content.text, classes: content.type });
|
|
|
});
|
|
|
- this.stompClient.subscribe("/user/queue/query", this.handleStompQuery);
|
|
|
+ this.stompClient?.subscribe("/user/queue/query", this.handleStompQuery);
|
|
|
this.subscribe(this.uuid);
|
|
|
},
|
|
|
(error) => {
|
|
|
@@ -155,7 +158,7 @@ export default defineComponent({
|
|
|
},
|
|
|
methods: {
|
|
|
subscribe(uuid: string) {
|
|
|
- if (uuid && this.stompClient.connected) {
|
|
|
+ if (uuid && this.stompClient?.connected) {
|
|
|
this.stompClient.subscribe("/planning/" + uuid, (msg) => this.handlePlanningChange(msg));
|
|
|
this.stompClient.send(
|
|
|
"/app/notify",
|
|
|
@@ -188,7 +191,7 @@ export default defineComponent({
|
|
|
destination: content.destination,
|
|
|
payload: zipEncode(JSON.stringify(this.$store.getters.getJSONEvenementState)),
|
|
|
};
|
|
|
- this.stompClient.send("/app/response", {}, JSON.stringify(response));
|
|
|
+ this.stompClient?.send("/app/response", {}, JSON.stringify(response));
|
|
|
}
|
|
|
if (content.type == "planningData" && content.uuid == this.uuid) {
|
|
|
const payload = JSON.parse(decodeUnzip(content.payload)) as EvenementStateJSON;
|