-
Notifications
You must be signed in to change notification settings - Fork 276
/
user-management-update.component.html
301 lines (301 loc) · 17.1 KB
/
user-management-update.component.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<div class="row justify-content-center">
<div class="col-md-8">
<form name="editForm" role="form" novalidate (ngSubmit)="save()" [formGroup]="editForm">
<h2 id="myUserLabel" jhiTranslate="artemisApp.userManagement.home.createOrEditLabel">Create or edit a User</h2>
<div>
<div class="form-group">
<label for="login" class="form-control-label" jhiTranslate="artemisApp.userManagement.login">Login</label>
<input
id="login"
type="text"
class="form-control"
name="login"
[(ngModel)]="user.login"
required
[maxLength]="USERNAME_MAX_LENGTH"
pattern="^[_.@A-Za-z0-9-]*$"
formControlName="loginInput"
/>
@if (editForm.get('loginInput')!.dirty && editForm.get('loginInput')!.invalid) {
<div>
@if (editForm.get('loginInput')!.errors?.required) {
<small class="form-text text-danger" jhiTranslate="entity.validation.required"> This field is required. </small>
}
@if (editForm.get('loginInput')!.errors?.maxlength) {
<small
class="form-text text-danger"
jhiTranslate="artemisApp.userManagement.inputConstraints"
[translateValues]="{ min: USERNAME_MIN_LENGTH, max: USERNAME_MAX_LENGTH }"
>
This field has to contain 4-50 characters!
</small>
}
@if (editForm.get('loginInput')!.errors?.pattern) {
<small class="form-text text-danger" jhiTranslate="entity.validation.patternLogin">
This field can only contain letters, digits and e-mail addresses.
</small>
}
@if (editForm.get('loginInput')!.errors?.minlength) {
<small
class="form-text text-danger"
jhiTranslate="artemisApp.userManagement.inputConstraints"
[translateValues]="{ min: USERNAME_MIN_LENGTH, max: USERNAME_MAX_LENGTH }"
>
This field has to contain 4-50 characters!
</small>
}
</div>
}
</div>
<div class="form-group">
<label for="firstName" class="form-control-label" jhiTranslate="artemisApp.userManagement.firstName">First Name</label>
<input
id="firstName"
type="text"
class="form-control"
name="firstName"
[(ngModel)]="user.firstName"
formControlName="firstNameInput"
[maxlength]="USERNAME_MAX_LENGTH"
required
/>
@if (editForm.get('firstNameInput')!.dirty && editForm.get('firstNameInput')!.invalid) {
<div>
@if (editForm.get('firstNameInput')!.errors?.maxlength) {
<small class="form-text text-danger" jhiTranslate="entity.validation.maxlength" [translateValues]="{ max: USERNAME_MAX_LENGTH }">
This field cannot be longer than 50 characters.
</small>
}
</div>
}
</div>
<div class="form-group">
<label for="lastName" jhiTranslate="artemisApp.userManagement.lastName">Last Name</label>
<input
id="lastName"
type="text"
class="form-control"
name="lastName"
[(ngModel)]="user.lastName"
formControlName="lastNameInput"
[maxlength]="USERNAME_MAX_LENGTH"
required
/>
@if (editForm.get('lastNameInput')!.dirty && editForm.get('lastNameInput')!.invalid) {
<div>
@if (editForm.get('lastNameInput')!.errors?.maxlength) {
<small class="form-text text-danger" jhiTranslate="entity.validation.maxlength" [translateValues]="{ max: USERNAME_MAX_LENGTH }">
This field cannot be longer than 50 characters.
</small>
}
</div>
}
</div>
<div class="form-check mb-2">
<input type="checkbox" class="form-check-input" name="randomPassword" id="randomPassword" (change)="shouldRandomizePassword($event)" checked #editPassword />
<label
class="form-check-label"
for="randomPassword"
[jhiTranslate]="user.id ? 'artemisApp.userManagement.keepPassword' : 'artemisApp.userManagement.randomPassword'"
>Random password / Keep old password</label
>
</div>
<div class="form-group" [hidden]="editPassword.checked">
<input
type="password"
class="form-control"
name="password"
id="password"
placeholder="{{ 'global.menu.account.password' | artemisTranslate }}"
[minLength]="PASSWORD_MIN_LENGTH"
[maxLength]="PASSWORD_MAX_LENGTH"
[(ngModel)]="user.password"
formControlName="passwordInput"
[required]="!editPassword.checked"
/>
@if (editForm.get('passwordInput')!.dirty && editForm.get('passwordInput')!.invalid) {
<div>
@if (editForm.get('passwordInput')!.errors?.maxlength) {
<small
class="form-text text-danger"
jhiTranslate="artemisApp.userManagement.inputConstraints"
[translateValues]="{ min: PASSWORD_MIN_LENGTH, max: PASSWORD_MAX_LENGTH }"
>
This field has to contain 8-50 characters!
</small>
}
@if (editForm.get('passwordInput')!.errors?.minlength) {
<small
class="form-text text-danger"
jhiTranslate="artemisApp.userManagement.inputConstraints"
[translateValues]="{ min: PASSWORD_MIN_LENGTH, max: PASSWORD_MAX_LENGTH }"
>
This field has to contain 8-50 characters!
</small>
}
</div>
}
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="artemisApp.userManagement.groups">Groups</label>
<mat-form-field appearance="outline" class="group-tag-list">
<mat-chip-grid #groupList aria-label="Group selection">
@for (group of user.groups; track group) {
<mat-chip-row (removed)="onGroupRemove(user, group)" class="group-tag">
<div class="custom-tag">
{{ group }}
<button matChipRemove>
<fa-icon [icon]="faTimes" class="group-tag-remove" />
</button>
</div>
</mat-chip-row>
}
<input
#groupInput
(matChipInputTokenEnd)="onGroupAdd(user, $event)"
[formControl]="groupCtrl"
[matAutocomplete]="auto"
[matChipInputFor]="groupList"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
[placeholder]="'artemisApp.userManagement.addGroup' | artemisTranslate"
class="group-tag-input"
/>
</mat-chip-grid>
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="onSelected($event); groupInput.value = ''" class="group-panel" classlist="group-panel">
@for (group of filteredGroups | async; track group) {
@if (!user.groups?.includes(group)) {
<mat-option [value]="group">
{{ group }}
</mat-option>
}
}
</mat-autocomplete>
</mat-form-field>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="artemisApp.userManagement.organizations">User organizations</label>
<div class="btn-group d-flex flex-wrap">
@for (organization of user.organizations; track organization) {
<div>
<h5>
<span class="badge bg-primary font-weight-normal m-1 ps-3"
>{{ organization.name
}}<button type="button" class="btn text-light" (click)="removeOrganizationFromUser(organization)">
<fa-icon [icon]="faTimes" /></button
></span>
</h5>
</div>
}
</div>
<button type="button" class="btn btn-outline-primary" (click)="openOrganizationsModal()">Add</button>
</div>
<div class="form-group">
<label for="email" class="form-control-label" jhiTranslate="artemisApp.userManagement.email">Email</label>
<input
id="email"
type="email"
class="form-control"
name="email"
[(ngModel)]="user.email"
formControlName="emailInput"
[minlength]="EMAIL_MIN_LENGTH"
required
[maxlength]="EMAIL_MAX_LENGTH"
email
/>
@if (editForm.get('emailInput')!.dirty && editForm.get('emailInput')!.invalid) {
<div>
@if (editForm.get('emailInput')!.errors?.required) {
<small class="form-text text-danger" jhiTranslate="entity.validation.required"> This field is required. </small>
}
@if (editForm.get('emailInput')!.errors?.maxlength) {
<small
class="form-text text-danger"
jhiTranslate="artemisApp.userManagement.inputConstraints"
[translateValues]="{ min: EMAIL_MIN_LENGTH, max: EMAIL_MAX_LENGTH }"
>
This field has to contain 5-100 characters!
</small>
}
@if (editForm.get('emailInput')!.errors?.minlength) {
<small
class="form-text text-danger"
jhiTranslate="entity.validation.minlength"
jhiTranslate="artemisApp.userManagement.inputConstraints"
[translateValues]="{ min: EMAIL_MIN_LENGTH, max: EMAIL_MAX_LENGTH }"
>
This field has to contain 5-100 characters!
</small>
}
@if (editForm.get('emailInput')!.errors?.email) {
<small class="form-text text-danger" jhiTranslate="global.messages.validate.email.invalid"> Your email is invalid. </small>
}
</div>
}
</div>
<div class="form-group">
<label for="registrationNumber" class="form-control-label" jhiTranslate="artemisApp.userManagement.registrationNumber">Registration Number</label>
<input
id="registrationNumber"
type="text"
class="form-control"
name="registrationNumber"
[(ngModel)]="user.visibleRegistrationNumber"
formControlName="registrationNumberInput"
maxlength="20"
registrationNumber
/>
@if (editForm.get('registrationNumberInput')!.invalid) {
<div>
@if (editForm.get('registrationNumberInput')!.errors?.maxlength) {
<small class="form-text text-danger" jhiTranslate="entity.validation.maxlength" [translateValues]="{ max: REGISTRATION_NUMBER_MAX_LENGTH }">
This field cannot be longer than 20 characters.
</small>
}
</div>
}
</div>
<div class="form-check">
<label for="activated" class="form-check-label">
<input
class="form-check-input"
[disabled]="user.id === null"
type="checkbox"
id="activated"
name="activated"
formControlName="activatedInput"
[(ngModel)]="user.activated"
/>
<span jhiTranslate="artemisApp.userManagement.activated">Activated</span>
</label>
</div>
@if (languages && languages.length > 0) {
<div class="form-group">
<label for="langKey" jhiTranslate="artemisApp.userManagement.langKey">Lang Key</label>
<select class="form-select" id="langKey" name="langKey" formControlName="langKeyInput" [(ngModel)]="user.langKey">
@for (language of languages; track language) {
<option [value]="language">{{ language | findLanguageFromKey }}</option>
}
</select>
</div>
}
<div class="form-group">
<label for="authority" jhiTranslate="artemisApp.userManagement.profiles">Profiles</label>
<select id="authority" class="form-select" multiple name="authority" formControlName="authorityInput" [(ngModel)]="user.authorities">
@for (authority of authorities; track authority) {
<option [value]="authority">{{ authority }}</option>
}
</select>
</div>
</div>
<div>
<button type="button" class="btn btn-secondary" (click)="previousState()">
<fa-icon [icon]="faBan" /> <span jhiTranslate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" [disabled]="editForm.invalid || isSaving" class="btn btn-primary">
<fa-icon [icon]="faSave" /> <span jhiTranslate="entity.action.save">Save</span>
</button>
</div>
</form>
</div>
</div>