Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: display more gt metadata in timeline view #79

Merged
merged 17 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/workflows/timeline/MetricAverageChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function tooltipContent(d: TimelineChartDataPoint) {
</script>

<template>
<div @click="op?.toggle($event)" class="cursor-pointer flex justify-end">
<div @click="op?.toggle($event)" class="cursor-pointer flex">
<BaseTimelineChart
:data="data"
:max-y="maxY"
Expand Down
33 changes: 26 additions & 7 deletions src/components/workflows/timeline/TimelineItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { Icon } from '@iconify/vue'
import { onMounted, nextTick, ref } from "vue"
import { OverlayPanelDropdownStyles } from "@/helpers/pt"
import workflowsStore from "@/store/workflows-store"
import TimelineItemMetadata from "@/components/workflows/timeline/TimelineItemMetadata.vue"


const props = defineProps<{
gt: GroundTruth,
Expand All @@ -22,6 +24,7 @@ const startDate = ref<Date>(new Date('2023-10-01'))
const endDate = ref<Date>(new Date())
const workflows = ref<Workflow[]>([])


onMounted(() => {
workflows.value = workflowsStore.workflows
})
Expand Down Expand Up @@ -52,6 +55,7 @@ function toggleParameterOverlay(step: WorkflowStep, event: Event) {
}
}


</script>

<template>
Expand All @@ -69,10 +73,24 @@ function toggleParameterOverlay(step: WorkflowStep, event: Event) {
}"
>
<template v-slot:header>
<div class="flex w-full px-4 pb-2">
<h2 class="w-1/2 text-xl font-bold flex-shrink-0 truncate" :title="gt.label">{{ gt.label }}</h2>
<div class="w-1/2 flex justify-end">
<div class="flex overflow-x-auto">
<div class="flex flex-col px-4 pb-2">
<div class="flex items-center overflow-hidden">
<h2 class="text-xl font-bold truncate mr-8" :title="gt.label">{{ gt.label }}</h2>
<a :href="gt.metadata.url" class="text-gray-500 hover:text-gray-600 flex-shrink-0 ml-auto mr-2 flex items-center bg-gray-100 rounded-full py-1 px-2">
<Icon icon="mdi:github" class="text-xl mr-1"/>
<span class="text-xs">{{ gt.metadata.title }}</span>
</a>
<a :href="gt.metadata.license[0].url" class="text-gray-500 hover:text-gray-600 flex-shrink-0 flex items-center bg-gray-100 rounded-full py-1 px-2">
<Icon icon="octicon:law" class="text-xl mr-1"/>
<span class="text-xs">{{ gt.metadata.license[0].name }}</span>
</a>
</div>
<div class="flex mt-6 md:flex-row flex-col">
<div class="md:w-1/2 mb-5 md:mb-0">
<TimelineItemMetadata :gtMetadata="gt.metadata"/>
</div>
<div class="md:w-1/2 flex flex-col overflow-x-auto md:items-end">
<h3 class="font-bold pr-[240px] mb-2">{{$t('average_timeline')}}</h3>
<MetricAverageChart
:workflow-name="$t('average')"
:gt-name="gt.label"
Expand All @@ -82,9 +100,10 @@ function toggleParameterOverlay(step: WorkflowStep, event: Event) {
:width="400"
:start-date="startDate"
:end-date="endDate"
/>
/>
</div>
</div>

</div>
</template>
<template v-slot:default>
Expand All @@ -104,7 +123,7 @@ function toggleParameterOverlay(step: WorkflowStep, event: Event) {
<span
v-for="step in workflow.steps"
:key="step.id"
class="p-1 cursor-pointer"
class="p-1 cursor-pointer text-highlight"
@click="toggleParameterOverlay(step, $event)"
>
{{ getStepAcronym(step.id) }}
Expand Down Expand Up @@ -156,7 +175,7 @@ function toggleParameterOverlay(step: WorkflowStep, event: Event) {
</template>

<style scoped lang="scss">
span:hover {
.text-highlight:hover {
color: var(--highlight-text-color);
}
</style>
107 changes: 107 additions & 0 deletions src/components/workflows/timeline/TimelineItemMetadata.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<script setup lang="ts">
import OverlayPanel from "primevue/overlaypanel"
import Button from "primevue/button"
import { Icon } from "@iconify/vue"
import { OverlayPanelDropdownStyles } from "@/helpers/pt"
import { ref } from "vue"
import type { GroundTruth } from "@/types"
import { useI18n } from "vue-i18n"

const { t } = useI18n()

const props = defineProps<{
gtMetadata: GroundTruth["metadata"]
}>()

const opLabelling = ref()
const opVolume = ref()
const volumeMetadata = {
label: t('volume'),
data: Array.isArray(props.gtMetadata.volume) ? props.gtMetadata.volume.reduce((acc, curr) => ({ ...acc, [curr.metric]: curr.count }), {}) : props.gtMetadata.volume,
}

const metadata = [
{
label: t('language', props.gtMetadata.language.length),
data: props.gtMetadata.language,
isArray: true,
},
{
label: t('script', props.gtMetadata.script.length),
data: props.gtMetadata.script,
isArray: true,
},
{
label: t('script-type'),
data: props.gtMetadata["script-type"],
},
]

function toggleOpLabelling(event: any) {
opLabelling.value?.toggle(event)
}

function toggleOpVolume(event: any) {
opVolume.value?.toggle(event)
}

</script>
<template>
<div class="flex flex-wrap md:grid md:grid-cols-3 md:space-x-0 md:gap-2 lg:flex lg:space-x-5 lg:flex-nowrap items-start text-sm text-slate-700">
<div v-for="meta in metadata" :key="meta.label" class="mr-5 mb-5 md:mr-0 md:mb-0">
<div class="flex flex-col">
<span class="font-medium">{{ meta.label }}:</span>
<span v-if="meta.isArray">{{ meta.data?.join(', ') }}</span>
<span v-else>{{ meta.data }}</span>
</div>
</div>
<Button @click="toggleOpLabelling"
unstyled
:pt="{
root: 'text-sm mr-5 md:mr-0 flex items-center bg-gray-100 text-slate-700 p-2 hover:bg-gray-200 rounded hover:text-black focus:outline-none'
}">
<span>{{ $t('labelling') }}</span>
<Icon v-if="opLabelling?.visible" icon="ic:baseline-close-fullscreen" class="ml-2"></Icon>
<Icon v-else icon="ic:baseline-open-in-full" class="ml-2"></Icon>
</Button>

<Button @click="toggleOpVolume"
unstyled
:pt="{ root: 'text-sm flex items-center bg-gray-100 text-slate-700 p-2 hover:bg-gray-200 rounded hover:text-black focus:outline-none'}"
>
<span>{{ $t('volume') }}</span>
<Icon v-if="opVolume?.visible" icon="ic:baseline-close-fullscreen" class="ml-2"></Icon>
<Icon v-else icon="ic:baseline-open-in-full" class="ml-2"></Icon>
</Button>
</div>

<OverlayPanel ref="opLabelling" unstyled :pt="OverlayPanelDropdownStyles">
<template #container>
<div v-if="gtMetadata.labelling?.length > 0" class="flex flex-col py-1 space-y-1 overflow-y-scroll max-w-[80vw] sm:max-w-[90vw] max-h-[300px]">
<span v-for="label in gtMetadata.labelling.slice(0).sort()" :key="label" class="hover:bg-gray-200 rounded px-2 text-sm">
{{ label }}
</span>
</div>
<div v-else class="py-1 px-2">
<span>{{ $t('no_labels_for_this_entry') }}</span>
</div>
</template>
</OverlayPanel>
<OverlayPanel ref="opVolume" unstyled :pt="OverlayPanelDropdownStyles">
<template #container>
<div class="flex space-x-2 p-4">
<div v-for="(value, key) in volumeMetadata.data" :key="key">
<div class="border-b-2 border-gray-300">{{ key }}</div>
<div>{{ value }}</div>
</div>
</div>

</template>
</OverlayPanel>
</template>

<style scoped lang="scss">
.text-highlight:hover {
color: var(--highlight-text-color);
}
</style>
11 changes: 10 additions & 1 deletion src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,14 @@
"workflows_intro_gt_guidelines": "Die OCR-D Ground Truth Richtlinien können unter {gt_guidelines_link} abgerufen werden.",
"gt_guidelines_link": "https://ocr-d.de/de/gt-guidelines/trans/",
"no_documents_selected": "Es sind keine Dokumente (Ground Truth) ausgewählt. Bitte wählen Sie alle oder spezifische Ground Truths aus.",
"error_please_try_again_later": "Es ist ein Fehler aufgetreten. Bitte versuchen Sie es später erneut!"
"error_please_try_again_later": "Es ist ein Fehler aufgetreten. Bitte versuchen Sie es später erneut!",
"url": "URL",
"language": "Sprache | Sprachen",
"script": "Skript | Skripte",
"scripttype": "Skript-Typ",
"license": "Lizenz | Lizenzen",
"volume": "Umfang",
"labelling": "Kennzeichnung",
"no_labels_for_this_entry": "Keine Kennzeichnung für diesen Eintrag.",
"average_timeline": "Chronik (Durchschnitt)"
}
12 changes: 11 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,15 @@
"workflows_intro_gt_guidelines": "The OCR-D Ground Truth Guidelines can be found under {gt_guidelines_link}.",
"gt_guidelines_link": "https://ocr-d.de/en/gt-guidelines/trans/",
"no_documents_selected": "No documents (Ground Truth) are selected. Please select all or specific ground truths.",
"error_please_try_again_later": "An error has occurred. Please try again later!"
"error_please_try_again_later": "An error has occurred. Please try again later!",
"url": "URL",
"language": "Language | Languages",
"script": "Script | Scripts",
"script-type": "Script-Type",
"license": "License | Licenses",
"volume": "Volume",
"labelling": "Labelling",
"no_labels_for_this_entry": "No labels for this entry.",
"average_timeline": "Average Timeline"

}
27 changes: 26 additions & 1 deletion src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
export interface GroundTruth {
id: string,
label: string
label: string,
metadata: {
title: string,
url: string,
language: string[],
script: string[],
'script-type': string,
license: {
name: string,
url: string,
}[],
volume: {
TxtRegion?: string,
GraphRegion?: string,
SepRegion?: string,
MusicRegion?: string,
NoiseRegion?: string,
TextLine?: string,
Page?: string,
} |
{
metric: string,
count: number,
}[]
labelling: string[],
}
}

export interface Workflow {
Expand Down
Loading