From 8b410932a3eec259749034749aea0ff2b446a636 Mon Sep 17 00:00:00 2001 From: Ahmed Awan Date: Thu, 7 Sep 2023 16:12:06 -0500 Subject: [PATCH] add url filter for `histories/list_published?f-username=xname` - also added the `user-eq` filter for exact match along with existing `user` (contains) filter --- .../History/HistoryPublishedList.vue | 24 ++++++++++++++----- client/src/entry/analysis/router.js | 6 ++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/client/src/components/History/HistoryPublishedList.vue b/client/src/components/History/HistoryPublishedList.vue index 02b165a05a62..16522e086504 100644 --- a/client/src/components/History/HistoryPublishedList.vue +++ b/client/src/components/History/HistoryPublishedList.vue @@ -7,7 +7,7 @@ import StatelessTags from "components/TagsMultiselect/StatelessTags"; import ScrollToTopButton from "components/ToolsList/ScrollToTopButton"; import UtcDate from "components/UtcDate"; import { useAnimationFrameScroll } from "composables/sensors/animationFrameScroll"; -import Filtering, { contains, expandNameTag } from "utils/filtering"; +import Filtering, { contains, equals, expandNameTag } from "utils/filtering"; import { computed, onMounted, onUnmounted, ref, watch } from "vue"; import { getPublishedHistories, updateTags } from "./services"; @@ -19,10 +19,19 @@ const validFilters = { annotation: contains("annotation"), tag: contains("tags", "tag", expandNameTag), user: contains("username"), + user_eq: equals("username"), }; const filters = new Filtering(validFilters, false); +const props = defineProps({ + fUsername: { + type: String, + required: false, + default: null, + }, +}); + const offset = ref({ "-update_time-true": 0 }); const allHistories = ref([]); const results = ref([]); @@ -91,12 +100,12 @@ const scrollToTop = () => { const sortAndFilterHistories = () => { allHistories.value = allHistories.value.sort((a, b) => { - const aVal = a[sortBy.value].trim(); - const bVal = b[sortBy.value].trim(); + const aVal = String(a[sortBy.value]).trim(); + const bVal = String(b[sortBy.value]).trim(); if (!sortDesc.value) { - return aVal.localeCompare(bVal); + return aVal - bVal; } else { - return bVal.localeCompare(aVal); + return bVal - aVal; } }); @@ -180,6 +189,9 @@ async function load() { } onMounted(async () => { + if (props.fUsername) { + filterText.value = filters.getFilterText({ "user_eq:": props.fUsername }); + } await load(); useInfiniteScroll(scrollableDiv.value, () => load()); }); @@ -309,7 +321,7 @@ watch([filterText, sortBy, sortDesc], async () => { {{ row.item.username }} diff --git a/client/src/entry/analysis/router.js b/client/src/entry/analysis/router.js index a45d8cd5768f..c0d6d8010bc6 100644 --- a/client/src/entry/analysis/router.js +++ b/client/src/entry/analysis/router.js @@ -266,7 +266,11 @@ export function getRouter(Galaxy) { { path: "histories/list_published", component: HistoryPublishedList, - props: true, + props: (route) => { + return { + ...route.query, + }; + }, }, { path: "histories/archived",