diff --git a/src/api/mock-data/meshes/default/circuit-breakers.json b/src/api/mock-data/meshes/default/circuit-breakers.json index cee3ab768..a76cc424b 100644 --- a/src/api/mock-data/meshes/default/circuit-breakers.json +++ b/src/api/mock-data/meshes/default/circuit-breakers.json @@ -98,5 +98,5 @@ } } ], - "next": null + "next": "http://localhost:5681/meshes/default/circuit-breakers?offset=1" } diff --git a/src/app/data-planes/views/DataPlaneListView.vue b/src/app/data-planes/views/DataPlaneListView.vue index a1f02794b..0255ce318 100644 --- a/src/app/data-planes/views/DataPlaneListView.vue +++ b/src/app/data-planes/views/DataPlaneListView.vue @@ -400,11 +400,12 @@ async function parseData(dataPlaneOverview: DataPlaneOverview) { } async function loadData(offset: number): Promise { - isLoading.value = true pageOffset.value = offset - // Puts the offset parameter in the URL so it can be retrieved when the user reloads the page. patchQueryParam('offset', offset > 0 ? offset : null) + + isLoading.value = true + const mesh = route.params.mesh as string const size = PAGE_SIZE diff --git a/src/app/policies/views/PolicyView.vue b/src/app/policies/views/PolicyView.vue index 05b421abb..717d116fa 100644 --- a/src/app/policies/views/PolicyView.vue +++ b/src/app/policies/views/PolicyView.vue @@ -35,6 +35,7 @@ :table-data="tableData" :table-data-is-empty="tableDataIsEmpty" :next="nextUrl" + :page-offset="pageOffset" @table-action="getEntity" @load-data="loadData" > @@ -137,6 +138,7 @@ import PolicyConnections from '../components/PolicyConnections.vue' import TabsWidget from '@/app/common/TabsWidget.vue' import YamlView from '@/app/common/YamlView.vue' import { PolicyEntity, TableHeader } from '@/types/index.d' +import { patchQueryParam } from '@/utilities/patchQueryParam' const tabs = [ { @@ -157,6 +159,12 @@ const props = defineProps({ type: String, required: true, }, + + offset: { + type: Number, + required: false, + default: 0, + }, }) const isLoading = ref(true) @@ -169,6 +177,7 @@ const tableDataIsEmpty = ref(false) const entity = ref({}) const rawEntity = ref | null>(null) const nextUrl = ref(null) +const pageOffset = ref(props.offset) const tableData = ref<{ headers: TableHeader[], data: any[] }>({ headers: [ @@ -202,12 +211,16 @@ watch(() => route.params.mesh, function () { tableDataIsEmpty.value = false error.value = null - loadData() + loadData(0) }) -loadData() +loadData(props.offset) + +async function loadData(offset: number): Promise { + pageOffset.value = offset + // Puts the offset parameter in the URL so it can be retrieved when the user reloads the page. + patchQueryParam('offset', offset > 0 ? offset : null) -async function loadData(offset: number = 0): Promise { isLoading.value = true error.value = null diff --git a/src/app/services/views/ServiceListView.vue b/src/app/services/views/ServiceListView.vue index eba9dba8c..f2958d49a 100644 --- a/src/app/services/views/ServiceListView.vue +++ b/src/app/services/views/ServiceListView.vue @@ -10,6 +10,7 @@ :table-data="tableData" :table-data-is-empty="tableData.data.length === 0" :next="nextUrl" + :page-offset="pageOffset" @table-action="setActiveServiceInsight" @load-data="loadData" /> @@ -36,6 +37,7 @@ import ServiceDetails from '../components/ServiceDetails.vue' import { kumaApi } from '@/api/kumaApi' import { STATUS } from '@/constants' import { ServiceInsight, TableHeader } from '@/types/index.d' +import { patchQueryParam } from '@/utilities/patchQueryParam' const headers: TableHeader[] = [ { label: 'Service', key: 'name' }, @@ -54,9 +56,18 @@ const EMPTY_STATE = { const route = useRoute() +const props = defineProps({ + offset: { + type: Number, + required: false, + default: 0, + }, +}) + const isLoading = ref(true) const error = ref(null) const nextUrl = ref(null) +const pageOffset = ref(props.offset) const serviceInsight = ref<{ name: string, mesh: string, serviceType?: 'internal' | 'external' | 'gateway_builtin' | 'gateway_delegated' } | null>(null) const tableData = ref<{ headers: TableHeader[], data: any[] }>({ headers, @@ -72,9 +83,13 @@ watch(() => route.params.mesh, function () { loadData(0) }) -loadData(0) +loadData(props.offset) async function loadData(offset: number): Promise { + pageOffset.value = offset + // Puts the offset parameter in the URL so it can be retrieved when the user reloads the page. + patchQueryParam('offset', offset > 0 ? offset : null) + isLoading.value = true error.value = null diff --git a/src/app/zones/views/ZoneEgresses.vue b/src/app/zones/views/ZoneEgresses.vue index 7072d8c26..98e8eb7af 100644 --- a/src/app/zones/views/ZoneEgresses.vue +++ b/src/app/zones/views/ZoneEgresses.vue @@ -10,6 +10,7 @@ :table-data="tableData" :table-data-is-empty="isEmpty" :next="next" + :page-offset="pageOffset" @table-action="tableAction" @load-data="loadData($event)" > @@ -129,6 +130,7 @@ import LabelList from '@/app/common/LabelList.vue' import SubscriptionDetails from '@/app/common/subscriptions/SubscriptionDetails.vue' import SubscriptionHeader from '@/app/common/subscriptions/SubscriptionHeader.vue' import TabsWidget from '@/app/common/TabsWidget.vue' +import { patchQueryParam } from '@/utilities/patchQueryParam' export default { name: 'ZoneEgresses', @@ -147,6 +149,14 @@ export default { KCard, }, + props: { + offset: { + type: Number, + required: false, + default: 0, + }, + }, + data() { return { isLoading: true, @@ -192,8 +202,10 @@ export default { pageSize: PAGE_SIZE_DEFAULT, next: null, subscriptionsReversed: [], + pageOffset: this.offset, } }, + watch: { $route() { // Ensures basic state is reset when switching meshes using the mesh selector. @@ -201,16 +213,15 @@ export default { this.isEmpty = false this.error = null - this.init() + this.loadData(0) }, }, + beforeMount() { - this.init() + this.loadData(this.offset) }, + methods: { - init() { - this.loadData() - }, tableAction(ev) { const data = ev @@ -218,7 +229,11 @@ export default { this.getEntity(data) }, - async loadData(offset = '0') { + async loadData(offset) { + this.pageOffset = offset + // Puts the offset parameter in the URL so it can be retrieved when the user reloads the page. + patchQueryParam('offset', offset > 0 ? offset : null) + this.isLoading = true this.isEmpty = false diff --git a/src/app/zones/views/ZoneIngresses.vue b/src/app/zones/views/ZoneIngresses.vue index 2a1618736..d05c00e98 100644 --- a/src/app/zones/views/ZoneIngresses.vue +++ b/src/app/zones/views/ZoneIngresses.vue @@ -13,8 +13,9 @@ :table-data="tableData" :table-data-is-empty="isEmpty" :next="next" + :page-offset="pageOffset" @table-action="tableAction" - @load-data="loadData($event)" + @load-data="loadData" >