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

Sorting and filtering on cluster table #1413

Merged
merged 2 commits into from
Dec 8, 2023
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
123 changes: 123 additions & 0 deletions report-viewer/src/components/ComparisonTableFilter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<template>
<div class="space-y-2">
<div class="flex flex-row flex-wrap items-center gap-x-8 gap-y-2">
<h2>{{ header }}</h2>
<ToolTipComponent direction="bottom" class="min-w-[50%] flex-grow">
<template #default>
<SearchBarComponent placeholder="Filter/Unhide Comparisons" v-model="searchStringValue" />
</template>
<template #tooltip>
<p class="whitespace-pre text-sm">
Type in the name of a submission to only show comparisons that contain this submission.
</p>
<p class="whitespace-pre text-sm">Fully written out names get unhidden.</p>
</template>
</ToolTipComponent>

<ButtonComponent class="w-24" @click="changeAnonymousForAll()">
{{
store().state.anonymous.size == store().getSubmissionIds.length ? 'Show All' : 'Hide All'
}}
</ButtonComponent>
</div>
<OptionsSelector
title="Sort By:"
:defaultSelected="getSortingMetric()"
:labels="tableSortingOptions"
@selection-changed="(index: number) => changeSortingMetric(index)"
/>
</div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import SearchBarComponent from './SearchBarComponent.vue'
import ToolTipComponent from './ToolTipComponent.vue'
import ButtonComponent from './ButtonComponent.vue'
import OptionsSelector from './optionsSelectors/OptionsSelectorComponent.vue'
import { store } from '@/stores/store'
import { MetricType, metricToolTips } from '@/model/MetricType'
import type { ToolTipLabel } from '@/model/ui/ToolTip'

const props = defineProps({
searchString: {
type: String,
default: ''
},
enableClusterSorting: {
type: Boolean,
default: true
},
header: {
type: String,
default: 'Top Comparisons:'
}
})

const emit = defineEmits<{
(e: 'update:searchString', v: string): void
}>()

const searchStringValue = computed({
get: () => props.searchString,
set: (value) => {
emit('update:searchString', value)
// Update the anonymous set

const searches = value
.trimEnd()
.toLowerCase()
.split(/ +/g)
.map((s) => s.trim().replace(/,/g, ''))
if (searches.length == 0) {
return
}

for (const search of searches) {
for (const submissionId of store().getSubmissionIds) {
if (submissionId.toLowerCase() == search) {
store().state.anonymous.delete(submissionId)
}
}
}
}
})

function changeSortingMetric(index: number) {
store().uiState.comparisonTableSortingMetric =
index < tableSortingMetricOptions.length ? tableSortingMetricOptions[index] : MetricType.AVERAGE
store().uiState.comparisonTableClusterSorting = tableSortingOptions.value[index] == 'Cluster'
}

function getSortingMetric() {
if (store().uiState.comparisonTableClusterSorting && props.enableClusterSorting) {
return tableSortingOptions.value.indexOf('Cluster')
}
return tableSortingMetricOptions.indexOf(store().uiState.comparisonTableSortingMetric)
}

const tableSortingMetricOptions = [MetricType.AVERAGE, MetricType.MAXIMUM]
const tableSortingOptions = computed(() => {
const options: (ToolTipLabel | string)[] = tableSortingMetricOptions.map((metric) => {
return {
displayValue: metricToolTips[metric].longName,
tooltip: metricToolTips[metric].tooltip
}
})
if (props.enableClusterSorting) {
options.push('Cluster')
}
return options
})

/**
* Sets the anonymous set to empty if it is full or adds all submission ids to it if it is not full
*/
function changeAnonymousForAll() {
if (store().state.anonymous.size == store().getSubmissionIds.length) {
store().state.anonymous.clear()
} else {
store().state.anonymous = new Set(store().getSubmissionIds)
}
}
</script>
Loading
Loading