Show code change

This commit is contained in:
Gleb Koval 2021-07-19 01:24:09 +01:00
parent 2374023667
commit a77074b29e
No known key found for this signature in database
GPG Key ID: 120F2F6DA9D995FB
1 changed files with 8 additions and 2 deletions

View File

@ -5,6 +5,7 @@
import { getGraphs, getPermissions } from "../lib/api";
let add = false;
let showCode = false;
let graphsPromise: ReturnType<typeof getGraphs> = new Promise(() => {});
$: if ($login !== undefined) {
graphsPromise = getGraphs($login?.token);
@ -12,6 +13,9 @@
if (checkPermissions([Permissions.ADD_GRAPH], permissions)) {
add = true;
}
if (checkPermissions([Permissions.MANUAL_GRAPH], permissions)) {
showCode = true;
}
});
}
</script>
@ -25,8 +29,10 @@
{#each graphs as graph}
<a class="item" href="{hrefPrefix}/graph/{graph.graph}">
<h2>{graph.data.name} <span>#{graph.graph}</span></h2>
<p>{graph.data.style}</p>
<code>{graph.data.value}</code>
<p><strong>Style: </strong>{graph.data.style}</p>
{#if showCode}
<code>{graph.data.value}</code>
{/if}
</a>
{/each}
<!-- svelte-ignore a11y-missing-content -->