Browse Source

User form

pull/61/head
Martin Stockhammer 3 years ago
parent
commit
1caa397790
11 changed files with 141 additions and 49 deletions
  1. 1
    1
      archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/login/login.component.ts
  2. 1
    1
      archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/paginated-entities/paginated-entities.component.html
  3. 1
    1
      archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/paginated-entities/paginated-entities.component.ts
  4. 45
    1
      archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-add/manage-users-add.component.html
  5. 41
    7
      archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-add/manage-users-add.component.ts
  6. 7
    7
      archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-list/manage-users-list.component.html
  7. 2
    2
      archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-list/manage-users-list.component.ts
  8. 2
    2
      archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/archiva-request.service.ts
  9. 4
    4
      archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/authentication.service.ts
  10. 6
    6
      archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/user.service.ts
  11. 31
    17
      archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/assets/i18n/en.json

+ 1
- 1
archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/login/login.component.ts View File

@@ -64,7 +64,7 @@ export class LoginComponent implements OnInit {
if (err != null) {
this.errorMessages = [];
for (let msg of err) {
console.log("Error "+msg.errorKey);
console.log("Error "+msg.error_key);
this.errorMessages.push(this.archivaRequest.translateError(msg));
}
}

+ 1
- 1
archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/paginated-entities/paginated-entities.component.html View File

@@ -20,7 +20,7 @@
<div class="form-row align-items-center">
<div class="col-lg-4 col-md-2 col-sm-1">
<label class="sr-only" for="searchQuery">{{'search.label' |translate}}</label>
<input type="text" class="form-control" id="searchQuery" placeholder="Search" #searchTerm
<input type="text" class="form-control" id="searchQuery" placeholder="{{'search.input'|translate}}" #searchTerm
(keyup)="search(searchTerm.value)">
</div>
<div class="col-auto">

+ 1
- 1
archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/paginated-entities/paginated-entities.component.ts View File

@@ -190,7 +190,7 @@ export class PaginatedEntitiesComponent<T> implements OnInit, FieldToggle, After
}
if (sortFieldChanged || sortOrderChanged) {
this.page = 1;
this.changePage(1);
this.changePage(this.page);
}
}


+ 45
- 1
archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-add/manage-users-add.component.html View File

@@ -17,4 +17,48 @@
~ under the License.
-->

<p>manage-users-add works!</p>
<form class="mt-3 mb-3" [formGroup]="userForm" (ngSubmit)="onSubmit()">
<fieldset>
<div class="form-group col-md-8">
<label for="userId">{{'users.attributes.user_id' |translate}}</label>
<input type="text" class="form-control" formControlName="userId" id="userId"
[ngClass]="valid('userId')"
placeholder="{{'users.input.user_id'|translate}}">
<small>{{'users.input.small.user_id'|translate}}</small>
</div>
<div class="form-group col-md-8">
<label for="fullName">{{'users.attributes.full_name' |translate}}</label>
<input type="text" class="form-control" formControlName="fullName" id="fullName"
[ngClass]="valid('fullName')"
placeholder="{{'users.input.full_name'|translate}}">
<small>{{'users.input.small.full_name'|translate}}</small>
</div>
<div class="form-group col-md-8">
<label for="email">{{'users.attributes.email' |translate}}</label>
<input type="text" class="form-control" formControlName="email" id="email"
[ngClass]="valid('email')"
placeholder="{{'users.input.email'|translate}}">
</div>
<div class="form-group col-md-8">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" formControlName="locked" id="locked">
<label class="form-check-label" for="locked">
{{'users.attributes.locked'|translate}}
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" formControlName="passwordChangeRequired"
id="password_change_required" checked>
<label class="form-check-label" for="password_change_required">
{{'users.attributes.password_change_required'|translate}}
</label>
</div>
</div>
<div class="form-group col-md-8">
<button class="btn btn-primary" type="submit"
[disabled]="!userForm.valid">{{'users.add.submit'|translate}}</button>
</div>
</fieldset>


</form>

+ 41
- 7
archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-add/manage-users-add.component.ts View File

@@ -17,18 +17,52 @@
* under the License.
*/

import { Component, OnInit } from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {FormControl, FormGroup, Validators, FormBuilder} from '@angular/forms';
import {UserService} from "../../../../services/user.service";

@Component({
selector: 'app-manage-users-add',
templateUrl: './manage-users-add.component.html',
styleUrls: ['./manage-users-add.component.scss']
selector: 'app-manage-users-add',
templateUrl: './manage-users-add.component.html',
styleUrls: ['./manage-users-add.component.scss']
})
export class ManageUsersAddComponent implements OnInit {

constructor() { }
userForm = this.fb.group({
userId: ['', [Validators.required, Validators.minLength(8)]],
fullName: ['', Validators.required],
email: ['', [Validators.required,Validators.email]],
locked: [false],
passwordChangeRequired: [true]
})

ngOnInit(): void {
}
constructor(private userService: UserService, private fb: FormBuilder) {

}

ngOnInit(): void {
}

onSubmit() {
// Process checkout data here
console.warn('Your order has been submitted', JSON.stringify(this.userForm.value));
}

get userId() {
return this.userForm.get('userId');
}

valid(field:string) : string {
let formField = this.userForm.get(field);
if (formField.dirty||formField.touched) {
if (formField.valid) {
return 'is-valid'
} else {
return 'is-invalid'
}
} else {
return ''
}
}

}

+ 7
- 7
archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-list/manage-users-list.component.html View File

@@ -24,9 +24,9 @@
<thead class="thead-light">
<tr sorted [sortFieldEmitter]="parent.sortFieldChange" [sortOrderEmitter]="parent.sortOrderChange"
[toggleObserver]="parent">
<app-th-sorted [fieldArray]="['user_id']" contentText="users.list.table.head.user_id"></app-th-sorted>
<app-th-sorted [fieldArray]="['full_name']" contentText="users.list.table.head.full_name" ></app-th-sorted>
<app-th-sorted [fieldArray]="['email']" contentText="users.list.table.head.email" ></app-th-sorted>
<app-th-sorted [fieldArray]="['user_id']" contentText="users.attributes.user_id"></app-th-sorted>
<app-th-sorted [fieldArray]="['full_name']" contentText="users.attributes.full_name" ></app-th-sorted>
<app-th-sorted [fieldArray]="['email']" contentText="users.attributes.email" ></app-th-sorted>
<app-th-sorted [fieldArray]="['validated','user_id']">
<span class="fas fa-check" placement="top"
[ngbTooltip]="heads.validated" [attr.aria-label]="heads.validated"></span>
@@ -34,11 +34,11 @@
<app-th-sorted [fieldArray]="['locked','user_id']"><span class="fas fa-lock" placement="top"
[ngbTooltip]="heads.locked" [attr.aria-label]="heads.locked"></span></app-th-sorted>
<app-th-sorted [fieldArray]="['password_change_required','user_id']"><span class="fa fa-chevron-circle-right" placement="top"
[ngbTooltip]="heads.pwchange" [attr.aria-label]="heads.pwchange"></span>
[ngbTooltip]="heads.password_change_required" [attr.aria-label]="heads.password_change_required"></span>
</app-th-sorted>
<app-th-sorted [fieldArray]="['last_login']" contentText="users.list.table.head.last_login"></app-th-sorted>
<app-th-sorted [fieldArray]="['created']" contentText="users.list.table.head.created" ></app-th-sorted>
<app-th-sorted [fieldArray]="['last_password_change']" contentText="users.list.table.head.last_password_change"></app-th-sorted>
<app-th-sorted [fieldArray]="['last_login']" contentText="users.attributes.last_login"></app-th-sorted>
<app-th-sorted [fieldArray]="['created']" contentText="users.attributes.created" ></app-th-sorted>
<app-th-sorted [fieldArray]="['last_password_change']" contentText="users.attributes.last_password_change"></app-th-sorted>
</tr>
</thead>
<tbody>

+ 2
- 2
archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-list/manage-users-list.component.ts View File

@@ -51,8 +51,8 @@ export class ManageUsersListComponent implements OnInit {
// We need to wait for the translator initialization and use the init key as step in.
this.translator.get('init').subscribe(() => {
// Only table headings for small columns that use icons
for (let suffix of ['validated', 'locked', 'pwchange']) {
this.heads[suffix] = this.translator.instant('users.list.table.head.' + suffix);
for (let suffix of ['validated', 'locked', 'password_change_required']) {
this.heads[suffix] = this.translator.instant('users.attributes.' + suffix);
}
});
}

+ 2
- 2
archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/archiva-request.service.ts View File

@@ -87,14 +87,14 @@ export class ArchivaRequestService {
* @param errorMsg the errorMsg as returned by a REST call
*/
public translateError(errorMsg: ErrorMessage): string {
if (errorMsg.errorKey != null && errorMsg.errorKey != '') {
if (errorMsg.error_key != null && errorMsg.error_key != '') {
let parms = {};
if (errorMsg.args != null && errorMsg.args.length > 0) {
for (let i = 0; i < errorMsg.args.length; i++) {
parms['arg' + i] = errorMsg.args[i];
}
}
return this.translator.instant('api.' + errorMsg.errorKey, parms);
return this.translator.instant('api.' + errorMsg.error_key, parms);
}
}
}

+ 4
- 4
archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/authentication.service.ts View File

@@ -136,11 +136,11 @@ export class AuthenticationService {
error: (err: HttpErrorResponse) => {
console.log("Error " + (JSON.stringify(err)));
let result = err.error as ErrorResult
if (result.errorMessages != null) {
for (let msg of result.errorMessages) {
console.debug('Observer got an error: ' + msg.errorKey)
if (result.error_messages != null) {
for (let msg of result.error_messages) {
console.debug('Observer got an error: ' + msg.error_key)
}
resultHandler("ERROR", result.errorMessages);
resultHandler("ERROR", result.error_messages);
} else {
resultHandler("ERROR", null);
}

+ 6
- 6
archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/user.service.ts View File

@@ -115,9 +115,9 @@ export class UserService implements OnInit, OnDestroy {
error: (err: HttpErrorResponse) => {
console.log("Error " + (JSON.stringify(err)));
let result = err.error as ErrorResult
if (result != null && result.errorMessages != null) {
for (let msg of result.errorMessages) {
console.error('Observer got an error: ' + msg.errorKey)
if (result != null && result.error_messages != null) {
for (let msg of result.error_messages) {
console.error('Observer got an error: ' + msg.error_key)
}
} else if (err.message != null) {
console.error("Bad response from user info call: " + err.message);
@@ -150,9 +150,9 @@ export class UserService implements OnInit, OnDestroy {
error: (err: HttpErrorResponse) => {
console.log("Error " + (JSON.stringify(err)));
let result = err.error as ErrorResult
if (result.errorMessages != null) {
for (let msg of result.errorMessages) {
console.debug('Observer got an error: ' + msg.errorKey)
if (result.error_messages != null) {
for (let msg of result.error_messages) {
console.debug('Observer got an error: ' + msg.error_key)
}
}
this.resetPermissions();

+ 31
- 17
archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/assets/i18n/en.json View File

@@ -50,29 +50,43 @@
"rb.auth.invalid_credentials": "Invalid credentials given"
},
"users": {
"attributes":{
"id": "ID",
"user_id": "Login Name",
"email": "Email",
"full_name": "Name",
"validated": "User Validated",
"locked": "User Locked",
"password_change_required": "Password Change Required",
"last_login": "Last Login",
"created": "Created",
"permanent": "Permanent",
"last_password_change": "Last Password Change"
},
"input" : {
"small": {
"user_id": "Must be a unique key. No space allowed.",
"full_name": "This is the display name of the user"
},
"user_id": "Enter user ID",
"full_name": "Enter full user name",
"email": "email@example.org"
},

"list": {
"head": "List Users",
"table":{
"head": {
"id": "ID",
"user_id": "Login Name",
"email": "Email",
"full_name": "Name",
"validated": "User Validated",
"locked": "User Locked",
"pwchange": "Password Change Required",
"lastLogin": "Last Login",
"created": "Created",
"last_password_change": "Last Password Change"
}
}
"head": "List Users"
},
"add": {
"head": "Add User"
"head": "Add User",
"submit": "Add User"
}
},
"search": {
"button": "Search",
"label": "Enter your search term"
"label": "Enter your search term",
"input": "Search"
},
"form": {
"submit": "Submit"
}
}

Loading…
Cancel
Save