From 312f7e36297cf54bc92d342d781296f9a0ded972 Mon Sep 17 00:00:00 2001 From: Quentin Guillemin Date: Tue, 16 Jan 2024 18:02:57 +0100 Subject: [PATCH] feat: add file search --- .../src/components/layouts/FilesLayout.vue | 6 +++-- src/main/webapp/src/plugins/fontawsome.ts | 4 +++ .../webapp/src/stores/configurationStore.ts | 4 +++ .../webapp/src/views/home/ProjectsView.vue | 25 +++++++++++++++++-- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/main/webapp/src/components/layouts/FilesLayout.vue b/src/main/webapp/src/components/layouts/FilesLayout.vue index 55fcc8e3..066cb6ab 100644 --- a/src/main/webapp/src/components/layouts/FilesLayout.vue +++ b/src/main/webapp/src/components/layouts/FilesLayout.vue @@ -14,7 +14,7 @@ const { xs } = useDisplay(); const configurationStore = useConfigurationStore(); const { loadFile } = configurationStore; -const { isGrid } = storeToRefs(configurationStore); +const { search, isGrid } = storeToRefs(configurationStore); defineProps<{ files: Array | undefined; @@ -27,7 +27,7 @@ setInterval(() => { }, 10000); const headers = ref>([ - { title: t('information.title'), value: 'title', sortable: true, width: '100%' }, + { title: t('information.title'), key: 'title', sortable: true, width: '100%' }, { title: '', key: 'actions', sortable: false, align: 'end' }, ]); @@ -65,6 +65,8 @@ watch( :headers="headers" :items="files" :sort-by="[{ key: 'title', order: 'asc' }]" + :search="search" + filter-keys="title" :loading="files == undefined" :items-per-page="-1" sort-asc-icon="fas fa-sort-up" diff --git a/src/main/webapp/src/plugins/fontawsome.ts b/src/main/webapp/src/plugins/fontawsome.ts index a73d60ad..4b6adaa9 100644 --- a/src/main/webapp/src/plugins/fontawsome.ts +++ b/src/main/webapp/src/plugins/fontawsome.ts @@ -14,12 +14,14 @@ import { faFolder, faGear, faGlobe, + faMagnifyingGlass, faPlus, faSave, faShareNodes, faSortDown, faSortUp, faStar, + faTimesCircle, faTrash, faXmark, } from '@fortawesome/free-solid-svg-icons'; @@ -42,12 +44,14 @@ const register = (app: App): void => { faFolder, faGear, faGlobe, + faMagnifyingGlass, faPlus, faSave, faShareNodes, faSortDown, faSortUp, faStar, + faTimesCircle, faTrash, faXmark, ); diff --git a/src/main/webapp/src/stores/configurationStore.ts b/src/main/webapp/src/stores/configurationStore.ts index 604f88c1..1d506424 100644 --- a/src/main/webapp/src/stores/configurationStore.ts +++ b/src/main/webapp/src/stores/configurationStore.ts @@ -39,6 +39,8 @@ export const useConfigurationStore = defineStore('configuration', () => { let lastUpdated = new Date(); + const search = ref(); + const files = ref | undefined>(); const loadFiles = debounce(async (requestedFiles: Navigation | string): Promise => { @@ -98,6 +100,7 @@ export const useConfigurationStore = defineStore('configuration', () => { const isNew = ref(false); const resetState = (): void => { + search.value = undefined; currentFile.value = undefined; isInfo.value = false; isConfirmation.value = false; @@ -116,6 +119,7 @@ export const useConfigurationStore = defineStore('configuration', () => { isInit, isSoffitOk, lastNavigation, + search, files, loadFiles, refresh, diff --git a/src/main/webapp/src/views/home/ProjectsView.vue b/src/main/webapp/src/views/home/ProjectsView.vue index 3f2a3f49..e701c56e 100644 --- a/src/main/webapp/src/views/home/ProjectsView.vue +++ b/src/main/webapp/src/views/home/ProjectsView.vue @@ -1,16 +1,37 @@ + +