From 0d3fcd4d7d5a68242bd57764b7decb23ab8caa05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iva=CC=81n=20Raskovsky?= Date: Wed, 13 Nov 2024 10:44:20 -0300 Subject: [PATCH] add experimental tree view to snapshots Also show snapshots backwards from newest first. --- .../src/lib/Components/SnapshotsTable.svelte | 605 +++++++++--------- .../src/lib/Components/SnapshotsTree.svelte | 138 ++++ .../routes/(app)/playground/[id]/+page.svelte | 405 ++++++------ .../src/routes/(app)/playground/[id]/+page.ts | 20 +- 4 files changed, 665 insertions(+), 503 deletions(-) create mode 100644 studio/src/lib/Components/SnapshotsTree.svelte diff --git a/studio/src/lib/Components/SnapshotsTable.svelte b/studio/src/lib/Components/SnapshotsTable.svelte index 5d2c9fa..f91ccc2 100644 --- a/studio/src/lib/Components/SnapshotsTable.svelte +++ b/studio/src/lib/Components/SnapshotsTable.svelte @@ -1,319 +1,338 @@

Execution History

- -
- - - - - - {#if controls} - - {/if} - - {#each ltm.snapshots as snapshot, i} - (snapshotIndex = i)} - on:keydown={() => (snapshotIndex = i)} - role="button" - > - - - - {#if controls} - - {/if} - {/each} -
ReasonItemTime
{snapshot.reason} - - {snapshot.time} -
- - {#if snapshot.reason === 'transition' || snapshot.reason === 'start'} - - {/if} -
-
- -
-
- -
- - - - - - - - - {#if controls} - - {/if} - - {#each ltm.errors as error, i} - {@const lastRetry = error.retries.at(-1)} - {@const status = error.success ? 'success' : error.retrying ? 'retrying' : 'error'} - - - - - - - {#if controls} - - {/if} - - {#if showErrorDetails[error.id] === true} - - - - {/if} - {/each} -
ReasonItemTimeStatusRetries
{error.reason} - - {lastRetry.time}{status}{error.retries.length} -
- {#if !showErrorDetails[error.id]} - - {:else} - - {/if} - {#if status === 'error'} - - {/if} -
-
- {lastRetry.type}: - {lastRetry.description} -
-									{lastRetry.details}
-								
-
-
-
+ +
+ + + + + + {#if controls} + + {/if} + + {#each reversedSnapshots as [i, snapshot]} + (snapshotIndex = i)} + on:keydown={() => (snapshotIndex = i)} + role="button" + > + + + + {#if controls} + + {/if} + {/each} +
ReasonItemTime
{snapshot.reason} + + {snapshot.time} +
+ + {#if snapshot.reason === 'transition' || snapshot.reason === 'start'} + + {/if} +
+
+ +
+
+ +

* Experimental

+
    + i + 1)]} + snapshots={[ltm.snapshots, ...ltm.rollbacks.map((r) => r.snapshots)]} + /> +
+
+ +
+ + + + + + + + + {#if controls} + + {/if} + + {#each ltm.errors as error, i} + {@const lastRetry = error.retries.at(-1)} + {@const status = error.success ? 'success' : error.retrying ? 'retrying' : 'error'} + + + + + + + {#if controls} + + {/if} + + {#if showErrorDetails[error.id] === true} + + + + {/if} + {/each} +
ReasonItemTimeStatusRetries
{error.reason} + + {lastRetry.time}{status}{error.retries.length} +
+ {#if !showErrorDetails[error.id]} + + {:else} + + {/if} + {#if status === 'error'} + + {/if} +
+
+ {lastRetry.type}: + {lastRetry.description} +
+                                    {lastRetry.details}
+                                
+
+
+
diff --git a/studio/src/lib/Components/SnapshotsTree.svelte b/studio/src/lib/Components/SnapshotsTree.svelte new file mode 100644 index 0000000..fc9572b --- /dev/null +++ b/studio/src/lib/Components/SnapshotsTree.svelte @@ -0,0 +1,138 @@ + + +{#if Object.keys(groups).length > 0} + {#if Object.keys(groups).length < 2} + {#each Object.entries(groups) as [id, groupIndexes]} +
  • + reason: {snapshots[groupIndexes[0]][step].reason} + + indexes: {JSON.stringify(groupIndexes)} + {#if ended.length > 0} + ended: {JSON.stringify(ended)} + {/if} +
  • + + {/each} + {:else} + {#if ended.length > 0} + ended: {JSON.stringify(ended)} + {/if} +
  • + {#each Object.entries(groups) as [id, groupIndexes]} +
      +
    • + reason: {snapshots[groupIndexes[0]][step].reason} + + indexes: {JSON.stringify(groupIndexes)} +
    • + +
    + {/each} +
  • + {/if} +{:else if ended.length > 0} +
  • + ended: {JSON.stringify(ended)} +
  • +{/if} + + diff --git a/studio/src/routes/(app)/playground/[id]/+page.svelte b/studio/src/routes/(app)/playground/[id]/+page.svelte index 394b828..ed1bc5b 100644 --- a/studio/src/routes/(app)/playground/[id]/+page.svelte +++ b/studio/src/routes/(app)/playground/[id]/+page.svelte @@ -1,227 +1,216 @@ - +
    - {#if ltm} -
    - -
    -

    {ltm.name}

    -
    -
    ID
    -
    {data.id}
    -
    Fqn
    -
    {ltm.fqn}
    -
    Kwargs
    -
    {JSON.stringify(ltm.kwargs)}
    -
    -
    -
    -
    Created At
    -
    {ltm.created_at}
    -
    Updated At
    -
    {ltm.updated_at}
    -
    -
    - -
    -
    -
    -
    - -
    - -
    -
    -
    -
    - -
    - -
    -
    -
    -
    - -
    -

    Visual representation

    - - -
    -
    -
    -
    - - - -
    - {:else} -

    Loading...

    - {/if} + {#if ltm} +
    + +
    +

    {ltm.name}

    +
    +
    ID
    +
    {params.id}
    +
    Fqn
    +
    {ltm.fqn}
    +
    Kwargs
    +
    {JSON.stringify(ltm.kwargs)}
    +
    +
    +
    +
    Created At
    +
    {ltm.created_at}
    +
    Updated At
    +
    {ltm.updated_at}
    +
    +
    + +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    +

    Visual representation

    + + +
    +
    +
    +
    + + + +
    + {:else} +

    Loading...

    + {/if}
    diff --git a/studio/src/routes/(app)/playground/[id]/+page.ts b/studio/src/routes/(app)/playground/[id]/+page.ts index 732b4e3..df8da10 100644 --- a/studio/src/routes/(app)/playground/[id]/+page.ts +++ b/studio/src/routes/(app)/playground/[id]/+page.ts @@ -1,6 +1,22 @@ import type { PageLoad } from './$types'; +import { PUBLIC_API_BASE_URL } from '$env/static/public'; -export const load: PageLoad = ({ params }) => { - return params +export const load: PageLoad = async ({ fetch, params }) => { + + let ltmUrl = `${PUBLIC_API_BASE_URL}ltm/${params.id}?rollbacks=True`; + + const ltm = fetch(ltmUrl) + .then((response) => response.json()) + .then((data) => { + console.log(ltm); + return data; + }) + .catch((error) => { + console.log(error); + return []; + }); + + + return { params, ltm: await ltm } }; export const ssr = false; \ No newline at end of file