Ignore:
Timestamp:
11/16/20 03:55:10 (4 years ago)
Author:
DimitarSlezenkovski <dslezenkovski@…>
Branches:
master
Children:
db484c9
Parents:
8b13eb2
Message:

Fix bugs, add some more.

Location:
Farmatiko/ClientApp/src/app
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • Farmatiko/ClientApp/src/app/admin/admin.component.html

    r8b13eb2 r8e74e2f  
    1212        <div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
    1313          <ul class="navbar-nav flex-grow">
    14             <li>Administration panel</li>
     14            <li>Administration panel:</li>
     15            <li>&nbsp;Logged as <p *ngIf="head">{{adminHead.Name}}</p> </li>
     16            <li (click)="logout()" class="btn btn-link"><a>Logout</a></li>
    1517          </ul>
    1618        </div>
     
    1820    </nav>
    1921</header>
    20 <mat-tab-group mat-stretch-tabs>
     22<mat-tab-group mat-stretch-tabs dynamicHeight>
    2123      <mat-tab label="Claiming requests">
    2224        <div class="wrapper">
  • Farmatiko/ClientApp/src/app/admin/admin.component.ts

    r8b13eb2 r8e74e2f  
    77import { EditPharmacyHeadDialogComponent } from '../dialogs/edit-pharmacy-head-dialog/edit-pharmacy-head-dialog.component';
    88import { PharmacyDialogComponent } from '../dialogs/pharmacy-dialog/pharmacy-dialog.component';
    9 import { PharmacyHeadDialogComponent } from '../nav-menu/dialogs/pharmacy-head-dialog/pharmacy-head-dialog.component';
     9import { PharmacyHeadDialogComponent } from '../dialogs/pharmacy-head-dialog/pharmacy-head-dialog.component';
     10import { AuthService } from '../shared/services/auth.service';
    1011
    1112
     
    1920  public requests: IPharmacyHeadRequest[] = [];
    2021  public head: IPharmacyHead = {
    21     PharmacyMedicines: null,
    22     Pharmacy: null,
    2322    Email: '',
    2423    Passwd: '',
    2524    Name: ''
    2625  };
     26  public adminHead: IPharmacyHead;
    2727
    28   constructor(private dataService: DataService, private dialog: MatDialog, private snackBar: MatSnackBar, private router: Router) {
     28  constructor(private dataService: DataService, private authService: AuthService, private dialog: MatDialog, private snackBar: MatSnackBar, private router: Router) {
    2929
    3030  }
    3131
    3232  ngOnInit(): void {
     33    this.authService.getUser()
     34        .subscribe((data) => {
     35          console.log(data);
     36          this.adminHead = data;
     37        },
     38        (err: any) => console.log(err),
     39        () => console.log('User data retrieved'));
     40
    3341    this.dataService.getPharmacyHeads()
    3442        .subscribe((pHeads: IPharmacyHead[]) => {
     
    3947
    4048    this.dataService.getClaimingRequests()
    41     .subscribe((pRequests: IPharmacyHeadRequest[]) => {
    42       this.requests = pRequests;
    43     },
    44     (err: any) => console.log(err),
    45     () => console.log("PharmacyHead data retrieved"));
     49        .subscribe((pRequests: IPharmacyHeadRequest[]) => {
     50          this.requests = pRequests;
     51        },
     52        (err: any) => console.log(err),
     53        () => console.log("PharmacyHead data retrieved"));
    4654  }
    4755
     
    5765        () => console.log("PharmacyHead inserted"));
    5866    this.head = {
    59       PharmacyMedicines: null,
    60       Pharmacy: null,
    6167      Email: '',
    6268      Passwd: '',
     
    8389    dialogRef.afterClosed().subscribe((editedHead: IPharmacyHead) => {
    8490      if(editedHead){
     91        console.log(editedHead);
    8592        this.heads = this.heads.filter(x => x !== eHead);
    8693        this.heads.push(editedHead);
     
    142149  }
    143150
     151  logout() {
     152    this.authService.logout();
     153  }
     154
    144155  openSnackBar(message: string, action: string) : MatSnackBarRef<SimpleSnackBar> {
    145156    return this.snackBar.open(message, action, {
  • Farmatiko/ClientApp/src/app/app.module.ts

    r8b13eb2 r8e74e2f  
    2626import { EditPharmacyDialogComponent } from './dialogs/edit-pharmacy-dialog/edit-pharmacy-dialog.component';
    2727import { EditPharmacyHeadDialogComponent } from './dialogs/edit-pharmacy-head-dialog/edit-pharmacy-head-dialog.component';
    28 import { PharmacyHeadDialogComponent } from './nav-menu/dialogs/pharmacy-head-dialog/pharmacy-head-dialog.component';
     28import { PharmacyHeadDialogComponent } from './dialogs/pharmacy-head-dialog/pharmacy-head-dialog.component';
     29import { AddMedicineDialogComponent } from './dialogs/add-medicine-dialog/add-medicine-dialog.component';
     30import { ListMedicinesDialogComponent } from './dialogs/list-medicines-dialog/list-medicines-dialog.component';
    2931
    3032@NgModule({
     
    4446    EditPharmacyDialogComponent,
    4547    EditPharmacyHeadDialogComponent,
    46     PharmacyHeadDialogComponent
     48    PharmacyHeadDialogComponent,
     49    AddMedicineDialogComponent,
     50    ListMedicinesDialogComponent
    4751  ],
    4852  imports: [
  • Farmatiko/ClientApp/src/app/counter/counter.component.css

    r8b13eb2 r8e74e2f  
    1212 
    1313.header {
    14     min-height: 64px;
    1514    padding: 8px 24px 0;
    1615}
  • Farmatiko/ClientApp/src/app/counter/counter.component.html

    r8b13eb2 r8e74e2f  
    22<app-nav-menu></app-nav-menu>
    33
    4 <mat-tab-group mat-stretch-tabs>
     4<mat-tab-group dynamicHeight mat-stretch-tabs>
    55  <mat-tab class="tab" label="Здравствени установи">
    66  <div class="wrapper">
  • Farmatiko/ClientApp/src/app/dashboard/dashboard.component.css

    r8b13eb2 r8e74e2f  
    1515 
    1616.header {
    17     min-height: 64px;
    1817    padding: 8px 24px 0;
    1918}
     
    3130    padding: 1em 0;
    3231}
     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  
    1313          <ul class="navbar-nav flex-grow">
    1414            <li>Logged as <p *ngIf="head">{{head.Name}}</p> </li>
    15             <li (click)="logout()" class="btn btn-link"><a>Logout</a></li>
    1615          </ul>
    1716        </div>
     
    2019        <mat-menu #menu="matMenu">
    2120          <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>
    2222        </mat-menu>
    2323      </div>
     
    2525</header>
    2626
    27 <mat-tab-group mat-stretch-tabs>
     27<mat-tab-group dynamicHeight mat-stretch-tabs>
    2828  <mat-tab class="tab" label="Мои аптеки">
    2929  <div class="wrapper">
     
    8888    <div class="header">
    8989    <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">
    9198      <input matInput (keyup)="applyFilterMedicines($event.target.value)" placeholder="Пронајди лек">
    9299    </mat-form-field>
    93       </div>
     100    </div>
    94101      <table class='table table-striped table-bordered table-sm' cellspacing="0" width="100%" aria-labelledby="tableLabel" *ngIf="head">
    95102        <thead>
     
    102109            <th>Цена</th>
    103110            <th>Пакување</th>
     111            <th>Контроли</th>
    104112          </tr>
    105113        </thead>
    106114        <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>
    116135          </tr>
    117136      </tbody>
  • Farmatiko/ClientApp/src/app/dashboard/dashboard.component.ts

    r8b13eb2 r8e74e2f  
    99import { ActivatedRoute, Router } from '@angular/router';
    1010import { AuthService } from '../shared/services/auth.service';
     11import { AddMedicineDialogComponent } from '../dialogs/add-medicine-dialog/add-medicine-dialog.component';
     12import { ListMedicinesDialogComponent } from '../dialogs/list-medicines-dialog/list-medicines-dialog.component';
    1113
    1214@Component({
     
    2123  public filteredMedicines: IMedicine[] = [];
    2224  public request: IPharmacyHeadRequest;
     25  editedMedicine: boolean = false;
     26  medicinesEditMode: boolean = false;
    2327
    2428  constructor(private dataService: DataService, private authService: AuthService, private dialog: MatDialog, private snackBar: MatSnackBar, private router: Router, private route: ActivatedRoute) {
     
    3741        .subscribe((pharmacy: IPharmacy[]) => {
    3842          this.pharmacies = pharmacy;
     43          this.head.Pharmacy.forEach((pharma) => {
     44            this.filteredPharmacies = this.pharmacies = this.pharmacies.filter(x => x == pharma);
     45          });
    3946        },
    4047        (err: any) => console.log(err),
    4148        () => console.log('Pharmacy data retrieved'));
     49    this.filteredMedicines = this.head.PharmacyMedicines;
    4250  }
    4351 
     
    8391  deleteMedicine(medicine: IMedicine){
    8492    this.head.PharmacyMedicines = this.head.PharmacyMedicines.filter(x => x !== medicine);
     93    this.filteredMedicines = this.head.PharmacyMedicines;
     94    this.editedMedicine = true;
     95  }
     96 
     97  saveDeletedMedicines() {
    8598    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!'));
    96110  }
    97111
     
    99113    console.log("applyFilterMedicines works!")
    100114    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()));
    107116    }
    108117    else {
    109118      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;
    110168    }
    111169  }
     
    117175          .subscribe((pharmacy: IPharmacy[]) => {
    118176            this.filteredPharmacies = pharmacy;
     177            this.head.Pharmacy.forEach((pharma) => {
     178              this.filteredPharmacies = this.filteredPharmacies.filter(x => x == pharma);
     179            });
    119180          },
    120181          (err: any) => console.log(err),
     
    123184    else {
    124185      this.filteredPharmacies = this.pharmacies;
    125     }   
     186    }
    126187  }
    127188
     
    138199
    139200  openEditPharmacyDialog(pharmacy: IPharmacy): void {
     201    console.log(pharmacy);
    140202    let dialogRef = this.dialog.open(EditPharmacyDialogComponent, {
    141203      width: '450px',
  • Farmatiko/ClientApp/src/app/dialogs/edit-pharmacy-dialog/edit-pharmacy-dialog.component.html

    r8b13eb2 r8e74e2f  
    1313    <div class="form-group">
    1414      <label>Location</label>
    15       <input type="text" class="form-control" [(ngModel)]="pharmacy.location" #email="ngModel" required />
     15      <input type="text" class="form-control" name="location" [(ngModel)]="pharmacy.location" #location="ngModel" required />
    1616      <div class="alert alert-danger" [hidden]="pharmacy.location">Location is required</div>
    1717    </div>
    1818    <div class="form-group">
    1919        <label>Work 24/7</label>
    20         <br />
    2120        <div class="radio">
    2221          <label>
    23             <input type="radio" name="workAllTime" [(ngModel)]="pharmacy.workAllTime" #workAllTime="ngModel" value="true" required />
    24             Да
    25           </label>
    26         </div>
    27         <div class="radio">
    28           <label>
    29             <input type="radio" name="workAllTime" [(ngModel)]="pharmacy.workAllTime" #workAlltime="ngModel" value="false" required />
    30             Не
     22            <input type="checkbox" name="workAllTime" [(ngModel)]="pharmacy.workAllTime" #workAllTime="ngModel" [value]="pharmacy.workAllTime"/>
    3123          </label>
    3224        </div>
  • Farmatiko/ClientApp/src/app/dialogs/edit-pharmacy-dialog/edit-pharmacy-dialog.component.ts

    r8b13eb2 r8e74e2f  
    1919
    2020  save() {
     21    console.log(this.pharmacy);
    2122    this.dialogRef.close(this.pharmacy);
    2223  }
  • Farmatiko/ClientApp/src/app/dialogs/list-medicines-dialog/list-medicines-dialog.component.html

    r8b13eb2 r8e74e2f  
    2121      <tbody>
    2222        <tr *ngFor="let medicine of filteredListMedicines">
    23           <td>>{{ medicine.name }}</td>
     23          <td>{{ medicine.name }}</td>
    2424          <td>{{ medicine.strength }}</td>
    2525          <td>{{ medicine.form }}</td>
  • Farmatiko/ClientApp/src/app/dialogs/list-medicines-dialog/list-medicines-dialog.component.ts

    r8b13eb2 r8e74e2f  
    1010})
    1111export class ListMedicinesDialogComponent implements OnInit {
    12   medicines: IMedicine[];
     12  medicines: IMedicine[] = [];
    1313  listMedicines: IMedicine[];
    1414  filteredListMedicines: IMedicine[];
     
    3030      this.medicines = this.medicines.filter(x => x != selectedMedicine);
    3131    }
    32     else {
    33       this.medicines.push(selectedMedicine);
    34     }
     32    this.medicines.push(selectedMedicine);
    3533  }
    3634
  • Farmatiko/ClientApp/src/app/home/home.component.css

    r8b13eb2 r8e74e2f  
    1212
    1313.header {
    14   min-height: 64px;
    1514  padding: 8px 24px 0;
    1615}
  • Farmatiko/ClientApp/src/app/home/home.component.html

    r8b13eb2 r8e74e2f  
    11<app-nav-menu></app-nav-menu>
    22
    3 <mat-tab-group mat-stretch-tabs>
     3<mat-tab-group dynamicHeight mat-stretch-tabs>
    44  <mat-tab class="tab" label="Лекови">
    55  <div class="wrapper">
  • Farmatiko/ClientApp/src/app/nav-menu/nav-menu.component.html

    r8b13eb2 r8e74e2f  
    2626            <a class="nav-link text-dark" [routerLink]="['/koronavirus']">Коронавирус</a>
    2727          </li>
     28          <li *ngIf="loggedIn">
     29            <button mat-button [matMenuTriggerFor]="menu"><mat-icon>more_vert</mat-icon></button>
     30            <mat-menu #menu="matMenu">
     31              <button mat-menu-item [routerLink]="['/dashboard']"><mat-icon>dashboard</mat-icon>Контролна табла</button>
     32              <button mat-menu-item (click)="logout()"><mat-icon>exit_to_app</mat-icon>Одјави се</button>
     33            </mat-menu>
     34          </li>
    2835        </ul>
    2936      </div>
  • Farmatiko/ClientApp/src/app/nav-menu/nav-menu.component.ts

    r8b13eb2 r8e74e2f  
    1 import { Component } from '@angular/core';
     1import { Component, OnInit } from '@angular/core';
     2import { AuthService } from '../shared/services/auth.service';
    23
    34@Component({
     
    67  styleUrls: ['./nav-menu.component.css']
    78})
    8 export class NavMenuComponent {
     9export class NavMenuComponent implements OnInit {
    910  isExpanded = false;
     11  loggedIn: boolean = false;
     12
     13  constructor(private authService: AuthService) {
     14   
     15  }
     16 
     17  ngOnInit(): void {
     18    if(localStorage.getItem('access_token')) {
     19      this.loggedIn = true;
     20    }
     21  }
     22
     23  logout() {
     24    this.authService.logout();
     25  }
    1026
    1127  collapse() {
Note: See TracChangeset for help on using the changeset viewer.