Updating pagination in automation run history to use the same pagination store helper as the users pagination.

This commit is contained in:
mike12345567 2022-07-01 15:48:36 +01:00
parent 686cf6e1c4
commit ae0391c304
4 changed files with 48 additions and 53 deletions

View File

@ -4,6 +4,7 @@
import StatusRenderer from "./StatusRenderer.svelte" import StatusRenderer from "./StatusRenderer.svelte"
import HistoryDetailsPanel from "./HistoryDetailsPanel.svelte" import HistoryDetailsPanel from "./HistoryDetailsPanel.svelte"
import { automationStore } from "builderStore" import { automationStore } from "builderStore"
import { createPaginationStore } from "helpers/pagination"
import { onMount } from "svelte" import { onMount } from "svelte"
import dayjs from "dayjs" import dayjs from "dayjs"
@ -12,6 +13,7 @@
STOPPED = "stopped" STOPPED = "stopped"
export let app export let app
let pageInfo = createPaginationStore()
let runHistory = null let runHistory = null
let showPanel = false let showPanel = false
let selectedHistory = null let selectedHistory = null
@ -19,12 +21,8 @@
let automationId = null let automationId = null
let status = null let status = null
let timeRange = null let timeRange = null
let prevPage,
nextPage,
page,
hasNextPage,
pageNumber = 1
$: page = $pageInfo.page
$: fetchLogs(automationId, status, page, timeRange) $: fetchLogs(automationId, status, page, timeRange)
const timeOptions = [ const timeOptions = [
@ -64,23 +62,10 @@
page, page,
startDate, startDate,
}) })
nextPage = response.nextPage pageInfo.fetched(response.hasNextPage, response.nextPage)
hasNextPage = response.hasNextPage
runHistory = enrichHistory($automationStore.blockDefinitions, response.data) runHistory = enrichHistory($automationStore.blockDefinitions, response.data)
} }
function goToNextPage() {
pageNumber++
prevPage = page
page = nextPage
}
function goToPrevPage() {
pageNumber--
nextPage = page
page = prevPage
}
function enrichHistory(definitions, runHistory) { function enrichHistory(definitions, runHistory) {
if (!definitions) { if (!definitions) {
return [] return []
@ -185,11 +170,11 @@
</div> </div>
<div class="pagination"> <div class="pagination">
<Pagination <Pagination
page={pageNumber} page={$pageInfo.pageNumber}
hasPrevPage={pageNumber > 1} hasPrevPage={$pageInfo.loading ? false : $pageInfo.hasPrevPage}
{hasNextPage} hasNextPage={$pageInfo.loading ? false : $pageInfo.hasNextPage}
{goToPrevPage} goToPrevPage={pageInfo.prevPage}
{goToNextPage} goToNextPage={pageInfo.nextPage}
/> />
</div> </div>

View File

@ -27,13 +27,23 @@
} }
let pageInfo = createPaginationStore() let pageInfo = createPaginationStore()
let search = undefined let prevSearch = undefined,
search = undefined
$: page = $pageInfo.page $: page = $pageInfo.page
$: fetchUsers(page, search) $: fetchUsers(page, search)
let createUserModal let createUserModal
async function fetchUsers(page, search) { async function fetchUsers(page, search) {
if ($pageInfo.loading) {
return
}
// need to remove the page if they've started searching
if (search && !prevSearch) {
pageInfo.reset()
page = undefined
}
prevSearch = search
try { try {
pageInfo.loading() pageInfo.loading()
await users.search({ page, search }) await users.search({ page, search })

View File

@ -1080,12 +1080,12 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.0.212-alpha.0": "@budibase/backend-core@1.0.212-alpha.10":
version "1.0.212-alpha.0" version "1.0.212-alpha.10"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.212-alpha.0.tgz#6ac3448c8272e918f1af1fff0cf8c5773ae61219" resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.212-alpha.10.tgz#21c74d209c5fecea4b49e0c59db87069493169bc"
integrity sha512-hFvbQQEbF3w2u9fe/S+RhNw5HUETS6rhu9q5KDTDQ57k05D4YMPcpMBGSh7SPMqmVyEwUDgcL36mkFOc3AgjYQ== integrity sha512-8UcYfVC/8HYK3QkdysSVyiPUbNHXKpayoM9NMrJEA+QUSRcchQBLn1/5qhEAwfnPz55X+BlNV1whIJdMzXbP2A==
dependencies: dependencies:
"@budibase/types" "^1.0.212-alpha.0" "@budibase/types" "^1.0.212-alpha.10"
"@techpass/passport-openidconnect" "0.3.2" "@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0" aws-sdk "2.1030.0"
bcrypt "5.0.1" bcrypt "5.0.1"
@ -1161,12 +1161,12 @@
svelte-flatpickr "^3.2.3" svelte-flatpickr "^3.2.3"
svelte-portal "^1.0.0" svelte-portal "^1.0.0"
"@budibase/pro@1.0.212-alpha.0": "@budibase/pro@1.0.212-alpha.10":
version "1.0.212-alpha.0" version "1.0.212-alpha.10"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.212-alpha.0.tgz#843f8291fcc0a2fbcb4d857a750bc116cdaee293" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.212-alpha.10.tgz#0a0c2e695884075db03068c93705d1bc233b0c7a"
integrity sha512-4nhWxjMcxSQBPXRy/U+37IaVLYOr4/RVe79/fUvnXrr5qAeecbEk/QbkJJd3dU1WaNxB2eGhNtH3uBUPQvcT9A== integrity sha512-qNzaT7+Wyy7roS/QX/WCpyhddapbarur3uPj8SBfVql8YEvEZw/f+3aOS3Ixj5m5r5eQxphWm/dCXC3RYjXKFg==
dependencies: dependencies:
"@budibase/backend-core" "1.0.212-alpha.0" "@budibase/backend-core" "1.0.212-alpha.10"
node-fetch "^2.6.1" node-fetch "^2.6.1"
"@budibase/standard-components@^0.9.139": "@budibase/standard-components@^0.9.139":
@ -1187,10 +1187,10 @@
svelte-apexcharts "^1.0.2" svelte-apexcharts "^1.0.2"
svelte-flatpickr "^3.1.0" svelte-flatpickr "^3.1.0"
"@budibase/types@^1.0.212-alpha.0": "@budibase/types@^1.0.212-alpha.10":
version "1.0.212" version "1.0.214"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.212.tgz#e66a15b711544b4fab7767261fd5f2f1dd7f40d7" resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.214.tgz#400724fb23a1ce4b80bd04ed472a376d59126069"
integrity sha512-DhGyw6snwJQZQlx7havVYnqPZfZERueKZfmVCBySzwInZZt0+sXZaBl1BVjGjYuwpaUQBMDBf7geBgHXp6DIKg== integrity sha512-KD9XkCdL+R4Nal/X2IX0Bv+AxsylGzAAmo7M6tuoM7YAegskmsX5Kfk5yasnbMnhOdICyvbJ1D6Hz7WKwdApzw==
"@bull-board/api@3.7.0": "@bull-board/api@3.7.0":
version "3.7.0" version "3.7.0"

View File

@ -293,12 +293,12 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.0.212-alpha.0": "@budibase/backend-core@1.0.212-alpha.10":
version "1.0.212-alpha.0" version "1.0.212-alpha.10"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.212-alpha.0.tgz#6ac3448c8272e918f1af1fff0cf8c5773ae61219" resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.212-alpha.10.tgz#21c74d209c5fecea4b49e0c59db87069493169bc"
integrity sha512-hFvbQQEbF3w2u9fe/S+RhNw5HUETS6rhu9q5KDTDQ57k05D4YMPcpMBGSh7SPMqmVyEwUDgcL36mkFOc3AgjYQ== integrity sha512-8UcYfVC/8HYK3QkdysSVyiPUbNHXKpayoM9NMrJEA+QUSRcchQBLn1/5qhEAwfnPz55X+BlNV1whIJdMzXbP2A==
dependencies: dependencies:
"@budibase/types" "^1.0.212-alpha.0" "@budibase/types" "^1.0.212-alpha.10"
"@techpass/passport-openidconnect" "0.3.2" "@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0" aws-sdk "2.1030.0"
bcrypt "5.0.1" bcrypt "5.0.1"
@ -325,18 +325,18 @@
uuid "8.3.2" uuid "8.3.2"
zlib "1.0.5" zlib "1.0.5"
"@budibase/pro@1.0.212-alpha.0": "@budibase/pro@1.0.212-alpha.10":
version "1.0.212-alpha.0" version "1.0.212-alpha.10"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.212-alpha.0.tgz#843f8291fcc0a2fbcb4d857a750bc116cdaee293" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.212-alpha.10.tgz#0a0c2e695884075db03068c93705d1bc233b0c7a"
integrity sha512-4nhWxjMcxSQBPXRy/U+37IaVLYOr4/RVe79/fUvnXrr5qAeecbEk/QbkJJd3dU1WaNxB2eGhNtH3uBUPQvcT9A== integrity sha512-qNzaT7+Wyy7roS/QX/WCpyhddapbarur3uPj8SBfVql8YEvEZw/f+3aOS3Ixj5m5r5eQxphWm/dCXC3RYjXKFg==
dependencies: dependencies:
"@budibase/backend-core" "1.0.212-alpha.0" "@budibase/backend-core" "1.0.212-alpha.10"
node-fetch "^2.6.1" node-fetch "^2.6.1"
"@budibase/types@^1.0.212-alpha.0": "@budibase/types@^1.0.212-alpha.10":
version "1.0.212" version "1.0.214"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.212.tgz#e66a15b711544b4fab7767261fd5f2f1dd7f40d7" resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.214.tgz#400724fb23a1ce4b80bd04ed472a376d59126069"
integrity sha512-DhGyw6snwJQZQlx7havVYnqPZfZERueKZfmVCBySzwInZZt0+sXZaBl1BVjGjYuwpaUQBMDBf7geBgHXp6DIKg== integrity sha512-KD9XkCdL+R4Nal/X2IX0Bv+AxsylGzAAmo7M6tuoM7YAegskmsX5Kfk5yasnbMnhOdICyvbJ1D6Hz7WKwdApzw==
"@cspotcode/source-map-consumer@0.8.0": "@cspotcode/source-map-consumer@0.8.0":
version "0.8.0" version "0.8.0"