Merge pull request #184 from ClusterCockpit/177_add_scrambling

fix: add scrambling to user names and projectIds
This commit is contained in:
Jan Eitzinger 2023-07-19 09:30:09 +02:00 committed by GitHub
commit 1062989686
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -119,10 +119,10 @@
<thead> <thead>
<tr> <tr>
<th scope="col"> <th scope="col">
<!-- {({ --> {({
<!-- USER: "Username", --> USER: "Username",
<!-- PROJECT: "Project Name", --> PROJECT: "Project Name",
<!-- })[type]} --> })[type]}
<Button <Button
color={sorting.field == "id" ? "primary" : "light"} color={sorting.field == "id" ? "primary" : "light"}
size="sm" size="sm"
@ -216,14 +216,14 @@
> >
{:else if type == "PROJECT"} {:else if type == "PROJECT"}
<a href="/monitoring/jobs/?project={row.id}" <a href="/monitoring/jobs/?project={row.id}"
>{row.id}</a >{scrambleNames ? scramble(row.id) : row.id}</a
> >
{:else} {:else}
{row.id} {row.id}
{/if} {/if}
</td> </td>
{#if type == "USER"} {#if type == "USER"}
<td>{row?.name ? row.name : ""}</td> <td>{scrambleNames ? scramble(row?.name?row.name:"-") : row?.name?row.name:"-"}</td>
{/if} {/if}
<td>{row.totalJobs}</td> <td>{row.totalJobs}</td>
<td>{row.totalWalltime}</td> <td>{row.totalWalltime}</td>

View File

@ -7,7 +7,10 @@
--> -->
<script context="module"> <script context="module">
export const scrambleNames = window.localStorage.getItem("cc-scramble-names") export const scrambleNames = window.localStorage.getItem("cc-scramble-names")
export const scramble = (str) => [...str].reduce((x, c, i) => x * 7 + c.charCodeAt(0) * i * 21, 5).toString(32) export const scramble = function(str) {
if (str === '-') return str
else return [...str].reduce((x, c, i) => x * 7 + c.charCodeAt(0) * i * 21, 5).toString(32).substr(0, 6)
}
</script> </script>
<script> <script>
import Tag from '../Tag.svelte'; import Tag from '../Tag.svelte';