@nymphjs/tilmeld-setup 1.0.0-beta.13 → 1.0.0-beta.131

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.
@@ -0,0 +1,203 @@
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}
8
+ <div class="solo-search-container solo-container">
9
+ <Fab
10
+ href="/groups/edit/+"
11
+ use={[link]}
12
+ color="primary"
13
+ mini
14
+ class="solo-fab"
15
+ title="New Group"
16
+ >
17
+ <Icon tag="svg" viewBox="0 0 24 24">
18
+ <path fill="currentColor" d={mdiPlus} />
19
+ </Icon>
20
+ </Fab>
21
+ <Paper class="solo-paper" elevation={6}>
22
+ <Icon class="solo-icon" tag="svg" viewBox="0 0 24 24">
23
+ <path fill="currentColor" d={mdiMagnify} />
24
+ </Icon>
25
+ <Input
26
+ bind:value={entitySearch}
27
+ onkeydown={entitySearchKeyDown}
28
+ placeholder="Group Search"
29
+ class="solo-input"
30
+ />
31
+ </Paper>
32
+ <Fab
33
+ onclick={searchEntities}
34
+ disabled={entitySearch === ''}
35
+ color="primary"
36
+ mini
37
+ class="solo-fab"
38
+ title="Search"
39
+ >
40
+ <Icon tag="svg" viewBox="0 0 24 24">
41
+ <path fill="currentColor" d={mdiArrowRight} />
42
+ </Icon>
43
+ </Fab>
44
+ </div>
45
+ <section>
46
+ {#if failureMessage}
47
+ <div class="tilmeld-failure">
48
+ {failureMessage}
49
+ </div>
50
+ {/if}
51
+
52
+ {#if entitiesSearching}
53
+ <div style="display: flex; justify-content: center; align-items: center;">
54
+ <CircularProgress style="height: 32px; width: 32px;" indeterminate />
55
+ </div>
56
+ {:else if entities != null}
57
+ <DataTable table$aria-label="Group list" style="width: 100%;">
58
+ <Head>
59
+ <Row>
60
+ {#if !$clientConfig.emailUsernames}
61
+ <Cell>Groupname</Cell>
62
+ {/if}
63
+ {#if $clientConfig.userFields.includes('name')}
64
+ <Cell>Name</Cell>
65
+ {/if}
66
+ {#if $clientConfig.userFields.includes('email')}
67
+ <Cell>Email</Cell>
68
+ {/if}
69
+ <Cell>Enabled</Cell>
70
+ </Row>
71
+ </Head>
72
+ <Body>
73
+ {#each entities as curEntity (curEntity.guid)}
74
+ <Row>
75
+ {#if !$clientConfig.emailUsernames}
76
+ <Cell
77
+ ><a
78
+ href="/groups/edit/{encodeURIComponent(
79
+ curEntity.guid || '',
80
+ )}"
81
+ use:link>{curEntity.groupname}</a
82
+ ></Cell
83
+ >
84
+ {/if}
85
+ {#if $clientConfig.userFields.includes('name')}
86
+ <Cell
87
+ ><a
88
+ href="/groups/edit/{encodeURIComponent(
89
+ curEntity.guid || '',
90
+ )}"
91
+ use:link>{curEntity.name}</a
92
+ ></Cell
93
+ >
94
+ {/if}
95
+ {#if $clientConfig.userFields.includes('email')}
96
+ <Cell
97
+ ><a
98
+ href="/groups/edit/{encodeURIComponent(
99
+ curEntity.guid || '',
100
+ )}"
101
+ use:link>{curEntity.email}</a
102
+ ></Cell
103
+ >
104
+ {/if}
105
+ <Cell>{curEntity.enabled ? 'Yes' : 'No'}</Cell>
106
+ </Row>
107
+ {:else}
108
+ <Row>
109
+ <Cell
110
+ colspan={1 +
111
+ (!$clientConfig.emailUsernames ? 1 : 0) +
112
+ ($clientConfig.userFields.includes('name') ? 1 : 0) +
113
+ ($clientConfig.userFields.includes('email') ? 1 : 0)}
114
+ >None found.</Cell
115
+ >
116
+ </Row>
117
+ {/each}
118
+ </Body>
119
+ </DataTable>
120
+ {/if}
121
+ </section>
122
+ {/if}
123
+
124
+ <script lang="ts">
125
+ import type { Writable } from 'svelte/store';
126
+ import { getContext } from 'svelte';
127
+ import { link, push } from 'svelte-spa-router';
128
+ import queryParser from '@nymphjs/query-parser';
129
+ import type {
130
+ AdminGroupData,
131
+ ClientConfig,
132
+ CurrentUserData,
133
+ } from '@nymphjs/tilmeld-client';
134
+ import type {
135
+ Group as GroupClass,
136
+ User as UserClass,
137
+ } from '@nymphjs/tilmeld-client';
138
+ import { mdiMagnify, mdiArrowRight, mdiPlus } from '@mdi/js';
139
+ import CircularProgress from '@smui/circular-progress';
140
+ import Paper from '@smui/paper';
141
+ import DataTable, { Head, Body, Row, Cell } from '@smui/data-table';
142
+ import { Input } from '@smui/textfield';
143
+ import Fab from '@smui/fab';
144
+ import { Icon } from '@smui/common';
145
+
146
+ import { nymph, Group, User } from '../nymph.js';
147
+
148
+ let { params }: { params: { query?: string } } = $props();
149
+
150
+ let entitySearch = $derived(params.query ?? '');
151
+ let failureMessage: string | undefined = $state();
152
+
153
+ const clientConfig =
154
+ getContext<Writable<ClientConfig | undefined>>('clientConfigStore');
155
+ const user =
156
+ getContext<Writable<(UserClass & CurrentUserData) | null | undefined>>(
157
+ 'userStore',
158
+ );
159
+
160
+ $effect(() => {
161
+ if (params) {
162
+ handleSearchParam();
163
+ }
164
+ });
165
+
166
+ async function handleSearchParam() {
167
+ if (params.query && params.query !== '') {
168
+ entitiesSearching = true;
169
+ failureMessage = undefined;
170
+ try {
171
+ const query = queryParser({
172
+ query: params.query,
173
+ entityClass: Group,
174
+ defaultFields: ['groupname', 'name', 'email'],
175
+ qrefMap: {
176
+ User: {
177
+ class: User,
178
+ defaultFields: ['username', 'name', 'email'],
179
+ },
180
+ Group: {
181
+ class: Group,
182
+ defaultFields: ['groupname', 'name', 'email'],
183
+ },
184
+ },
185
+ });
186
+ entities = await nymph.getEntities(...query);
187
+ } catch (e: any) {
188
+ failureMessage = e?.message;
189
+ }
190
+ entitiesSearching = false;
191
+ }
192
+ }
193
+
194
+ let entitiesSearching = $state(false);
195
+ let entities: (GroupClass & AdminGroupData)[] | undefined = $state();
196
+ async function searchEntities() {
197
+ push(`/groups/${encodeURIComponent(entitySearch)}`);
198
+ }
199
+ function entitySearchKeyDown(event: CustomEvent | KeyboardEvent) {
200
+ event = event as KeyboardEvent;
201
+ if (event.key === 'Enter') searchEntities();
202
+ }
203
+ </script>
@@ -3,7 +3,12 @@
3
3
 
4
4
  <p>
5
5
  Welcome to Tilmeld. This program handles users and groups. It can be a
6
- little tricky to set up, so read through this introduction carefully.
6
+ little tricky to set up, so read through this introduction carefully. You
7
+ can familiarize yourself with the search box's syntax <a
8
+ href="https://nymph.io/packages/query-parser/"
9
+ target="_blank"
10
+ rel="noreferrer noopener">here</a
11
+ >.
7
12
  </p>
8
13
 
9
14
  <h3>How It Works</h3>
@@ -19,6 +24,10 @@
19
24
  server-side entities. The first user account registered in Tilmeld will be
20
25
  granted admin priveleges with the <code>system/admin</code> ability.
21
26
  </p>
27
+ <p>
28
+ If you create a user account through this setup app, it will not have a
29
+ generated primary group, so you may want to avoid that.
30
+ </p>
22
31
 
23
32
  <h3>Primary Groups</h3>
24
33
  <p>
@@ -62,3 +71,7 @@
62
71
  user is changed, that information is propagated to the group.
63
72
  </p>
64
73
  </section>
74
+
75
+ <script lang="ts">
76
+ let {}: {} = $props();
77
+ </script>
@@ -0,0 +1,9 @@
1
+ <section>
2
+ <h2 style="margin-top: 0;">Not Found</h2>
3
+
4
+ <p>Sorry, that address was not found.</p>
5
+ </section>
6
+
7
+ <script lang="ts">
8
+ let {}: {} = $props();
9
+ </script>