import { Router, ActivatedRoute } from '@angular/router'; import { MdDialog, MdDialogConfig } from '@angular/material'; import { ITdDataTableColumn, ITdDataTableSortChangeEvent, TdDataTableService, TdDataTableSortingOrder, TdPagingBarComponent } from '@covalent/core'; import { IPageChangeEvent } from '@covalent/core'; import { Component, ViewChild, AfterViewInit } from '@angular/core'; import { TdMediaService } from '@covalent/core'; import { UsersService } from '../resources/users'; import { PackFormComponent } from '../forms/pack.form.component'; import { LocaleService } from '../common/i18n'; import { ListingBase } from './base'; var user_example = { username: 'rym', roles: [ 1 ], lastLogin: 1488885433000, modificationTimestamp: 1479898458000, email: 'rbouchair@curistec.com', first_name: 'Rym', last_name: 'Bouchair', creation_timestamp: 1479898458000, organizations_ids: [ 1, 2, 5, 6, 7, 8 ] } @Component({ selector: 'user-list', templateUrl: 'src/app/listing/user.list.component.html' }) export class UserListComponent extends ListingBase implements AfterViewInit { columns: ITdDataTableColumn[] = [ { name: 'username', label: 'Username', tooltip: 'Username to access app' }, { name: 'fullname', label: 'Fullname' }, { name: 'email', label: 'User email' }, { name: 'lastLogin', label: 'Last login date' }, { name: 'menu', label: '' } ]; pack_menu_options : any[] = [{ command: 'edit', name: 'Edit' },{ command: 'cancel', name: 'Cancel' }] constructor(_dataTableService: TdDataTableService, private media: TdMediaService, private router: Router, private $L: LocaleService, private applicationForm: PackFormComponent, private users: UsersService) { super(_dataTableService); this.users.get().subscribe( (list : any[]) => { this.data = list; this.refresh(); }, (err: any) => console.error(err) ); } packAction(action: any) { console.log(action.command); } isActionAvailable(pack : any) : boolean { return true; } create() : void { this.router.navigate(['users/create']); } edit(username: number | string) : void { this.router.navigate([`users/edit/${username}`]); } }