github.com/readium/readium-lcp-server@v0.0.0-20240101192032-6e95190e99f1/frontend/manage/app/components/user-component.ts (about)

     1  import { Component, Input, OnInit } from '@angular/core';
     2  import {ActivatedRoute, Params} from '@angular/router';
     3  import {Location} from '@angular/common';
     4  
     5  import { User } from './user';
     6  import { UserService } from './user.service';
     7  
     8  @Component({
     9      moduleId: module.id,
    10      selector: 'user',
    11      templateUrl: '/app/components/user.html',
    12      styleUrls: ['../../app/components/user.css'],
    13      providers: [UserService]
    14  })
    15  
    16  export class UserComponent implements OnInit {
    17      @Input() user: User;
    18      @Input() newPassword: string;
    19  
    20      constructor(
    21          private userService: UserService,
    22          private route: ActivatedRoute,
    23          private location: Location
    24      ) {}
    25  
    26      ngOnInit(): void {
    27          this.route.params.forEach((params: Params) => {
    28              let id = +params['id'];
    29              this.userService.getUser(id)
    30              .then(user => this.user = user);
    31          });
    32      }
    33      goBack(): void {
    34          this.location.back();
    35      }
    36  
    37      save(): void {
    38          this.userService.update(this.user, this.newPassword)
    39          .then(() => this.goBack());
    40      }
    41  }