activations

This commit is contained in:
Martin McKeaveney 2021-05-19 10:46:47 +01:00
parent a781239632
commit 8ceba79a12
2 changed files with 25 additions and 17 deletions

View File

@ -8,23 +8,23 @@
const CRON_EXPRESSIONS = [
{
label: "Every Minute",
value: "* * * * *"
value: "* * * * *",
},
{
label: "Every Hour",
value: "0 * * * *"
value: "0 * * * *",
},
{
label: "Every Morning at 8AM",
value: "0 8 * * *"
value: "0 8 * * *",
},
{
label: "Every Night at Midnight",
value: "0 0 * * *"
value: "0 0 * * *",
},
{
label: "Every Budibase Reboot",
value: "@reboot"
value: "@reboot",
},
]
</script>
@ -33,9 +33,17 @@
<Input bind:value />
<div class="presets">
<Button on:click={() => (presets = !presets)}>{presets ? "Hide" : "Show"} Presets</Button>
<Button on:click={() => (presets = !presets)}
>{presets ? "Hide" : "Show"} Presets</Button
>
{#if presets}
<Select bind:value secondary extraThin label="Presets" options={CRON_EXPRESSIONS} />
<Select
bind:value
secondary
extraThin
label="Presets"
options={CRON_EXPRESSIONS}
/>
{/if}
</div>
</div>

View File

@ -39,8 +39,6 @@ function cleanAutomationInputs(automation) {
* @param {string} appId The ID of the app in which we are checking for webhooks
* @param {object|undefined} oldAuto The old automation object if updating/deleting
* @param {object|undefined} newAuto The new automation object if creating/updating
* @returns {Promise<object|undefined>} After this is complete the new automation object may have been updated and should be
* written to DB (this does not write to DB as it would be wasteful to repeat).
*/
async function checkForCronTriggers({ appId, oldAuto, newAuto }) {
const oldTrigger = oldAuto ? oldAuto.definition.trigger : null
@ -53,11 +51,13 @@ async function checkForCronTriggers({ appId, oldAuto, newAuto }) {
)
}
const isLive = auto => auto && auto.live
const cronTriggerRemoved =
isCronTrigger(oldAuto) && !isCronTrigger(newAuto) && oldTrigger.cronJobId
const cronTriggerDeactivated = !newAuto.live && oldAuto.live
const cronTriggerDeactivated = !isLive(newAuto) && isLive(oldAuto)
const cronTriggerActivated = newAuto.live && !oldAuto.live
const cronTriggerActivated = isLive(newAuto) && !isLive(oldAuto)
if (cronTriggerRemoved || cronTriggerDeactivated) {
await triggers.automationQueue.removeRepeatableByKey(oldTrigger.cronJobId)