web/satellite: fix object browser pagination for the folders
Fix pagination for the folders which are not on the first page. Also, fixed object count calculation inside folders. Issue: https://github.com/storj/customer-issues/issues/1055 Change-Id: I1d0fbb8856f13be6fb20698315a7e4d20b4affd9
This commit is contained in:
parent
e1215d5da8
commit
63645205c0
@ -114,6 +114,7 @@
|
|||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
class="file-browser-table"
|
class="file-browser-table"
|
||||||
:on-page-change="isPaginationEnabled ? changePageAndLimit : null"
|
:on-page-change="isPaginationEnabled ? changePageAndLimit : null"
|
||||||
|
:page-number="cursor.page"
|
||||||
@selectAllClicked="toggleSelectAllFiles"
|
@selectAllClicked="toggleSelectAllFiles"
|
||||||
>
|
>
|
||||||
<template #head>
|
<template #head>
|
||||||
@ -272,6 +273,7 @@ const isOver = ref<boolean>(false);
|
|||||||
const routePath = ref(calculateRoutePath());
|
const routePath = ref(calculateRoutePath());
|
||||||
|
|
||||||
const NUMBER_OF_DISPLAYED_OBJECTS = 1000;
|
const NUMBER_OF_DISPLAYED_OBJECTS = 1000;
|
||||||
|
const routePageCache = new Map<string, number>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates page count depending on object count and page limit.
|
* Calculates page count depending on object count and page limit.
|
||||||
@ -440,7 +442,8 @@ const bucket = computed((): string => {
|
|||||||
/**
|
/**
|
||||||
* Changes table page and limit.
|
* Changes table page and limit.
|
||||||
*/
|
*/
|
||||||
async function changePageAndLimit(page: number, limit: number): void {
|
async function changePageAndLimit(page: number, limit: number): Promise<void> {
|
||||||
|
routePageCache.set(routePath.value, page);
|
||||||
obStore.setCursor({ limit, page });
|
obStore.setCursor({ limit, page });
|
||||||
|
|
||||||
const lastObjectOnPage = page * limit;
|
const lastObjectOnPage = page * limit;
|
||||||
@ -501,6 +504,15 @@ async function onRouteChange(): Promise<void> {
|
|||||||
await list(routePath.value);
|
await list(routePath.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (isPaginationEnabled.value) {
|
||||||
|
const cachedPage = routePageCache.get(routePath.value);
|
||||||
|
if (cachedPage !== undefined) {
|
||||||
|
obStore.setCursor({ limit: cursor.value.limit, page: cachedPage });
|
||||||
|
} else {
|
||||||
|
obStore.setCursor({ limit: cursor.value.limit, page: 1 });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,7 +87,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
|
|
||||||
import { PageChangeCallback } from '@/types/pagination';
|
import { PageChangeCallback } from '@/types/pagination';
|
||||||
import { useLoading } from '@/composables/useLoading';
|
import { useLoading } from '@/composables/useLoading';
|
||||||
@ -114,6 +114,7 @@ const props = withDefaults(defineProps<{
|
|||||||
onNextClicked?: (() => Promise<void>) | null;
|
onNextClicked?: (() => Promise<void>) | null;
|
||||||
onPreviousClicked?: (() => Promise<void>) | null;
|
onPreviousClicked?: (() => Promise<void>) | null;
|
||||||
onPageSizeChanged?: ((size: number) => Promise<void> | void) | null;
|
onPageSizeChanged?: ((size: number) => Promise<void> | void) | null;
|
||||||
|
pageNumber?: number;
|
||||||
}>(), {
|
}>(), {
|
||||||
itemsLabel: 'items',
|
itemsLabel: 'items',
|
||||||
totalPageCount: 0,
|
totalPageCount: 0,
|
||||||
@ -124,6 +125,7 @@ const props = withDefaults(defineProps<{
|
|||||||
onNextClicked: null,
|
onNextClicked: null,
|
||||||
onPreviousClicked: null,
|
onPreviousClicked: null,
|
||||||
onPageSizeChanged: null,
|
onPageSizeChanged: null,
|
||||||
|
pageNumber: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
const currentPageNumber = ref<number>(1);
|
const currentPageNumber = ref<number>(1);
|
||||||
@ -260,6 +262,10 @@ async function prevPage(): Promise<void> {
|
|||||||
currentPageNumber.value--;
|
currentPageNumber.value--;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(() => props.pageNumber, () => {
|
||||||
|
goToPage(props.pageNumber);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
:on-page-change="onPageChange"
|
:on-page-change="onPageChange"
|
||||||
:on-next-clicked="onNextClicked"
|
:on-next-clicked="onNextClicked"
|
||||||
:on-previous-clicked="onPreviousClicked"
|
:on-previous-clicked="onPreviousClicked"
|
||||||
|
:page-number="pageNumber"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -57,6 +58,7 @@ const props = withDefaults(defineProps<{
|
|||||||
showSelect?: boolean,
|
showSelect?: boolean,
|
||||||
simplePagination?: boolean,
|
simplePagination?: boolean,
|
||||||
loading?: boolean,
|
loading?: boolean,
|
||||||
|
pageNumber?: number,
|
||||||
}>(), {
|
}>(), {
|
||||||
selectable: false,
|
selectable: false,
|
||||||
selected: false,
|
selected: false,
|
||||||
@ -71,6 +73,7 @@ const props = withDefaults(defineProps<{
|
|||||||
onPreviousClicked: null,
|
onPreviousClicked: null,
|
||||||
onPageSizeChanged: null,
|
onPageSizeChanged: null,
|
||||||
loading: false,
|
loading: false,
|
||||||
|
pageNumber: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['selectAllClicked']);
|
const emit = defineEmits(['selectAllClicked']);
|
||||||
|
@ -297,6 +297,12 @@ export const useObjectBrowserStore = defineStore('objectBrowser', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
keyCount += response.KeyCount ?? 0;
|
keyCount += response.KeyCount ?? 0;
|
||||||
|
// We decrement key count if we're inside a folder to exclude .file_placeholder object
|
||||||
|
// which was auto created for this folder because it's not visible by the user
|
||||||
|
// and it shouldn't be included in pagination process.
|
||||||
|
if (path) {
|
||||||
|
keyCount -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!response.NextContinuationToken) break;
|
if (!response.NextContinuationToken) break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user