From 112a62f01eacb2917340e057fe96adc9372a8ebc Mon Sep 17 00:00:00 2001 From: Drillllll <118617644+Drillllll@users.noreply.github.com> Date: Mon, 17 Jun 2024 20:11:58 +0200 Subject: [PATCH 1/2] image to map location in list added, image to map location in window info added --- .../map-location-info-window.component.css | 1 + .../map-location-info-window.component.html | 3 +- .../map-location-info-window.component.ts | 48 +++++------- .../map-location-list.component.css | 6 ++ .../map-location-list.component.html | 16 ++-- .../map-location-list.component.ts | 77 ++++++++++++------- src/app/map-location/map-location.service.ts | 14 +++- 7 files changed, 101 insertions(+), 64 deletions(-) diff --git a/src/app/map-location/map-location-info-window/map-location-info-window.component.css b/src/app/map-location/map-location-info-window/map-location-info-window.component.css index 4cca0f0..88857a1 100644 --- a/src/app/map-location/map-location-info-window/map-location-info-window.component.css +++ b/src/app/map-location/map-location-info-window/map-location-info-window.component.css @@ -39,6 +39,7 @@ height: 180px; width: 180px; overflow: hidden; + background-color: #89ecda; } .photo img { diff --git a/src/app/map-location/map-location-info-window/map-location-info-window.component.html b/src/app/map-location/map-location-info-window/map-location-info-window.component.html index 92f64d8..c2486e5 100644 --- a/src/app/map-location/map-location-info-window/map-location-info-window.component.html +++ b/src/app/map-location/map-location-info-window/map-location-info-window.component.html @@ -7,7 +7,8 @@
- map-location-photo + +
diff --git a/src/app/map-location/map-location-info-window/map-location-info-window.component.ts b/src/app/map-location/map-location-info-window/map-location-info-window.component.ts index 542b69b..fb0dab1 100644 --- a/src/app/map-location/map-location-info-window/map-location-info-window.component.ts +++ b/src/app/map-location/map-location-info-window/map-location-info-window.component.ts @@ -1,11 +1,9 @@ import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core'; import {MapLocation} from "../map-location.model"; import {NgForOf, NgIf} from "@angular/common"; -import {AudioService} from "../../audio/audio.service"; import {DomSanitizer, SafeUrl} from "@angular/platform-browser"; -import {maxPageSize} from "../../shared/http.config"; -import {Audio} from "../../audio/audio.model"; import {MapService} from "../../shared/map/map.service"; +import {MapLocationService} from "../map-location.service"; @Component({ selector: 'app-map-location-info-window', @@ -20,42 +18,36 @@ import {MapService} from "../../shared/map/map.service"; export class MapLocationInfoWindowComponent implements OnInit, OnChanges { @Input() mapLocation: MapLocation; - audiosEntities: Audio[] = []; - audiosUrls: SafeUrl[] = []; + imageUrl: SafeUrl = null; - constructor(private audioService: AudioService, private sanitizer: DomSanitizer, private mapService: MapService) { + + constructor( private sanitizer: DomSanitizer, + private mapService: MapService, + private mapLocationService: MapLocationService) { } ngOnChanges(changes: SimpleChanges): void { - this.audiosEntities = []; - this.audiosUrls = []; - - this.audioService.getAudiosByMapLocation(this.mapLocation, 0, maxPageSize).subscribe(response => { - this.audiosEntities = response.content; - - - for (let audio of this.audiosEntities) { - this.audioService.getAudioFileByAudio(audio).subscribe({ - next: (response: Blob | null) => { - //convert Blob (raw byte object) to url - if (response) { - const objectURL = URL.createObjectURL(response); - this.audiosUrls.push(this.sanitizer.bypassSecurityTrustUrl(objectURL)); - } - - }, - error: (error: any) => { - // - console.log("getaudio error") - } - }); + this.imageUrl = null; + + this.mapLocationService.getMapLocationImageById(this.mapLocation.id).subscribe({ + next: (response: Blob | null) => { + if (response) { + //convert Blob (raw byte object) to url to display it in the template + const objectURL = URL.createObjectURL(response); + this.imageUrl = this.sanitizer.bypassSecurityTrustUrl(objectURL); + } + }, + error: (error: any) => { + // } }); + } ngOnInit(): void { + } onDetailsClick() { diff --git a/src/app/map-location/map-location-list/map-location-list.component.css b/src/app/map-location/map-location-list/map-location-list.component.css index 3838c3c..4b4fe8c 100644 --- a/src/app/map-location/map-location-list/map-location-list.component.css +++ b/src/app/map-location/map-location-list/map-location-list.component.css @@ -26,6 +26,12 @@ width:200px; height: 200px; background-color: cadetblue; + overflow: hidden; +} + +.photo img { + height: 100%; + width: 100%; } .info-wrap { diff --git a/src/app/map-location/map-location-list/map-location-list.component.html b/src/app/map-location/map-location-list/map-location-list.component.html index 4fd8665..b9115d5 100644 --- a/src/app/map-location/map-location-list/map-location-list.component.html +++ b/src/app/map-location/map-location-list/map-location-list.component.html @@ -1,27 +1,27 @@
diff --git a/src/app/route/route-list/route-list.component.ts b/src/app/route/route-list/route-list.component.ts index db1ef2e..7d0d173 100644 --- a/src/app/route/route-list/route-list.component.ts +++ b/src/app/route/route-list/route-list.component.ts @@ -1,7 +1,7 @@ import {Component} from '@angular/core'; import {Route} from "../route.model"; import {RouteService} from "../route.service"; -import {NgForOf} from "@angular/common"; +import {NgForOf, NgIf} from "@angular/common"; import {RouteItemComponent} from "./route-item/route-item.component"; import {ActivatedRoute, Router, RouterLink, RouterLinkActive, RouterOutlet} from "@angular/router"; import {MapLocationService} from "../../map-location/map-location.service"; @@ -19,7 +19,8 @@ import {FormsModule} from "@angular/forms"; RouterLinkActive, RouterLink, RouterOutlet, - FormsModule + FormsModule, + NgIf ], templateUrl: './route-list.component.html', styleUrl: './route-list.component.css'