Skip to content

A self-hosted media server and file management system

page compacting

aminnausin08a76b1094e2
diff --git a/resources/js/components/table/TablePagination.vue b/resources/js/components/table/TablePagination.vue
index b5d087a9..f6a78f05 100644
--- a/resources/js/components/table/TablePagination.vue
+++ b/resources/js/components/table/TablePagination.vue
@@ -4,6 +4,23 @@ import TablePaginationButton from './TablePaginationButton.vue';
const props = defineProps(['listLength', 'currentPage', 'itemsPerPage']);
const pageCount = computed(() => { return Math.ceil(props.listLength / props.itemsPerPage); });
+const pageRange = computed(() => {
+ let out = null;
+ if(pageCount.value <= 5) out = pageCount.value;
+ else if(props.currentPage <= 3) out = Math.min(4, pageCount.value)
+ else if(pageCount.value - props.currentPage <= 2){
+ let range = [];
+ for(var i = pageCount.value - 3; i <= pageCount.value; i++){
+ console.log(i);
+ range = [...range, i];
+ }
+ out = range;
+ }
+ console.log(out);
+
+ return out === null ? [props.currentPage - 1, props.currentPage, props.currentPage + 1] : out;
+
+ })
</script>
<template>
@@ -22,13 +39,45 @@ const pageCount = computed(() => { return Math.ceil(props.listLength / props.ite
class="flex flex-wrap items-center text-sm leading-tight bg-white dark:bg-neutral-800 border divide-x rounded h-9 text-neutral-500 dark:text-neutral-200 divide-neutral-200 dark:divide-neutral-700 border-neutral-200 dark:border-neutral-700">
<TablePaginationButton :pageNumber="-1" :text="'Previous'"
@click="$emit('setPage', Math.max(1, props.currentPage - 1))" />
- <TablePaginationButton v-for="page in pageCount" :key="page" :pageNumber="page"
+
+ <template v-if="pageCount > 5 && props.currentPage > 3">
+ <TablePaginationButton :pageNumber="1" :currentPage="props.currentPage" @click="$emit('setPage', 1)" />
+ <TablePaginationButton :pageNumber="-1" :text="'...'" @click="$emit('setPage', Math.floor(currentPage/2))" />
+ </template>
+
+ <TablePaginationButton v-for="page in pageRange" :key="page" :pageNumber="page"
:currentPage="props.currentPage" @click="$emit('setPage', page)" />
+
+ <template v-if="pageCount > 5 && pageCount - props.currentPage > 2">
+ <TablePaginationButton :pageNumber="-1" :text="'...'" @click="$emit('setPage', Math.floor((pageCount - currentPage) / 2 + currentPage))" />
+ <TablePaginationButton :pageNumber="pageCount" :currentPage="props.currentPage" @click="$emit('setPage', pageCount)" />
+ </template>
+
<TablePaginationButton :pageNumber="-1" :text="'Next'"
@click="$emit('setPage', Math.min(pageCount, props.currentPage + 1))" />
+ <!-- 1 ... 5 7 8 ... 12 - current is 7
- <!-- <li class="h-full">
+ 1 ... 5 7 8 9 current is 8
+
+ 1 2 3 4 ... 12
+
+ 1 2 3 4 5 6 7 8 9 10
+ 12 - 3 = 9 -> 9 > 3
+ ie within 3 of start
+
+ 9 < 3 not within 3 of end
+
+ 12345
+ 5 - 3 < 3
+
+
+ if number is 1 .. 3 4 5 right
+ so if number is greater than 3 add a ... between start and finish
+
+
+
+ <li class="h-full">
<button @click="$emit('setPage', Math.max(1, props.currentPage - 1))"
class="relative inline-flex items-center h-full px-3 ml-0 rounded-l group hover:text-neutral-900">
<span>Previous</span>
diff --git a/resources/js/components/video/VideoTable.vue b/resources/js/components/video/VideoTable.vue
index 4e676df0..ec8bf20b 100644
--- a/resources/js/components/video/VideoTable.vue
+++ b/resources/js/components/video/VideoTable.vue
@@ -13,7 +13,7 @@ const { searchQuery, stateFilteredPlaylist, stateVideo } = storeToRefs(ContentSt
const { playlistFind } = ContentStore;
const currentPage = ref(1);
-const itemsPerPage = ref(10);
+const itemsPerPage = ref(1);
const filteredPage = computed(() => {
const minIndex = itemsPerPage.value * (currentPage.value - 1);
const maxIndex = Math.min(itemsPerPage.value * (currentPage.value), stateFilteredPlaylist.value.length);