2021-10-14 11:22:47 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
2021-10-17 20:29:32 +02:00
|
|
|
import * as tr from "../lib/ftl";
|
2021-10-17 18:38:28 +02:00
|
|
|
import type { Stats } from "../lib/proto";
|
2021-10-17 20:29:32 +02:00
|
|
|
import { getCardStats } from "./lib";
|
2021-10-17 18:38:28 +02:00
|
|
|
import CardStats from "./CardStats.svelte";
|
2021-10-14 11:22:47 +02:00
|
|
|
import Revlog from "./Revlog.svelte";
|
|
|
|
|
2021-10-18 09:11:00 +02:00
|
|
|
export let cardId: number | null = null;
|
2021-10-18 09:04:49 +02:00
|
|
|
export let includeRevlog: boolean = true;
|
2021-10-17 20:29:32 +02:00
|
|
|
|
2021-10-18 09:29:33 +02:00
|
|
|
let stats: Stats.CardStatsResponse | null = null;
|
2021-10-17 20:29:32 +02:00
|
|
|
|
2021-10-18 09:11:00 +02:00
|
|
|
$: if (cardId === null) {
|
2021-10-18 09:29:33 +02:00
|
|
|
stats = null;
|
2021-10-17 21:08:19 +02:00
|
|
|
} else {
|
2021-10-18 09:12:10 +02:00
|
|
|
const requestedCardId = cardId;
|
|
|
|
getCardStats(requestedCardId).then((s) => {
|
2021-10-17 21:08:19 +02:00
|
|
|
/* Skip if another update has been triggered in the meantime. */
|
2021-10-18 09:12:10 +02:00
|
|
|
if (requestedCardId === cardId) {
|
2021-10-17 20:29:32 +02:00
|
|
|
stats = s;
|
2021-10-17 21:08:19 +02:00
|
|
|
}
|
|
|
|
});
|
2021-10-17 22:06:44 +02:00
|
|
|
}
|
2021-10-14 11:22:47 +02:00
|
|
|
</script>
|
|
|
|
|
2021-10-18 09:29:33 +02:00
|
|
|
{#if stats !== null}
|
2021-10-17 22:06:44 +02:00
|
|
|
<div class="container">
|
|
|
|
<div>
|
2021-10-17 20:29:32 +02:00
|
|
|
<CardStats {stats} />
|
|
|
|
{#if includeRevlog}
|
|
|
|
<Revlog {stats} />
|
|
|
|
{/if}
|
2021-10-17 22:06:44 +02:00
|
|
|
</div>
|
2021-10-14 11:22:47 +02:00
|
|
|
</div>
|
2021-10-17 22:06:44 +02:00
|
|
|
{:else}
|
|
|
|
<div class="placeholder">{tr.cardStatsNoCard()}</div>
|
|
|
|
{/if}
|
2021-10-14 11:22:47 +02:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.container {
|
2021-10-14 10:49:40 +02:00
|
|
|
max-width: 40em;
|
2021-10-14 11:22:47 +02:00
|
|
|
}
|
2021-10-17 20:29:32 +02:00
|
|
|
|
|
|
|
.placeholder {
|
2021-10-17 22:06:44 +02:00
|
|
|
margin: 0;
|
|
|
|
position: absolute;
|
|
|
|
top: 50%;
|
|
|
|
left: 50%;
|
|
|
|
transform: translate(-50%, -50%);
|
2021-10-17 20:29:32 +02:00
|
|
|
}
|
2021-10-14 11:22:47 +02:00
|
|
|
</style>
|