Files
windmill/frontend/src/lib/components/apps/editor/contextPanel/ComponentOutputViewer.svelte
Faton Ramadani fb395655e6 App bugfix (#1049)
* adapt static adapter to cloudflare

* fix(frontend): Various bug fix

* fix typecheck

* numerous fixes

* fix all connects

* fix all connects

* more improvements

* more improvements

* everything work?

Co-authored-by: Ruben Fiszel <ruben@rubenfiszel.com>
2022-12-29 12:47:53 +01:00

36 lines
983 B
Svelte

<script lang="ts">
import ObjectViewer from '$lib/components/propertyPicker/ObjectViewer.svelte'
import { getContext } from 'svelte'
import type { Output } from '../../rx'
import type { AppEditorContext } from '../../types'
export let outputs: string[] = []
export let componentId: string
const { worldStore } = getContext<AppEditorContext>('AppEditorContext')
let object = {}
function subscribeToAllOutputs(observableOutputs: Record<string, Output<any>>) {
if (observableOutputs) {
outputs.forEach((output: string) => {
object[output] = undefined
observableOutputs[output]?.subscribe({
next: (value) => {
object[output] = value
}
})
})
}
}
$: $worldStore?.outputsById[componentId] &&
subscribeToAllOutputs($worldStore.outputsById[componentId])
</script>
{#if Object.keys(object).length > 0}
<ObjectViewer json={object} on:select topBrackets={false} />
{:else}
<div class="text-xs text-gray-500 px-4">No outputs</div>
{/if}