only show bot stderr to its owner
This commit is contained in:
parent
8feccfeb23
commit
79479ba8ba
2 changed files with 23 additions and 2 deletions
|
@ -32,6 +32,7 @@ pub struct ApiMatchPlayer {
|
||||||
bot_version_id: Option<i32>,
|
bot_version_id: Option<i32>,
|
||||||
bot_id: Option<i32>,
|
bot_id: Option<i32>,
|
||||||
bot_name: Option<String>,
|
bot_name: Option<String>,
|
||||||
|
owner_id: Option<i32>,
|
||||||
had_errors: Option<bool>,
|
had_errors: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +125,7 @@ pub fn match_data_to_api(data: matches::FullMatchData) -> ApiMatch {
|
||||||
bot_version_id: p.bot_version.as_ref().map(|cb| cb.id),
|
bot_version_id: p.bot_version.as_ref().map(|cb| cb.id),
|
||||||
bot_id: p.bot.as_ref().map(|b| b.id),
|
bot_id: p.bot.as_ref().map(|b| b.id),
|
||||||
bot_name: p.bot.as_ref().map(|b| b.name.clone()),
|
bot_name: p.bot.as_ref().map(|b| b.name.clone()),
|
||||||
|
owner_id: p.bot.as_ref().and_then(|b| b.owner_id),
|
||||||
had_errors: p.base.had_errors,
|
had_errors: p.base.had_errors,
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
import PlayerLog from "$lib/components/PlayerLog.svelte";
|
import PlayerLog from "$lib/components/PlayerLog.svelte";
|
||||||
import Select from "svelte-select";
|
import Select from "svelte-select";
|
||||||
import { PLAYER_COLORS } from "$lib/constants";
|
import { PLAYER_COLORS } from "$lib/constants";
|
||||||
|
import { currentUser } from "$lib/stores/current_user";
|
||||||
|
|
||||||
export let matchLog: string | undefined;
|
export let matchLog: string | undefined;
|
||||||
export let matchData: object;
|
export let matchData: object;
|
||||||
|
@ -42,20 +43,38 @@
|
||||||
playerId: index + 1, // stoopid player number + 1
|
playerId: index + 1, // stoopid player number + 1
|
||||||
label: player["bot_name"],
|
label: player["bot_name"],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// TODO: refactor match logs so that users can no longer get match logs for other players.
|
||||||
|
function currentUserCanSeeStdErr(matchPlayer: object): boolean {
|
||||||
|
if (!matchPlayer["owner_id"]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(matchPlayer, $currentUser);
|
||||||
|
return matchPlayer["owner_id"] === $currentUser?.["user_id"];
|
||||||
|
}
|
||||||
|
|
||||||
|
$: showStdErr =
|
||||||
|
!!selectedPlayer && currentUserCanSeeStdErr(matchData["players"][selectedPlayer["value"]]);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<Visualizer {matchLog} {matchData} />
|
<Visualizer {matchLog} {matchData} />
|
||||||
<div class="output-pane">
|
<div class="output-pane">
|
||||||
<div class="player-select">
|
<div class="player-select">
|
||||||
<Select items={matchPlayerSelectItems} clearable={false} bind:value={selectedPlayer}>
|
<Select
|
||||||
|
items={matchPlayerSelectItems}
|
||||||
|
clearable={false}
|
||||||
|
searchable={false}
|
||||||
|
bind:value={selectedPlayer}
|
||||||
|
>
|
||||||
<div slot="item" let:item>
|
<div slot="item" let:item>
|
||||||
<span style:color={item.color}>{item.label}</span>
|
<span style:color={item.color}>{item.label}</span>
|
||||||
</div>
|
</div>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
<div class="player-log">
|
<div class="player-log">
|
||||||
<PlayerLog {matchLog} playerId={selectedPlayer?.playerId} />
|
<PlayerLog {matchLog} playerId={selectedPlayer?.playerId} {showStdErr} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue