1
0
Fork 0
mirror of synced 2024-06-03 02:55:14 +12:00

Adding UI for displaying when the CRON job has been stopped and alert the user to next steps.

This commit is contained in:
mike12345567 2022-07-26 13:59:22 +01:00
parent caaf5dc3c9
commit cfde86a996
5 changed files with 44 additions and 5 deletions

View file

@ -32,7 +32,8 @@
if (!results) {
return {}
}
if (results.outputs?.status?.toLowerCase() === "stopped") {
const lcStatus = results.outputs?.status?.toLowerCase()
if (lcStatus === "stopped" || lcStatus === "stopped_error") {
return { yellow: true, message: "Stopped" }
} else if (results.outputs?.success || isTrigger) {
return { positive: true, message: "Success" }

View file

@ -1,5 +1,5 @@
<script>
import { Layout, Icon, ActionButton } from "@budibase/bbui"
import { Layout, Icon, ActionButton, InlineAlert } from "@budibase/bbui"
import StatusRenderer from "./StatusRenderer.svelte"
import DateTimeRenderer from "components/common/renderers/DateTimeRenderer.svelte"
import TestDisplay from "components/automation/AutomationBuilder/TestDisplay.svelte"
@ -9,6 +9,7 @@
export let history
export let appId
export let close
const STOPPED_ERROR = "stopped_error"
$: exists = $automationStore.automations?.find(
auto => auto._id === history?.automationId
@ -32,6 +33,15 @@
<Icon name="JourneyVoyager" />
<div>{history.automationName}</div>
</div>
{#if history.status === STOPPED_ERROR}
<div class="cron-error">
<InlineAlert
type="error"
header="CRON automation disabled"
message="Fix the error and re-publish your app to re-activate."
/>
</div>
{/if}
<div>
{#if exists}
<ActionButton
@ -87,4 +97,10 @@
grid-template-columns: 1fr auto;
gap: var(--spacing-s);
}
.cron-error {
display: flex;
width: 100%;
justify-content: center;
}
</style>

View file

@ -3,7 +3,8 @@
export let value
$: isError = !value || value.toLowerCase() === "error"
$: isStopped = value?.toLowerCase() === "stopped"
$: isStoppedError = value?.toLowerCase() === "stopped_error"
$: isStopped = value?.toLowerCase() === "stopped" || isStoppedError
$: status = getStatus(isError, isStopped)
function getStatus(error, stopped) {

View file

@ -144,7 +144,15 @@ class Orchestrator {
`CRON disabled due to errors - ${this._appId}/${this._automation._id}`
)
await disableCron(this._repeat?.jobId, this._repeat?.jobKey)
this.updateExecutionOutput(trigger.id, trigger.stepId, {}, STOPPED_STATUS)
this.updateExecutionOutput(
trigger.id,
trigger.stepId,
{},
{
status: AutomationStatus.STOPPED_ERROR,
success: false,
}
)
await storeLog(automation, this.executionOutput)
return true
}
@ -183,8 +191,20 @@ class Orchestrator {
updateExecutionOutput(id: string, stepId: string, inputs: any, outputs: any) {
const stepObj = { id, stepId, inputs, outputs }
// replacing trigger when disabling CRON
if (
stepId === CRON_STEP_ID &&
outputs.status === AutomationStatus.STOPPED_ERROR
) {
this.executionOutput.trigger = stepObj
this.executionOutput.steps = [stepObj]
return
}
// first entry is always the trigger (constructor)
if (this.executionOutput.steps.length === 0) {
if (
this.executionOutput.steps.length === 0 ||
this.executionOutput.trigger.id === id
) {
this.executionOutput.trigger = stepObj
}
this.executionOutput.steps.push(stepObj)

View file

@ -31,6 +31,7 @@ export enum AutomationStatus {
SUCCESS = "success",
ERROR = "error",
STOPPED = "stopped",
STOPPED_ERROR = "stopped_error",
}
export interface AutomationResults {