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: add filters for gt labelling and gt script-type #88

Merged
merged 30 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d75253a
feat: filter by workflow and processor
Feb 1, 2024
26699d2
feat: filter by date range
Feb 6, 2024
78b3830
feat: implement multi-selectable workflow steps filtering
Feb 27, 2024
f4b6adb
fix: make only related workflows visible while filtering by processors
Mar 18, 2024
3387ceb
fix: set all checkboxes of processor filter to selected on page load
Apr 17, 2024
cedbc59
ref: highlight selected processors
noornoorie May 21, 2024
2379399
fix: refactor to own component and prepare visual filtering
Jun 21, 2024
191f8d9
Merge remote-tracking branch 'origin/master' into workflow-processor-…
Jun 21, 2024
ee81e7f
fix: show filter also when no data is selected
Jun 21, 2024
d0c7689
fix: workflow filter label
Jun 21, 2024
040a8e8
feat: hide workflow when neither workflow or processor in workflow ar…
Jun 21, 2024
ea3cbea
refactor: remove unused imports/vars, style
Jun 21, 2024
00336ce
fix: remove search from workflow filter
Jun 21, 2024
11afc47
feat: change date range dropdown to multiselect
Jun 21, 2024
b6ff953
refactor: change order
Jun 21, 2024
d138ebc
feat: add i18n translations
Jun 21, 2024
db665ab
fix: adjust filter position for smaller screens
Jun 21, 2024
4687958
fix: changed faulty imported that failed build
Jun 21, 2024
73c0cac
wip: add label filter
Jun 25, 2024
ae905c7
wip: added label and script-type filter
Jun 25, 2024
8b3539b
fix: adjust styling for all screen sizes
Jun 25, 2024
9be2ba8
style: clearer indentation
Jun 28, 2024
bd67414
Merge remote-tracking branch 'origin/master' into gt-filtering
Jun 28, 2024
07a1b35
fix: readd missing comparision
Jun 28, 2024
0468788
style: break filter condition into multiple lines
Jul 5, 2024
b4f790d
docs: add comment explaining the computed ref labellingOptions
Jul 5, 2024
9639690
feat: add select all label; refactor to own component
Jul 12, 2024
f660f0a
fix: make color of select all variable
Jul 19, 2024
d48d1cf
Merge remote-tracking branch 'origin/master' into gt-filtering
Jul 23, 2024
74f3d88
Merge remote-tracking branch 'origin/master' into gt-filtering
Jul 26, 2024
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
89 changes: 82 additions & 7 deletions src/components/workflows/timeline/TimelineFilters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,43 @@ const selectedWorkflows = ref<DropdownOption[]>([])
const workflowStepOptions = ref<DropdownOption[]>([])
const selectedWorkflowSteps = ref<DropdownOption[]>([])

const labellingOptions = computed(() => {
return [
...new Set(workflowsStore.gt.map(gt =>
t11r marked this conversation as resolved.
Show resolved Hide resolved
Array.isArray(gt.metadata.labelling) && gt.metadata.labelling.length > 0 ? gt.metadata.labelling : [t('no_labelling')]
).flat(1)
)
]
.sort()
.map(value => ({ value, label: value }))
})
const selectedLabelling = ref<DropdownOption[]>([])

const scriptTypeOptions = computed(() => {
return [
...new Set(workflowsStore.gt.map(gt =>
gt.metadata["script-type"]
))
]
.sort()
.map(value => ({ value, label: value }))
})
const selectedScriptTypes = ref<DropdownOption[]>([])

const labellingDropdownLabel = computed(() => {
if (labellingOptions.value.length === selectedLabelling.value.length) {
return t('filter_by_labelling')
}
return null
})

const scriptTypeDropdownLabel = computed(() => {
if (scriptTypeOptions.value.length === selectedScriptTypes.value.length) {
return t('filter_by_script_type')
}
return null
})

const dateRangeDropdownLabel = computed(() => {
if (dateRangeOptions.value.length === selectedDateRange.value.length) {
return t('filter_by_date_range')
Expand All @@ -46,6 +83,16 @@ const workflowStepDropdownLabel = computed(() => {
return null
})

const onLabellingChange = (event: any) => {
selectedLabelling.value = event
selectGTs()
}

const onScriptTypeChange = (event: any) => {
selectedScriptTypes.value = event
selectGTs()
}

const onDateRangeChange = (event: any) => {
selectedDateRange.value = event
selectGTs()
Expand All @@ -67,13 +114,23 @@ const selectGTs = () => {
filtersStore.gtTimeline = filtersStore.gt.filter(({ value }) => {
const gt = workflowsStore.getGtById(value)
if(!gt) return false
return hasSomeSelectedProcessor(gt) && hasSomeSelectedDateRange(gt) && hasSomeSelectedWorkflow(gt)
return hasSomeSelectedLabelling(gt) && hasSomeSelectedScriptType(gt) && hasSomeSelectedProcessor(gt) && hasSomeSelectedDateRange(gt) && hasSomeSelectedWorkflow(gt)
t11r marked this conversation as resolved.
Show resolved Hide resolved
})
}

const selectWorkflows = () => {
filtersStore.workflow = selectedWorkflows.value.filter(({ value }) => (workflowhasSomeSelectedWorkflowStep(value)))
}
const hasSomeSelectedLabelling = (gt: GroundTruth) => {
return selectedLabelling.value.some(({ value }) => {
if(!Array.isArray(gt.metadata.labelling) || gt.metadata.labelling.length <= 0) return value === t('no_labelling')
return gt.metadata.labelling?.some(labelling => labelling === value)
})
}

const hasSomeSelectedScriptType = (gt: GroundTruth) => {
return selectedScriptTypes.value.some(({ value }) => value === gt.metadata["script-type"])
}

const hasSomeSelectedProcessor = (gt: GroundTruth) => {
const gtRuns = workflowsStore.getRuns(gt.id)
Expand All @@ -96,7 +153,7 @@ const hasSomeSelectedDateRange = (gt: GroundTruth) => {
const hasSomeSelectedWorkflow = (gt: GroundTruth) => {
const gtRuns = workflowsStore.getRuns(gt.id)
return gtRuns.some((gtRun) => {
return selectedWorkflows.value.findIndex(({ value }) => (value === mapGtId(gtRun.metadata.ocr_workflow.id))) > -1
return selectedWorkflows.value.findIndex(({ value }) => (value === mapGtId(gtRun.metadata.ocr_workflow.id))) > -1
})
}

Expand All @@ -116,14 +173,35 @@ onMounted(() => {
selectedDateRange.value = dateRangeOptions.value
selectedWorkflows.value = workflowOptions.value
selectedWorkflowSteps.value = workflowStepOptions.value

selectedLabelling.value = labellingOptions.value
selectedScriptTypes.value = scriptTypeOptions.value

selectGTs()
selectWorkflows()
})
</script>

<template>
<div class="flex flex-wrap mb-4 justify-start lg:justify-end">
<div class="pb-4 lg:pb-6 grid sm:grid-cols-2 gap-4 xl:grid-cols-5 xl:gap-8">
<MultiSelect
v-model="selectedLabelling"
@update:model-value="onLabellingChange($event)"
filter
:max-selected-labels="0"
:options="labellingOptions"
option-label="label"
:placeholder="t('select_a_label')"
:selected-items-label="labellingDropdownLabel"
/>
<MultiSelect
v-model="selectedScriptTypes"
@update:model-value="onScriptTypeChange($event)"
:max-selected-labels="0"
:options="scriptTypeOptions"
option-label="label"
:placeholder="t('select_a_script_type')"
:selected-items-label="scriptTypeDropdownLabel"
/>
<MultiSelect
v-model="selectedDateRange"
@update:model-value="onDateRangeChange($event)"
Expand All @@ -132,7 +210,6 @@ onMounted(() => {
optionLabel="label"
:placeholder="t('select_a_date_range')"
:selected-items-label="dateRangeDropdownLabel"
class="mr-4 mb-2 lg:m-0 lg:ml-auto md:w-14rem"
/>
<MultiSelect
v-model="selectedWorkflows"
Expand All @@ -142,7 +219,6 @@ onMounted(() => {
optionLabel="label"
:placeholder="t('select_a_workflow')"
:selected-items-label="workflowDropdownLabel"
class="mr-4 mb-2 lg:m-0 lg:ml-4 md:w-14rem"
/>
<MultiSelect
v-model="selectedWorkflowSteps"
Expand All @@ -153,7 +229,6 @@ onMounted(() => {
optionLabel="label"
:placeholder="t('select_a_processor')"
:selected-items-label="workflowStepDropdownLabel"
class="lg:ml-4 md:w-14rem"
/>
</div>

Expand Down
7 changes: 6 additions & 1 deletion src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@
"filter_by_date_range": "Nach Zeitspanne filtern",
"filter_by_workflow": "Nach Workflow filtern",
"filter_by_processor": "Nach Prozessor filtern",
"filter_by_labelling": "Nach Kennzeichnungen filtern",
"filter_by_script_type": "Nach Skript-Typ filtern",
"select_a_date_range": "Zeitraum auswählen",
"select_a_workflow": "Workflow auswählen",
"select_a_processor": "Prozessor auswählen"
"select_a_processor": "Prozessor auswählen",
"select_a_label": "Kennzeichnung auswählen",
"select_a_script_type": "Skript-Typ auswählen",
"no_labelling": "Keine Kennzeichnung"
}
7 changes: 6 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@
"filter_by_date_range": "Filter by date range",
"filter_by_workflow": "Filter by workflow",
"filter_by_processor": "Filter by processor",
"filter_by_labelling": "Filter by labelling",
"filter_by_script_type": "Filter by script-type",
"select_a_date_range": "Select a date range",
"select_a_workflow": "Select a workflow",
"select_a_processor": "Select a processor"
"select_a_processor": "Select a processor",
"select_a_label": "Select a label",
"select_a_script_type": "Select a script-type",
"no_labelling": "No labelling"
}
2 changes: 1 addition & 1 deletion src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface GroundTruthMetadata {
count: string,
level: string
},
labelling: string[],
labelling?: string[],
language: string[],
license: {
name: string,
Expand Down
Loading