@nymphjs/tilmeld-setup 1.0.0-beta.11 → 1.0.0-beta.111

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,159 +0,0 @@
1
- {#if clientConfig == null || user == null}
2
- <section>
3
- <div style="display: flex; justify-content: center; align-items: center;">
4
- <CircularProgress style="height: 45px; width: 45px;" indeterminate />
5
- </div>
6
- </section>
7
- {:else if entity == null}
8
- <div class="solo-search-container solo-container">
9
- <Fab
10
- on:click={async () => (entity = await Group.factory())}
11
- color="primary"
12
- mini
13
- class="solo-fab"
14
- title="New Group"
15
- >
16
- <Icon component={Svg} viewBox="0 0 24 24">
17
- <path fill="currentColor" d={mdiPlus} />
18
- </Icon>
19
- </Fab>
20
- <Paper class="solo-paper" elevation={6}>
21
- <Icon class="solo-icon" component={Svg} viewBox="0 0 24 24">
22
- <path fill="currentColor" d={mdiMagnify} />
23
- </Icon>
24
- <Input
25
- bind:value={entitySearch}
26
- on:keydown={entitySearchKeyDown}
27
- placeholder="Group Search"
28
- class="solo-input"
29
- />
30
- </Paper>
31
- <Fab
32
- on:click={searchEntities}
33
- disabled={entitySearch === ''}
34
- color="primary"
35
- mini
36
- class="solo-fab"
37
- title="Search"
38
- >
39
- <Icon component={Svg} viewBox="0 0 24 24">
40
- <path fill="currentColor" d={mdiArrowRight} />
41
- </Icon>
42
- </Fab>
43
- </div>
44
- <section>
45
- {#if failureMessage}
46
- <div class="tilmeld-failure">
47
- {failureMessage}
48
- </div>
49
- {/if}
50
-
51
- {#if entitiesSearching}
52
- <div style="display: flex; justify-content: center; align-items: center;">
53
- <CircularProgress style="height: 32px; width: 32px;" indeterminate />
54
- </div>
55
- {:else if entities != null}
56
- <DataTable table$aria-label="Group list" style="width: 100%;">
57
- <Head>
58
- <Row>
59
- {#if !clientConfig.emailUsernames}
60
- <Cell>Groupname</Cell>
61
- {/if}
62
- <Cell>Name</Cell>
63
- <Cell>Email</Cell>
64
- <Cell>Enabled</Cell>
65
- </Row>
66
- </Head>
67
- <Body>
68
- {#each entities as curEntity (curEntity.guid)}
69
- <Row on:click={() => (entity = curEntity)} style="cursor: pointer;">
70
- {#if !clientConfig.emailUsernames}
71
- <Cell>{curEntity.groupname}</Cell>
72
- {/if}
73
- <Cell>{curEntity.name}</Cell>
74
- <Cell>{curEntity.email}</Cell>
75
- <Cell>{curEntity.enabled ? 'Yes' : 'No'}</Cell>
76
- </Row>
77
- {/each}
78
- </Body>
79
- </DataTable>
80
- {/if}
81
- </section>
82
- {:else}
83
- <GroupEdit
84
- {entity}
85
- on:leave={() => {
86
- entity = undefined;
87
- }}
88
- />
89
- {/if}
90
-
91
- <script lang="ts">
92
- import { onMount } from 'svelte';
93
- import queryParser from '@nymphjs/query-parser';
94
- import type {
95
- AdminGroupData,
96
- ClientConfig,
97
- CurrentUserData,
98
- } from '@nymphjs/tilmeld-client';
99
- import type {
100
- Group as GroupClass,
101
- User as UserClass,
102
- } from '@nymphjs/tilmeld-client';
103
- import { mdiMagnify, mdiArrowRight, mdiPlus } from '@mdi/js';
104
- import CircularProgress from '@smui/circular-progress';
105
- import Paper from '@smui/paper';
106
- import DataTable, { Head, Body, Row, Cell } from '@smui/data-table';
107
- import { Input } from '@smui/textfield';
108
- import Fab from '@smui/fab';
109
- import { Icon, Svg } from '@smui/common';
110
-
111
- import { nymph, Group, User } from './nymph';
112
- import GroupEdit from './GroupEdit.svelte';
113
-
114
- let clientConfig: ClientConfig | undefined = undefined;
115
- let user: (UserClass & CurrentUserData) | undefined = undefined;
116
- let entitySearch = '';
117
- let failureMessage: string | undefined = undefined;
118
-
119
- let entity: (GroupClass & AdminGroupData) | undefined = undefined;
120
-
121
- onMount(async () => {
122
- user = (await User.current()) ?? undefined;
123
- });
124
- onMount(async () => {
125
- clientConfig = await User.getClientConfig();
126
- });
127
-
128
- let entitiesSearching = false;
129
- let entities: (GroupClass & AdminGroupData)[] | undefined = undefined;
130
- async function searchEntities() {
131
- entitiesSearching = true;
132
- failureMessage = undefined;
133
- try {
134
- const query = queryParser({
135
- query: entitySearch,
136
- entityClass: Group,
137
- defaultFields: ['groupname', 'name', 'email'],
138
- qrefMap: {
139
- User: {
140
- class: User,
141
- defaultFields: ['username', 'name', 'email'],
142
- },
143
- Group: {
144
- class: Group,
145
- defaultFields: ['groupname', 'name', 'email'],
146
- },
147
- },
148
- });
149
- entities = await nymph.getEntities(...query);
150
- } catch (e: any) {
151
- failureMessage = e?.message;
152
- }
153
- entitiesSearching = false;
154
- }
155
- function entitySearchKeyDown(event: CustomEvent | KeyboardEvent) {
156
- event = event as KeyboardEvent;
157
- if (event.key === 'Enter') searchEntities();
158
- }
159
- </script>