Ignore:
Timestamp:
07/29/20 19:46:21 (3 years ago)
Author:
Mile Jankuloski <mile.jankuloski@…>
Branches:
master
Children:
4e72684
Parents:
e42f61a
Message:

Prepared and improved components for data flows

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Farmatiko/ClientApp/src/app/dashboard/dashboard.component.ts

    re42f61a rde18858  
    44import { MatPaginator } from '@angular/material/paginator';
    55import { MatSort } from '@angular/material/sort';
    6 import { HealthFacilities } from '../models/HealthFacilities';
    76import { HttpClient } from '@angular/common/http';
    87import { MatDialog } from '@angular/material/dialog';
     
    109import { Router, RouterModule } from '@angular/router';
    1110import { HomeComponent } from '../home/home.component';
     11import { Medicine } from '../models/Medicine';
     12import { PharmacyHead } from '../models/PharmacyHead';
     13import { MedicineList } from '../models/MedicineList';
    1214
    1315@Component({
     
    1719})
    1820export class DashboardComponent implements OnInit {
    19   public facilities: HealthFacilities[];
    20   displayedColumns = ['Име','Општина','Адреса', 'Тип', 'Е-пошта', 'Телефон'];
    21   dataSource = new MatTableDataSource<HealthFacilities>();
     21  public mymedicines: Medicine[];
     22  public hasmymedicines: boolean[];
     23  public pharmacies: Pharmacy[];
     24  public mypharmacies: Pharmacy[];
     25  public head: PharmacyHead;
     26  public status: string;
     27  displayedColumns = ['Име','Јачина','Форма', 'Начин на издавање', 'Производител', 'Цена', 'Пакување', 'Actions'];
     28  displayedColumnsPharmacies = ['Име','Локација','Адреса', 'Actions'];
     29  dataSource = new MatTableDataSource<Medicine>();
     30  dataSourcePharmacies = new MatTableDataSource<Pharmacy>();
    2231
    2332  @ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
     
    2534
    2635  constructor(http: HttpClient, @Inject('BASE_URL') baseUrl: string, private dialog: MatDialog, private _snackBar: MatSnackBar, private router: Router) {
    27     http.get<HealthFacilities[]>(baseUrl + 'HealthFacilities/Get?').subscribe(result => {
    28       this.facilities = result;
    29       console.log(this.facilities);
    30       this.dataSource = new MatTableDataSource<HealthFacilities>(this.facilities);
     36    http.get<PharmacyHead>(baseUrl + 'PharmacyHead/GetLoggedHead?').subscribe(result => {
     37      this.head = result;
     38      console.log(this.head);
     39      this.mymedicines = this.head.PharmacyMedicines.Medicines;
     40      console.log(this.mymedicines);
     41      this.mypharmacies = this.head.Pharmacy;
     42      console.log(this.mypharmacies);
     43      this.dataSource = new MatTableDataSource<Medicine>(this.mymedicines);
     44    }, error => console.error(error));
     45    http.get<Pharmacy[]>(baseUrl + 'Pharmacy/Get?').subscribe(result => {
     46      this.pharmacies = result;
     47      console.log(this.pharmacies);
     48      this.dataSourcePharmacies = new MatTableDataSource<Pharmacy>(this.pharmacies);
    3149    }, error => console.error(error));
    3250  }
     51
    3352  ngOnInit(): void {
    3453  }
     
    3756    this.dataSource.paginator = this.paginator;
    3857    this.dataSource.sort = this.sort;
     58    this.dataSourcePharmacies.paginator = this.paginator;
     59    this.dataSourcePharmacies.sort = this.sort;
     60  }
     61
     62  works24hrs(pharmacy: Pharmacy) {
     63    console.log(pharmacy);
     64    // post request vo prodolzenie
     65
     66    this.status="Status bar works24hrs";
     67  }
     68
     69  doesntWork24hrs(pharmacy: Pharmacy) {
     70    console.log(pharmacy);
     71    // post request vo prodolzenie
     72
     73    this.status="Status bar doesntWork24hrs";
     74  }
     75
     76  claimPharmacy(pharmacy: Pharmacy) {
     77    console.log(pharmacy);
     78    // post request vo prodolzenie
     79
     80    this.status="Status bar claimPharmacy";
     81  }
     82
     83  medicineExists(mymedicine: Medicine) {
     84    console.log(mymedicine);
     85    // post request vo prodolzenie
     86
     87    this.status="Status bar medicineexists";
     88  }
     89
     90  medicineDoesntSell(mymedicine: Medicine) {
     91    console.log(mymedicine);
     92    // post request vo prodolzenie
     93
     94    this.status="Status bar medicineDoesntSell";
    3995  }
    4096
     
    44100    this.dataSource.filter = filterValue;
    45101  }
     102 
     103  applyFilterPharmacies(filterValue: string) {
     104    filterValue = filterValue.trim();
     105    filterValue = filterValue.toLowerCase();
     106    this.dataSourcePharmacies.filter = filterValue;
     107  }
     108
    46109  test(): void {
    47110    console.log('Snackbar works!');
Note: See TracChangeset for help on using the changeset viewer.