User
{{userid}} was added to the list.
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-edit/manage-users-edit.component.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-edit/manage-users-edit.component.ts
index 5d55089f9..adb5b91ea 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-edit/manage-users-edit.component.ts
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-edit/manage-users-edit.component.ts
@@ -18,21 +18,40 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
+import {UserService} from "../../../../services/user.service";
+import {FormBuilder, Validators} from "@angular/forms";
+import {ManageUsersAddComponent, MustMatch} from "../manage-users-add/manage-users-add.component";
+import {environment} from "../../../../../environments/environment";
+import {map, switchMap} from 'rxjs/operators';
@Component({
selector: 'app-manage-users-edit',
templateUrl: './manage-users-edit.component.html',
styleUrls: ['./manage-users-edit.component.scss']
})
-export class ManageUsersEditComponent implements OnInit {
+export class ManageUsersEditComponent extends ManageUsersAddComponent implements OnInit {
- userid;
+ editUser;
+ editMode:boolean=false;
- constructor(private route: ActivatedRoute) {
- this.route.params.subscribe(params => this.userid=params.userid);
+ constructor(private route: ActivatedRoute, public userService: UserService, public fb: FormBuilder) {
+ super(userService, fb);
+ this.editUser = this.route.params.pipe(map (params => params.userid ), switchMap(userid => userService.getUser(userid)) ).subscribe(user => {
+ this.editUser = user;});
}
ngOnInit(): void {
+
}
+ valid(field: string): string[] {
+ if (this.editMode) {
+ let classArr = super.valid(field);
+ return classArr.concat('form-control')
+ } else {
+ return ['form-control-plaintext'];
+ }
+ }
+
+
}
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 d3b8e9a87..5e0f17282 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
@@ -24,8 +24,7 @@ import {ErrorResult} from "../model/error-result";
import {Observable, throwError} from "rxjs";
import {Permission} from '../model/permission';
import {PagedResult} from "../model/paged-result";
-import {EntityService} from "../model/entity-service";
-import { User } from '../model/user';
+import {User} from '../model/user';
import {catchError, map} from "rxjs/operators";
@Injectable({
@@ -37,25 +36,25 @@ export class UserService implements OnInit, OnDestroy {
permissions: Permission[];
guestPermissions: Permission[];
authenticated: boolean;
- uiPermissionsDefault = {
+ uiPermissionsDefault = {
'menu': {
- 'repo':{
- 'section':true,
- 'browse':true,
- 'search':true,
- 'upload':false
+ 'repo': {
+ 'section': true,
+ 'browse': true,
+ 'search': true,
+ 'upload': false
},
- 'admin':{
- 'section':false,
- 'config':false,
- 'status':false,
- 'reports':false
+ 'admin': {
+ 'section': false,
+ 'config': false,
+ 'status': false,
+ 'reports': false
},
- 'user':{
- 'section':false,
- 'manage':false,
- 'roles':false,
- 'config':false
+ 'user': {
+ 'section': false,
+ 'manage': false,
+ 'roles': false,
+ 'config': false
}
}
};
@@ -86,7 +85,7 @@ export class UserService implements OnInit, OnDestroy {
}
},
error: err => {
- console.log("Could not retrieve permissions "+err);
+ console.log("Could not retrieve permissions " + err);
}
}
this.retrievePermissionInfo().subscribe(observer);
@@ -172,13 +171,14 @@ export class UserService implements OnInit, OnDestroy {
resetPermissions() {
this.deepCopy(this.uiPermissionsDefault, this.uiPermissions);
}
+
parsePermissions(permissions: Permission[]) {
this.resetPermissions();
- for ( let perm of permissions) {
+ for (let perm of permissions) {
// console.debug("Checking permission for op: " + perm.operation.name);
switch (perm.operation.name) {
case "archiva-manage-configuration": {
- if (perm.resource.identifier=='*') {
+ if (perm.resource.identifier == '*') {
this.uiPermissions.menu.admin.section = true;
this.uiPermissions.menu.admin.config = true;
this.uiPermissions.menu.admin.reports = true;
@@ -187,7 +187,7 @@ export class UserService implements OnInit, OnDestroy {
}
case "archiva-manage-users": {
- if (perm.resource.identifier=='*') {
+ if (perm.resource.identifier == '*') {
this.uiPermissions.menu.user.section = true;
this.uiPermissions.menu.user.config = true;
this.uiPermissions.menu.user.manage = true;
@@ -195,7 +195,7 @@ export class UserService implements OnInit, OnDestroy {
}
}
case "redback-configuration-edit": {
- if (perm.resource.identifier=='*') {
+ if (perm.resource.identifier == '*') {
this.uiPermissions.menu.user.section = true;
this.uiPermissions.menu.user.config = true;
}
@@ -210,7 +210,7 @@ export class UserService implements OnInit, OnDestroy {
private deepCopy(src: Object, dst: Object) {
Object.keys(src).forEach((key, idx) => {
let srcEl = src[key];
- if (typeof(srcEl)=='object' ) {
+ if (typeof (srcEl) == 'object') {
let dstEl;
if (!dst.hasOwnProperty(key)) {
dst[key] = {}
@@ -260,22 +260,35 @@ export class UserService implements OnInit, OnDestroy {
this.authenticated = false;
}
- public query(searchTerm : string, offset : number = 0, limit : number = 10, orderBy : string[] = ['user_id'], order: string = 'asc') : Observable
> {
+ public query(searchTerm: string, offset: number = 0, limit: number = 10, orderBy: string[] = ['user_id'], order: string = 'asc'): Observable> {
console.log("getUserList " + searchTerm + "," + offset + "," + limit + "," + orderBy + "," + order);
- if (searchTerm==null) {
- searchTerm=""
+ if (searchTerm == null) {
+ searchTerm = ""
}
- if (orderBy==null || orderBy.length==0) {
+ if (orderBy == null || orderBy.length == 0) {
orderBy = ['user_id'];
}
- return this.rest.executeRestCall>("get", "redback", "users", {'q':searchTerm, 'offset':offset,'limit':limit,'orderBy':orderBy,'order':order});
+ return this.rest.executeRestCall>("get", "redback", "users", {
+ 'q': searchTerm,
+ 'offset': offset,
+ 'limit': limit,
+ 'orderBy': orderBy,
+ 'order': order
+ });
}
- public addUser(user : User) : Observable {
+ public addUser(user: User): Observable {
return this.rest.executeResponseCall("post", "redback", "users", user).pipe(
- catchError( ( error: HttpErrorResponse) => {
+ catchError((error: HttpErrorResponse) => {
return throwError(this.rest.getTranslatedErrorResult(error));
- }),map( (httpResponse : HttpResponse) => httpResponse.headers.get('Location')));
+ }), map((httpResponse: HttpResponse) => httpResponse.headers.get('Location')));
+ }
+
+ public getUser(userid: string): Observable {
+ return this.rest.executeRestCall("get", "redback", "users/" + userid, null).pipe(
+ catchError((error: HttpErrorResponse) => {
+ return throwError(this.rest.getTranslatedErrorResult(error));
+ }));
}
}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/environments/environment.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/environments/environment.ts
index cf788e28d..12dddabb1 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/environments/environment.ts
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/environments/environment.ts
@@ -28,6 +28,7 @@ export const environment = {
client_id:'archiva_web_client',
baseUrl: 'http://localhost:8080',
restPath: '/archiva/api/v2',
+ minUserIdLength: 8,
servicePaths: {
archiva:"archiva",
redback:"redback",