diff --git a/package-lock.json b/package-lock.json
index 654c907..c86341e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -32,6 +32,7 @@
"@tsconfig/node20": "^20.1.4",
"@types/eslint": "~9.6.0",
"@types/lodash.clonedeep": "^4.5.9",
+ "@types/lodash.difference": "^4.5.9",
"@types/lodash.isequal": "^4.5.8",
"@types/node": "^20.14.5",
"@types/nprogress": "^0.2.0",
@@ -3085,6 +3086,16 @@
"@types/lodash": "*"
}
},
+ "node_modules/@types/lodash.difference": {
+ "version": "4.5.9",
+ "resolved": "https://registry.npmjs.org/@types/lodash.difference/-/lodash.difference-4.5.9.tgz",
+ "integrity": "sha512-MNlajcjtwzLpXk+cw38UkBvEXJNEPhULgS8A4EHwtUwT7f7yFH/SFKD0iw5Rfilwh60yJIgFo0vsMr7xsa5+aw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/lodash": "*"
+ }
+ },
"node_modules/@types/lodash.isequal": {
"version": "4.5.8",
"resolved": "https://registry.npmjs.org/@types/lodash.isequal/-/lodash.isequal-4.5.8.tgz",
diff --git a/package.json b/package.json
index 6b17df4..e886a5f 100644
--- a/package.json
+++ b/package.json
@@ -47,6 +47,7 @@
"@tsconfig/node20": "^20.1.4",
"@types/eslint": "~9.6.0",
"@types/lodash.clonedeep": "^4.5.9",
+ "@types/lodash.difference": "^4.5.9",
"@types/lodash.isequal": "^4.5.8",
"@types/node": "^20.14.5",
"@types/nprogress": "^0.2.0",
diff --git a/src/components/admin/club/protocol/CreateProtocolModal.vue b/src/components/admin/club/protocol/CreateProtocolModal.vue
new file mode 100644
index 0000000..7a576b4
--- /dev/null
+++ b/src/components/admin/club/protocol/CreateProtocolModal.vue
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
diff --git a/src/components/admin/club/protocol/CurrentlySyncingModal.vue b/src/components/admin/club/protocol/CurrentlySyncingModal.vue
new file mode 100644
index 0000000..5bd8f47
--- /dev/null
+++ b/src/components/admin/club/protocol/CurrentlySyncingModal.vue
@@ -0,0 +1,26 @@
+
+
+
+
Protokoll wird noch synchronisiert
+
+
+
+
Es gibt noch Daten, welche synchronisiert werden müssen.
+
Dieses PopUp entfernt sich von selbst nach erfolgreicher Synchronisierung.
+
+
+
+
+
+
diff --git a/src/components/admin/club/protocol/ProtocolListItem.vue b/src/components/admin/club/protocol/ProtocolListItem.vue
index 6cf34e3..141006a 100644
--- a/src/components/admin/club/protocol/ProtocolListItem.vue
+++ b/src/components/admin/club/protocol/ProtocolListItem.vue
@@ -4,10 +4,10 @@
:to="{ name: 'admin-club-protocol-overview', params: { protocolId: protocol.id } }"
class="bg-primary p-2 text-white flex flex-row justify-between items-center"
>
-
{{ protocol.title }}
+ {{ protocol.title }} - {{ protocol.date }}
-
diff --git a/src/components/admin/club/protocol/ProtocolSyncing.vue b/src/components/admin/club/protocol/ProtocolSyncing.vue
new file mode 100644
index 0000000..d3fea13
--- /dev/null
+++ b/src/components/admin/club/protocol/ProtocolSyncing.vue
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/stores/admin/protocol.ts b/src/stores/admin/protocol.ts
index 87d315a..ca39eea 100644
--- a/src/stores/admin/protocol.ts
+++ b/src/stores/admin/protocol.ts
@@ -3,6 +3,9 @@ import type { CreateProtocolViewModel, SyncProtocolViewModel } from "@/viewmodel
import { http } from "@/serverCom";
import type { AxiosResponse } from "axios";
import type { ProtocolViewModel } from "@/viewmodels/admin/protocol.models";
+import cloneDeep from "lodash.clonedeep";
+import isEqual from "lodash.isEqual";
+import difference from "lodash.difference";
export const useProtocolStore = defineStore("protocol", {
state: () => {
@@ -12,11 +15,18 @@ export const useProtocolStore = defineStore("protocol", {
loading: "loading" as "loading" | "fetched" | "failed",
activeProtocol: null as number | null,
activeProtocolObj: null as ProtocolViewModel | null,
+ origin: null as ProtocolViewModel | null,
loadingActive: "loading" as "loading" | "fetched" | "failed",
- syncing: "synced" as "synced" | "syncing" | "detectedChanges" | "failed",
+ syncingProtocol: "synced" as "synced" | "syncing" | "detectedChanges" | "failed",
};
},
+ getters: {
+ detectedChangeProtocol: (state) => !isEqual(state.origin, state.activeProtocolObj),
+ },
actions: {
+ setProtocolSyncingState(state: "synced" | "syncing" | "detectedChanges" | "failed") {
+ this.syncingProtocol = state;
+ },
fetchProtocols(offset = 0, count = 25, clear = false) {
if (clear) this.protocols = [];
this.loading = "loading";
@@ -46,7 +56,8 @@ export const useProtocolStore = defineStore("protocol", {
http
.get(`/admin/protocol/${this.activeProtocol}`)
.then((res) => {
- this.activeProtocolObj = res.data;
+ this.origin = res.data;
+ this.activeProtocolObj = cloneDeep(this.origin);
this.loadingActive = "fetched";
})
.catch((err) => {
@@ -64,16 +75,30 @@ export const useProtocolStore = defineStore("protocol", {
this.fetchProtocols();
return result;
},
- async synchronizeActiveProtocol(protocol: SyncProtocolViewModel): Promise> {
- const result = await http.patch(`/admin/protocol/${protocol.id}`, {
- title: protocol.title,
- date: protocol.date,
- starttime: protocol.starttime,
- endtime: protocol.endtime,
- summary: protocol.summary,
- });
- this.fetchProtocols();
- return result;
+ async synchronizeActiveProtocol(): Promise {
+ if (this.origin == null || this.activeProtocolObj == null) return;
+
+ this.syncingProtocol = "syncing";
+ await http
+ .put(`/admin/protocol/${this.origin.id}/synchronize`, {
+ title: this.activeProtocolObj.title,
+ date: this.activeProtocolObj.date,
+ starttime: this.activeProtocolObj.starttime,
+ endtime: this.activeProtocolObj.endtime,
+ summary: this.activeProtocolObj.summary,
+ })
+ .then((res) => {
+ this.syncingProtocol = "synced";
+ })
+ .catch((err) => {
+ this.syncingProtocol = "failed";
+ });
+ this.fetchProtocolById(this.origin.id)
+ .then((res) => {
+ this.origin = res.data;
+ this.activeProtocolObj = cloneDeep(this.origin);
+ })
+ .catch((err) => {});
},
},
});
diff --git a/src/views/admin/club/protocol/Protocol.vue b/src/views/admin/club/protocol/Protocol.vue
index dc9a17f..273d37c 100644
--- a/src/views/admin/club/protocol/Protocol.vue
+++ b/src/views/admin/club/protocol/Protocol.vue
@@ -57,9 +57,9 @@ export default defineComponent({
...mapActions(useProtocolStore, ["fetchProtocols"]),
...mapActions(useModalStore, ["openModal"]),
openCreateModal() {
- // this.openModal(
- // markRaw(defineAsyncComponent(() => import("@/components/admin/club/protocol/CreateProtocolModal.vue")))
- // );
+ this.openModal(
+ markRaw(defineAsyncComponent(() => import("@/components/admin/club/protocol/CreateProtocolModal.vue")))
+ );
},
},
});
diff --git a/src/views/admin/club/protocol/ProtocolRouting.vue b/src/views/admin/club/protocol/ProtocolRouting.vue
index f24d348..f77c91b 100644
--- a/src/views/admin/club/protocol/ProtocolRouting.vue
+++ b/src/views/admin/club/protocol/ProtocolRouting.vue
@@ -5,14 +5,16 @@
-
- {{ activeProtocolObj?.title }}, {{ activeProtocolObj?.date }}
-
-
-
-
-
-
+
{{ origin?.title }}, {{ origin?.date }}
+
{
+ syncState = state;
+ }
+ "
+ />
+
@@ -49,14 +51,8 @@ import { mapActions, mapState } from "pinia";
import MainTemplate from "@/templates/Main.vue";
import { RouterLink, RouterView } from "vue-router";
import { useProtocolStore } from "@/stores/admin/protocol";
-import {
- ArrowPathIcon,
- CloudArrowUpIcon,
- CloudIcon,
- ExclamationTriangleIcon,
- TrashIcon,
-} from "@heroicons/vue/24/outline";
import { useModalStore } from "@/stores/modal";
+import ProtocolSyncing from "@/components/admin/club/protocol/ProtocolSyncing.vue";