Changeset 8e74e2f for Farmatiko/ClientApp/src/app/dashboard
- Timestamp:
- 11/16/20 03:55:10 (4 years ago)
- Branches:
- master
- Children:
- db484c9
- Parents:
- 8b13eb2
- Location:
- Farmatiko/ClientApp/src/app/dashboard
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Farmatiko/ClientApp/src/app/dashboard/dashboard.component.css
r8b13eb2 r8e74e2f 15 15 16 16 .header { 17 min-height: 64px;18 17 padding: 8px 24px 0; 19 18 } … … 31 30 padding: 1em 0; 32 31 } 32 33 .btns { 34 display: flex; 35 flex-direction: row; 36 justify-content: flex-start; 37 } 38 39 .btns button { 40 margin: 0.5em 0.5em 0.5em 0; 41 } -
Farmatiko/ClientApp/src/app/dashboard/dashboard.component.html
r8b13eb2 r8e74e2f 13 13 <ul class="navbar-nav flex-grow"> 14 14 <li>Logged as <p *ngIf="head">{{head.Name}}</p> </li> 15 <li (click)="logout()" class="btn btn-link"><a>Logout</a></li>16 15 </ul> 17 16 </div> … … 20 19 <mat-menu #menu="matMenu"> 21 20 <button mat-menu-item [routerLink]="['/']"><mat-icon>directions</mat-icon>Почетна</button> 21 <button mat-menu-item (click)="logout()"><mat-icon>exit_to_app</mat-icon>Одјави се</button> 22 22 </mat-menu> 23 23 </div> … … 25 25 </header> 26 26 27 <mat-tab-group mat-stretch-tabs>27 <mat-tab-group dynamicHeight mat-stretch-tabs> 28 28 <mat-tab class="tab" label="Мои аптеки"> 29 29 <div class="wrapper"> … … 88 88 <div class="header"> 89 89 <h2>Достапни лекови</h2> 90 <mat-form-field> 90 <div class="btns"> 91 <button mat-raised-button color="primary" (click)="saveDeletedMedicines()" [disabled]="editedMedicine==false">Зачувај ги промените</button> 92 <button mat-raised-button color="accent" aria-label="Add medicine" (click)="addMedicine()">Додај нов лек</button> 93 <button mat-raised-button color="accent" aria-label="Add medicine" (click)="addMedicinesFromList()">Додај постоечки лекови</button> 94 </div><br/> 95 <mat-slide-toggle (click)="switchEditMedicineMode()">Edit mode</mat-slide-toggle> 96 97 <mat-form-field *ngIf="!medicinesEditMode"> 91 98 <input matInput (keyup)="applyFilterMedicines($event.target.value)" placeholder="Пронајди лек"> 92 99 </mat-form-field> 93 100 </div> 94 101 <table class='table table-striped table-bordered table-sm' cellspacing="0" width="100%" aria-labelledby="tableLabel" *ngIf="head"> 95 102 <thead> … … 102 109 <th>Цена</th> 103 110 <th>Пакување</th> 111 <th>Контроли</th> 104 112 </tr> 105 113 </thead> 106 114 <tbody> 107 <tr *ngFor="let medicine of head.PharmacyMedicines"> 108 <td><a (click)="openMedicineDialog(medicine)">{{ medicine.name }}</a></td> 109 <td>{{ medicine.strength }}</td> 110 <td>{{ medicine.form }}</td> 111 <td>{{ medicine.wayOfIssuing }}</td> 112 <td>{{ medicine.manufacturer }}</td> 113 <td>{{ medicine.price }}</td> 114 <td>{{ medicine.packaging }}</td> 115 <td><a (click)="deleteMedicine(medicine)">Delete</a></td> 115 <tr *ngFor="let medicine of filteredMedicines"> 116 <td *ngIf="!medicinesEditMode"><a (click)="openMedicineDialog(medicine)">{{ medicine.name }}</a></td> 117 <td *ngIf="medicinesEditMode"><mat-form-field appearance="fill"><input matInput [(ngModel)]="medicine.name" name="medname"></mat-form-field></td> 118 <td *ngIf="!medicinesEditMode">{{ medicine.strength }}</td> 119 <td *ngIf="medicinesEditMode"><mat-form-field appearance="fill"><input matInput [(ngModel)]="medicine.strength" name="medstr"></mat-form-field></td> 120 <td *ngIf="!medicinesEditMode">{{ medicine.form }}</td> 121 <td *ngIf="medicinesEditMode"><mat-form-field appearance="fill"><input matInput [(ngModel)]="medicine.form" name="medform"></mat-form-field></td> 122 <td *ngIf="!medicinesEditMode">{{ medicine.wayOfIssuing }}</td> 123 <td *ngIf="medicinesEditMode"><mat-form-field appearance="fill"><input matInput [(ngModel)]="medicine.wayOfIssuing" name="medwayOfIssuing"></mat-form-field></td> 124 <td *ngIf="!medicinesEditMode">{{ medicine.manufacturer }}</td> 125 <td *ngIf="medicinesEditMode"><mat-form-field appearance="fill"><input matInput [(ngModel)]="medicine.manufacturer" name="medmanufacturer"></mat-form-field></td> 126 <td *ngIf="!medicinesEditMode">{{ medicine.price }}</td> 127 <td *ngIf="medicinesEditMode"><mat-form-field appearance="fill"><input matInput [(ngModel)]="medicine.price" name="medprice"></mat-form-field></td> 128 <td *ngIf="!medicinesEditMode">{{ medicine.packaging }}</td> 129 <td *ngIf="medicinesEditMode"><mat-form-field appearance="fill"><input matInput [(ngModel)]="medicine.packaging" name="medpackaging"></mat-form-field></td> 130 <td> 131 <button mat-mini-fab color="warn" aria-label="Delete medicine" (click)="deleteMedicine(medicine)"> 132 <mat-icon>delete</mat-icon> 133 </button> 134 </td> 116 135 </tr> 117 136 </tbody> -
Farmatiko/ClientApp/src/app/dashboard/dashboard.component.ts
r8b13eb2 r8e74e2f 9 9 import { ActivatedRoute, Router } from '@angular/router'; 10 10 import { AuthService } from '../shared/services/auth.service'; 11 import { AddMedicineDialogComponent } from '../dialogs/add-medicine-dialog/add-medicine-dialog.component'; 12 import { ListMedicinesDialogComponent } from '../dialogs/list-medicines-dialog/list-medicines-dialog.component'; 11 13 12 14 @Component({ … … 21 23 public filteredMedicines: IMedicine[] = []; 22 24 public request: IPharmacyHeadRequest; 25 editedMedicine: boolean = false; 26 medicinesEditMode: boolean = false; 23 27 24 28 constructor(private dataService: DataService, private authService: AuthService, private dialog: MatDialog, private snackBar: MatSnackBar, private router: Router, private route: ActivatedRoute) { … … 37 41 .subscribe((pharmacy: IPharmacy[]) => { 38 42 this.pharmacies = pharmacy; 43 this.head.Pharmacy.forEach((pharma) => { 44 this.filteredPharmacies = this.pharmacies = this.pharmacies.filter(x => x == pharma); 45 }); 39 46 }, 40 47 (err: any) => console.log(err), 41 48 () => console.log('Pharmacy data retrieved')); 49 this.filteredMedicines = this.head.PharmacyMedicines; 42 50 } 43 51 … … 83 91 deleteMedicine(medicine: IMedicine){ 84 92 this.head.PharmacyMedicines = this.head.PharmacyMedicines.filter(x => x !== medicine); 93 this.filteredMedicines = this.head.PharmacyMedicines; 94 this.editedMedicine = true; 95 } 96 97 saveDeletedMedicines() { 85 98 this.dataService.updatePharmacyHead(this.head) 86 .subscribe((hd: IPharmacyHead) => { 87 if(hd) { 88 this.openSnackBar("Success! Medicine deleted", "OK"); 89 } 90 else { 91 this.openSnackBar("Unable to delete Medicine", "Try again"); 92 } 93 }, 94 (err: any) => console.log(err), 95 () => console.log('Update sent!')); 99 .subscribe((hd: IPharmacyHead) => { 100 if(hd) { 101 this.openSnackBar("Success! Medicine deleted", "OK"); 102 this.editedMedicine = false; 103 } 104 else { 105 this.openSnackBar("Unable to delete Medicine", "Try again"); 106 } 107 }, 108 (err: any) => console.log(err), 109 () => console.log('Update sent!')); 96 110 } 97 111 … … 99 113 console.log("applyFilterMedicines works!") 100 114 if(filterValue) { 101 this.dataService.searchMedicines(filterValue) 102 .subscribe((medicine: IMedicine[]) => { 103 this.filteredMedicines = medicine; 104 }, 105 (err: any) => console.log(err), 106 () => console.log('Medicine data retrieved')); 115 this.filteredMedicines = this.filteredMedicines.filter(x => x.name.toLocaleLowerCase().includes(filterValue.toLocaleLowerCase())); 107 116 } 108 117 else { 109 118 this.filteredMedicines = this.head.PharmacyMedicines; 119 } 120 } 121 122 addMedicine() { 123 let dialogRef = this.dialog.open(AddMedicineDialogComponent, { 124 width: 'auto' 125 }); 126 dialogRef.afterClosed().subscribe((newMedicine: IMedicine) => { 127 if(newMedicine){ 128 this.head.PharmacyMedicines.push(newMedicine); 129 this.filteredMedicines = this.head.PharmacyMedicines; 130 if(this.editedMedicine == false) { 131 this.editedMedicine = true; 132 } 133 this.openSnackBar("Success! Medicine added, please save changes now", "OK"); 134 } 135 else { 136 this.openSnackBar("Failed! Please try again", "OK"); 137 } 138 }, () => this.openSnackBar("Failed! Please try again", "OK")); 139 } 140 141 addMedicinesFromList() { 142 let dialogRef = this.dialog.open(ListMedicinesDialogComponent, { 143 width: 'auto', 144 height: 'auto' 145 }); 146 dialogRef.afterClosed().subscribe((listMedicines: IMedicine[]) => { 147 if(listMedicines){ 148 listMedicines.forEach((medicine) => { 149 this.head.PharmacyMedicines = this.head.PharmacyMedicines.filter(x => x != medicine); 150 this.head.PharmacyMedicines.push(medicine); 151 this.filteredMedicines = this.head.PharmacyMedicines; 152 }); 153 if(this.editedMedicine == false) { 154 this.editedMedicine = true; 155 } 156 this.openSnackBar("Success! Medicines added, please save changes now", "OK"); 157 } 158 else { 159 this.openSnackBar("Failed! Please try again", "OK"); 160 } 161 }, () => this.openSnackBar("Failed! Please try again", "OK")); 162 } 163 164 switchEditMedicineMode() { 165 this.medicinesEditMode = !this.medicinesEditMode; 166 if(this.editedMedicine == false) { 167 this.editedMedicine = true; 110 168 } 111 169 } … … 117 175 .subscribe((pharmacy: IPharmacy[]) => { 118 176 this.filteredPharmacies = pharmacy; 177 this.head.Pharmacy.forEach((pharma) => { 178 this.filteredPharmacies = this.filteredPharmacies.filter(x => x == pharma); 179 }); 119 180 }, 120 181 (err: any) => console.log(err), … … 123 184 else { 124 185 this.filteredPharmacies = this.pharmacies; 125 } 186 } 126 187 } 127 188 … … 138 199 139 200 openEditPharmacyDialog(pharmacy: IPharmacy): void { 201 console.log(pharmacy); 140 202 let dialogRef = this.dialog.open(EditPharmacyDialogComponent, { 141 203 width: '450px',
Note:
See TracChangeset
for help on using the changeset viewer.