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