import { Component , OnInit } from '@angular/core' ; import { NzMessageService } from 'ng-zorro-antd' ; import { map } from 'rxjs/operators' ; import { RandomUserService } from '../randomUser.service' ; import { CHARTS } from '../../_mock/_chart' ; @ Component ( { selector : 'app-table-full' , templateUrl : './full.component.html' } ) export class TableFullComponent implements OnInit { pi = 1 ; ps = 10 ; total = 200 ; list = [ ] ; loading = false ; args : any = { } ; _indeterminate = false ; _allChecked = false ; events : any [ ] = [ ] ; load ( pi ? ) { if ( typeof pi !== 'undefined' ) { this . pi = pi || 1 ; } this . loading = true ; this . _allChecked = false ; this . _indeterminate = false ; this . _randomUser . getUsers ( this . pi , this . ps , this . args ) . pipe ( map ( data => { return data ; } ) ) . subscribe ( data => { this . loading = false ; this . list = data . results ; } ) ; } clear ( ) { this . args = { } ; this . load ( 1 ) ; } _checkAll ( ) { this . list . forEach ( item => item . checked = this . _allChecked ) ; this . refChecked ( ) ; } refChecked ( ) { const checkedCount = this . list . filter ( w => w . checked ) . length ; this . _allChecked = checkedCount === this . list . length ; this . _indeterminate = this . _allChecked ? false : checkedCount > 0 ; } constructor ( private _randomUser , private message ) { } ngOnInit ( ) { this . load ( ) ; let res = CHARTS [ "/chart/visit" ] ; this . events = res ; } showMsg ( msg ) { this . message . info ( msg ) ; } }