diff --git a/components/concept/grid.vue b/components/concept/grid.vue deleted file mode 100644 index ec87437..0000000 --- a/components/concept/grid.vue +++ /dev/null @@ -1,66 +0,0 @@ - - - - \ No newline at end of file diff --git a/netcode/handlers/concept.handler.ts b/netcode/handlers/concept.handler.ts deleted file mode 100644 index 5395c6b..0000000 --- a/netcode/handlers/concept.handler.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { useConceptStore } from "~/store/concepts.store"; -import type { - ConceptCreateEvent, - ConceptDeleteEvent, - ConceptDisableEvent, - ConceptEditEvent, - ConceptEnableEvent, -} from "../events/concept.events"; - -export const handlers = { - create: (event: ConceptCreateEvent) => { - const conceptStore = useConceptStore(); - conceptStore.concepts[event.concept.id] = event.concept; - }, - edit: (event: ConceptEditEvent) => { - const conceptStore = useConceptStore(); - conceptStore.concepts[event.concept.id].value = event.concept.value; - }, - delete: (event: ConceptDeleteEvent) => { - const conceptStore = useConceptStore(); - delete conceptStore.concepts[event.id]; - }, - // enable: (event: ConceptEnableEvent) => { - // const conceptStore = useConceptStore(); - // conceptStore.concepts[event.id].enabled = true; - // }, - // disable: (event: ConceptDisableEvent) => { - // const conceptStore = useConceptStore(); - // conceptStore.concepts[event.id].enabled = false; - // }, -}; diff --git a/pages/concepts.vue b/pages/concepts.vue deleted file mode 100644 index 1535973..0000000 --- a/pages/concepts.vue +++ /dev/null @@ -1,6 +0,0 @@ - - - diff --git a/store/concepts.store.ts b/store/concepts.store.ts deleted file mode 100644 index ffb1b14..0000000 --- a/store/concepts.store.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { defineStore } from "pinia"; -import { subscribe } from "~/netcode"; -import type { - ConceptResponseDTO, - ConceptTypeResponseDTO, -} from "~/netcode/events/dto/conceptresponse.dto"; -import type { ConceptEvent } from "~/netcode/events/events"; -import { handlers } from "~/netcode/handlers/concept.handler"; - -export const useConceptStore = defineStore("concept", { - state: () => ({ - concepts: {} as Record, - eventSource: null as null | EventSource, - conceptTypes: {} as Record, - }), - actions: { - subscribe() { - this.eventSource = subscribe(`/concepts/subscribe`); - this.eventSource.addEventListener("message", (message) => { - const data = JSON.parse(message.data) as ConceptEvent; - const type = data.type; - if (type in handlers) { - handlers[type as keyof typeof handlers](data); - } - }); - }, - close() { - this.eventSource?.close(); - }, - async fetchConceptTypes() { - const config = useRuntimeConfig(); - const data = await useFetch( - config.public.endpoint + `/concepts/types`, - { - credentials: "include", - }, - ); - if (data.data.value && !data.error.value) { - for (const conceptType of data.data.value) { - this.conceptTypes[conceptType.id] = conceptType; - } - } - return this.conceptTypes; - }, - async fetchConceptList() { - const config = useRuntimeConfig(); - const data = await useFetch( - config.public.endpoint + `/concepts/all`, - { - credentials: "include", - }, - ); - if (data.data.value && !data.error.value) { - for (const concept of data.data.value) { - this.concepts[concept.id] = concept; - } - } - return data; - }, - async enableConcept(concepts: ConceptResponseDTO) { - const config = useRuntimeConfig(); - const data = await $fetch( - config.public.endpoint + `/concepts/` + concepts.id + "/enable", - { - credentials: "include", - method: "PUT", - }, - ); - // word.enabled = true; - // return data; - }, - async disableConcept(concepts: ConceptResponseDTO) { - const config = useRuntimeConfig(); - const data = await $fetch( - config.public.endpoint + `/concepts/` + concepts.id + "/disable", - { - credentials: "include", - method: "PUT", - }, - ); - // word.enabled = false; - // return data; - }, - async createConcept(value: string) { - const config = useRuntimeConfig(); - const data = await $fetch( - config.public.endpoint + `/concepts/`, - { - credentials: "include", - body: { value }, - method: "POST", - }, - ); - }, - async deleteConcept(id: number) { - const config = useRuntimeConfig(); - const data = await $fetch( - config.public.endpoint + `/concepts/` + id, - { - credentials: "include", - method: "DELETE", - }, - ); - }, - }, -});