From 1caa397790ee006b645e6ca9f666382ff0a2f97f Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Tue, 10 Nov 2020 00:18:36 +0100 Subject: [PATCH] User form --- .../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.component.ts | 48 ++++++++++++++++--- .../manage-users-list.component.html | 14 +++--- .../manage-users-list.component.ts | 4 +- .../app/services/archiva-request.service.ts | 4 +- .../app/services/authentication.service.ts | 8 ++-- .../src/app/services/user.service.ts | 12 ++--- .../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 5cdc7f5a6..0a12e1a0e 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 f37059ef5..ce0a6a50a 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 @@
-
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 a2b967abe..ef9582f50 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 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 83b880c35..1bfac6606 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. --> -

manage-users-add works!

+
+
+
+ + + {{'users.input.small.user_id'|translate}} +
+
+ + + {{'users.input.small.full_name'|translate}} +
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ +
+
+ + +
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 d6d391e53..ce95bff62 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 b64f18270..fbd689508 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 @@ - - - + + + @@ -34,11 +34,11 @@ + [ngbTooltip]="heads.password_change_required" [attr.aria-label]="heads.password_change_required"> - - - + + + 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 d2a073a2f..7c9d7b107 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 c8028ff0d..0227893c1 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 b4a247866..978aa440a 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 68f9857fc..1792ec805 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 bfb2709a4..02a32fd84 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