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
RevLine 
[ee137aa]1import { Component, OnInit } from '@angular/core';
2import { IHealthFacilities, IHealthcareWorkers } from '../shared/interfaces';
[ad60966]3import { DataService } from '../shared/data.service';
[ee137aa]4import { MatDialog } from '@angular/material/dialog';
5import { FacilityDialogComponent } from '../dialogs/facility-dialog/facility-dialog.component';
6import { WorkerDialogComponent } from '../dialogs/worker-dialog/worker-dialog.component';
[ef1219a]7
[30a465f]8@Component({
9 selector: 'app-counter-component',
[ec6ac45]10 templateUrl: './counter.component.html',
11 styleUrls: ['./counter.component.css']
[30a465f]12})
[ef1219a]13export class CounterComponent implements OnInit {
[ee137aa]14 public facilities: IHealthFacilities[] = [];
15 public workers: IHealthcareWorkers[] = [];
16 public filteredFacilities: IHealthFacilities[] = [];
17 public filteredWorkers: IHealthcareWorkers[] = [];
[ef1219a]18
[ee137aa]19 constructor(private dataService: DataService, private dialog: MatDialog) {
20
[d2e69be]21 }
[ee137aa]22
[ef1219a]23 ngOnInit(): void {
[ee137aa]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!'));
[d2e69be]30
[ee137aa]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!'));
[ef1219a]37 }
38
[ee137aa]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 }
[de18858]52 }
53
54 applyFilterWorkers(filterValue: string) {
[ee137aa]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 });
[ef1219a]81 }
[e42f61a]82}
Note: See TracBrowser for help on using the repository browser.