mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-21 21:33:18 +01:00
@@ -11,7 +11,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="container in containers" :key="container.id">
|
<tr v-for="container in paginated" :key="container.id">
|
||||||
<td>
|
<td>
|
||||||
<router-link :to="{ name: 'container-id', params: { id: container.id } }" :title="container.name">
|
<router-link :to="{ name: 'container-id', params: { id: container.id } }" :title="container.name">
|
||||||
{{ container.name }}
|
{{ container.name }}
|
||||||
@@ -28,10 +28,17 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<nav class="pagination is-right" role="navigation" aria-label="pagination" v-if="isPaginated">
|
||||||
|
<ul class="pagination-list">
|
||||||
|
<li v-for="i in totalPages">
|
||||||
|
<a class="pagination-link" :class="{ 'is-current': i === currentPage }" @click="currentPage = i">{{ i }}</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const { containers } = defineProps<{
|
const { containers, perPage = 15 } = defineProps<{
|
||||||
containers: {
|
containers: {
|
||||||
movingAverage: { cpu: number; memory: number };
|
movingAverage: { cpu: number; memory: number };
|
||||||
created: Date;
|
created: Date;
|
||||||
@@ -39,7 +46,18 @@ const { containers } = defineProps<{
|
|||||||
name: string;
|
name: string;
|
||||||
id: string;
|
id: string;
|
||||||
}[];
|
}[];
|
||||||
|
perPage?: number;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const totalPages = computed(() => Math.ceil(containers.length / perPage));
|
||||||
|
const isPaginated = computed(() => totalPages.value > 1);
|
||||||
|
const currentPage = ref(1);
|
||||||
|
const paginated = computed(() => {
|
||||||
|
const start = (currentPage.value - 1) * perPage;
|
||||||
|
const end = start + perPage;
|
||||||
|
|
||||||
|
return containers.slice(start, end);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
<style lang="scss" scoped></style>
|
||||||
|
|||||||
Reference in New Issue
Block a user