- Timestamp:
- 07/27/20 23:36:14 (4 years ago)
- Branches:
- master
- Children:
- e42f61a
- Parents:
- d2e69be
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Farmatiko/ClientApp/src/app/dashboard/dashboard.component.ts
rd2e69be ref1219a 1 import { Component, OnInit, Input, ViewChild} from '@angular/core';1 import { Component, OnInit, ViewChild, Inject, Output, EventEmitter } from '@angular/core'; 2 2 import { Pharmacy } from '../models/Pharmacy'; 3 3 import { MatTableDataSource } from '@angular/material/table'; 4 4 import { MatPaginator } from '@angular/material/paginator'; 5 5 import { MatSort } from '@angular/material/sort'; 6 import { HealthFacilities } from '../models/HealthFacilities'; 7 import { HttpClient } from '@angular/common/http';; 8 import { MatDialog } from '@angular/material/dialog'; 9 import { MatSnackBar, MatSnackBarRef, SimpleSnackBar } from '@angular/material/snack-bar'; 10 import { Router, RouterModule } from '@angular/router'; 11 import { HomeComponent } from '../home/home.component'; 6 12 7 13 @Component({ … … 11 17 }) 12 18 export class DashboardComponent implements OnInit { 19 public facilities: HealthFacilities[]; 20 displayedColumns = ['Име','Општина','Адреса', 'Тип', 'Е-пошта', 'Телефон']; 21 dataSource = new MatTableDataSource<HealthFacilities>(); 13 22 14 constructor() { } 23 @ViewChild(MatPaginator, {static: true}) paginator: MatPaginator; 24 @ViewChild(MatSort) sort: MatSort; 15 25 16 ngOnInit(): void { } 26 constructor(http: HttpClient, @Inject('BASE_URL') baseUrl: string, private dialog: MatDialog, private _snackBar: MatSnackBar, private router: Router) { 27 http.get<HealthFacilities[]>(baseUrl + 'HealthFacilities/Get?').subscribe(result => { 28 this.facilities = result; 29 console.log(this.facilities); 30 this.dataSource = new MatTableDataSource<HealthFacilities>(this.facilities); 31 }, error => console.error(error)); 32 } 33 ngOnInit(): void { 34 } 35 36 ngAfterViewInit(): void { 37 this.dataSource.paginator = this.paginator; 38 this.dataSource.sort = this.sort; 39 } 40 41 applyFilter(filterValue: string) { 42 filterValue = filterValue.trim(); 43 filterValue = filterValue.toLowerCase(); 44 this.dataSource.filter = filterValue; 45 } 46 test(): void { 47 console.log('Snackbar works!'); 48 this.openSnackBar("Are you sure?", "Yes").onAction().subscribe(() => { 49 this.router.navigate(['/']); 50 }); 51 } 52 53 openDialog():void { 54 let dialogRef = this.dialog.open(HomeComponent, { 55 width: '70%' 56 }); 57 dialogRef.afterClosed().subscribe(result => { 58 if(result) { 59 this.openSnackBar("Success", "OK"); 60 } 61 }); 62 } 63 64 openSnackBar(message: string, action: string) : MatSnackBarRef<SimpleSnackBar> { 65 return this._snackBar.open(message, action, { 66 duration: 10000, 67 }); 68 } 17 69 }
Note:
See TracChangeset
for help on using the changeset viewer.