Skip to content

Commit

Permalink
feat: add file search
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin-Guillemin committed Jan 16, 2024
1 parent 8e0773a commit 312f7e3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/main/webapp/src/components/layouts/FilesLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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<File> | undefined;
Expand All @@ -27,7 +27,7 @@ setInterval(() => {
}, 10000);
const headers = ref<Array<any>>([
{ 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' },
]);
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions src/main/webapp/src/plugins/fontawsome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import {
faFolder,
faGear,
faGlobe,
faMagnifyingGlass,
faPlus,
faSave,
faShareNodes,
faSortDown,
faSortUp,
faStar,
faTimesCircle,
faTrash,
faXmark,
} from '@fortawesome/free-solid-svg-icons';
Expand All @@ -42,12 +44,14 @@ const register = (app: App): void => {
faFolder,
faGear,
faGlobe,
faMagnifyingGlass,
faPlus,
faSave,
faShareNodes,
faSortDown,
faSortUp,
faStar,
faTimesCircle,
faTrash,
faXmark,
);
Expand Down
4 changes: 4 additions & 0 deletions src/main/webapp/src/stores/configurationStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export const useConfigurationStore = defineStore('configuration', () => {

let lastUpdated = new Date();

const search = ref<string | undefined>();

const files = ref<Array<File> | undefined>();

const loadFiles = debounce(async (requestedFiles: Navigation | string): Promise<void> => {
Expand Down Expand Up @@ -98,6 +100,7 @@ export const useConfigurationStore = defineStore('configuration', () => {
const isNew = ref<boolean>(false);

const resetState = (): void => {
search.value = undefined;
currentFile.value = undefined;
isInfo.value = false;
isConfirmation.value = false;
Expand All @@ -116,6 +119,7 @@ export const useConfigurationStore = defineStore('configuration', () => {
isInit,
isSoffitOk,
lastNavigation,
search,
files,
loadFiles,
refresh,
Expand Down
25 changes: 23 additions & 2 deletions src/main/webapp/src/views/home/ProjectsView.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
<script setup lang="ts">
import { useConfigurationStore } from '@/stores/configurationStore.ts';
import { storeToRefs } from 'pinia';
import { useI18n } from 'vue-i18n';
import { useDisplay } from 'vuetify';
const { mobile } = useDisplay();
const configurationStore = useConfigurationStore();
const { isNew } = storeToRefs(configurationStore);
const { search, isNew } = storeToRefs(configurationStore);
const { t } = useI18n();
</script>

<template>
<div :class="[mobile ? 'mb-2' : 'mb-4']">
<div :class="['d-flex', 'align-center', ' justify-space-between', mobile ? 'mb-2' : 'mb-4']">
<v-btn icon="fas fa-plus" variant="tonal" @click="isNew = true" />
<v-text-field
v-model="search"
variant="solo"
density="compact"
rounded="xl"
prepend-inner-icon="fas fa-magnifying-glass"
flat
hide-details
single-line
clearable
:class="[mobile ? 'ml-2' : 'ml-4', 'max-width']"
/>
</div>
</template>

<style scoped lang="scss">
.max-width {
max-width: 300px;
}
</style>

0 comments on commit 312f7e3

Please sign in to comment.