From b0530be5010494f2db3deded340c16a6dc3cbe56 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Sat, 12 Nov 2022 12:51:58 +0100 Subject: [PATCH] collapse PlayerLog entries --- .../src/lib/components/OutputPane.svelte | 2 +- .../src/lib/components/PlayerLog.svelte | 153 ----------------- .../lib/components/log_viewer/LogTurn.svelte | 160 ++++++++++++++++++ .../components/log_viewer/PlayerLog.svelte | 39 +++++ .../src/routes/matches/[match_id].svelte | 2 +- web/pw-visualizer/src/index.ts | 21 ++- 6 files changed, 211 insertions(+), 166 deletions(-) delete mode 100644 web/pw-server/src/lib/components/PlayerLog.svelte create mode 100644 web/pw-server/src/lib/components/log_viewer/PlayerLog.svelte diff --git a/web/pw-server/src/lib/components/OutputPane.svelte b/web/pw-server/src/lib/components/OutputPane.svelte index 68c5c3b..65ae507 100644 --- a/web/pw-server/src/lib/components/OutputPane.svelte +++ b/web/pw-server/src/lib/components/OutputPane.svelte @@ -1,5 +1,5 @@ diff --git a/web/pw-server/src/lib/components/PlayerLog.svelte b/web/pw-server/src/lib/components/PlayerLog.svelte deleted file mode 100644 index 60097d8..0000000 --- a/web/pw-server/src/lib/components/PlayerLog.svelte +++ /dev/null @@ -1,153 +0,0 @@ - - -
- {#if showRawStderr} -
- {playerLog.flatMap((turn) => turn.stderr).join("\n")} -
- {:else} -
- {#each playerLog as logTurn, i} -
-
- Turn {i} - {#if logTurn.action?.type === "dispatches"} - {pluralize(logTurn.action.dispatches.length, "dispatch")} - {:else if logTurn.action?.type === "timeout"} - timeout - {:else if logTurn.action?.type === "bad_command"} - invalid command - {/if} -
- {#if logTurn.action?.type === "dispatches"} -
- {#each logTurn.action.dispatches as dispatch} -
-
- {pluralize(dispatch.ship_count, "ship")} from {dispatch.origin} to {dispatch.destination} -
- {#if dispatch.error} - {dispatch.error} - {/if} -
- {/each} -
- {:else if logTurn.action?.type === "bad_command"} -
-
{logTurn.action.command}
-
Parse error: {logTurn.action.error}
-
- {/if} - {#if showStdErr && logTurn.stderr.length > 0} -
stderr
-
- {#each logTurn.stderr as stdErrMsg} -
{stdErrMsg}
- {/each} -
- {/if} -
- {/each} -
- {/if} -
- - diff --git a/web/pw-server/src/lib/components/log_viewer/LogTurn.svelte b/web/pw-server/src/lib/components/log_viewer/LogTurn.svelte index e69de29..80367f4 100644 --- a/web/pw-server/src/lib/components/log_viewer/LogTurn.svelte +++ b/web/pw-server/src/lib/components/log_viewer/LogTurn.svelte @@ -0,0 +1,160 @@ + + +
+
+ + + {#if expanded} + + {:else} + + {/if} + + + Turn {turnNum} + + + {#if logTurn.action?.type === "dispatches"} + {pluralize(logTurn.action.dispatches.length, "dispatch")} + {:else if logTurn.action?.type === "timeout"} + timeout + {:else if logTurn.action?.type === "bad_command"} + invalid command + {/if} +
+ {#if expanded} +
+ {#if logTurn.action?.type === "dispatches"} +
+ {#each logTurn.action.dispatches as dispatch} +
+
+ {pluralize(dispatch.ship_count, "ship")} from {dispatch.origin} to {dispatch.destination} +
+ {#if dispatch.error} + {dispatch.error} + {/if} +
+ {/each} +
+ {:else if logTurn.action?.type === "bad_command"} +
+
{logTurn.action.command}
+
Parse error: {logTurn.action.error}
+
+ {/if} + {#if logTurn.stderr.length > 0} +
stderr
+
+ {#each logTurn.stderr as stdErrMsg} +
{stdErrMsg}
+ {/each} +
+ {/if} +
+ {/if} +
+ + diff --git a/web/pw-server/src/lib/components/log_viewer/PlayerLog.svelte b/web/pw-server/src/lib/components/log_viewer/PlayerLog.svelte new file mode 100644 index 0000000..450fdf2 --- /dev/null +++ b/web/pw-server/src/lib/components/log_viewer/PlayerLog.svelte @@ -0,0 +1,39 @@ + + +
+ {#if showRawStderr} +
+ {playerLog.flatMap((turn) => turn.stderr).join("\n")} +
+ {:else} + + {#key playerId} +
+ {#each playerLog as logTurn, turnNum} + + {/each} +
+ {/key} + {/if} +
+ + diff --git a/web/pw-server/src/routes/matches/[match_id].svelte b/web/pw-server/src/routes/matches/[match_id].svelte index 653b3bf..1d5e072 100644 --- a/web/pw-server/src/routes/matches/[match_id].svelte +++ b/web/pw-server/src/routes/matches/[match_id].svelte @@ -22,7 +22,7 @@