|
1 | 1 | <script lang="ts">
|
2 | 2 | import { graphql } from '$houdini';
|
3 |
| - import { Alert, Button, Heading } from '@nais/ds-svelte-community'; |
| 3 | + import Card from '$lib/Card.svelte'; |
| 4 | + import Pagination from '$lib/Pagination.svelte'; |
| 5 | + import { changeParams, limitOffset } from '$lib/pagination'; |
| 6 | + import { Button, Table, Tbody, Td, Th, Thead, Tr } from '@nais/ds-svelte-community'; |
4 | 7 | import type { PageData } from './$houdini';
|
5 |
| - import Reconciler from './Reconciler.svelte'; |
6 | 8 |
|
7 | 9 | export let data: PageData;
|
8 | 10 |
|
9 |
| - $: ({ AdminReconcilers } = data); |
10 |
| - $: reconcilers = $AdminReconcilers.data?.reconcilers.nodes; |
| 11 | + $: ({ AdminUsers } = data); |
| 12 | + $: ({ limit, offset } = limitOffset($AdminUsers.variables)); |
11 | 13 |
|
12 | 14 | const synchronize = graphql(`
|
13 |
| - mutation Synchronize { |
14 |
| - synchronizeAllTeams { |
15 |
| - correlationID |
16 |
| - } |
| 15 | + mutation SynchronizeUsers { |
| 16 | + synchronizeUsers |
17 | 17 | }
|
18 | 18 | `);
|
19 | 19 |
|
|
24 | 24 | loading = true;
|
25 | 25 | const resp = await synchronize.mutate(null);
|
26 | 26 | loading = false;
|
27 |
| -
|
28 | 27 | if (resp.errors) {
|
29 | 28 | errors = resp.errors.filter((e) => e.message != 'unable to resolve').map((e) => e.message);
|
30 | 29 | }
|
31 | 30 | };
|
32 | 31 | </script>
|
33 | 32 |
|
34 |
| -<Heading size="large"> |
35 |
| - <div class="h"> |
36 |
| - Admin |
37 |
| - <Button disabled={loading} {loading} on:click={triggerSynchronize} size="small"> |
38 |
| - Synchronize all teams |
39 |
| - </Button> |
40 |
| - </div> |
41 |
| -</Heading> |
| 33 | +<div class="h"> |
| 34 | + <Button disabled={loading} {loading} on:click={triggerSynchronize} size="small"> |
| 35 | + Synchronize users |
| 36 | + </Button> |
| 37 | +</div> |
| 38 | + |
42 | 39 | <br />
|
43 | 40 |
|
44 | 41 | {#each errors as e}
|
45 |
| - <Alert variant="error">{e}</Alert> |
| 42 | + <p>{e}</p> |
46 | 43 | {/each}
|
47 | 44 |
|
48 |
| -{#each reconcilers || [] as r} |
49 |
| - <Reconciler reconciler={r} /> |
50 |
| -{:else} |
51 |
| - <p>No reconcilers registered</p> |
52 |
| -{/each} |
| 45 | +<Card> |
| 46 | + {#if $AdminUsers.data} |
| 47 | + <Table zebraStripes> |
| 48 | + <Thead> |
| 49 | + <Tr> |
| 50 | + <Th>Name</Th> |
| 51 | + <Th>Email</Th> |
| 52 | + <Th>External ID</Th> |
| 53 | + <Th>Nais admin</Th> |
| 54 | + </Tr> |
| 55 | + </Thead> |
| 56 | + <Tbody> |
| 57 | + {#each $AdminUsers.data.users.nodes || [] as user} |
| 58 | + <Tr> |
| 59 | + <Td>{user.name}</Td> |
| 60 | + <Td>{user.email}</Td> |
| 61 | + <Td>{user.externalId}</Td> |
| 62 | + <Td>{user.isAdmin ? 'Yes' : ''}</Td> |
| 63 | + </Tr> |
| 64 | + {:else} |
| 65 | + <Tr> |
| 66 | + <Td colspan={99}>No users found</Td> |
| 67 | + </Tr> |
| 68 | + {/each} |
| 69 | + </Tbody> |
| 70 | + </Table> |
| 71 | + |
| 72 | + <Pagination |
| 73 | + style="margin-top: 1rem;" |
| 74 | + pageInfo={$AdminUsers.data.users.pageInfo} |
| 75 | + {limit} |
| 76 | + {offset} |
| 77 | + changePage={(page) => { |
| 78 | + changeParams({ page: page.toString() }); |
| 79 | + }} |
| 80 | + /> |
| 81 | + {/if} |
| 82 | +</Card> |
53 | 83 |
|
54 | 84 | <style>
|
55 | 85 | .h {
|
56 | 86 | display: flex;
|
57 |
| - justify-content: space-between; |
| 87 | + justify-content: flex-end; |
58 | 88 | align-items: center;
|
59 | 89 | }
|
60 | 90 | </style>
|
0 commit comments