2020-05-28 08:51:32 +12:00
|
|
|
<script>
|
2020-09-12 01:23:31 +12:00
|
|
|
import { afterUpdate } from "svelte"
|
2020-09-22 00:49:34 +12:00
|
|
|
import { automationStore, backendUiStore } from "builderStore"
|
2020-06-24 23:41:26 +12:00
|
|
|
import { notifier } from "builderStore/store/notifications"
|
2020-06-02 08:40:02 +12:00
|
|
|
import Flowchart from "./flowchart/FlowChart.svelte"
|
2020-05-28 08:51:32 +12:00
|
|
|
|
2020-09-22 00:49:34 +12:00
|
|
|
$: automation = $automationStore.selectedAutomation?.automation
|
|
|
|
$: automationLive = automation?.live
|
2020-05-29 10:31:55 +12:00
|
|
|
$: instanceId = $backendUiStore.selectedDatabase._id
|
2020-05-28 08:51:32 +12:00
|
|
|
|
|
|
|
function onSelect(block) {
|
2020-09-22 00:49:34 +12:00
|
|
|
automationStore.update(state => {
|
2020-09-12 01:23:31 +12:00
|
|
|
state.selectedBlock = block
|
2020-05-28 08:51:32 +12:00
|
|
|
return state
|
|
|
|
})
|
|
|
|
}
|
2020-05-29 10:31:55 +12:00
|
|
|
|
2020-09-22 00:49:34 +12:00
|
|
|
function setAutomationLive(live) {
|
|
|
|
automation.live = live
|
|
|
|
automationStore.actions.save({ instanceId, automation })
|
2020-05-29 10:31:55 +12:00
|
|
|
if (live) {
|
2020-09-22 00:49:34 +12:00
|
|
|
notifier.info(`Automation ${automation.name} enabled.`)
|
2020-05-29 10:31:55 +12:00
|
|
|
} else {
|
2020-09-22 00:49:34 +12:00
|
|
|
notifier.danger(`Automation ${automation.name} disabled.`)
|
2020-05-29 10:31:55 +12:00
|
|
|
}
|
|
|
|
}
|
2020-05-28 08:51:32 +12:00
|
|
|
</script>
|
|
|
|
|
2020-09-12 08:14:58 +12:00
|
|
|
<section>
|
2020-09-22 00:49:34 +12:00
|
|
|
<Flowchart {automation} {onSelect} />
|
2020-05-28 08:51:32 +12:00
|
|
|
</section>
|
2020-09-10 18:46:01 +12:00
|
|
|
<footer>
|
2020-09-22 00:49:34 +12:00
|
|
|
{#if automation}
|
2020-09-10 18:46:01 +12:00
|
|
|
<button
|
2020-09-22 00:49:34 +12:00
|
|
|
class:highlighted={automationLive}
|
|
|
|
class:hoverable={automationLive}
|
2020-09-10 18:46:01 +12:00
|
|
|
class="stop-button hoverable">
|
2020-09-22 00:49:34 +12:00
|
|
|
<i class="ri-stop-fill" on:click={() => setAutomationLive(false)} />
|
2020-09-10 18:46:01 +12:00
|
|
|
</button>
|
|
|
|
<button
|
2020-09-22 00:49:34 +12:00
|
|
|
class:highlighted={!automationLive}
|
|
|
|
class:hoverable={!automationLive}
|
2020-09-10 18:46:01 +12:00
|
|
|
class="play-button hoverable"
|
2020-09-22 00:49:34 +12:00
|
|
|
data-cy="activate-automation"
|
|
|
|
on:click={() => setAutomationLive(true)}>
|
2020-09-10 18:46:01 +12:00
|
|
|
<i class="ri-play-fill" />
|
|
|
|
</button>
|
|
|
|
{/if}
|
|
|
|
</footer>
|
2020-05-29 07:20:03 +12:00
|
|
|
|
|
|
|
<style>
|
2020-09-10 18:46:01 +12:00
|
|
|
section {
|
|
|
|
display: flex;
|
2020-10-01 03:06:47 +13:00
|
|
|
flex-direction: column;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: center;
|
2020-09-10 18:46:01 +12:00
|
|
|
overflow: auto;
|
|
|
|
height: 100%;
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
|
2020-05-29 07:20:03 +12:00
|
|
|
footer {
|
|
|
|
position: absolute;
|
2020-09-23 23:24:57 +12:00
|
|
|
bottom: var(--spacing-xl);
|
2020-09-10 18:46:01 +12:00
|
|
|
right: 30px;
|
2020-05-29 07:20:03 +12:00
|
|
|
display: flex;
|
|
|
|
align-items: flex-end;
|
|
|
|
}
|
|
|
|
|
|
|
|
footer > button {
|
|
|
|
border-radius: 100%;
|
|
|
|
color: var(--white);
|
|
|
|
width: 76px;
|
|
|
|
height: 76px;
|
|
|
|
border: none;
|
|
|
|
background: #adaec4;
|
|
|
|
font-size: 45px;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
2020-09-10 18:46:01 +12:00
|
|
|
}
|
|
|
|
footer > button:first-child {
|
2020-09-23 23:24:57 +12:00
|
|
|
margin-right: var(--spacing-m);
|
2020-05-29 07:20:03 +12:00
|
|
|
}
|
|
|
|
|
2020-05-29 10:31:55 +12:00
|
|
|
.play-button.highlighted {
|
2020-06-27 01:32:45 +12:00
|
|
|
background: var(--purple);
|
2020-05-29 07:20:03 +12:00
|
|
|
}
|
|
|
|
|
2020-05-29 10:31:55 +12:00
|
|
|
.stop-button.highlighted {
|
2020-06-23 19:19:16 +12:00
|
|
|
background: var(--red);
|
2020-05-29 07:20:03 +12:00
|
|
|
}
|
|
|
|
</style>
|