From 34697b1a558b90fb30e13d9a4197c3e61f2d3f52 Mon Sep 17 00:00:00 2001 From: Martin Stockhammer <martin_s@apache.org> Date: Wed, 11 Nov 2020 21:01:58 +0100 Subject: [PATCH] Adding user edit component --- .../archiva-web/src/app/app-routing.module.ts | 2 + .../main/archiva-web/src/app/app.module.ts | 2 + .../manage-users-edit.component.html | 83 +++++++++++++++++++ .../manage-users-edit.component.scss | 18 ++++ .../manage-users-edit.component.spec.ts | 43 ++++++++++ .../manage-users-edit.component.ts | 38 +++++++++ 6 files changed, 186 insertions(+) create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-edit/manage-users-edit.component.html create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-edit/manage-users-edit.component.scss create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-edit/manage-users-edit.component.spec.ts create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-edit/manage-users-edit.component.ts diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app-routing.module.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app-routing.module.ts index 9f1249e7b..eed0365a7 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app-routing.module.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app-routing.module.ts @@ -32,6 +32,7 @@ import {ManageRolesComponent} from "./modules/user/manage-roles/manage-roles.com import {SecurityConfigurationComponent} from "./modules/user/security-configuration/security-configuration.component"; import {ManageUsersListComponent} from "./modules/user/users/manage-users-list/manage-users-list.component"; import {ManageUsersAddComponent} from "./modules/user/users/manage-users-add/manage-users-add.component"; +import {ManageUsersEditComponent} from "./modules/user/users/manage-users-edit/manage-users-edit.component"; const routes: Routes = [ { path: '', component: HomeComponent, @@ -47,6 +48,7 @@ const routes: Routes = [ children: [ {path: 'list', component: ManageUsersListComponent}, {path: 'add', component: ManageUsersAddComponent}, + {path: 'edit/:userid', component: ManageUsersEditComponent}, {path: '', redirectTo:'list', pathMatch:'full'} ] }, diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app.module.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app.module.ts index f3ddcc7f9..6b7d2c4bb 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app.module.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app.module.ts @@ -45,6 +45,7 @@ import { NgbPaginationModule, NgbTooltipModule} from "@ng-bootstrap/ng-bootstrap import { PaginatedEntitiesComponent } from './modules/general/paginated-entities/paginated-entities.component'; import { SortedTableHeaderComponent } from './modules/general/sorted-table-header/sorted-table-header.component'; import { SortedTableHeaderRowComponent } from './modules/general/sorted-table-header-row/sorted-table-header-row.component'; +import { ManageUsersEditComponent } from './modules/user/users/manage-users-edit/manage-users-edit.component'; @NgModule({ @@ -69,6 +70,7 @@ import { SortedTableHeaderRowComponent } from './modules/general/sorted-table-he PaginatedEntitiesComponent, SortedTableHeaderComponent, SortedTableHeaderRowComponent, + ManageUsersEditComponent, ], imports: [ BrowserModule, 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.html b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-edit/manage-users-edit.component.html new file mode 100644 index 000000000..c70355ad2 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-edit/manage-users-edit.component.html @@ -0,0 +1,83 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> + +<form class="mt-3 mb-3" [formGroup]="userForm" (ngSubmit)="onSubmit()"> + <div class="form-group col-md-8"> + <label for="user_id">{{'users.attributes.user_id' |translate}}</label> + <input type="text" class="form-control" formControlName="user_id" id="user_id" + [ngClass]="valid('user_id')" + placeholder="{{'users.input.user_id'|translate}}"> + <small>{{'users.input.small.user_id'|translate:{'minSize':this.minUserIdSize} }}</small> + </div> + <div class="form-group col-md-8"> + <label for="full_name">{{'users.attributes.full_name' |translate}}</label> + <input type="text" class="form-control" formControlName="full_name" id="full_name" + [ngClass]="valid('full_name')" + 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"> + <label for="password">{{'users.attributes.password' |translate}}</label> + <input type="password" class="form-control" formControlName="password" id="password" + [ngClass]="valid('password')" + placeholder="{{'users.input.password'|translate}}"> + </div> + <div class="form-group col-md-8"> + <label for="confirm_password">{{'users.attributes.confirm_password' |translate}}</label> + <input type="password" class="form-control" formControlName="confirm_password" id="confirm_password" + [ngClass]="valid('confirm_password')" + placeholder="{{'users.input.confirm_password'|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="password_change_required" + 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> + <div *ngIf="success" class="alert alert-success" role="alert"> + User <a [routerLink]="['user','users','edit',userid]">{{userid}}</a> was added to the list. + </div> + <div *ngIf="error" class="alert alert-danger" role="alert" > + <h4 class="alert-heading">Errors</h4> + <ng-container *ngFor="let message of errorResult?.error_messages; first as isFirst" > + <hr *ngIf="!isFirst"> + <p>{{message.message}}</p> + </ng-container> + </div> + + +</form> 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.scss b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-edit/manage-users-edit.component.scss new file mode 100644 index 000000000..343c3b1c0 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-edit/manage-users-edit.component.scss @@ -0,0 +1,18 @@ +/*! + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 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.spec.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-edit/manage-users-edit.component.spec.ts new file mode 100644 index 000000000..f21a49f32 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-edit/manage-users-edit.component.spec.ts @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ManageUsersEditComponent } from './manage-users-edit.component'; + +describe('ManageUsersEditComponent', () => { + let component: ManageUsersEditComponent; + let fixture: ComponentFixture<ManageUsersEditComponent>; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ManageUsersEditComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(ManageUsersEditComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); 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 new file mode 100644 index 000000000..5d55089f9 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/users/manage-users-edit/manage-users-edit.component.ts @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +@Component({ + selector: 'app-manage-users-edit', + templateUrl: './manage-users-edit.component.html', + styleUrls: ['./manage-users-edit.component.scss'] +}) +export class ManageUsersEditComponent implements OnInit { + + userid; + + constructor(private route: ActivatedRoute) { + this.route.params.subscribe(params => this.userid=params.userid); + } + + ngOnInit(): void { + } + +}