Skip to content

Commit

Permalink
Rundialog attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
Yngve S. Kristiansen committed Sep 26, 2024
1 parent 5a402b8 commit ad7302d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
<div>
<ExperimentsView/>
<EventView/>
<RunDialog/>
<!--RunDialog/-->
</div>
12 changes: 9 additions & 3 deletions frontend/ert-gui-svelte/ert-gui-svelte/src/lib/RunDialog.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@

<script lang="ts">
import { renderedEvents, experiments } from "../stores/store"
import { renderedSnapshots } from "../stores/consolidatedSnapshots"
</script>

<div>
TODO
<div class="rundialog-container">
{#each $renderedSnapshots as sn}
<div class="iteration-container">
{#each Object.entries(sn.snapshot.reals) as [real, rstate]}
<div>iter-{sn.iteration}, realization{real} - {rstate.status}</div>
{/each}
</div>
{/each}
</div>
Original file line number Diff line number Diff line change
@@ -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<any> = 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)
}
17 changes: 17 additions & 0 deletions frontend/ert-gui-svelte/ert-gui-svelte/src/stores/store.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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))
}

Expand Down

0 comments on commit ad7302d

Please sign in to comment.