1
0
Fork 0
mirror of synced 2024-09-11 23:16:00 +12:00

Fix automation error linking from apps page and improve automation fetching logic in automation history

This commit is contained in:
Andrew Kingston 2023-01-09 09:20:26 +00:00
parent 395b4d7ad8
commit 183bf9a84a
2 changed files with 18 additions and 9 deletions

View file

@ -95,10 +95,9 @@
const goToAutomationError = appId => {
const params = new URLSearchParams({
tab: "Automation History",
open: "error",
})
$goto(`../overview/${appId}?${params.toString()}`)
$goto(`../overview/${appId}/automation-history?${params.toString()}`)
}
const errorCount = errors => {

View file

@ -33,6 +33,7 @@
let automationId = null
let status = null
let timeRange = null
let loaded = false
$: licensePlan = $auth.user?.license?.plan
$: app = $overview.selectedApp
@ -66,7 +67,16 @@
{ column: "status", component: StatusRenderer },
]
async function fetchLogs(automationId, status, page, timeRange) {
async function fetchLogs(
automationId,
status,
page,
timeRange,
force = false
) {
if (!force && !loaded) {
return
}
let startDate = null
if (timeRange) {
const [length, units] = timeRange.split("-")
@ -118,19 +128,19 @@
await automationStore.actions.fetch()
const params = new URLSearchParams(window.location.search)
const shouldOpen = params.get("open") === ERROR
// open with errors, open panel for latest
if (shouldOpen) {
status = ERROR
}
await automationStore.actions.fetch()
await fetchLogs(null, status)
if (shouldOpen) {
viewDetails({ detail: runHistory[0] })
}
automationOptions = []
for (let automation of $automationStore.automations) {
automationOptions.push({ value: automation._id, label: automation.name })
}
await fetchLogs(automationId, status, 0, timeRange, true)
// Open the first automation info if one exists
if (shouldOpen && runHistory?.[0]) {
viewDetails({ detail: runHistory[0] })
}
loaded = true
})
onDestroy(() => {