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

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

JSON processing added

  • Property mode set to 100644
File size: 2.2 KB
RevLine 
[c73269d]1import { Component, OnInit, ViewChild, Inject, Input } from '@angular/core';
[4b342bb]2import { HttpClient } from '@angular/common/http';
3import { HealthFacilities } from '../models/HealthFacilities';
[ef1219a]4import { MatTableDataSource } from '@angular/material/table';
5import { MatPaginator } from '@angular/material/paginator';
6import { MatSort } from '@angular/material/sort';
[e42f61a]7import { HealthcareWorkers } from '../models/HealthcareWorkers';
[ef1219a]8
[30a465f]9@Component({
10 selector: 'app-counter-component',
[ec6ac45]11 templateUrl: './counter.component.html',
12 styleUrls: ['./counter.component.css']
[30a465f]13})
[ef1219a]14export class CounterComponent implements OnInit {
[c73269d]15 @Input() facilities: HealthFacilities[];
[e42f61a]16 public workers: HealthcareWorkers[];
[c73269d]17 displayedColumns = ['id','createdOn','deletedOn','Име','Општина','Адреса', 'Тип', 'Е-пошта', 'Телефон'];
[e42f61a]18 displayedColumnsWorkers = ['Име','Гранка','Установа', 'Назив'];
[ef1219a]19 dataSource = new MatTableDataSource<HealthFacilities>();
[e42f61a]20 dataSourceWorkers = new MatTableDataSource<HealthcareWorkers>();
[ef1219a]21
[c73269d]22 @ViewChild(MatPaginator, {static: false}) paginator: MatPaginator;
[ef1219a]23 @ViewChild(MatSort) sort: MatSort;
[30a465f]24
[4b342bb]25 constructor(http: HttpClient, @Inject('BASE_URL') baseUrl: string) {
[d2e69be]26 http.get<HealthFacilities[]>(baseUrl + 'HealthFacilities/Get?').subscribe(result => {
[4b342bb]27 this.facilities = result;
[d2e69be]28 console.log(this.facilities);
[ef1219a]29 this.dataSource = new MatTableDataSource<HealthFacilities>(this.facilities);
[4b342bb]30 }, error => console.error(error));
[e42f61a]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));
[d2e69be]36 }
[ef1219a]37 ngOnInit(): void {
38 }
[d2e69be]39
[ef1219a]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;
[de18858]49 }
50
51 applyFilterWorkers(filterValue: string) {
52 filterValue = filterValue.trim();
53 filterValue = filterValue.toLowerCase();
[e42f61a]54 this.dataSourceWorkers.filter = filterValue;
[ef1219a]55 }
[e42f61a]56}
Note: See TracBrowser for help on using the repository browser.