1 | import { Component, OnInit, ViewChild, Inject } from '@angular/core';
|
---|
2 | import { HttpClient } from '@angular/common/http';
|
---|
3 | import { HealthFacilities } from '../models/HealthFacilities';
|
---|
4 | import { MatTableDataSource } from '@angular/material/table';
|
---|
5 | import { MatPaginator } from '@angular/material/paginator';
|
---|
6 | import { MatSort } from '@angular/material/sort';
|
---|
7 | import { HealthcareWorkers } from '../models/HealthcareWorkers';
|
---|
8 |
|
---|
9 | @Component({
|
---|
10 | selector: 'app-counter-component',
|
---|
11 | templateUrl: './counter.component.html',
|
---|
12 | styleUrls: ['./counter.component.css']
|
---|
13 | })
|
---|
14 | export class CounterComponent implements OnInit {
|
---|
15 | public facilities: HealthFacilities[];
|
---|
16 | public workers: HealthcareWorkers[];
|
---|
17 | displayedColumns = ['Име','Општина','Адреса', 'Тип', 'Е-пошта', 'Телефон'];
|
---|
18 | displayedColumnsWorkers = ['Име','Гранка','Установа', 'Назив'];
|
---|
19 | dataSource = new MatTableDataSource<HealthFacilities>();
|
---|
20 | dataSourceWorkers = new MatTableDataSource<HealthcareWorkers>();
|
---|
21 |
|
---|
22 | @ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
|
---|
23 | @ViewChild(MatSort) sort: MatSort;
|
---|
24 |
|
---|
25 | constructor(http: HttpClient, @Inject('BASE_URL') baseUrl: string) {
|
---|
26 | http.get<HealthFacilities[]>(baseUrl + 'HealthFacilities/Get?').subscribe(result => {
|
---|
27 | this.facilities = result;
|
---|
28 | console.log(this.facilities);
|
---|
29 | this.dataSource = new MatTableDataSource<HealthFacilities>(this.facilities);
|
---|
30 | }, error => console.error(error));
|
---|
31 | http.get<HealthcareWorkers[]>(baseUrl + 'HealthcareWorker/Get?').subscribe(result => {
|
---|
32 | this.workers = result;
|
---|
33 | console.log(this.workers);
|
---|
34 | this.dataSourceWorkers = new MatTableDataSource<HealthcareWorkers>(this.workers);
|
---|
35 | }, error => console.error(error));
|
---|
36 | }
|
---|
37 | ngOnInit(): void {
|
---|
38 | }
|
---|
39 |
|
---|
40 | ngAfterViewInit(): void {
|
---|
41 | this.dataSource.paginator = this.paginator;
|
---|
42 | this.dataSource.sort = this.sort;
|
---|
43 | this.dataSourceWorkers.paginator = this.paginator;
|
---|
44 | this.dataSourceWorkers.sort = this.sort;
|
---|
45 | }
|
---|
46 |
|
---|
47 | applyFilter(filterValue: string) {
|
---|
48 | filterValue = filterValue.trim();
|
---|
49 | filterValue = filterValue.toLowerCase();
|
---|
50 | this.dataSource.filter = filterValue;
|
---|
51 | }
|
---|
52 |
|
---|
53 | applyFilterWorkers(filterValue: string) {
|
---|
54 | filterValue = filterValue.trim();
|
---|
55 | filterValue = filterValue.toLowerCase();
|
---|
56 | this.dataSourceWorkers.filter = filterValue;
|
---|
57 | }
|
---|
58 | }
|
---|