2020-05-28 08:51:32 +12:00
|
|
|
<script>
|
|
|
|
import { onMount } from "svelte"
|
|
|
|
import { workflowStore, backendUiStore } from "builderStore"
|
2020-05-29 10:31:55 +12:00
|
|
|
import { notifier } from "@beyonk/svelte-notifications"
|
2020-06-02 08:40:02 +12:00
|
|
|
import Flowchart from "./flowchart/FlowChart.svelte"
|
2020-05-28 08:51:32 +12:00
|
|
|
import api from "builderStore/api"
|
|
|
|
|
2020-05-29 10:31:55 +12:00
|
|
|
let selectedWorkflow
|
2020-05-28 08:51:32 +12:00
|
|
|
let uiTree
|
|
|
|
let instanceId = $backendUiStore.selectedDatabase._id
|
|
|
|
|
2020-05-29 10:31:55 +12:00
|
|
|
$: selectedWorkflow = $workflowStore.currentWorkflow
|
2020-05-28 08:51:32 +12:00
|
|
|
|
2020-05-29 10:31:55 +12:00
|
|
|
$: workflowLive = selectedWorkflow && selectedWorkflow.workflow.live
|
|
|
|
|
2020-05-30 03:06:23 +12:00
|
|
|
$: uiTree = selectedWorkflow ? selectedWorkflow.createUiTree() : []
|
2020-05-29 10:31:55 +12:00
|
|
|
|
|
|
|
$: instanceId = $backendUiStore.selectedDatabase._id
|
2020-05-28 08:51:32 +12:00
|
|
|
|
|
|
|
function onSelect(block) {
|
|
|
|
workflowStore.update(state => {
|
|
|
|
state.selectedWorkflowBlock = block
|
|
|
|
return state
|
|
|
|
})
|
|
|
|
}
|
2020-05-29 10:31:55 +12:00
|
|
|
|
|
|
|
function setWorkflowLive(live) {
|
|
|
|
const { workflow } = selectedWorkflow
|
|
|
|
workflow.live = live
|
|
|
|
workflowStore.actions.save({ instanceId, workflow })
|
|
|
|
if (live) {
|
|
|
|
notifier.info(`Workflow ${workflow.name} enabled.`)
|
|
|
|
} else {
|
|
|
|
notifier.danger(`Workflow ${workflow.name} disabled.`)
|
|
|
|
}
|
|
|
|
}
|
2020-05-28 08:51:32 +12:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<section>
|
2020-05-30 03:06:23 +12:00
|
|
|
<Flowchart blocks={uiTree} {onSelect} />
|
2020-05-29 07:20:03 +12:00
|
|
|
<footer>
|
2020-05-29 10:31:55 +12:00
|
|
|
{#if selectedWorkflow}
|
|
|
|
<button
|
|
|
|
class:highlighted={workflowLive}
|
|
|
|
class:hoverable={workflowLive}
|
|
|
|
class="stop-button hoverable">
|
|
|
|
<i class="ri-stop-fill" on:click={() => setWorkflowLive(false)} />
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
class:highlighted={!workflowLive}
|
|
|
|
class:hoverable={!workflowLive}
|
|
|
|
class="play-button hoverable"
|
|
|
|
on:click={() => setWorkflowLive(true)}>
|
|
|
|
<i class="ri-play-fill" />
|
|
|
|
</button>
|
|
|
|
{/if}
|
2020-05-29 07:20:03 +12:00
|
|
|
</footer>
|
2020-05-28 08:51:32 +12:00
|
|
|
</section>
|
2020-05-29 07:20:03 +12:00
|
|
|
|
|
|
|
<style>
|
|
|
|
footer {
|
|
|
|
position: absolute;
|
|
|
|
bottom: 0;
|
|
|
|
right: 0;
|
|
|
|
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;
|
|
|
|
margin-right: 24px;
|
|
|
|
}
|
|
|
|
|
2020-05-29 10:31:55 +12:00
|
|
|
.play-button.highlighted {
|
2020-05-29 07:20:03 +12:00
|
|
|
background: var(--primary);
|
|
|
|
}
|
|
|
|
|
2020-05-29 10:31:55 +12:00
|
|
|
.stop-button.highlighted {
|
2020-05-29 07:20:03 +12:00
|
|
|
background: var(--coral);
|
|
|
|
}
|
|
|
|
</style>
|