diff --git a/apps/dumili/api/services/indexation/index.ts b/apps/dumili/api/services/indexation/index.ts index 9c8578c17..d7ff773ba 100644 --- a/apps/dumili/api/services/indexation/index.ts +++ b/apps/dumili/api/services/indexation/index.ts @@ -383,7 +383,20 @@ export default (io: Server) => { indexationSocket.on("runKumikoOnPage", async (pageId, callback) => { const { indexation } = indexationSocket.data; - const page = indexation.pages.find(({ id }) => id === pageId)!; + const page = await prisma.page.findUnique({ + where: { + id: pageId, + indexationId: indexation.id, + }, + }); + + if (!page) { + callback({ + error: `This indexation does not have any page with this ID`, + errorDetails: JSON.stringify({ pageId }), + }); + return; + } await setKumikoInferredPageStoryKinds([page]); const entry = getEntryFromPage(indexation, pageId)!; diff --git a/apps/dumili/api/services/indexation/types.ts b/apps/dumili/api/services/indexation/types.ts index f9edf9ea7..ab52b22f0 100644 --- a/apps/dumili/api/services/indexation/types.ts +++ b/apps/dumili/api/services/indexation/types.ts @@ -51,7 +51,7 @@ export default abstract class { abstract setPageUrl: ( id: number, - url: string, + url: string|null, callback: () => void, ) => void; @@ -138,7 +138,7 @@ export default abstract class { abstract runKumikoOnPage: ( pageId: page["id"], callback: ( - data: Errorable<{ status: "OK" }, "Kumiko output could not be parsed">, + data: Errorable<{ status: "OK" }, "This indexation does not have any page with this ID"|"Kumiko output could not be parsed">, ) => void, ) => void; diff --git a/apps/dumili/src/components/AiTooltip.vue b/apps/dumili/src/components/AiTooltip.vue index eeba05e2c..0a7ceed1c 100644 --- a/apps/dumili/src/components/AiTooltip.vue +++ b/apps/dumili/src/components/AiTooltip.vue @@ -3,9 +3,11 @@ @mouseout="() => (showRepeat = false)" @mouseover="() => (showRepeat = true)" > - + + + {{ $t("Type inconnu") }} - {{ $t("Types d'entrées déduits pour les pages") }} -
- {{ $t("Type d'entrée déduit") }} - {{ - storyKindAiSuggestion - ? storyKinds[storyKindAiSuggestion?.kind] - : $t("Non calculé") - }}
- - diff --git a/apps/dumili/src/components/TableOfContentsPage.vue b/apps/dumili/src/components/TableOfContentsPage.vue new file mode 100644 index 000000000..e2e5fa971 --- /dev/null +++ b/apps/dumili/src/components/TableOfContentsPage.vue @@ -0,0 +1,53 @@ + + \ No newline at end of file diff --git a/apps/dumili/src/components/UploadModal.vue b/apps/dumili/src/components/UploadModal.vue index 3b88669d0..14a9cdfcc 100644 --- a/apps/dumili/src/components/UploadModal.vue +++ b/apps/dumili/src/components/UploadModal.vue @@ -3,11 +3,10 @@ id="upload-modal" v-model="modal" :title="$t('Envoi d\'images de pages')" - :cancel-title="$t('Annuler')" align="center" - hide-footer + no-footer centered - :class="{ 'pe-none': isProcessing }" + :class="{ 'pe-none': isUploading || processLog }" content-class="h-100 " dialog-class="h-100" body-class="d-flex flex-column align-items-start overflow-auto" @@ -53,7 +52,7 @@ -
+
@@ -63,25 +62,25 @@ import type { CloudinaryUploadWidgetInfo, } from "cloudinary-widget"; import { dumiliSocketInjectionKey } from "~/composables/useDumiliSocket"; +import { suggestions } from "~/stores/suggestions"; import { stores as webStores } from "~web"; const { indexationSocket } = inject(dumiliSocketInjectionKey)!; +const { indexation } = storeToRefs(suggestions()); const { user } = storeToRefs(webStores.collection()); const modal = ref(true); const uploadFileType = ref<"PDF" | "Images">("PDF"); -const { folderName, pages } = defineProps<{ +const { pages } = defineProps<{ pages: { id: number; pageNumber: number }[]; - folderName: string; }>(); -console.log("folderName", folderName); - const currentPageIndex = ref(0); -const isProcessing = ref(false); +const showWidget = ref(true); +const isUploading = ref(false); const processLog = ref(""); const emit = defineEmits<{ @@ -101,6 +100,7 @@ const processPage = async (pageIndex: number, url: string) => { }; onMounted(() => { + const folderName = indexation.value!.id; const uploadWidget = cloudinary.createUploadWidget( { cloudName: import.meta.env.VITE_CLOUDINARY_CLOUDNAME, @@ -123,9 +123,10 @@ onMounted(() => { } else { switch (result?.event) { case "queues-start": - isProcessing.value = true; + isUploading.value = true; break; case "success": + showWidget.value = false; const info = result.info as CloudinaryUploadWidgetInfo; console.log("Done! Here is the image info: ", info); @@ -146,9 +147,7 @@ onMounted(() => { await processPage(currentPageIndex.value++, info.secure_url); } currentPageIndex.value = 0; - processLog.value = ``; - isProcessing.value = false; - uploadWidget.close(); + modal.value = false; emit("done"); break; case "abort": @@ -158,6 +157,12 @@ onMounted(() => { } }, ); + + watch(showWidget, (value) => { + if (!value) { + uploadWidget.close(); + } + }); }); diff --git a/apps/dumili/src/composables/useHint.ts b/apps/dumili/src/composables/useHint.ts index 70ec516f4..d8e6a67b1 100644 --- a/apps/dumili/src/composables/useHint.ts +++ b/apps/dumili/src/composables/useHint.ts @@ -6,7 +6,6 @@ import { dumiliSocketInjectionKey } from "./useDumiliSocket"; export default () => { const { loadIndexation } = suggestions(); - const { indexation } = storeToRefs(suggestions()); const { fetchIssuecodeDetails, fetchPublicationNames } = coa(); const { issuecodeDetails } = storeToRefs(coa()); @@ -28,7 +27,7 @@ export default () => { ), ); - await loadIndexation(indexation.value!.id); + await loadIndexation(); await fetchIssuecodeDetails( results.covers.map(({ issuecode }) => issuecode!), diff --git a/apps/dumili/src/pages/indexation/[id].vue b/apps/dumili/src/pages/indexation/[id].vue index 09f83e339..51ca67750 100644 --- a/apps/dumili/src/pages/indexation/[id].vue +++ b/apps/dumili/src/pages/indexation/[id].vue @@ -1,15 +1,7 @@