Add pagination to scan list
This commit is contained in:
parent
93ff7999f5
commit
cd5d5149a3
1 changed files with 38 additions and 1 deletions
|
|
@ -66,7 +66,7 @@
|
|||
There are no scans available to show.
|
||||
</p>
|
||||
</div>
|
||||
<div v-for="scanData in scans" :key="scanData.id">
|
||||
<div v-for="scanData in paginatedScans" :key="scanData.id">
|
||||
<scan-card
|
||||
:scan-data="scanData"
|
||||
:scans-uri="scansUri"
|
||||
|
|
@ -77,6 +77,25 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="totalPages > 1" class="pagination-container uk-margin-top uk-flex uk-flex-center">
|
||||
<ul class="uk-pagination">
|
||||
<li :class="{ 'uk-disabled': currentPage === 1 }">
|
||||
<a href="#" @click.prevent="changePage(currentPage - 1)">
|
||||
<span uk-pagination-previous></span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li v-for="page in totalPages" :key="page" :class="{ 'uk-active': page === currentPage }">
|
||||
<a href="#" @click.prevent="changePage(page)">{{ page }}</a>
|
||||
</li>
|
||||
|
||||
<li :class="{ 'uk-disabled': currentPage === totalPages }">
|
||||
<a href="#" @click.prevent="changePage(currentPage + 1)">
|
||||
<span uk-pagination-next></span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -97,6 +116,8 @@ export default {
|
|||
ongoing: null,
|
||||
selectedScan: null,
|
||||
osdViewer: null,
|
||||
currentPage: 1,
|
||||
itemsPerPage: 18,
|
||||
};
|
||||
},
|
||||
|
||||
|
|
@ -119,6 +140,13 @@ export default {
|
|||
return null;
|
||||
}
|
||||
},
|
||||
totalPages() {
|
||||
return Math.ceil(this.scans.length / this.itemsPerPage);
|
||||
},
|
||||
paginatedScans() {
|
||||
const start = (this.currentPage - 1) * this.itemsPerPage;
|
||||
return this.scans.slice(start, start + this.itemsPerPage);
|
||||
},
|
||||
},
|
||||
|
||||
async mounted() {
|
||||
|
|
@ -215,6 +243,11 @@ export default {
|
|||
this.modalError("Scan not stitched for viewing in webapp, please download or stitch");
|
||||
}
|
||||
},
|
||||
changePage(page) {
|
||||
if (page >= 1 && page <= this.totalPages) {
|
||||
this.currentPage = page;
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
@ -235,4 +268,8 @@ export default {
|
|||
margin-top: 5px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue