1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-04-19 08:51:03 +00:00

51 lines
1.2 KiB
Svelte
Raw Normal View History

2023-01-11 20:41:15 +01:00
<script>
2023-05-29 21:36:44 +02:00
import Icon from '$components/icon.svelte';
2023-02-15 19:27:51 +01:00
import ObjectGrid from '$components/objectgrid.svelte';
2023-01-11 20:41:15 +01:00
export let collection;
2023-05-29 21:36:44 +02:00
let copySucceeded = false;
async function copy() {
const json = JSON.stringify(collection.stats, undefined, '\t');
await navigator.clipboard.writeText(json);
copySucceeded = true;
setTimeout(() => copySucceeded = false, 1500);
}
2023-01-11 20:41:15 +01:00
</script>
<div class="stats">
<!-- <CodeExample code="db.stats()" /> -->
2023-01-17 16:45:22 +01:00
<div class="grid">
<ObjectGrid
data={collection.stats}
errorTitle={collection.statsError ? 'Error fetching collection stats' : ''}
errorDescription={collection.statsError}
busy={!collection.stats && !collection.statsError && `Fetching stats for ${collection.key}`}
/>
2023-01-17 16:45:22 +01:00
</div>
2023-05-29 21:36:44 +02:00
<div class="buttons">
2023-06-27 17:21:54 +02:00
<button class="button secondary" on:click={copy} disabled={!collection.stats}>
2023-05-29 21:36:44 +02:00
<Icon name={copySucceeded ? 'check' : 'clipboard'} />
Copy JSON
</button>
</div>
2023-01-11 20:41:15 +01:00
</div>
<style>
.stats {
display: grid;
gap: 0.5rem;
2023-05-29 21:36:44 +02:00
grid-template: 1fr auto / 1fr;
2023-01-11 20:41:15 +01:00
}
2023-01-17 16:45:22 +01:00
.stats .grid {
overflow: auto;
min-height: 0;
min-width: 0;
border: 1px solid #ccc;
}
2023-01-11 20:41:15 +01:00
</style>