diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-11-12 12:51:58 +0100 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-11-12 12:51:58 +0100 |
commit | b0530be5010494f2db3deded340c16a6dc3cbe56 (patch) | |
tree | a18bd1226ee3cf0be73316cbef7cd357285ad489 /web/pw-server/src/lib/components/log_viewer/PlayerLog.svelte | |
parent | d140759ea539c43f3b9a50b37719b34b58ba430e (diff) | |
download | planetwars.dev-b0530be5010494f2db3deded340c16a6dc3cbe56.tar.xz planetwars.dev-b0530be5010494f2db3deded340c16a6dc3cbe56.zip |
collapse PlayerLog entries
Diffstat (limited to 'web/pw-server/src/lib/components/log_viewer/PlayerLog.svelte')
-rw-r--r-- | web/pw-server/src/lib/components/log_viewer/PlayerLog.svelte | 39 |
1 files changed, 39 insertions, 0 deletions
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 @@ +<script lang="ts"> + import { parsePlayerLog, PlayerLog } from "$lib/log_parser"; + import LogTurn from "./LogTurn.svelte"; + + export let matchLog: string; + export let playerId: number; + + let playerLog: PlayerLog; + let showRawStderr = false; + + $: if (matchLog) { + playerLog = parsePlayerLog(playerId, matchLog); + } else { + playerLog = []; + } +</script> + +<div class="output"> + {#if showRawStderr} + <div class="output-text stderr-text"> + {playerLog.flatMap((turn) => turn.stderr).join("\n")} + </div> + {:else} + <!-- The log should be rerendered when playerId changes --> + {#key playerId} + <div class="log-contents"> + {#each playerLog as logTurn, turnNum} + <LogTurn {logTurn} {turnNum} /> + {/each} + </div> + {/key} + {/if} +</div> + +<style lang="scss"> + .output { + background-color: rgb(41, 41, 41); + } +</style> |