Changeset 28d7d35 for Farmatiko/ClientApp/src/app/counter
- Timestamp:
- 01/31/21 06:27:26 (4 years ago)
- Branches:
- master
- Children:
- de9d697
- Parents:
- 7520f88
- Location:
- Farmatiko/ClientApp/src/app/counter
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Farmatiko/ClientApp/src/app/counter/counter.component.css
r7520f88 r28d7d35 2 2 display: flex; 3 3 flex-direction: column; 4 max-height: 500px;5 4 min-width: 300px; 6 5 } … … 27 26 padding: 1em 0; 28 27 } 28 .tableRow:hover { 29 background-color: #D4F2CD; 30 transform: scale(1.0005); 31 } 32 33 h2 button { 34 float: right; 35 padding: 0 5em; 36 } 37 38 #map { 39 height: 100%; 40 } 41 42 .map-frame { 43 border: 2px solid black; 44 height: 100%; 45 } 46 47 .map-wrapper { 48 margin: 0 3em 3em 3em; 49 min-height: 400px; 50 } -
Farmatiko/ClientApp/src/app/counter/counter.component.html
r7520f88 r28d7d35 6 6 <div class="wrapper"> 7 7 <div class="header"> 8 <h2>Здравствени установи</h2> 8 <h2>Здравствени установи 9 <button mat-icon-button color="primary" (click)="refreshMap()" [disabled]="!showMap"> 10 <mat-icon>refresh</mat-icon>Освежи 11 </button> 12 <button mat-icon-button color="accent" [disabled]="clicked" (click)="toggleMap(); clicked = true"> 13 <mat-icon>map</mat-icon>Активирај 14 </button> 15 </h2> 16 <div class="map-wrapper" *ngIf="showMap"> 17 <div class="map-frame"> 18 <div id="map" style="height: 400px;" leaflet [leafletOptions]="options"></div> 19 </div> 20 </div> 21 9 22 <mat-form-field> 10 23 <input matInput (keyup)="applyFilterFacilities($event.target.value)" placeholder="Пронајди установа"> … … 16 29 <th>Име</th> 17 30 <th>Општина</th> 18 <th>Адреса</th>19 31 <th>Тип</th> 20 <th>Е-пошта</th>21 <th>Телефон</th>22 32 </tr> 23 33 </thead> 24 34 <tbody> 25 <tr *ngFor="let facility of filteredFacilities" >26 <td> <a (click)="openFacilityDialog(facility)">{{ facility.name }}</a></td>35 <tr *ngFor="let facility of filteredFacilities" (click)="openFacilityDialog(facility)" class="tableRow"> 36 <td>{{ facility.name }}</td> 27 37 <td>{{ facility.municipality }}</td> 28 <td>{{ facility.address }}</td>29 38 <td>{{ facility.type }}</td> 30 <td>{{ facility.email }}</td>31 <td>{{ facility.phone }}</td>32 39 </tr> 33 40 </tbody> … … 48 55 <th>Име</th> 49 56 <th>Гранка</th> 50 <th>Установа</th>51 <th>Назив</th>52 57 </tr> 53 58 </thead> 54 59 <tbody> 55 <tr *ngFor="let worker of filteredWorkers" >56 <td> <a (click)="openWorkerDialog(worker)">{{ worker.name }}</a></td>60 <tr *ngFor="let worker of filteredWorkers" (click)="openWorkerDialog(worker)" class="tableRow"> 61 <td>{{ worker.name }}</td> 57 62 <td>{{ worker.branch }}</td> 58 <td>{{ worker.facility }}</td>59 <td>{{ worker.title }}</td>60 63 </tr> 61 64 </tbody> -
Farmatiko/ClientApp/src/app/counter/counter.component.ts
r7520f88 r28d7d35 5 5 import { FacilityDialogComponent } from '../dialogs/facility-dialog/facility-dialog.component'; 6 6 import { WorkerDialogComponent } from '../dialogs/worker-dialog/worker-dialog.component'; 7 import { latLng, LatLng, tileLayer, marker, icon } from 'leaflet'; 8 import { HttpClient } from '@angular/common/http'; 7 9 8 10 @Component({ … … 16 18 public filteredFacilities: IHealthFacilities[] = []; 17 19 public filteredWorkers: IHealthcareWorkers[] = []; 18 19 constructor(private dataService: DataService, private dialog: MatDialog) { 20 public lat; 21 public lng; 22 clicked = false; 23 showMap: boolean = false; 24 options = { 25 layers: [ 26 tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' }) 27 ], 28 zoom: 8, 29 center: latLng(41.61807, 21.74348) 30 } 31 32 constructor(private dataService: DataService, private dialog: MatDialog, private http: HttpClient) { 20 33 21 34 } … … 27 40 }, 28 41 (err: any) => console.log(err), 29 () => console.log('Facility data retrieved!')); 42 () => { 43 this.appendFacilityMarkers(this.facilities) 44 console.log('Facility data retrieved!'); 45 }); 30 46 31 47 this.dataService.getWorkers() … … 35 51 (err: any) => console.log(err), 36 52 () => console.log('Facility data retrieved!')); 53 54 if (navigator.geolocation) { 55 navigator.geolocation.getCurrentPosition((position) => { 56 if (position) { 57 this.lat = position.coords.latitude; 58 this.lng = position.coords.longitude; 59 let layer = marker([ this.lat, this.lng ], { 60 icon: icon({ 61 iconSize: [ 25, 41 ], 62 iconAnchor: [ 13, 41 ], 63 iconUrl: 'assets/home-icon.png' 64 }) 65 }).bindPopup("Вашата локација"); 66 this.options.layers.push(layer); 67 } 68 }); 69 } 70 } 71 72 appendFacilityMarkers(facils: IHealthFacilities[]) { 73 this.options.layers = []; 74 this.options.layers.push(tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'})); 75 if(this.lat && this.lng) { 76 this.options.layers.push(marker([ this.lat, this.lng ], { 77 icon: icon({ 78 iconSize: [ 25, 41 ], 79 iconAnchor: [ 13, 41 ], 80 iconUrl: 'assets/home-icon.png' 81 }) 82 }).bindPopup("Вашата локација")); 83 } 84 facils.forEach((facil) => { 85 this.http.get<any>('https://nominatim.openstreetmap.org/search/?country=Macedonia&city='+facil.municipality+'&street='+facil.address+'&format=json').subscribe(obj => { 86 console.log(obj); 87 if(obj.length) { 88 let layer = marker([ obj[0]?.lat, obj[0]?.lon ], { 89 icon: icon({ 90 iconSize: [ 25, 41 ], 91 iconAnchor: [ 13, 41 ], 92 iconUrl: 'assets/hospital-icon.png' 93 }) 94 }).bindPopup(facil.name); 95 this.options.layers.push(layer); 96 } 97 }, error => console.error(error)); 98 }); 37 99 } 38 100 … … 45 107 }, 46 108 (err: any) => console.log(err), 47 () => console.log('Facility data retrieved!')); 109 () => { 110 this.appendFacilityMarkers(this.filteredFacilities); 111 if(this.showMap) { 112 this.showMap = false; 113 setTimeout(() => this.showMap = true, 300); 114 } 115 console.log('Facility data retrieved!'); 116 }); 48 117 } 49 118 else { 50 119 this.filteredFacilities = this.facilities; 120 this.appendFacilityMarkers(this.facilities); 121 if(this.showMap) { 122 this.showMap = false; 123 setTimeout(() => this.showMap = true, 300); 124 } 51 125 } 52 126 } … … 80 154 }); 81 155 } 156 157 toggleMap() { 158 this.showMap = !this.showMap; 159 } 160 161 refreshMap() { 162 this.showMap = false; 163 setTimeout(() => this.showMap = true, 300); 164 } 165 82 166 }
Note:
See TracChangeset
for help on using the changeset viewer.