Skip to content

Commit

Permalink
dumili: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Nov 4, 2024
1 parent 9066cfd commit 7b79186
Show file tree
Hide file tree
Showing 10 changed files with 177 additions and 126 deletions.
21 changes: 8 additions & 13 deletions apps/dumili/api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ model storySuggestion {
}

model issueSuggestion {
id Int @id @default(autoincrement())
indexationId String @map("indexation_id") @db.VarChar(20)
source issueSuggestionSource
publicationcode String @db.VarChar(12)
issuenumber String @db.VarChar(13)
issuecode String @db.VarChar(25)
acceptedOnEntries indexation[] @relation("indexation_accepted_issue_suggestion_idToissue_suggestion")
indexation indexation @relation(fields: [indexationId], references: [id], onUpdate: Restrict, map: "issue_suggestion_indexation_id_fk")
id Int @id @default(autoincrement())
indexationId String @map("indexation_id") @db.VarChar(20)
isChosenByAi Boolean @default(false) @map("is_chosen_by_ai")
publicationcode String @db.VarChar(12)
issuenumber String @db.VarChar(13)
issuecode String @db.VarChar(25)
acceptedOnEntries indexation[] @relation("indexation_accepted_issue_suggestion_idToissue_suggestion")
indexation indexation @relation(fields: [indexationId], references: [id], onUpdate: Restrict, map: "issue_suggestion_indexation_id_fk")
@@index([indexationId], map: "issue_suggestion_indexation_id_fk")
@@map("issue_suggestion")
Expand Down Expand Up @@ -145,11 +145,6 @@ model aiKumikoResultPanel {
@@map("ai_kumiko_result_panel")
}

enum issueSuggestionSource {
ai
user
}

enum storyKind {
a
c
Expand Down
71 changes: 53 additions & 18 deletions apps/dumili/src/components/AiSuggestionIcon.vue
Original file line number Diff line number Diff line change
@@ -1,42 +1,77 @@
<template>
<i-bi-extra-lightbulb-broken-fill
v-if="disabled"
<component
:is="component"
:id="id"
:class="`${className} broken ms-2 me-4 ${status === 'info' ? 'black-background' : ''}`"
/>
<i-bi-lightbulb-fill
v-else
:id="id"
:class="`${className} ms-2 ${status === 'info' ? 'black-background' : ''}`"
:class="{
button,
[className]: true,
[status]: true,
broken: status === 'failure',
'ms-2': true,
'me-4': true,
}"
/>
</template>
<script setup lang="ts">
import IBiExtraLightbulbBrokenFill from "~icons/extra-icons/brokenLightbulb";
import IBiLightbulbFill from "~icons/bi/lightbulb-fill";
const { class: className } = defineProps<{
status: "success" | "failure" | "info";
id?: string;
disabled?: boolean;
class?: string;
}>();
const { class: className, status } = withDefaults(
defineProps<{
button?: boolean;
status: "success" | "failure" | "idle" | "loading";
id?: string;
class?: string;
}>(),
{
class: "",
id: undefined,
},
);
const component = computed(() =>
status === "failure" ? IBiExtraLightbulbBrokenFill : IBiLightbulbFill,
);
</script>

<style lang="scss" scoped>
@keyframes pulse-yellow {
0% {
color: #999;
}
50% {
color: yellow;
}
100% {
color: #999;
}
}
svg {
width: 20px;
min-width: 20px;
color: yellow;
&.black-background {
cursor: help;
color: grey;
&.button {
background: black;
cursor: help;
border-radius: 10px;
padding: 4px;
height: 20px;
}
&.broken {
&.success {
color: yellow;
}
&.failure {
color: orange;
}
&.loading {
animation: pulse-yellow 2s infinite;
pointer-events: none;
cursor: not-allowed;
}
}
Expand Down
27 changes: 11 additions & 16 deletions apps/dumili/src/components/AiTooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,27 @@
>
<b-tooltip :target="id" click><slot /></b-tooltip>
<AiSuggestionIcon
:id="id"
status="info"
:id="disabled ? `${id}-disabled` : id"
button
:status="status"
class="me-5"
:disabled="disabled"
@click.stop="() => {}" />
<i-bi-arrow-repeat
v-show="showRepeat"
class="position-absolute right-0"
@click="emit('re-run')"
@click="onClickRerun"
/></span>
</template>
<script setup lang="ts">
withDefaults(
defineProps<{
id: string;
disabled?: boolean;
}>(),
{
disabled: false,
},
);
const { value } = defineProps<{
id: string;
value: string[] | string | null | undefined;
onClickRerun: (...args: unknown[]) => void | Promise<void>;
}>();
defineSlots();
const emit = defineEmits<{
(e: "re-run"): void;
}>();
const disabled = ref(false); // TODO handle failed suggestions
const status = computed(() => (value ? "success" : "idle"));
const showRepeat = ref(false);
</script>
Expand Down
12 changes: 0 additions & 12 deletions apps/dumili/src/components/DumiliBook.vue
Original file line number Diff line number Diff line change
Expand Up @@ -256,18 +256,6 @@ nextTick(() => {
cursor: grab;
}
@keyframes pulse-yellow {
0% {
color: #999;
}
50% {
color: yellow;
}
100% {
color: #999;
}
}
.flip-book {
max-width: 100% !important;
margin: auto;
Expand Down
6 changes: 4 additions & 2 deletions apps/dumili/src/components/Entry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
}}</template></suggestion-list
><ai-tooltip
:id="`ai-results-entry-story-kind-${entry.id}`"
:value="storyKindAiSuggestion?.kind"
:disabled="!storyKindAiSuggestion"
:on-click-rerun="() => runKumiko(entry.id)"
@click="showAiDetectionsOn = entry.id"
@re-run="runKumiko(entry.id)"
>
<b>Inferred page story kinds</b>
<table-results
Expand All @@ -40,9 +41,10 @@
<StorySuggestionList v-model="entry" />
<ai-tooltip
:id="`ai-results-entry-story-${entry.id}`"
:value="storyAiSuggestions.map(({ storycode }) => storycode)"
:disabled="!storyAiSuggestions.length"
:on-click-rerun="() => runStorycodeOcr(entry.id)"
@click="showAiDetectionsOn = entry.id"
@re-run="runStorycodeOcr(entry.id)"
>
<template v-if="storyAiSuggestions.length">
OCR results:
Expand Down
Loading

0 comments on commit 7b79186

Please sign in to comment.