2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
19 import { Component, OnInit } from '@angular/core';
20 import { ActivatedRoute } from '@angular/router';
21 import {UserService} from "../../../../services/user.service";
22 import {FormBuilder, FormControl} from "@angular/forms";
23 import {map, switchMap} from 'rxjs/operators';
24 import {ManageUsersBaseComponent} from "../manage-users-base.component";
27 selector: 'app-manage-users-edit',
28 templateUrl: './manage-users-edit.component.html',
29 styleUrls: ['./manage-users-edit.component.scss']
31 export class ManageUsersEditComponent extends ManageUsersBaseComponent implements OnInit {
33 editProperties = ['user_id', 'full_name', 'email', 'locked', 'password_change_required',
34 'password', 'confirm_password', 'validated'];
37 editMode:boolean=false;
40 constructor(private route: ActivatedRoute, public userService: UserService, public fb: FormBuilder) {
41 super(userService, fb);
42 this.editUser = this.route.params.pipe(map (params => params.userid ), switchMap(userid => userService.getUser(userid)) ).subscribe(user => {
44 this.originUser = user;
45 this.copyToForm(this.editProperties, this.editUser);});
49 this.userForm.setControl('user_id', new FormControl());
52 valid(field: string): string[] {
54 let classArr = super.valid(field);
55 return classArr.concat('form-control')
57 return ['form-control-plaintext'];
63 this.copyFromForm(this.editProperties)