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

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

Auth fixes, bug fixes etc.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1import { Component, OnInit } from '@angular/core';
2import { IHealthFacilities, IHealthcareWorkers } from '../shared/interfaces';
3import { DataService } from '../shared/data.service';
4import { MatDialog } from '@angular/material/dialog';
5import { FacilityDialogComponent } from '../dialogs/facility-dialog/facility-dialog.component';
6import { WorkerDialogComponent } from '../dialogs/worker-dialog/worker-dialog.component';
7
8@Component({
9 selector: 'app-counter-component',
10 templateUrl: './counter.component.html',
11 styleUrls: ['./counter.component.css']
12})
13export class CounterComponent implements OnInit {
14 public facilities: IHealthFacilities[] = [];
15 public workers: IHealthcareWorkers[] = [];
16 public filteredFacilities: IHealthFacilities[] = [];
17 public filteredWorkers: IHealthcareWorkers[] = [];
18
19 constructor(private dataService: DataService, private dialog: MatDialog) {
20
21 }
22
23 ngOnInit(): void {
24 this.dataService.getFacilities()
25 .subscribe((facility: IHealthFacilities[]) => {
26 this.facilities = this.filteredFacilities = facility;
27 },
28 (err: any) => console.log(err),
29 () => console.log('Facility data retrieved!'));
30
31 this.dataService.getWorkers()
32 .subscribe((worker: IHealthcareWorkers[]) => {
33 this.workers = this.filteredWorkers = worker;
34 },
35 (err: any) => console.log(err),
36 () => console.log('Facility data retrieved!'));
37 }
38
39 applyFilterFacilities(filterValue: string) {
40 console.log("applyFilterFacilities works!")
41 if(filterValue) {
42 this.dataService.searchFacilities(filterValue)
43 .subscribe((facility: IHealthFacilities[]) => {
44 this.filteredFacilities = facility;
45 },
46 (err: any) => console.log(err),
47 () => console.log('Facility data retrieved!'));
48 }
49 else {
50 this.filteredFacilities = this.facilities;
51 }
52 }
53
54 applyFilterWorkers(filterValue: string) {
55 console.log("applyFilterWorkers works!")
56 if(filterValue) {
57 this.dataService.searchWorkers(filterValue)
58 .subscribe((worker: IHealthcareWorkers[]) => {
59 this.filteredWorkers = worker;
60 },
61 (err: any) => console.log(err),
62 () => console.log('Worker data retrieved!'));
63 }
64 else {
65 this.filteredWorkers = this.workers;
66 }
67 }
68
69 openFacilityDialog(facility: IHealthFacilities): void {
70 this.dialog.open(FacilityDialogComponent, {
71 width: '450px',
72 data: facility
73 });
74 }
75
76 openWorkerDialog(worker: IHealthcareWorkers): void {
77 this.dialog.open(WorkerDialogComponent, {
78 width: '450px',
79 data: worker
80 });
81 }
82}
Note: See TracBrowser for help on using the repository browser.