@myrmidon/auth-jwt-admin 1.0.5 → 2.0.0

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.
Files changed (43) hide show
  1. package/esm2022/lib/auth-jwt-admin.module.mjs +120 -0
  2. package/esm2022/lib/components/auth-jwt-registration/auth-jwt-registration.component.mjs +165 -0
  3. package/esm2022/lib/components/confirm-dialog/confirm-dialog.component.mjs +30 -0
  4. package/esm2022/lib/components/password-strength-bar/password-strength-bar.component.mjs +81 -0
  5. package/esm2022/lib/components/state/user-list.repository.mjs +145 -0
  6. package/esm2022/lib/components/user-editor/user-editor.component.mjs +113 -0
  7. package/esm2022/lib/components/user-filter/user-filter.component.mjs +56 -0
  8. package/esm2022/lib/components/user-list/user-list.component.mjs +71 -0
  9. package/esm2022/lib/services/auth-jwt-account.service.mjs +182 -0
  10. package/esm2022/lib/services/dialog.service.mjs +38 -0
  11. package/{esm2020 → esm2022}/lib/validators/password.validators.mjs +48 -48
  12. package/{esm2020 → esm2022}/myrmidon-auth-jwt-admin.mjs +4 -4
  13. package/{esm2020 → esm2022}/public-api.mjs +12 -12
  14. package/fesm2022/myrmidon-auth-jwt-admin.mjs +992 -0
  15. package/fesm2022/myrmidon-auth-jwt-admin.mjs.map +1 -0
  16. package/index.d.ts +5 -5
  17. package/lib/auth-jwt-admin.module.d.ts +30 -30
  18. package/lib/components/auth-jwt-registration/auth-jwt-registration.component.d.ts +37 -37
  19. package/lib/components/confirm-dialog/confirm-dialog.component.d.ts +15 -15
  20. package/lib/components/password-strength-bar/password-strength-bar.component.d.ts +17 -17
  21. package/lib/components/state/user-list.repository.d.ts +36 -36
  22. package/lib/components/user-editor/user-editor.component.d.ts +29 -29
  23. package/lib/components/user-filter/user-filter.component.d.ts +21 -21
  24. package/lib/components/user-list/user-list.component.d.ts +29 -28
  25. package/lib/services/auth-jwt-account.service.d.ts +114 -114
  26. package/lib/services/dialog.service.d.ts +19 -19
  27. package/lib/validators/password.validators.d.ts +6 -6
  28. package/package.json +24 -17
  29. package/public-api.d.ts +8 -8
  30. package/esm2020/lib/auth-jwt-admin.module.mjs +0 -119
  31. package/esm2020/lib/components/auth-jwt-registration/auth-jwt-registration.component.mjs +0 -164
  32. package/esm2020/lib/components/confirm-dialog/confirm-dialog.component.mjs +0 -29
  33. package/esm2020/lib/components/password-strength-bar/password-strength-bar.component.mjs +0 -80
  34. package/esm2020/lib/components/state/user-list.repository.mjs +0 -144
  35. package/esm2020/lib/components/user-editor/user-editor.component.mjs +0 -112
  36. package/esm2020/lib/components/user-filter/user-filter.component.mjs +0 -55
  37. package/esm2020/lib/components/user-list/user-list.component.mjs +0 -69
  38. package/esm2020/lib/services/auth-jwt-account.service.mjs +0 -181
  39. package/esm2020/lib/services/dialog.service.mjs +0 -37
  40. package/fesm2015/myrmidon-auth-jwt-admin.mjs +0 -997
  41. package/fesm2015/myrmidon-auth-jwt-admin.mjs.map +0 -1
  42. package/fesm2020/myrmidon-auth-jwt-admin.mjs +0 -991
  43. package/fesm2020/myrmidon-auth-jwt-admin.mjs.map +0 -1
@@ -0,0 +1,992 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, EventEmitter, Component, Input, Output, Optional, Inject, NgModule } from '@angular/core';
3
+ import * as i1$1 from '@angular/forms';
4
+ import { Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
5
+ import { retry, catchError, take } from 'rxjs/operators';
6
+ import * as i2$1 from '@angular/material/snack-bar';
7
+ import { MatSnackBarModule } from '@angular/material/snack-bar';
8
+ import * as i1 from '@angular/common/http';
9
+ import { HttpParams, HttpClientModule } from '@angular/common/http';
10
+ import * as i2 from '@myrmidon/ng-tools';
11
+ import { NgToolsModule } from '@myrmidon/ng-tools';
12
+ import * as i4 from '@angular/common';
13
+ import { CommonModule } from '@angular/common';
14
+ import * as i5 from '@angular/material/button';
15
+ import { MatButtonModule } from '@angular/material/button';
16
+ import * as i6 from '@angular/material/icon';
17
+ import { MatIconModule } from '@angular/material/icon';
18
+ import * as i7 from '@angular/material/input';
19
+ import { MatInputModule } from '@angular/material/input';
20
+ import * as i8 from '@angular/material/form-field';
21
+ import * as i9 from '@angular/material/progress-spinner';
22
+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
23
+ import { BehaviorSubject, combineLatest, map, debounceTime, take as take$1 } from 'rxjs';
24
+ import { select, createStore, withProps } from '@ngneat/elf';
25
+ import { selectActiveEntity, withEntities, withActiveId, upsertEntities, deleteAllEntities, setActiveId } from '@ngneat/elf-entities';
26
+ import { selectPaginationData, selectCurrentPageEntities, deleteAllPages, withPagination, updatePaginationData, setPage, hasPage, setCurrentPage } from '@ngneat/elf-pagination';
27
+ import { selectRequestStatus, withRequestsCache, withRequestsStatus, updateRequestStatus } from '@ngneat/elf-requests';
28
+ import * as i7$1 from '@angular/material/tooltip';
29
+ import { MatTooltipModule } from '@angular/material/tooltip';
30
+ import '@angular/localize/init';
31
+ import * as i1$2 from '@angular/material/dialog';
32
+ import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
33
+ import * as i2$2 from '@myrmidon/auth-jwt-login';
34
+ import { AuthJwtLoginModule } from '@myrmidon/auth-jwt-login';
35
+ import * as i6$1 from '@angular/material/expansion';
36
+ import { MatExpansionModule } from '@angular/material/expansion';
37
+ import * as i8$1 from '@angular/material/paginator';
38
+ import { MatPaginatorModule } from '@angular/material/paginator';
39
+ import * as i9$1 from '@angular/material/progress-bar';
40
+ import { MatProgressBarModule } from '@angular/material/progress-bar';
41
+ import * as i5$1 from '@angular/material/checkbox';
42
+ import { MatCheckboxModule } from '@angular/material/checkbox';
43
+ import { RouterModule } from '@angular/router';
44
+ import { MatCardModule } from '@angular/material/card';
45
+
46
+ class PasswordValidators {
47
+ /** "Standard" password validator for my API services. */
48
+ static standard() {
49
+ return (control) => {
50
+ if (!control.value) {
51
+ return null;
52
+ }
53
+ if (control.value.length < 8) {
54
+ return {
55
+ passwordtooshort: true,
56
+ };
57
+ }
58
+ if (!/.*[A-Z].*/.test(control.value)) {
59
+ return {
60
+ noupperinpassword: true,
61
+ };
62
+ }
63
+ if (!/.*[a-z].*/.test(control.value)) {
64
+ return {
65
+ nolowerinpassword: true,
66
+ };
67
+ }
68
+ if (!/.*[A-Z].*/.test(control.value)) {
69
+ return {
70
+ noupperinpassword: true,
71
+ };
72
+ }
73
+ if (!/.*[-`~!@#$%^&*()_+=\[\]{};:'",.<>/?|\\].*/.test(control.value)) {
74
+ return {
75
+ nosymbolinpassword: true,
76
+ };
77
+ }
78
+ return null;
79
+ };
80
+ }
81
+ static areEqual(controlName, otherControlName) {
82
+ return (control) => {
83
+ const g = control;
84
+ const a = g.controls[controlName];
85
+ const b = g.controls[otherControlName];
86
+ return a.value !== b.value
87
+ ? {
88
+ areequal: true,
89
+ }
90
+ : null;
91
+ };
92
+ }
93
+ }
94
+
95
+ class AuthJwtAccountService {
96
+ constructor(_http, _error, _env) {
97
+ this._http = _http;
98
+ this._error = _error;
99
+ this._env = _env;
100
+ }
101
+ /**
102
+ * Checks if the specified email address is registered on the server.
103
+ * @param email email address to test.
104
+ * @returns result.
105
+ */
106
+ isEmailRegistered(email) {
107
+ return this._http.get(this._env.get('apiUrl') +
108
+ 'accounts/emailexists/' +
109
+ encodeURIComponent(email));
110
+ }
111
+ /**
112
+ * Checks if the specified user's given name is registered on the server.
113
+ * This name is a nickname chosen by users during registration, and is the key
114
+ * used for referencing users when talking to the server.
115
+ * @param name name to test.
116
+ * @returns result.
117
+ */
118
+ isNameRegistered(name) {
119
+ return this._http.get(this._env.get('apiUrl') +
120
+ 'accounts/nameexists/' +
121
+ encodeURIComponent(name));
122
+ }
123
+ /**
124
+ * Register the user with the specified registration data.
125
+ * @param registration The registration data.
126
+ * @param confirmed True to automatically confirm the user's email address
127
+ * without sending the confirmation email message.
128
+ */
129
+ register(registration, confirmed = false) {
130
+ return this._http.post(this._env.get('apiUrl') +
131
+ 'accounts/register' +
132
+ (confirmed ? '?confirmed=true' : ''), registration);
133
+ }
134
+ /**
135
+ * Resend the confirmation email to the specified address.
136
+ * @param email address.
137
+ */
138
+ resendConfirmEmail(email) {
139
+ return this._http.get(this._env.get('apiUrl') +
140
+ 'accounts/resendconfirm/' +
141
+ encodeURIComponent(email)
142
+ // options
143
+ );
144
+ }
145
+ /**
146
+ * Request a password reset for the specified email address.
147
+ * @param email Email address.
148
+ */
149
+ requestPasswordReset(email) {
150
+ return this._http.post(this._env.get('apiUrl') + 'accounts/resetpassword/request', { email });
151
+ }
152
+ getAllUsers() {
153
+ return this._http
154
+ .get(this._env.get('apiUrl') + 'users', {
155
+ params: new HttpParams().set('pageNumber', '1'),
156
+ })
157
+ .pipe(retry(3), catchError(this._error.handleError));
158
+ }
159
+ getUsers(filter, pageNumber = 1, pageSize = 20) {
160
+ let httpParams = new HttpParams();
161
+ httpParams = httpParams.set('pageNumber', pageNumber.toString());
162
+ httpParams = httpParams.set('pageSize', pageSize.toString());
163
+ if (filter.name) {
164
+ httpParams = httpParams.set('name', filter.name);
165
+ }
166
+ return this._http
167
+ .get(this._env.get('apiUrl') + 'users', {
168
+ params: httpParams,
169
+ })
170
+ .pipe(retry(3), catchError(this._error.handleError));
171
+ }
172
+ /**
173
+ * Get the top N users matching the specified name filter.
174
+ * @param nameFilter The user name filter.
175
+ * @param limit The maximum number of users to get.
176
+ */
177
+ getTopUsers(nameFilter, limit = 10) {
178
+ let httpParams = new HttpParams();
179
+ httpParams = httpParams.set('pageNumber', '1');
180
+ httpParams = httpParams.set('pageSize', limit.toString());
181
+ if (nameFilter) {
182
+ httpParams = httpParams.set('name', nameFilter);
183
+ }
184
+ const options = httpParams.keys().length > 0
185
+ ? {
186
+ params: httpParams,
187
+ }
188
+ : {};
189
+ return this._http
190
+ .get(this._env.get('apiUrl') + 'users', options)
191
+ .pipe(retry(3), catchError(this._error.handleError));
192
+ }
193
+ /**
194
+ * Get information about all the users listed in the specified names.
195
+ * @param names User(s) names.
196
+ */
197
+ getUsersFromNames(names) {
198
+ let httpParams = new HttpParams();
199
+ if (names && names.length > 0) {
200
+ httpParams = httpParams.set('names', names.join(','));
201
+ }
202
+ const options = httpParams.keys().length > 0
203
+ ? {
204
+ params: httpParams,
205
+ }
206
+ : {};
207
+ return this._http
208
+ .get(this._env.get('apiUrl') + 'users-from-names', options)
209
+ .pipe(retry(3), catchError(this._error.handleError));
210
+ }
211
+ /**
212
+ * Get data about the specified user.
213
+ * @param name The user name.
214
+ */
215
+ getUser(name) {
216
+ return this._http
217
+ .get(this._env.get('apiUrl') + 'users/' + name)
218
+ .pipe(retry(3), catchError(this._error.handleError));
219
+ }
220
+ /**
221
+ * Update the editable data for the specified user.
222
+ * @param user The user to update.
223
+ */
224
+ updateUser(user) {
225
+ return this._http
226
+ .put(this._env.get('apiUrl') +
227
+ 'users' +
228
+ (user.emailConfirmed ? '?confirmed=true' : ''), user)
229
+ .pipe(catchError(this._error.handleError));
230
+ }
231
+ /**
232
+ * Request a password reset email for the specified email address.
233
+ * @param email The email address to receive the reset message.
234
+ */
235
+ resetPassword(email) {
236
+ return this._http
237
+ .post(this._env.get('apiUrl') + 'accounts/resetpassword/request', {
238
+ email: email,
239
+ })
240
+ .pipe(catchError(this._error.handleError));
241
+ }
242
+ /**
243
+ * Change the password.
244
+ * @param change The password change data.
245
+ */
246
+ changePassword(change) {
247
+ return this._http
248
+ .post(this._env.get('apiUrl') + 'accounts/changepassword', change)
249
+ .pipe(catchError(this._error.handleError));
250
+ }
251
+ /**
252
+ * Delete the user with the specified username.
253
+ * @param name The user name.
254
+ */
255
+ deleteUser(name) {
256
+ return this._http
257
+ .delete(this._env.get('apiUrl') + 'accounts/' + name)
258
+ .pipe(catchError(this._error.handleError));
259
+ }
260
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: AuthJwtAccountService, deps: [{ token: i1.HttpClient }, { token: i2.ErrorService }, { token: i2.EnvService }], target: i0.ɵɵFactoryTarget.Injectable }); }
261
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: AuthJwtAccountService, providedIn: 'root' }); }
262
+ }
263
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: AuthJwtAccountService, decorators: [{
264
+ type: Injectable,
265
+ args: [{
266
+ providedIn: 'root',
267
+ }]
268
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i2.ErrorService }, { type: i2.EnvService }]; } });
269
+
270
+ class PasswordStrengthBarComponent {
271
+ constructor() {
272
+ this._colors = ['#F00', '#F90', '#FF0', '#9F0', '#0F0'];
273
+ this.strengthChange = new EventEmitter();
274
+ this.strengthChange = new EventEmitter();
275
+ this.bars = [];
276
+ }
277
+ measureStrength(p) {
278
+ let force = 0;
279
+ const regex = /[$-/:-?{-~!"^_`\[\]]/g; // "
280
+ const lowerLetters = /[a-z]+/.test(p);
281
+ const upperLetters = /[A-Z]+/.test(p);
282
+ const numbers = /[0-9]+/.test(p);
283
+ const symbols = regex.test(p);
284
+ const flags = [lowerLetters, upperLetters, numbers, symbols];
285
+ let passedMatches = 0;
286
+ for (const flag of flags) {
287
+ passedMatches += flag === true ? 1 : 0;
288
+ }
289
+ force += 2 * p.length + (p.length >= 10 ? 1 : 0);
290
+ force += passedMatches * 10;
291
+ // penalty (short password)
292
+ force = p.length <= 6 ? Math.min(force, 10) : force;
293
+ // penalty (poor letiety of characters)
294
+ force = passedMatches === 1 ? Math.min(force, 10) : force;
295
+ force = passedMatches === 2 ? Math.min(force, 20) : force;
296
+ force = passedMatches === 3 ? Math.min(force, 40) : force;
297
+ return force;
298
+ }
299
+ getColor(s) {
300
+ let idx = 0;
301
+ if (s <= 10) {
302
+ idx = 0;
303
+ }
304
+ else if (s <= 20) {
305
+ idx = 1;
306
+ }
307
+ else if (s <= 30) {
308
+ idx = 2;
309
+ }
310
+ else if (s <= 40) {
311
+ idx = 3;
312
+ }
313
+ else {
314
+ idx = 4;
315
+ }
316
+ return {
317
+ idx: idx + 1,
318
+ col: this._colors[idx],
319
+ };
320
+ }
321
+ ngOnChanges(changes) {
322
+ const password = changes['passwordToCheck'].currentValue;
323
+ this.setBarColors(5, '#DDD');
324
+ if (password) {
325
+ const strength = this.measureStrength(password);
326
+ const c = this.getColor(strength);
327
+ this.setBarColors(c.idx, c.col);
328
+ this.strengthChange.emit(strength);
329
+ }
330
+ }
331
+ setBarColors(count, col) {
332
+ for (let n = 0; n < count; n++) {
333
+ this.bars[n] = col;
334
+ }
335
+ }
336
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: PasswordStrengthBarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
337
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.1", type: PasswordStrengthBarComponent, selector: "auth-jwt-password-strength-bar", inputs: { passwordToCheck: "passwordToCheck" }, outputs: { strengthChange: "strengthChange" }, usesOnChanges: true, ngImport: i0, template: "<div id=\"strength\">\n <small>strength:</small>\n <ul id=\"strengthBar\">\n <li class=\"point\" [style.background-color]=\"bars[0]\"></li>\n <li class=\"point\" [style.background-color]=\"bars[1]\"></li>\n <li class=\"point\" [style.background-color]=\"bars[2]\"></li>\n <li class=\"point\" [style.background-color]=\"bars[3]\"></li>\n <li class=\"point\" [style.background-color]=\"bars[4]\"></li>\n </ul>\n</div>\n", styles: ["ul#strengthBar{display:inline;list-style:none;margin:0 0 0 15px;padding:0;vertical-align:2px}li.point:last{margin:0!important}li.point{background:#ddd;border-radius:2px;display:inline-block;height:5px;margin-right:1px;width:20px}\n"] }); }
338
+ }
339
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: PasswordStrengthBarComponent, decorators: [{
340
+ type: Component,
341
+ args: [{ selector: 'auth-jwt-password-strength-bar', template: "<div id=\"strength\">\n <small>strength:</small>\n <ul id=\"strengthBar\">\n <li class=\"point\" [style.background-color]=\"bars[0]\"></li>\n <li class=\"point\" [style.background-color]=\"bars[1]\"></li>\n <li class=\"point\" [style.background-color]=\"bars[2]\"></li>\n <li class=\"point\" [style.background-color]=\"bars[3]\"></li>\n <li class=\"point\" [style.background-color]=\"bars[4]\"></li>\n </ul>\n</div>\n", styles: ["ul#strengthBar{display:inline;list-style:none;margin:0 0 0 15px;padding:0;vertical-align:2px}li.point:last{margin:0!important}li.point{background:#ddd;border-radius:2px;display:inline-block;height:5px;margin-right:1px;width:20px}\n"] }]
342
+ }], ctorParameters: function () { return []; }, propDecorators: { passwordToCheck: [{
343
+ type: Input
344
+ }], strengthChange: [{
345
+ type: Output
346
+ }] } });
347
+
348
+ class AuthJwtRegistrationComponent {
349
+ constructor(formBuilder, _snackbar, _accountService) {
350
+ this._snackbar = _snackbar;
351
+ this._accountService = _accountService;
352
+ this.registered = new EventEmitter();
353
+ // form
354
+ this.email = formBuilder.control('', {
355
+ validators: [Validators.required, Validators.email],
356
+ asyncValidators: this.getUniqueEmailValidator(this._accountService).bind(this),
357
+ nonNullable: true,
358
+ });
359
+ this.name = formBuilder.control('', {
360
+ validators: Validators.required,
361
+ asyncValidators: this.getUniqueNameValidator(this._accountService).bind(this),
362
+ nonNullable: true,
363
+ });
364
+ this.firstName = formBuilder.control('', {
365
+ validators: [Validators.required, Validators.maxLength(50)],
366
+ nonNullable: true,
367
+ });
368
+ this.lastName = formBuilder.control('', {
369
+ validators: [Validators.required, Validators.maxLength(50)],
370
+ nonNullable: true,
371
+ });
372
+ // http://stackoverflow.com/questions/35474991/angular-2-form-validating-for-repeat-password
373
+ this.password = formBuilder.control('', {
374
+ validators: [Validators.required, PasswordValidators.standard()],
375
+ nonNullable: true,
376
+ });
377
+ this.confirmPassword = formBuilder.control('', {
378
+ validators: Validators.required,
379
+ nonNullable: true,
380
+ });
381
+ this.form = formBuilder.group({
382
+ email: this.email,
383
+ name: this.name,
384
+ firstName: this.firstName,
385
+ lastName: this.lastName,
386
+ password: this.password,
387
+ confirmPassword: this.confirmPassword,
388
+ }, {
389
+ validators: [
390
+ PasswordValidators.areEqual('password', 'confirmPassword'),
391
+ ],
392
+ });
393
+ }
394
+ /**
395
+ * Creates a unique name validator. There is no dependency injection at this level,
396
+ * but we can use closures. As a matter of fact, we have access to the service instance
397
+ * from the component where we register validators. So we will implement a function
398
+ * that will accept the service as parameter, and create the actual validation function.
399
+ * This function will have access to the service when called during the validation process.
400
+ * See http://restlet.com/blog/2016/02/17/implementing-angular2-forms-beyond-basics-part-2/.
401
+ */
402
+ getUniqueNameValidator(service) {
403
+ return (control) => {
404
+ return new Promise((resolve, reject) => {
405
+ // avoid checking if empty
406
+ if (!control.value) {
407
+ resolve(null);
408
+ }
409
+ else {
410
+ service.isNameRegistered(control.value).subscribe({
411
+ next: (data) => {
412
+ if (!data.isExisting) {
413
+ resolve(null);
414
+ }
415
+ else {
416
+ resolve({ uniqueName: true });
417
+ }
418
+ },
419
+ error: (error) => {
420
+ console.error('Unique name validator error' +
421
+ (error ? JSON.stringify(error) : ''));
422
+ resolve({ uniqueName: true });
423
+ },
424
+ });
425
+ }
426
+ });
427
+ };
428
+ }
429
+ getUniqueEmailValidator(service) {
430
+ return (control) => {
431
+ return new Promise((resolve, reject) => {
432
+ // avoid checking if empty
433
+ if (!control.value) {
434
+ resolve(null);
435
+ }
436
+ else {
437
+ service.isEmailRegistered(control.value).subscribe({
438
+ next: (data) => {
439
+ if (!data.isExisting) {
440
+ resolve(null);
441
+ }
442
+ else {
443
+ resolve({ uniqueEmail: true });
444
+ }
445
+ },
446
+ error: (error) => {
447
+ console.error('Unique email validator error' +
448
+ (error ? JSON.stringify(error) : ''));
449
+ resolve({ uniqueEmail: true });
450
+ },
451
+ });
452
+ }
453
+ });
454
+ };
455
+ }
456
+ onSubmit() {
457
+ if (!this.form.valid ||
458
+ this.busy ||
459
+ this.name.pending ||
460
+ this.email.pending) {
461
+ return;
462
+ }
463
+ const model = {
464
+ email: this.email.value,
465
+ name: this.name.value,
466
+ firstName: this.firstName.value,
467
+ lastName: this.lastName.value,
468
+ password: this.password.value,
469
+ };
470
+ this.busy = true;
471
+ this._accountService
472
+ .register(model)
473
+ .pipe(take(1))
474
+ .subscribe({
475
+ next: () => {
476
+ this.busy = false;
477
+ this._snackbar.open($localize `Registration succeeded`, 'OK');
478
+ this.registered.emit();
479
+ },
480
+ error: (error) => {
481
+ this.busy = false;
482
+ console.error('Registration error' + (error ? JSON.stringify(error) : ''));
483
+ this._snackbar.open($localize `Registration error`, 'OK');
484
+ },
485
+ });
486
+ }
487
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: AuthJwtRegistrationComponent, deps: [{ token: i1$1.FormBuilder }, { token: i2$1.MatSnackBar }, { token: AuthJwtAccountService }], target: i0.ɵɵFactoryTarget.Component }); }
488
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.1", type: AuthJwtRegistrationComponent, selector: "auth-jwt-registration", outputs: { registered: "registered" }, ngImport: i0, template: "<div>\r\n <form role=\"form\" [formGroup]=\"form\" (submit)=\"onSubmit()\">\r\n <fieldset>\r\n <legend i18n>registration</legend>\r\n <!-- email -->\r\n <div class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label i18n>email</mat-label>\r\n <input\r\n matInput\r\n type=\"email\"\r\n id=\"email\"\r\n maxlength=\"256\"\r\n required\r\n autofocus\r\n spellcheck=\"false\"\r\n [formControl]=\"email\"\r\n />\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n $any(email).errors?.required && (email.dirty || email.touched)\r\n \"\r\n >email required</mat-error\r\n >\r\n <mat-error\r\n i18n\r\n *ngIf=\"$any(email).errors?.email && (email.dirty || email.touched)\"\r\n >invalid email</mat-error\r\n >\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n $any(email).errors?.uniqueEmail && (email.dirty || email.touched)\r\n \"\r\n >email already registered</mat-error\r\n >\r\n </mat-form-field>\r\n <mat-icon *ngIf=\"email.pending\">hourglass</mat-icon>\r\n </div>\r\n\r\n <!-- name -->\r\n <div class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label i18n>username</mat-label>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"name\"\r\n maxlength=\"50\"\r\n required\r\n pattern=\"^[a-zA-Z][a-zA-Z0-9]{2,49}$\"\r\n spellcheck=\"false\"\r\n [formControl]=\"name\"\r\n />\r\n <mat-error\r\n i18n\r\n *ngIf=\"$any(name).errors?.required && (name.dirty || name.touched)\"\r\n >username required</mat-error\r\n >\r\n <mat-error\r\n i18n\r\n *ngIf=\"$any(name).errors?.pattern && (name.dirty || name.touched)\"\r\n >invalid username</mat-error\r\n >\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n $any(name).errors?.uniqueName && (name.dirty || name.touched)\r\n \"\r\n >username already registered</mat-error\r\n >\r\n </mat-form-field>\r\n <mat-icon *ngIf=\"name.pending\">hourglass</mat-icon>\r\n </div>\r\n\r\n <!-- first name -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label i18n>first name</mat-label>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"firstName\"\r\n maxlength=\"50\"\r\n required\r\n spellcheck=\"false\"\r\n [formControl]=\"firstName\"\r\n />\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n firstName.hasError('required') &&\r\n (firstName.dirty || firstName.touched)\r\n \"\r\n class=\"text-danger small\"\r\n >\r\n first name required\r\n </mat-error>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- last name -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label i18n>last name</mat-label>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"lastName\"\r\n maxlength=\"50\"\r\n required\r\n spellcheck=\"false\"\r\n [formControl]=\"lastName\"\r\n />\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n lastName.hasError('required') &&\r\n (lastName.dirty || lastName.touched)\r\n \"\r\n class=\"text-danger small\"\r\n >\r\n last name required\r\n </mat-error>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- <div [formGroup]=\"passwords\"> -->\r\n <!-- password -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label i18n>password</mat-label>\r\n <input\r\n matInput\r\n type=\"password\"\r\n name=\"password\"\r\n autocomplete=\"new-password\"\r\n maxlength=\"50\"\r\n required\r\n spellcheck=\"false\"\r\n [formControl]=\"password\"\r\n />\r\n <auth-jwt-password-strength-bar [passwordToCheck]=\"password.value\">\r\n </auth-jwt-password-strength-bar>\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n $any(password).errors?.required &&\r\n (password.dirty || password.touched)\r\n \"\r\n >password required</mat-error\r\n >\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n $any(password).errors?.passwordtooshort &&\r\n (password.dirty || password.touched)\r\n \"\r\n >at least 8 characters</mat-error\r\n >\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n $any(password).errors?.noupperinpassword &&\r\n (password.dirty || password.touched)\r\n \"\r\n >at least 1 uppercase letter</mat-error\r\n >\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n $any(password).errors?.nolowerinpassword &&\r\n (password.dirty || password.touched)\r\n \"\r\n >at least 1 lowercase letter</mat-error\r\n >\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n $any(password).errors?.nosymbolinpassword &&\r\n (password.dirty || password.touched)\r\n \"\r\n >at least 1 punctuation/symbol</mat-error\r\n >\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- confirm password -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label i18n>confirm password</mat-label>\r\n <input\r\n matInput\r\n type=\"password\"\r\n name=\"confirmPassword\"\r\n maxlength=\"50\"\r\n required\r\n spellcheck=\"false\"\r\n [formControl]=\"confirmPassword\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n <div\r\n i18n\r\n *ngIf=\"form.errors?.areequal && confirmPassword.touched\"\r\n style=\"color: red\"\r\n >\r\n password differs from confirmation password\r\n </div>\r\n\r\n <button i18n\r\n mat-raised-button\r\n type=\"submit\"\r\n color=\"primary\"\r\n [disabled]=\"\r\n form.invalid || form.pristine || busy || name.pending || email.pending\r\n \"\r\n >\r\n register\r\n </button>\r\n <mat-progress-spinner diameter=\"20\" *ngIf=\"busy\"></mat-progress-spinner>\r\n </fieldset>\r\n </form>\r\n\r\n <details>\r\n <summary i18n>Hints</summary>\r\n <p i18n>\r\n To register a new user, you must provide his email address, choose a\r\n password, and choose a username, which must be unique (you will be\r\n notified if another user has already taken that name). The username must\r\n include only letters/digits, start with a letter, and be no shorter than 3\r\n characters, nor longer than 50.\r\n </p>\r\n <p i18n>\r\n To promote a decent security level, the password must include at least 8\r\n characters, uppercase and lowercase letters, digits, and punctuation (like\r\n dashes, stops, parentheses, etc.).\r\n </p>\r\n <p i18n>\r\n Once registered, if messaging is enabled on the server side the user will\r\n receive an email message to the email address you specified; he will have\r\n to click on the provided link to complete the registration process.\r\n Otherwise, you should edit the newly created user and confirm the email\r\n registration.\r\n </p>\r\n </details>\r\n</div>\r\n", styles: ["mat-form-field{width:400px}fieldset{border:1px solid silver;border-radius:8px;padding:16px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}details{margin:8px}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1$1.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i1$1.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { kind: "directive", type: i1$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i5.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i6.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i7.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i8.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i8.MatLabel, selector: "mat-label" }, { kind: "directive", type: i8.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "component", type: i9.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "component", type: PasswordStrengthBarComponent, selector: "auth-jwt-password-strength-bar", inputs: ["passwordToCheck"], outputs: ["strengthChange"] }] }); }
489
+ }
490
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: AuthJwtRegistrationComponent, decorators: [{
491
+ type: Component,
492
+ args: [{ selector: 'auth-jwt-registration', template: "<div>\r\n <form role=\"form\" [formGroup]=\"form\" (submit)=\"onSubmit()\">\r\n <fieldset>\r\n <legend i18n>registration</legend>\r\n <!-- email -->\r\n <div class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label i18n>email</mat-label>\r\n <input\r\n matInput\r\n type=\"email\"\r\n id=\"email\"\r\n maxlength=\"256\"\r\n required\r\n autofocus\r\n spellcheck=\"false\"\r\n [formControl]=\"email\"\r\n />\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n $any(email).errors?.required && (email.dirty || email.touched)\r\n \"\r\n >email required</mat-error\r\n >\r\n <mat-error\r\n i18n\r\n *ngIf=\"$any(email).errors?.email && (email.dirty || email.touched)\"\r\n >invalid email</mat-error\r\n >\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n $any(email).errors?.uniqueEmail && (email.dirty || email.touched)\r\n \"\r\n >email already registered</mat-error\r\n >\r\n </mat-form-field>\r\n <mat-icon *ngIf=\"email.pending\">hourglass</mat-icon>\r\n </div>\r\n\r\n <!-- name -->\r\n <div class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label i18n>username</mat-label>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"name\"\r\n maxlength=\"50\"\r\n required\r\n pattern=\"^[a-zA-Z][a-zA-Z0-9]{2,49}$\"\r\n spellcheck=\"false\"\r\n [formControl]=\"name\"\r\n />\r\n <mat-error\r\n i18n\r\n *ngIf=\"$any(name).errors?.required && (name.dirty || name.touched)\"\r\n >username required</mat-error\r\n >\r\n <mat-error\r\n i18n\r\n *ngIf=\"$any(name).errors?.pattern && (name.dirty || name.touched)\"\r\n >invalid username</mat-error\r\n >\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n $any(name).errors?.uniqueName && (name.dirty || name.touched)\r\n \"\r\n >username already registered</mat-error\r\n >\r\n </mat-form-field>\r\n <mat-icon *ngIf=\"name.pending\">hourglass</mat-icon>\r\n </div>\r\n\r\n <!-- first name -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label i18n>first name</mat-label>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"firstName\"\r\n maxlength=\"50\"\r\n required\r\n spellcheck=\"false\"\r\n [formControl]=\"firstName\"\r\n />\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n firstName.hasError('required') &&\r\n (firstName.dirty || firstName.touched)\r\n \"\r\n class=\"text-danger small\"\r\n >\r\n first name required\r\n </mat-error>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- last name -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label i18n>last name</mat-label>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"lastName\"\r\n maxlength=\"50\"\r\n required\r\n spellcheck=\"false\"\r\n [formControl]=\"lastName\"\r\n />\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n lastName.hasError('required') &&\r\n (lastName.dirty || lastName.touched)\r\n \"\r\n class=\"text-danger small\"\r\n >\r\n last name required\r\n </mat-error>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- <div [formGroup]=\"passwords\"> -->\r\n <!-- password -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label i18n>password</mat-label>\r\n <input\r\n matInput\r\n type=\"password\"\r\n name=\"password\"\r\n autocomplete=\"new-password\"\r\n maxlength=\"50\"\r\n required\r\n spellcheck=\"false\"\r\n [formControl]=\"password\"\r\n />\r\n <auth-jwt-password-strength-bar [passwordToCheck]=\"password.value\">\r\n </auth-jwt-password-strength-bar>\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n $any(password).errors?.required &&\r\n (password.dirty || password.touched)\r\n \"\r\n >password required</mat-error\r\n >\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n $any(password).errors?.passwordtooshort &&\r\n (password.dirty || password.touched)\r\n \"\r\n >at least 8 characters</mat-error\r\n >\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n $any(password).errors?.noupperinpassword &&\r\n (password.dirty || password.touched)\r\n \"\r\n >at least 1 uppercase letter</mat-error\r\n >\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n $any(password).errors?.nolowerinpassword &&\r\n (password.dirty || password.touched)\r\n \"\r\n >at least 1 lowercase letter</mat-error\r\n >\r\n <mat-error\r\n i18n\r\n *ngIf=\"\r\n $any(password).errors?.nosymbolinpassword &&\r\n (password.dirty || password.touched)\r\n \"\r\n >at least 1 punctuation/symbol</mat-error\r\n >\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- confirm password -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label i18n>confirm password</mat-label>\r\n <input\r\n matInput\r\n type=\"password\"\r\n name=\"confirmPassword\"\r\n maxlength=\"50\"\r\n required\r\n spellcheck=\"false\"\r\n [formControl]=\"confirmPassword\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n <div\r\n i18n\r\n *ngIf=\"form.errors?.areequal && confirmPassword.touched\"\r\n style=\"color: red\"\r\n >\r\n password differs from confirmation password\r\n </div>\r\n\r\n <button i18n\r\n mat-raised-button\r\n type=\"submit\"\r\n color=\"primary\"\r\n [disabled]=\"\r\n form.invalid || form.pristine || busy || name.pending || email.pending\r\n \"\r\n >\r\n register\r\n </button>\r\n <mat-progress-spinner diameter=\"20\" *ngIf=\"busy\"></mat-progress-spinner>\r\n </fieldset>\r\n </form>\r\n\r\n <details>\r\n <summary i18n>Hints</summary>\r\n <p i18n>\r\n To register a new user, you must provide his email address, choose a\r\n password, and choose a username, which must be unique (you will be\r\n notified if another user has already taken that name). The username must\r\n include only letters/digits, start with a letter, and be no shorter than 3\r\n characters, nor longer than 50.\r\n </p>\r\n <p i18n>\r\n To promote a decent security level, the password must include at least 8\r\n characters, uppercase and lowercase letters, digits, and punctuation (like\r\n dashes, stops, parentheses, etc.).\r\n </p>\r\n <p i18n>\r\n Once registered, if messaging is enabled on the server side the user will\r\n receive an email message to the email address you specified; he will have\r\n to click on the provided link to complete the registration process.\r\n Otherwise, you should edit the newly created user and confirm the email\r\n registration.\r\n </p>\r\n </details>\r\n</div>\r\n", styles: ["mat-form-field{width:400px}fieldset{border:1px solid silver;border-radius:8px;padding:16px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}details{margin:8px}\n"] }]
493
+ }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: i2$1.MatSnackBar }, { type: AuthJwtAccountService }]; }, propDecorators: { registered: [{
494
+ type: Output
495
+ }] } });
496
+
497
+ const PAGE_SIZE = 20;
498
+ class UserListRepository {
499
+ constructor(_accService) {
500
+ this._accService = _accService;
501
+ // create store
502
+ this._store = this.createStore();
503
+ this._lastPageSize = PAGE_SIZE;
504
+ this._loading$ = new BehaviorSubject(false);
505
+ this._saving$ = new BehaviorSubject(false);
506
+ this.loading$ = this._loading$.asObservable();
507
+ this.saving$ = this._saving$.asObservable();
508
+ // combine pagination parameters with page data for our consumers
509
+ this.pagination$ = combineLatest([
510
+ this._store.pipe(selectPaginationData()),
511
+ this._store.pipe(selectCurrentPageEntities()),
512
+ ]).pipe(map(([pagination, data]) => ({ ...pagination, data })), debounceTime(0));
513
+ // the active user, if required
514
+ this.activeUser$ = this._store.pipe(selectActiveEntity());
515
+ // the filter, if required
516
+ this.filter$ = this._store.pipe(select((state) => state.filter));
517
+ this.filter$.subscribe((filter) => {
518
+ // when filter changed, reset any existing page and move to page 1
519
+ const paginationData = this._store.getValue().pagination;
520
+ this._store.update(deleteAllPages());
521
+ // load page 1
522
+ this.loadPage(1, paginationData.perPage);
523
+ });
524
+ // the request status
525
+ this.status$ = this._store.pipe(selectRequestStatus('user-list'));
526
+ // load page 1 and subscribe to pagination
527
+ this.loadPage(1, PAGE_SIZE);
528
+ this.pagination$.subscribe(console.log);
529
+ }
530
+ createStore() {
531
+ const store = createStore({ name: 'user-list' }, withProps({
532
+ filter: {},
533
+ }), withEntities({ idKey: 'userName' }), withActiveId(), withRequestsCache(), withRequestsStatus(), withPagination());
534
+ return store;
535
+ }
536
+ adaptPage(page) {
537
+ // adapt the server page DataPage<T> to Elf pagination
538
+ return {
539
+ currentPage: page.pageNumber,
540
+ perPage: page.pageSize,
541
+ lastPage: page.pageCount,
542
+ total: page.total,
543
+ data: page.items,
544
+ };
545
+ }
546
+ addPage(response) {
547
+ const { data, ...paginationData } = response;
548
+ this._store.update(upsertEntities(data), updatePaginationData(paginationData), setPage(paginationData.currentPage, data.map((c) => c.userName)));
549
+ }
550
+ loadPage(pageNumber, pageSize) {
551
+ if (!pageSize) {
552
+ pageSize = PAGE_SIZE;
553
+ }
554
+ // if the page exists and page size is the same, just move to it
555
+ if (this._store.query(hasPage(pageNumber)) &&
556
+ pageSize === this._lastPageSize) {
557
+ console.log('Page exists: ' + pageNumber);
558
+ this._store.update(setCurrentPage(pageNumber));
559
+ return;
560
+ }
561
+ // reset cached pages if page size changed
562
+ if (this._lastPageSize !== pageSize) {
563
+ this._store.update(deleteAllPages());
564
+ this._lastPageSize = pageSize;
565
+ }
566
+ // load page from server
567
+ this._store.update(updateRequestStatus('user-list', 'pending'));
568
+ this._loading$.next(true);
569
+ this._accService
570
+ .getUsers(this._store.getValue().filter, pageNumber, pageSize)
571
+ .pipe(take$1(1))
572
+ .subscribe((page) => {
573
+ this._loading$.next(false);
574
+ this.addPage({ ...this.adaptPage(page), data: page.items });
575
+ this._store.update(updateRequestStatus('user-list', 'success'));
576
+ });
577
+ }
578
+ setFilter(filter) {
579
+ this._store.update((state) => ({ ...state, filter: filter }));
580
+ }
581
+ clearCache() {
582
+ this._store.update(deleteAllEntities(), deleteAllPages());
583
+ }
584
+ setActive(name) {
585
+ this._store.update(setActiveId(name));
586
+ }
587
+ updateActive(user) {
588
+ const promise = new Promise((resolve, reject) => {
589
+ this._saving$.next(true);
590
+ this._accService.updateUser(user).subscribe({
591
+ next: (_) => {
592
+ this._saving$.next(false);
593
+ this._store.update(upsertEntities(user));
594
+ resolve(true);
595
+ },
596
+ error: (error) => {
597
+ this._saving$.next(false);
598
+ console.error(`Error updating user ${user.userName}: ` +
599
+ JSON.stringify(error || {}));
600
+ resolve(false);
601
+ },
602
+ });
603
+ });
604
+ return promise;
605
+ }
606
+ deleteUser(name) {
607
+ const promise = new Promise((resolve, reject) => {
608
+ this._saving$.next(true);
609
+ this._accService.deleteUser(name).subscribe({
610
+ next: (_) => {
611
+ this._saving$.next(false);
612
+ this.clearCache();
613
+ this.loadPage(1);
614
+ resolve(true);
615
+ },
616
+ error: (error) => {
617
+ this._saving$.next(false);
618
+ console.error(`Error deleting user ${name}: ` + JSON.stringify(error || {}));
619
+ reject(error);
620
+ },
621
+ });
622
+ });
623
+ return promise;
624
+ }
625
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: UserListRepository, deps: [{ token: AuthJwtAccountService }], target: i0.ɵɵFactoryTarget.Injectable }); }
626
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: UserListRepository, providedIn: 'root' }); }
627
+ }
628
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: UserListRepository, decorators: [{
629
+ type: Injectable,
630
+ args: [{ providedIn: 'root' }]
631
+ }], ctorParameters: function () { return [{ type: AuthJwtAccountService }]; } });
632
+
633
+ class UserFilterComponent {
634
+ constructor(formBuilder, _repository) {
635
+ this._repository = _repository;
636
+ this.filter$ = _repository.filter$;
637
+ // form
638
+ this.name = formBuilder.control(null);
639
+ this.form = formBuilder.group({
640
+ name: this.name,
641
+ });
642
+ }
643
+ ngOnInit() {
644
+ this.filter$.subscribe((f) => {
645
+ this.updateForm(f);
646
+ });
647
+ }
648
+ updateForm(filter) {
649
+ this.name.setValue(filter.name || null);
650
+ this.form.markAsPristine();
651
+ }
652
+ reset() {
653
+ this.form.reset();
654
+ this.apply();
655
+ }
656
+ getFilter() {
657
+ return {
658
+ name: this.name.value?.trim(),
659
+ };
660
+ }
661
+ apply() {
662
+ if (this.form.invalid) {
663
+ return;
664
+ }
665
+ const filter = this.getFilter();
666
+ // update filter in state
667
+ this._repository.setFilter(filter);
668
+ }
669
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: UserFilterComponent, deps: [{ token: i1$1.FormBuilder }, { token: UserListRepository }], target: i0.ɵɵFactoryTarget.Component }); }
670
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.1", type: UserFilterComponent, selector: "auth-jwt-user-filter", inputs: { disabled: "disabled" }, ngImport: i0, template: "<form [formGroup]=\"form\" (submit)=\"apply()\" ng-disabled=\"disabled\">\n <div class=\"form-row\">\n <mat-form-field>\n <mat-label i18n>name or ID</mat-label>\n <input matInput [formControl]=\"name\" />\n <button\n mat-icon-button\n matSuffix\n type=\"button\"\n (click)=\"reset()\"\n color=\"warn\"\n i18n-matTooltip\n matTooltip=\"Reset filters\"\n [disabled]=\"disabled\"\n >\n <mat-icon>clear</mat-icon>\n </button>\n </mat-form-field>\n\n <button\n style=\"margin-top: -20px\"\n type=\"submit\"\n mat-icon-button\n color=\"primary\"\n [disabled]=\"disabled\"\n i18n-matTooltip\n matTooltip=\"Apply filters\"\n >\n <mat-icon>check_circle</mat-icon>\n </button>\n </div>\n</form>\n", styles: [".form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}\n"], dependencies: [{ kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i5.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i6.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i7.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i8.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i8.MatLabel, selector: "mat-label" }, { kind: "directive", type: i8.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "directive", type: i7$1.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }] }); }
671
+ }
672
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: UserFilterComponent, decorators: [{
673
+ type: Component,
674
+ args: [{ selector: 'auth-jwt-user-filter', template: "<form [formGroup]=\"form\" (submit)=\"apply()\" ng-disabled=\"disabled\">\n <div class=\"form-row\">\n <mat-form-field>\n <mat-label i18n>name or ID</mat-label>\n <input matInput [formControl]=\"name\" />\n <button\n mat-icon-button\n matSuffix\n type=\"button\"\n (click)=\"reset()\"\n color=\"warn\"\n i18n-matTooltip\n matTooltip=\"Reset filters\"\n [disabled]=\"disabled\"\n >\n <mat-icon>clear</mat-icon>\n </button>\n </mat-form-field>\n\n <button\n style=\"margin-top: -20px\"\n type=\"submit\"\n mat-icon-button\n color=\"primary\"\n [disabled]=\"disabled\"\n i18n-matTooltip\n matTooltip=\"Apply filters\"\n >\n <mat-icon>check_circle</mat-icon>\n </button>\n </div>\n</form>\n", styles: [".form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}\n"] }]
675
+ }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: UserListRepository }]; }, propDecorators: { disabled: [{
676
+ type: Input
677
+ }] } });
678
+
679
+ // https://medium.com/@tarik.nzl/making-use-of-dialogs-in-material-2-mddialog-7533d27df41
680
+ class ConfirmDialogComponent {
681
+ constructor(dialogRef, data) {
682
+ this.dialogRef = dialogRef;
683
+ this.data = data;
684
+ this.title = $localize `Confirm`;
685
+ this.prompt = $localize `Confirm operation?`;
686
+ this.ok = $localize `yes`;
687
+ this.cancel = $localize `no`;
688
+ }
689
+ ngOnInit() { }
690
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: ConfirmDialogComponent, deps: [{ token: i1$2.MatDialogRef }, { token: MAT_DIALOG_DATA, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
691
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.1", type: ConfirmDialogComponent, selector: "ng-component", ngImport: i0, template: "<h1 mat-dialog-title>{{ title }}</h1>\r\n<mat-dialog-content>\r\n {{ prompt }}\r\n</mat-dialog-content>\r\n<mat-dialog-actions>\r\n <button\r\n type=\"button\"\r\n mat-raised-button\r\n color=\"warn\"\r\n (click)=\"dialogRef.close(true)\"\r\n >\r\n {{ ok }}\r\n </button>\r\n <button type=\"button\" mat-button (click)=\"dialogRef.close()\">\r\n {{ cancel }}\r\n </button>\r\n</mat-dialog-actions>\r\n", styles: [""], dependencies: [{ kind: "component", type: i5.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: i1$2.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i1$2.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "directive", type: i1$2.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }] }); }
692
+ }
693
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: ConfirmDialogComponent, decorators: [{
694
+ type: Component,
695
+ args: [{ template: "<h1 mat-dialog-title>{{ title }}</h1>\r\n<mat-dialog-content>\r\n {{ prompt }}\r\n</mat-dialog-content>\r\n<mat-dialog-actions>\r\n <button\r\n type=\"button\"\r\n mat-raised-button\r\n color=\"warn\"\r\n (click)=\"dialogRef.close(true)\"\r\n >\r\n {{ ok }}\r\n </button>\r\n <button type=\"button\" mat-button (click)=\"dialogRef.close()\">\r\n {{ cancel }}\r\n </button>\r\n</mat-dialog-actions>\r\n" }]
696
+ }], ctorParameters: function () { return [{ type: i1$2.MatDialogRef }, { type: undefined, decorators: [{
697
+ type: Optional
698
+ }, {
699
+ type: Inject,
700
+ args: [MAT_DIALOG_DATA]
701
+ }] }]; } });
702
+
703
+ // https://medium.com/@tarik.nzl/making-use-of-dialogs-in-material-2-mddialog-7533d27df41
704
+ /**
705
+ * This service acts as a wrapper for MatDialog to simplify the process of calling
706
+ * the dialog and subscribing to it. What it will do is create an Instance of
707
+ * MatDialog with our custom component (ConfirmDialogComponent). Then it will set
708
+ * any public properties it needs to by setting the properties on the
709
+ * componentInstance object. It will return the observable afterClosed()
710
+ * to the caller so they can subscribe to it. This will emit an event whenever
711
+ * the dialog is closed.
712
+ */
713
+ class DialogService {
714
+ constructor(dialog) {
715
+ this.dialog = dialog;
716
+ }
717
+ confirm(title, prompt, ok = $localize `yes`, cancel = $localize `no`) {
718
+ let dialogRef;
719
+ dialogRef = this.dialog.open(ConfirmDialogComponent);
720
+ dialogRef.componentInstance.title = title;
721
+ dialogRef.componentInstance.prompt = prompt;
722
+ dialogRef.componentInstance.ok = ok;
723
+ dialogRef.componentInstance.cancel = cancel;
724
+ return dialogRef.afterClosed();
725
+ }
726
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: DialogService, deps: [{ token: i1$2.MatDialog }], target: i0.ɵɵFactoryTarget.Injectable }); }
727
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: DialogService, providedIn: 'root' }); }
728
+ }
729
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: DialogService, decorators: [{
730
+ type: Injectable,
731
+ args: [{
732
+ providedIn: 'root'
733
+ }]
734
+ }], ctorParameters: function () { return [{ type: i1$2.MatDialog }]; } });
735
+
736
+ class UserEditorComponent {
737
+ set user(value) {
738
+ this._user = value;
739
+ this.updateForm(value);
740
+ }
741
+ get user() {
742
+ return this._user;
743
+ }
744
+ constructor(formBuilder, _authService) {
745
+ this._authService = _authService;
746
+ // events
747
+ this.userChange = new EventEmitter();
748
+ this.editorClose = new EventEmitter();
749
+ // form
750
+ this.email = formBuilder.control(null, [
751
+ Validators.required,
752
+ Validators.email,
753
+ ]);
754
+ this.emailConfirmed = formBuilder.control(false);
755
+ this.lockoutEnabled = formBuilder.control(false);
756
+ this.firstName = formBuilder.control(null, [
757
+ Validators.required,
758
+ Validators.maxLength(50),
759
+ ]);
760
+ this.lastName = formBuilder.control(null, [
761
+ Validators.required,
762
+ Validators.maxLength(50),
763
+ ]);
764
+ this.roles = formBuilder.control(null, Validators.maxLength(200));
765
+ this.form = formBuilder.group({
766
+ email: this.email,
767
+ emailConfirmed: this.emailConfirmed,
768
+ lockoutEnabled: this.lockoutEnabled,
769
+ firstName: this.firstName,
770
+ lastName: this.lastName,
771
+ roles: this.roles,
772
+ });
773
+ }
774
+ ngOnInit() { }
775
+ updateForm(user) {
776
+ if (!user) {
777
+ this.form.reset();
778
+ }
779
+ else {
780
+ this.email.setValue(user.email);
781
+ this.emailConfirmed.setValue(user.emailConfirmed);
782
+ this.lockoutEnabled.setValue(user.lockoutEnabled);
783
+ this.firstName.setValue(user.firstName);
784
+ this.lastName.setValue(user.lastName);
785
+ if (user.roles?.length > 0) {
786
+ this.roles.setValue(user.roles.join(' '));
787
+ }
788
+ else {
789
+ this.roles.setValue(null);
790
+ }
791
+ }
792
+ }
793
+ getUserFromForm() {
794
+ return {
795
+ userName: this._user?.userName || '',
796
+ email: this.email.value,
797
+ emailConfirmed: this.emailConfirmed.value,
798
+ lockoutEnabled: this.lockoutEnabled.value,
799
+ firstName: this.firstName.value,
800
+ lastName: this.lastName.value,
801
+ roles: this.roles.value
802
+ ? this.roles.value.split(' ').filter((s) => s)
803
+ : [],
804
+ };
805
+ }
806
+ endLockout() {
807
+ if (this.unlocked) {
808
+ return;
809
+ }
810
+ this._user.lockoutEnd = this._authService.getUTCDate();
811
+ this.unlocked = true;
812
+ }
813
+ close() {
814
+ this.editorClose.emit();
815
+ }
816
+ save() {
817
+ if (this.form.invalid) {
818
+ return;
819
+ }
820
+ this.userChange.emit(this.getUserFromForm());
821
+ }
822
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: UserEditorComponent, deps: [{ token: i1$1.UntypedFormBuilder }, { token: i2$2.AuthJwtService }], target: i0.ɵɵFactoryTarget.Component }); }
823
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.1", type: UserEditorComponent, selector: "auth-jwt-user-editor", inputs: { user: "user" }, outputs: { userChange: "userChange", editorClose: "editorClose" }, ngImport: i0, template: "<form [formGroup]=\"form\" (submit)=\"save()\">\n <div class=\"form-row\">\n <!-- email -->\n <mat-form-field>\n <mat-label i18n>email</mat-label>\n <input type=\"text\" matInput [formControl]=\"email\" />\n <mat-error\n i18n\n *ngIf=\"email.hasError('required') && (email.dirty || email.touched)\"\n >\n email address required\n </mat-error>\n <mat-error\n i18n\n *ngIf=\"email.hasError('pattern') && (email.dirty || email.touched)\"\n >\n invalid email address\n </mat-error>\n </mat-form-field>\n\n <!-- emailConfirmed -->\n <mat-checkbox [formControl]=\"emailConfirmed\" i18n\n >email address confirmed</mat-checkbox\n >\n </div>\n\n <!-- lockoutEnabled -->\n <div class=\"form-row\">\n <mat-checkbox [formControl]=\"lockoutEnabled\" i18n\n >lockout enabled</mat-checkbox\n >\n <button\n mat-icon-button\n color=\"primary\"\n (click)=\"endLockout()\"\n [disabled]=\"unlocked\"\n i18n-matTooltip\n matTooltip=\"Unlock this user if locked\"\n >\n <mat-icon>lock_open</mat-icon>\n </button>\n </div>\n\n <div class=\"form-row\">\n <!-- firstName -->\n <mat-form-field>\n <mat-label i18n>first name</mat-label>\n <input type=\"text\" matInput [formControl]=\"firstName\" />\n <mat-error\n i18n\n *ngIf=\"\n firstName.hasError('required') &&\n (firstName.dirty || firstName.touched)\n \"\n >\n first name required\n </mat-error>\n <mat-error\n i18n\n *ngIf=\"\n firstName.hasError('maxlength') &&\n (firstName.dirty || firstName.touched)\n \"\n >\n first name too long\n </mat-error>\n </mat-form-field>\n\n <!-- lastName -->\n <mat-form-field>\n <mat-label i18n>last name</mat-label>\n <input type=\"text\" matInput [formControl]=\"lastName\" />\n <mat-error\n i18n\n *ngIf=\"\n lastName.hasError('required') && (lastName.dirty || lastName.touched)\n \"\n >\n last name required\n </mat-error>\n <mat-error\n i18n\n *ngIf=\"\n lastName.hasError('maxlength') && (lastName.dirty || lastName.touched)\n \"\n >\n last name too long\n </mat-error>\n </mat-form-field>\n </div>\n\n <!-- roles -->\n <div>\n <mat-form-field style=\"width: 16em\">\n <mat-label i18n>roles</mat-label>\n <input type=\"text\" matInput [formControl]=\"roles\" />\n <mat-error\n i18n\n *ngIf=\"roles.hasError('maxlength') && (roles.dirty || roles.touched)\"\n >\n too long\n </mat-error>\n <mat-hint i18n>roles (separated by space)</mat-hint>\n </mat-form-field>\n </div>\n\n <!-- buttons -->\n <br />\n <div>\n <button\n type=\"button\"\n mat-icon-button\n color=\"warn\"\n i18n-matTooltip\n matTooltip=\"Close\"\n (click)=\"close()\"\n >\n <mat-icon>cancel</mat-icon>\n </button>\n <button\n type=\"submit\"\n mat-icon-button\n color=\"primary\"\n [disabled]=\"form.invalid\"\n i18n-matTooltip\n matTooltip=\"Save user\"\n >\n <mat-icon>check_circle</mat-icon>\n </button>\n </div>\n</form>\n", styles: [".form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i5.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i5$1.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex"], exportAs: ["matCheckbox"] }, { kind: "component", type: i6.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i7.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i8.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i8.MatLabel, selector: "mat-label" }, { kind: "directive", type: i8.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i8.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i7$1.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }] }); }
824
+ }
825
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: UserEditorComponent, decorators: [{
826
+ type: Component,
827
+ args: [{ selector: 'auth-jwt-user-editor', template: "<form [formGroup]=\"form\" (submit)=\"save()\">\n <div class=\"form-row\">\n <!-- email -->\n <mat-form-field>\n <mat-label i18n>email</mat-label>\n <input type=\"text\" matInput [formControl]=\"email\" />\n <mat-error\n i18n\n *ngIf=\"email.hasError('required') && (email.dirty || email.touched)\"\n >\n email address required\n </mat-error>\n <mat-error\n i18n\n *ngIf=\"email.hasError('pattern') && (email.dirty || email.touched)\"\n >\n invalid email address\n </mat-error>\n </mat-form-field>\n\n <!-- emailConfirmed -->\n <mat-checkbox [formControl]=\"emailConfirmed\" i18n\n >email address confirmed</mat-checkbox\n >\n </div>\n\n <!-- lockoutEnabled -->\n <div class=\"form-row\">\n <mat-checkbox [formControl]=\"lockoutEnabled\" i18n\n >lockout enabled</mat-checkbox\n >\n <button\n mat-icon-button\n color=\"primary\"\n (click)=\"endLockout()\"\n [disabled]=\"unlocked\"\n i18n-matTooltip\n matTooltip=\"Unlock this user if locked\"\n >\n <mat-icon>lock_open</mat-icon>\n </button>\n </div>\n\n <div class=\"form-row\">\n <!-- firstName -->\n <mat-form-field>\n <mat-label i18n>first name</mat-label>\n <input type=\"text\" matInput [formControl]=\"firstName\" />\n <mat-error\n i18n\n *ngIf=\"\n firstName.hasError('required') &&\n (firstName.dirty || firstName.touched)\n \"\n >\n first name required\n </mat-error>\n <mat-error\n i18n\n *ngIf=\"\n firstName.hasError('maxlength') &&\n (firstName.dirty || firstName.touched)\n \"\n >\n first name too long\n </mat-error>\n </mat-form-field>\n\n <!-- lastName -->\n <mat-form-field>\n <mat-label i18n>last name</mat-label>\n <input type=\"text\" matInput [formControl]=\"lastName\" />\n <mat-error\n i18n\n *ngIf=\"\n lastName.hasError('required') && (lastName.dirty || lastName.touched)\n \"\n >\n last name required\n </mat-error>\n <mat-error\n i18n\n *ngIf=\"\n lastName.hasError('maxlength') && (lastName.dirty || lastName.touched)\n \"\n >\n last name too long\n </mat-error>\n </mat-form-field>\n </div>\n\n <!-- roles -->\n <div>\n <mat-form-field style=\"width: 16em\">\n <mat-label i18n>roles</mat-label>\n <input type=\"text\" matInput [formControl]=\"roles\" />\n <mat-error\n i18n\n *ngIf=\"roles.hasError('maxlength') && (roles.dirty || roles.touched)\"\n >\n too long\n </mat-error>\n <mat-hint i18n>roles (separated by space)</mat-hint>\n </mat-form-field>\n </div>\n\n <!-- buttons -->\n <br />\n <div>\n <button\n type=\"button\"\n mat-icon-button\n color=\"warn\"\n i18n-matTooltip\n matTooltip=\"Close\"\n (click)=\"close()\"\n >\n <mat-icon>cancel</mat-icon>\n </button>\n <button\n type=\"submit\"\n mat-icon-button\n color=\"primary\"\n [disabled]=\"form.invalid\"\n i18n-matTooltip\n matTooltip=\"Save user\"\n >\n <mat-icon>check_circle</mat-icon>\n </button>\n </div>\n</form>\n", styles: [".form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}\n"] }]
828
+ }], ctorParameters: function () { return [{ type: i1$1.UntypedFormBuilder }, { type: i2$2.AuthJwtService }]; }, propDecorators: { user: [{
829
+ type: Input
830
+ }], userChange: [{
831
+ type: Output
832
+ }], editorClose: [{
833
+ type: Output
834
+ }] } });
835
+
836
+ class UserListComponent {
837
+ constructor(_repository, _dialogService, _gravatarService) {
838
+ this._repository = _repository;
839
+ this._dialogService = _dialogService;
840
+ this._gravatarService = _gravatarService;
841
+ this.pagination$ = _repository.pagination$;
842
+ this.active$ = _repository.activeUser$;
843
+ this.loading$ = _repository.loading$;
844
+ }
845
+ pageChange(event) {
846
+ this._repository.loadPage(event.pageIndex + 1, event.pageSize);
847
+ }
848
+ deleteUser(user) {
849
+ this._dialogService
850
+ .confirm($localize `Confirm`, $localize `Delete user ${user.userName}?`)
851
+ .pipe(take(1))
852
+ .subscribe((yes) => {
853
+ if (!yes) {
854
+ return;
855
+ }
856
+ this._repository.deleteUser(user.userName).finally(() => {
857
+ this._repository.clearCache();
858
+ this._repository.loadPage(1);
859
+ });
860
+ });
861
+ }
862
+ setActiveUser(user) {
863
+ this._repository.setActive(user?.userName || null);
864
+ }
865
+ resetActiveUser() {
866
+ this._repository.setActive(null);
867
+ }
868
+ saveActiveUser(user) {
869
+ this._repository.updateActive(user);
870
+ this._repository.setActive(null);
871
+ }
872
+ onUserEditorClose() {
873
+ this._repository.setActive(null);
874
+ }
875
+ getGravatarUrl(email, size = 80) {
876
+ return this._gravatarService.buildGravatarUrl(email, size);
877
+ }
878
+ clearCache() {
879
+ this._repository.clearCache();
880
+ this._repository.loadPage(1);
881
+ }
882
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: UserListComponent, deps: [{ token: UserListRepository }, { token: DialogService }, { token: i2$2.GravatarService }], target: i0.ɵɵFactoryTarget.Component }); }
883
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.1", type: UserListComponent, selector: "auth-jwt-user-list", ngImport: i0, template: "<div id=\"container\">\n <div>\n <!-- filters -->\n <div id=\"filters\">\n <auth-jwt-user-filter></auth-jwt-user-filter>\n </div>\n\n <!-- list -->\n <div id=\"list\" *ngIf=\"pagination$ | async as pagination\">\n <div *ngIf=\"loading$ | async\" gdArea=\"progress\">\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\n </div>\n <table>\n <thead>\n <td></td>\n <td></td>\n <th i18n>name</th>\n <th i18n class=\"noif-lt-md\">first</th>\n <th i18n class=\"noif-lt-md\">last</th>\n <th i18n class=\"noif-lt-md\">email</th>\n <th i18n>roles</th>\n <th i18n class=\"noif-lt-md\">lock end</th>\n </thead>\n <tbody>\n <tr *ngFor=\"let user of pagination.data\">\n <td>\n <button\n mat-icon-button\n type=\"button\"\n i18n-matTooltip\n matTooltip=\"Edit this user\"\n color=\"primary\"\n (click)=\"setActiveUser(user)\"\n >\n <mat-icon>mode_edit</mat-icon>\n </button>\n <button\n mat-icon-button\n type=\"button\"\n i18n-matTooltip\n matTooltip=\"Delete this user\"\n color=\"warn\"\n (click)=\"deleteUser(user)\"\n >\n <mat-icon>remove_circle</mat-icon>\n </button>\n </td>\n <td>\n <img\n alt=\"avatar\"\n [src]=\"getGravatarUrl(user.email, 32)\"\n [alt]=\"user.userName\"\n />\n </td>\n <td>{{ user.userName }}</td>\n <td class=\"noif-lt-md\">{{ user.firstName }}</td>\n <td class=\"noif-lt-md\">{{ user.lastName }}</td>\n <td class=\"noif-lt-md\">\n <a [href]=\"'mailto:' + user.email\">{{ user.email }}</a>\n </td>\n <td>{{ user.roles.join(\" \") }}</td>\n <td class=\"noif-lt-md\">{{ user.lockoutEnd }}</td>\n </tr>\n </tbody>\n </table>\n\n <!-- paginator -->\n <div id=\"paginator\" class=\"form-row\">\n <button\n type=\"button\"\n mat-icon-button\n color=\"warn\"\n i18n-matmatTooltip\n matTooltip=\"Clear items cache\"\n (click)=\"clearCache()\"\n >\n <mat-icon>autorenew</mat-icon>\n </button>\n\n <mat-paginator\n gdArea=\"pager\"\n gdAlignColumns=\"center\"\n gdAlignRows=\"start\"\n [length]=\"pagination.total\"\n [pageSize]=\"pagination.perPage\"\n [pageSizeOptions]=\"[20, 50, 75, 100]\"\n [pageIndex]=\"pagination.currentPage - 1\"\n [showFirstLastButtons]=\"true\"\n (page)=\"pageChange($event)\"\n ></mat-paginator>\n </div>\n </div>\n </div>\n\n <!-- editor -->\n <mat-expansion-panel\n id=\"editor\"\n [expanded]=\"active$ | async\"\n [disabled]=\"!(active$ | async)\"\n >\n <div *ngIf=\"active$ | async as active\">\n <fieldset>\n <legend>{{ active.userName }}</legend>\n <auth-jwt-user-editor\n [user]=\"active\"\n (userChange)=\"saveActiveUser($event)\"\n (editorClose)=\"resetActiveUser()\"\n ></auth-jwt-user-editor>\n </fieldset>\n </div>\n </mat-expansion-panel>\n</div>\n", styles: ["tr:nth-child(odd){background-color:#f8f8f8}th{padding:0 8px;text-align:left;color:silver;font-weight:400}td{padding:0 8px}td.command{width:24px}table{width:100%;border-collapse:collapse}fieldset{border:1px solid silver;border-radius:8px;padding:16px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}div#filters{grid-area:filters}div#list{grid-area:list}div#paginator{grid-area:paginator;justify-content:end}div#editor{grid-area:editor}div#container{display:grid;grid-template-rows:auto 1fr auto auto;grid-template-columns:1fr;grid-template-areas:\"filters\" \"list\" \"paginator\" \"editor\";gap:8px}@media only screen and (max-width: 959px){.noif-lt-md{display:none}}@media only screen and (min-width: 1920px){div#container{grid-template-rows:auto 1fr auto;grid-template-columns:1fr auto;grid-template-areas:\"filters filters\" \"list editor\" \"paginator .\"}}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i5.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i6$1.MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["disabled", "expanded", "hideToggle", "togglePosition"], outputs: ["opened", "closed", "expandedChange", "afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { kind: "component", type: i6.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i8$1.MatPaginator, selector: "mat-paginator", inputs: ["disabled"], exportAs: ["matPaginator"] }, { kind: "component", type: i9$1.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "directive", type: i7$1.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "component", type: UserFilterComponent, selector: "auth-jwt-user-filter", inputs: ["disabled"] }, { kind: "component", type: UserEditorComponent, selector: "auth-jwt-user-editor", inputs: ["user"], outputs: ["userChange", "editorClose"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }] }); }
884
+ }
885
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: UserListComponent, decorators: [{
886
+ type: Component,
887
+ args: [{ selector: 'auth-jwt-user-list', template: "<div id=\"container\">\n <div>\n <!-- filters -->\n <div id=\"filters\">\n <auth-jwt-user-filter></auth-jwt-user-filter>\n </div>\n\n <!-- list -->\n <div id=\"list\" *ngIf=\"pagination$ | async as pagination\">\n <div *ngIf=\"loading$ | async\" gdArea=\"progress\">\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\n </div>\n <table>\n <thead>\n <td></td>\n <td></td>\n <th i18n>name</th>\n <th i18n class=\"noif-lt-md\">first</th>\n <th i18n class=\"noif-lt-md\">last</th>\n <th i18n class=\"noif-lt-md\">email</th>\n <th i18n>roles</th>\n <th i18n class=\"noif-lt-md\">lock end</th>\n </thead>\n <tbody>\n <tr *ngFor=\"let user of pagination.data\">\n <td>\n <button\n mat-icon-button\n type=\"button\"\n i18n-matTooltip\n matTooltip=\"Edit this user\"\n color=\"primary\"\n (click)=\"setActiveUser(user)\"\n >\n <mat-icon>mode_edit</mat-icon>\n </button>\n <button\n mat-icon-button\n type=\"button\"\n i18n-matTooltip\n matTooltip=\"Delete this user\"\n color=\"warn\"\n (click)=\"deleteUser(user)\"\n >\n <mat-icon>remove_circle</mat-icon>\n </button>\n </td>\n <td>\n <img\n alt=\"avatar\"\n [src]=\"getGravatarUrl(user.email, 32)\"\n [alt]=\"user.userName\"\n />\n </td>\n <td>{{ user.userName }}</td>\n <td class=\"noif-lt-md\">{{ user.firstName }}</td>\n <td class=\"noif-lt-md\">{{ user.lastName }}</td>\n <td class=\"noif-lt-md\">\n <a [href]=\"'mailto:' + user.email\">{{ user.email }}</a>\n </td>\n <td>{{ user.roles.join(\" \") }}</td>\n <td class=\"noif-lt-md\">{{ user.lockoutEnd }}</td>\n </tr>\n </tbody>\n </table>\n\n <!-- paginator -->\n <div id=\"paginator\" class=\"form-row\">\n <button\n type=\"button\"\n mat-icon-button\n color=\"warn\"\n i18n-matmatTooltip\n matTooltip=\"Clear items cache\"\n (click)=\"clearCache()\"\n >\n <mat-icon>autorenew</mat-icon>\n </button>\n\n <mat-paginator\n gdArea=\"pager\"\n gdAlignColumns=\"center\"\n gdAlignRows=\"start\"\n [length]=\"pagination.total\"\n [pageSize]=\"pagination.perPage\"\n [pageSizeOptions]=\"[20, 50, 75, 100]\"\n [pageIndex]=\"pagination.currentPage - 1\"\n [showFirstLastButtons]=\"true\"\n (page)=\"pageChange($event)\"\n ></mat-paginator>\n </div>\n </div>\n </div>\n\n <!-- editor -->\n <mat-expansion-panel\n id=\"editor\"\n [expanded]=\"active$ | async\"\n [disabled]=\"!(active$ | async)\"\n >\n <div *ngIf=\"active$ | async as active\">\n <fieldset>\n <legend>{{ active.userName }}</legend>\n <auth-jwt-user-editor\n [user]=\"active\"\n (userChange)=\"saveActiveUser($event)\"\n (editorClose)=\"resetActiveUser()\"\n ></auth-jwt-user-editor>\n </fieldset>\n </div>\n </mat-expansion-panel>\n</div>\n", styles: ["tr:nth-child(odd){background-color:#f8f8f8}th{padding:0 8px;text-align:left;color:silver;font-weight:400}td{padding:0 8px}td.command{width:24px}table{width:100%;border-collapse:collapse}fieldset{border:1px solid silver;border-radius:8px;padding:16px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}div#filters{grid-area:filters}div#list{grid-area:list}div#paginator{grid-area:paginator;justify-content:end}div#editor{grid-area:editor}div#container{display:grid;grid-template-rows:auto 1fr auto auto;grid-template-columns:1fr;grid-template-areas:\"filters\" \"list\" \"paginator\" \"editor\";gap:8px}@media only screen and (max-width: 959px){.noif-lt-md{display:none}}@media only screen and (min-width: 1920px){div#container{grid-template-rows:auto 1fr auto;grid-template-columns:1fr auto;grid-template-areas:\"filters filters\" \"list editor\" \"paginator .\"}}\n"] }]
888
+ }], ctorParameters: function () { return [{ type: UserListRepository }, { type: DialogService }, { type: i2$2.GravatarService }]; } });
889
+
890
+ class AuthJwtAdminModule {
891
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: AuthJwtAdminModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
892
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.1", ngImport: i0, type: AuthJwtAdminModule, declarations: [AuthJwtRegistrationComponent,
893
+ PasswordStrengthBarComponent,
894
+ UserFilterComponent,
895
+ UserListComponent,
896
+ ConfirmDialogComponent,
897
+ UserEditorComponent], imports: [CommonModule,
898
+ HttpClientModule,
899
+ FormsModule,
900
+ RouterModule,
901
+ ReactiveFormsModule,
902
+ // material
903
+ MatButtonModule,
904
+ MatCardModule,
905
+ MatCheckboxModule,
906
+ MatDialogModule,
907
+ MatExpansionModule,
908
+ MatIconModule,
909
+ MatInputModule,
910
+ MatPaginatorModule,
911
+ MatProgressBarModule,
912
+ MatProgressSpinnerModule,
913
+ MatSnackBarModule,
914
+ MatTooltipModule,
915
+ AuthJwtLoginModule,
916
+ NgToolsModule], exports: [AuthJwtRegistrationComponent,
917
+ PasswordStrengthBarComponent,
918
+ UserFilterComponent,
919
+ UserListComponent] }); }
920
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: AuthJwtAdminModule, imports: [CommonModule,
921
+ HttpClientModule,
922
+ FormsModule,
923
+ RouterModule,
924
+ ReactiveFormsModule,
925
+ // material
926
+ MatButtonModule,
927
+ MatCardModule,
928
+ MatCheckboxModule,
929
+ MatDialogModule,
930
+ MatExpansionModule,
931
+ MatIconModule,
932
+ MatInputModule,
933
+ MatPaginatorModule,
934
+ MatProgressBarModule,
935
+ MatProgressSpinnerModule,
936
+ MatSnackBarModule,
937
+ MatTooltipModule,
938
+ AuthJwtLoginModule,
939
+ NgToolsModule] }); }
940
+ }
941
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: AuthJwtAdminModule, decorators: [{
942
+ type: NgModule,
943
+ args: [{
944
+ declarations: [
945
+ AuthJwtRegistrationComponent,
946
+ PasswordStrengthBarComponent,
947
+ UserFilterComponent,
948
+ UserListComponent,
949
+ ConfirmDialogComponent,
950
+ UserEditorComponent,
951
+ ],
952
+ imports: [
953
+ CommonModule,
954
+ HttpClientModule,
955
+ FormsModule,
956
+ RouterModule,
957
+ ReactiveFormsModule,
958
+ // material
959
+ MatButtonModule,
960
+ MatCardModule,
961
+ MatCheckboxModule,
962
+ MatDialogModule,
963
+ MatExpansionModule,
964
+ MatIconModule,
965
+ MatInputModule,
966
+ MatPaginatorModule,
967
+ MatProgressBarModule,
968
+ MatProgressSpinnerModule,
969
+ MatSnackBarModule,
970
+ MatTooltipModule,
971
+ AuthJwtLoginModule,
972
+ NgToolsModule
973
+ ],
974
+ exports: [
975
+ AuthJwtRegistrationComponent,
976
+ PasswordStrengthBarComponent,
977
+ UserFilterComponent,
978
+ UserListComponent
979
+ ],
980
+ }]
981
+ }] });
982
+
983
+ /*
984
+ * Public API Surface of auth-jwt-admin
985
+ */
986
+
987
+ /**
988
+ * Generated bundle index. Do not edit.
989
+ */
990
+
991
+ export { AuthJwtAccountService, AuthJwtAdminModule, AuthJwtRegistrationComponent, PasswordStrengthBarComponent, PasswordValidators, UserFilterComponent, UserListComponent, UserListRepository };
992
+ //# sourceMappingURL=myrmidon-auth-jwt-admin.mjs.map