diff --git a/src/main/webapp/src/App.vue b/src/main/webapp/src/App.vue
index bb21e80c..d5c923c6 100644
--- a/src/main/webapp/src/App.vue
+++ b/src/main/webapp/src/App.vue
@@ -12,13 +12,15 @@ import { useRouter } from 'vue-router';
import { useTheme } from 'vuetify';
const configurationStore = useConfigurationStore();
-const { resetState } = configurationStore;
-const { selectedFile, isSelectedFile, isConfirmation } = storeToRefs(configurationStore);
+const { refresh, resetState } = configurationStore;
+const { lastNavigation, selectedFile, isSelectedFile, isConfirmation } = storeToRefs(configurationStore);
const router = useRouter();
-router.beforeEach(() => {
+router.beforeEach((to) => {
resetState();
+ if (to.name != undefined && to.name != null) lastNavigation.value = to.name as string;
+ refresh(true, true);
});
const theme = useTheme();
@@ -52,6 +54,7 @@ const deleteItem = async (result: Response) => {
if (result == Response.yes && isSelectedFile.value) {
try {
await deleteFile(selectedFile.value!);
+ refresh(true);
} catch (e) {
errorHandler(e);
}
diff --git a/src/main/webapp/src/components/BottomNavigation.vue b/src/main/webapp/src/components/BottomNavigation.vue
index 8d2856a5..eb8065c8 100644
--- a/src/main/webapp/src/components/BottomNavigation.vue
+++ b/src/main/webapp/src/components/BottomNavigation.vue
@@ -1,26 +1,30 @@
-
+
{{ t('navigation.item.projects') }}
-
+
{{ t('navigation.item.favorites') }}
-
+
{{ t('navigation.item.shared') }}
-
+
{{ t('navigation.item.public') }}
diff --git a/src/main/webapp/src/components/drawers/NavigationDrawer.vue b/src/main/webapp/src/components/drawers/NavigationDrawer.vue
index 193e246d..b5770ccc 100644
--- a/src/main/webapp/src/components/drawers/NavigationDrawer.vue
+++ b/src/main/webapp/src/components/drawers/NavigationDrawer.vue
@@ -4,6 +4,7 @@ import { storeToRefs } from 'pinia';
import { useI18n } from 'vue-i18n';
const configurationStore = useConfigurationStore();
+const { refresh } = configurationStore;
const { isSettings } = storeToRefs(configurationStore);
const { t } = useI18n();
@@ -20,6 +21,7 @@ const { t } = useI18n();
:to="{ name: 'projects' }"
rounded="xl"
class="mb-2"
+ @click="refresh"
/>
diff --git a/src/main/webapp/src/components/layouts/FilesLayout.vue b/src/main/webapp/src/components/layouts/FilesLayout.vue
index cda57448..ae194f8b 100644
--- a/src/main/webapp/src/components/layouts/FilesLayout.vue
+++ b/src/main/webapp/src/components/layouts/FilesLayout.vue
@@ -3,7 +3,6 @@ import FileCard from '@/components/FileCard.vue';
defineProps<{
files: Array | undefined;
- list?: boolean;
}>();
diff --git a/src/main/webapp/src/router/index.ts b/src/main/webapp/src/router/index.ts
index 2803a433..d1ee7e77 100644
--- a/src/main/webapp/src/router/index.ts
+++ b/src/main/webapp/src/router/index.ts
@@ -1,3 +1,4 @@
+import { Navigation } from '@/types/enums/Navigation';
import { createRouter, createWebHistory } from 'vue-router';
const router = createRouter({
@@ -9,23 +10,23 @@ const router = createRouter({
component: () => import('@/views/HomeView.vue'),
children: [
{
- path: 'projects',
- name: 'projects',
+ path: Navigation.projects,
+ name: Navigation.projects,
component: () => import('@/views/home/ProjectsView.vue'),
},
{
- path: 'favorites',
- name: 'favorites',
+ path: Navigation.favorites,
+ name: Navigation.favorites,
component: () => import('@/views/home/FavoritesView.vue'),
},
{
- path: 'shared',
- name: 'shared',
+ path: Navigation.shared,
+ name: Navigation.shared,
component: () => import('@/views/home/SharedView.vue'),
},
{
- path: 'public',
- name: 'public',
+ path: Navigation.public,
+ name: Navigation.public,
component: () => import('@/views/home/PublicView.vue'),
},
],
diff --git a/src/main/webapp/src/stores/configurationStore.ts b/src/main/webapp/src/stores/configurationStore.ts
index 11a73554..2778166a 100644
--- a/src/main/webapp/src/stores/configurationStore.ts
+++ b/src/main/webapp/src/stores/configurationStore.ts
@@ -1,6 +1,10 @@
import { getConfiguration } from '@/services/configurationService';
+import { getFiles, getPublic, getShared, getStarred } from '@/services/fileService';
import type { Configuration } from '@/types/configurationType';
+import { Navigation } from '@/types/enums/Navigation';
import { errorHandler } from '@/utils/axiosUtils';
+import { differenceInMilliseconds } from 'date-fns';
+import debounce from 'lodash.debounce';
import { defineStore } from 'pinia';
import { computed, ref } from 'vue';
@@ -23,8 +27,52 @@ export const useConfigurationStore = defineStore('configuration', () => {
const isInit = computed(() => configuration.value != undefined);
+ /* -- Gestion de la navigation -- */
+
+ const lastNavigation = ref();
+
/* -- Gestion des fichier -- */
+ let lastUpdated = new Date();
+
+ const files = ref | undefined>();
+
+ const loadFiles = async (requestedFiles: Navigation | string) => {
+ try {
+ let response;
+ switch (requestedFiles) {
+ case Navigation.projects:
+ response = await getFiles();
+ break;
+ case Navigation.favorites:
+ response = await getStarred();
+ break;
+ case Navigation.shared:
+ response = await getShared();
+ break;
+ case Navigation.public:
+ response = await getPublic();
+ break;
+ }
+ files.value = response.data;
+ } catch (e) {
+ errorHandler(e);
+ }
+ };
+
+ const refresh = (instant?: boolean, loading?: boolean) => {
+ if (instant || differenceInMilliseconds(new Date(), lastUpdated) > 5000) {
+ if (loading) files.value = undefined;
+ const launch = debounce(() => {
+ if (lastNavigation.value != undefined) {
+ loadFiles(lastNavigation.value);
+ lastUpdated = new Date();
+ }
+ }, 200);
+ launch();
+ }
+ };
+
const selectedFile = ref();
const isSelectedFile = computed(() => selectedFile.value != undefined);
const isShare = ref(false);
@@ -45,6 +93,10 @@ export const useConfigurationStore = defineStore('configuration', () => {
return {
init,
isInit,
+ lastNavigation,
+ files,
+ loadFiles,
+ refresh,
selectedFile,
isSelectedFile,
isShare,
diff --git a/src/main/webapp/src/types/enums/Navigation.ts b/src/main/webapp/src/types/enums/Navigation.ts
new file mode 100644
index 00000000..5b7bfe35
--- /dev/null
+++ b/src/main/webapp/src/types/enums/Navigation.ts
@@ -0,0 +1,6 @@
+export enum Navigation {
+ projects = 'projects',
+ favorites = 'favorites',
+ shared = 'shared',
+ public = 'public',
+}
diff --git a/src/main/webapp/src/views/home/FavoritesView.vue b/src/main/webapp/src/views/home/FavoritesView.vue
index 5e73c81a..1b1b1f4e 100644
--- a/src/main/webapp/src/views/home/FavoritesView.vue
+++ b/src/main/webapp/src/views/home/FavoritesView.vue
@@ -1,16 +1,10 @@
diff --git a/src/main/webapp/src/views/home/ProjectsView.vue b/src/main/webapp/src/views/home/ProjectsView.vue
index 21f97624..1b1b1f4e 100644
--- a/src/main/webapp/src/views/home/ProjectsView.vue
+++ b/src/main/webapp/src/views/home/ProjectsView.vue
@@ -1,16 +1,10 @@
diff --git a/src/main/webapp/src/views/home/PublicView.vue b/src/main/webapp/src/views/home/PublicView.vue
index 2772eb3a..1b1b1f4e 100644
--- a/src/main/webapp/src/views/home/PublicView.vue
+++ b/src/main/webapp/src/views/home/PublicView.vue
@@ -1,16 +1,10 @@
diff --git a/src/main/webapp/src/views/home/SharedView.vue b/src/main/webapp/src/views/home/SharedView.vue
index 48bfcdc0..1b1b1f4e 100644
--- a/src/main/webapp/src/views/home/SharedView.vue
+++ b/src/main/webapp/src/views/home/SharedView.vue
@@ -1,16 +1,10 @@