diff --git a/dashboard/src/pages/packages/index.vue b/dashboard/src/pages/packages/index.vue index 4325031b0..7a2f43ac0 100644 --- a/dashboard/src/pages/packages/index.vue +++ b/dashboard/src/pages/packages/index.vue @@ -85,13 +85,47 @@ const toggleLegend = () => { >{{ pkg.name }} - + + + {{ $filters.formatDateTime(pkg.startedAt) }} - - + + + + + + +
+ +
diff --git a/dashboard/src/stores/package.ts b/dashboard/src/stores/package.ts index 4b3ac9293..5f2ea1398 100644 --- a/dashboard/src/stores/package.ts +++ b/dashboard/src/stores/package.ts @@ -23,6 +23,15 @@ export const usePackageStore = defineStore("package", { // A list of packages shown during searches. packages: [] as Array, + // Cursor for this page of packages. + cursor: 0, + + // Cursor for next page of packages. + nextCursor: 0, + + // A list of previous page cursors. + prevCursors: [] as Array, + // User-interface interactions between components. ui: { download: new UIRequest(), @@ -44,6 +53,12 @@ export const usePackageStore = defineStore("package", { isRejected(): boolean { return this.isDone && this.current?.locationId === undefined; }, + hasNextPage(): boolean { + return this.nextCursor != 0; + }, + hasPrevPage(): boolean { + return this.prevCursors.length > 0; + }, getActionById: (state) => { return ( actionId: number, @@ -103,8 +118,11 @@ export const usePackageStore = defineStore("package", { ]); }, async fetchPackages() { - const resp = await client.package.packageList(); + const resp = await client.package.packageList({ + cursor: this.cursor > 0 ? this.cursor.toString() : undefined, + }); this.packages = resp.items; + this.nextCursor = Number(resp.nextCursor); }, async fetchPackagesDebounced() { return this.fetchPackages(); @@ -156,6 +174,21 @@ export const usePackageStore = defineStore("package", { this.current.status = api.EnduroStoredPackageStatusEnum.InProgress; }); }, + nextPage() { + if (this.nextCursor == 0) { + return; + } + this.prevCursors.push(this.cursor); + this.cursor = this.nextCursor; + this.fetchPackages(); + }, + prevPage() { + let prev = this.prevCursors.pop(); + if (prev !== undefined) { + this.cursor = prev; + this.fetchPackages(); + } + }, }, debounce: { fetchPackagesDebounced: [500, { isImmediate: false }], diff --git a/dashboard/src/styles/README.md b/dashboard/src/styles/README.md index fa40952cb..5bb8c073e 100644 --- a/dashboard/src/styles/README.md +++ b/dashboard/src/styles/README.md @@ -3,5 +3,5 @@ Notes: - `main.scss` is imported by `main.ts` - the global stylesheet for the app. - `bootstrap-base.scss` is also made available to all components using `