import { Component , Injector , OnInit , ViewChild } from '@angular/core' ; import { ModalHelper } from '@shared/helpers/modal.helper' ; import { PagedListingComponentBase , PagedRequestDto } from "shared/component-base" ; import { UserServiceProxy , IUserDto , UserDto , CreateUserDto , RoleDto , PagedResultDtoOfUserDto } from '@shared/service-proxies/service-proxies' ; import { CreateUserComponent } from "./create-user/create-user.component" ; import { EditUserComponent } from "./edit-user/edit-user.component" ; @ Component ( { templateUrl : './users.component.html' } ) export class UsersComponent extends PagedListingComponentBase < UserDto > { loading = false ; dataItems : UserDto [ ] = [ ] ; constructor ( private injector , private userService , private modalHelper ) { super ( injector ) ; } list ( request , pageNumber , finishedCallback ) { this . loading = true ; this . userService . getAll ( request . skipCount , request . maxResultCount ) . finally ( ( ) => { finishedCallback ( ) ; this . loading = false ; } ) . subscribe ( ( result ) => { this . dataItems = result . items ; this . showPaging ( result , pageNumber ) ; } ) ; } delete ( user ) { this . message . confirm ( "Delete user '" + user . fullName + "'?" , ( result ) => { if ( result ) { this . userService . delete ( user . id ) . finally ( ( ) => { this . notify . info ( "Deleted User: " + user . name ) ; this . refresh ( ) ; } ) . subscribe ( ( ) => { } ) ; } } ) ; } create ( ) { this . modalHelper . open ( CreateUserComponent ) . subscribe ( res => this . refresh ( ) ) ; } edit ( user ) { this . modalHelper . open ( EditUserComponent , { id : user . id } ) . subscribe ( res => this . refresh ( ) ) ; } }