You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ma...@apache.org on 2020/11/09 23:18:50 UTC
[archiva] branch master updated: User form
This is an automated email from the ASF dual-hosted git repository.
martin_s pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/archiva.git
The following commit(s) were added to refs/heads/master by this push:
new 1caa397 User form
1caa397 is described below
commit 1caa397790ee006b645e6ca9f666382ff0a2f97f
Author: Martin Stockhammer <ma...@apache.org>
AuthorDate: Tue Nov 10 00:18:36 2020 +0100
User form
---
.../app/modules/general/login/login.component.ts | 2 +-
.../paginated-entities.component.html | 2 +-
.../paginated-entities.component.ts | 2 +-
.../manage-users-add.component.html | 46 ++++++++++++++++++++-
.../manage-users-add/manage-users-add.component.ts | 48 ++++++++++++++++++----
.../manage-users-list.component.html | 14 +++----
.../manage-users-list.component.ts | 4 +-
.../src/app/services/archiva-request.service.ts | 4 +-
.../src/app/services/authentication.service.ts | 8 ++--
.../archiva-web/src/app/services/user.service.ts | 12 +++---
.../src/main/archiva-web/src/assets/i18n/en.json | 48 ++++++++++++++--------
11 files changed, 141 insertions(+), 49 deletions(-)
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/login/login.component.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/login/login.component.ts
index 5cdc7f5..0a12e1a 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/login/login.component.ts
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/login/login.component.ts
@@ -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));
}
}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/paginated-entities/paginated-entities.component.html b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/paginated-entities/paginated-entities.component.html
index f37059e..ce0a6a5 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/paginated-entities/paginated-entities.component.html
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/paginated-entities/paginated-entities.component.html
@@ -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">
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/paginated-entities/paginated-entities.component.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/paginated-entities/paginated-entities.component.ts
index a2b967a..ef9582f 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/paginated-entities/paginated-entities.component.ts
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/paginated-entities/paginated-entities.component.ts
@@ -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);
}
}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-add/manage-users-add.component.html b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-add/manage-users-add.component.html
index 83b880c..1bfac66 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-add/manage-users-add.component.html
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-add/manage-users-add.component.html
@@ -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>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-add/manage-users-add.component.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-add/manage-users-add.component.ts
index d6d391e..ce95bff 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-add/manage-users-add.component.ts
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-add/manage-users-add.component.ts
@@ -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 ''
+ }
+ }
}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-list/manage-users-list.component.html b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-list/manage-users-list.component.html
index b64f182..fbd6895 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-list/manage-users-list.component.html
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-list/manage-users-list.component.html
@@ -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>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-list/manage-users-list.component.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-list/manage-users-list.component.ts
index d2a073a..7c9d7b1 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-list/manage-users-list.component.ts
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-list/manage-users-list.component.ts
@@ -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);
}
});
}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/archiva-request.service.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/archiva-request.service.ts
index c8028ff..0227893 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/archiva-request.service.ts
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/archiva-request.service.ts
@@ -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);
}
}
}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/authentication.service.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/authentication.service.ts
index b4a2478..978aa44 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/authentication.service.ts
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/authentication.service.ts
@@ -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);
}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/user.service.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/user.service.ts
index 68f9857..1792ec8 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/user.service.ts
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/user.service.ts
@@ -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();
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/assets/i18n/en.json b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/assets/i18n/en.json
index bfb2709..02a32fd 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/assets/i18n/en.json
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/assets/i18n/en.json
@@ -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"
}
}
\ No newline at end of file