From ad7302da82a88c692c66f7c82e16cb30e2466c57 Mon Sep 17 00:00:00 2001 From: "Yngve S. Kristiansen" Date: Thu, 26 Sep 2024 15:03:16 +0200 Subject: [PATCH] Rundialog attempt --- .../ert-gui-svelte/src/lib/MainWindow.svelte | 2 +- .../ert-gui-svelte/src/lib/RunDialog.svelte | 12 +++++++++--- .../src/stores/consolidatedSnapshots.ts | 18 ++++++++++++++++++ .../ert-gui-svelte/src/stores/store.ts | 17 +++++++++++++++++ 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 frontend/ert-gui-svelte/ert-gui-svelte/src/stores/consolidatedSnapshots.ts diff --git a/frontend/ert-gui-svelte/ert-gui-svelte/src/lib/MainWindow.svelte b/frontend/ert-gui-svelte/ert-gui-svelte/src/lib/MainWindow.svelte index 7d52324339e..3d4194f86f3 100644 --- a/frontend/ert-gui-svelte/ert-gui-svelte/src/lib/MainWindow.svelte +++ b/frontend/ert-gui-svelte/ert-gui-svelte/src/lib/MainWindow.svelte @@ -8,5 +8,5 @@
- +
diff --git a/frontend/ert-gui-svelte/ert-gui-svelte/src/lib/RunDialog.svelte b/frontend/ert-gui-svelte/ert-gui-svelte/src/lib/RunDialog.svelte index 853bc13eeef..5cfdbbbef8f 100644 --- a/frontend/ert-gui-svelte/ert-gui-svelte/src/lib/RunDialog.svelte +++ b/frontend/ert-gui-svelte/ert-gui-svelte/src/lib/RunDialog.svelte @@ -1,8 +1,14 @@ -
-TODO +
+ {#each $renderedSnapshots as sn} +
+ {#each Object.entries(sn.snapshot.reals) as [real, rstate]} +
iter-{sn.iteration}, realization{real} - {rstate.status}
+ {/each} +
+ {/each}
\ No newline at end of file diff --git a/frontend/ert-gui-svelte/ert-gui-svelte/src/stores/consolidatedSnapshots.ts b/frontend/ert-gui-svelte/ert-gui-svelte/src/stores/consolidatedSnapshots.ts new file mode 100644 index 00000000000..85e21dd9d87 --- /dev/null +++ b/frontend/ert-gui-svelte/ert-gui-svelte/src/stores/consolidatedSnapshots.ts @@ -0,0 +1,18 @@ +import { writable, type Writable, get } from 'svelte/store' +import type { Experiment, FullSnapshotEvent, SnapshotUpdateEvent } from '../types' +import { merge } from "lodash" + +export const renderedSnapshots: Writable = writable([]) + +const _consolidatedSnapshots: (SnapshotUpdateEvent | FullSnapshotEvent)[] = [] +export const writeSnapshot = (event: SnapshotUpdateEvent | FullSnapshotEvent) => { + // Find iteration + const iter = event.iteration + if (iter === _consolidatedSnapshots.length) { + _consolidatedSnapshots.push(event) + } else { + merge(_consolidatedSnapshots[iter], event) + } + + renderedSnapshots.set(_consolidatedSnapshots) +} diff --git a/frontend/ert-gui-svelte/ert-gui-svelte/src/stores/store.ts b/frontend/ert-gui-svelte/ert-gui-svelte/src/stores/store.ts index 5040953675d..6b0a7933a4c 100644 --- a/frontend/ert-gui-svelte/ert-gui-svelte/src/stores/store.ts +++ b/frontend/ert-gui-svelte/ert-gui-svelte/src/stores/store.ts @@ -1,5 +1,6 @@ import { writable, type Writable, get } from 'svelte/store' import type { Experiment, FullSnapshotEvent } from '../types' +import { writeSnapshot } from './consolidatedSnapshots' const urlParams = new URLSearchParams(window.location.search) const serverURL = decodeURIComponent( @@ -76,7 +77,23 @@ const ws = () => { let eventIndex = 0 let theInterval = null + const snapshotsPerIteration = {} + const graduallyAddRenderedEvents = () => { + if (eventIndex == allEvents.length) { + return + } + + const nextEvent = allEvents[eventIndex] + if ( + "event_type" in nextEvent && ( + nextEvent.event_type == "FullSnapshotUpdateEvent" || + nextEvent.event_type == "SnapshotUpdateEvent" + ) + ) { + writeSnapshot(nextEvent) + } + renderedEvents.set(allEvents.slice(0, ++eventIndex)) }