source: Farmatiko/ClientApp/src/app/counter/counter.component.ts@ c73269d

Last change on this file since c73269d was c73269d, checked in by Mile Jankuloski <mile.jankuloski@…>, 2 years ago

JSON processing added

  • Property mode set to 100644
File size: 2.2 KB
Line 
1import { Component, OnInit, ViewChild, Inject, Input } from '@angular/core';
2import { HttpClient } from '@angular/common/http';
3import { HealthFacilities } from '../models/HealthFacilities';
4import { MatTableDataSource } from '@angular/material/table';
5import { MatPaginator } from '@angular/material/paginator';
6import { MatSort } from '@angular/material/sort';
7import { HealthcareWorkers } from '../models/HealthcareWorkers';
8
9@Component({
10 selector: 'app-counter-component',
11 templateUrl: './counter.component.html',
12 styleUrls: ['./counter.component.css']
13})
14export class CounterComponent implements OnInit {
15 @Input() facilities: HealthFacilities[];
16 public workers: HealthcareWorkers[];
17 displayedColumns = ['id','createdOn','deletedOn','Име','Општина','Адреса', 'Тип', 'Е-пошта', 'Телефон'];
18 displayedColumnsWorkers = ['Име','Гранка','Установа', 'Назив'];
19 dataSource = new MatTableDataSource<HealthFacilities>();
20 dataSourceWorkers = new MatTableDataSource<HealthcareWorkers>();
21
22 @ViewChild(MatPaginator, {static: false}) 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 }
44
45 applyFilter(filterValue: string) {
46 filterValue = filterValue.trim();
47 filterValue = filterValue.toLowerCase();
48 this.dataSource.filter = filterValue;
49 }
50
51 applyFilterWorkers(filterValue: string) {
52 filterValue = filterValue.trim();
53 filterValue = filterValue.toLowerCase();
54 this.dataSourceWorkers.filter = filterValue;
55 }
56}
Note: See TracBrowser for help on using the repository browser.