aboutsummaryrefslogtreecommitdiff
path: root/web/pw-server/src/lib/components/OutputPane.svelte
blob: c72a22e6a00c6d6bc44737fee091ac6273a8ea98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<script lang="ts">
  export let matchLog: string;

  function getStdErr(log: string, botId: number): string {
    let output = [];
    log
      .split("\n")
      .slice(0, -1)
      .forEach((line) => {
        let message = JSON.parse(line);
        if (message["type"] === "stderr" && message["player_id"] === botId) {
          output.push(message["message"]);
        }
      });
    return output.join("\n");
  }

  $: botStdErr = getStdErr(matchLog, 1);
</script>

<div class="output">
  {#if botStdErr.length > 0}
    <h3 class="output-header">stderr:</h3>
    <div class="output-text">
      {botStdErr}
    </div>
  {/if}
</div>

<style lang="scss">
  .output {
    width: 100%;
    overflow-y: scroll;
    background-color: rgb(41, 41, 41);
    padding: 15px;
  }

  .output-text {
    color: #ccc;
    font-family: monospace;
    white-space: pre-wrap;
  }

  .output-header {
    color: #eee;
    padding-bottom: 20px;
  }
</style>