import {Component, OnInit} from '@angular/core'; import {Album} from "../shared/album.model"; import {ActivatedRoute} from "@angular/router"; import {Title} from "@angular/platform-browser"; import {DisplayImageService} from "../display-image/display-image.service"; import {environment} from "../../../environments/environment"; import {Image} from "../shared/image.model"; import {Thumbnail} from "../shared/thumbnail.model"; @Component({ selector: 'app-album', templateUrl: './album.component.html', styleUrls: ['./album.component.css'], }) export class AlbumComponent implements OnInit { public album: Album = new Album(); private thumbnails: Array; constructor(private titleService: Title, private route: ActivatedRoute, private displayImageService: DisplayImageService) {} ngOnInit() { this.route.data.subscribe((data: { albums: Array}) => { this.album = data.albums.find(album => album.slug == this.route.snapshot.params.slug); this.titleService.setTitle(`${this.album.name} - photos.yvan.hu`); this.thumbnails = this.initThumbnails(); if(this.route.snapshot.params.image) { this.imageClick( this.route.snapshot.params.slug, this.route.snapshot.params.image ); } }); } private initThumbnails(): Array { return this.album.images.map(image => { slug: '', image: this.imageUrl(image), path: image.path, label: { title: image.path, extraRight: '', extraLeft: '', }, }); } get thumbnailsLeft(): Array { let thumbs = []; for (let i=0;i { let thumbs = []; for (let i=1;i { let thumbs = []; for (let i=2;i image.path == path); if(this.album.images.length-1 > currentIndex) { this.displayImageService.activate( this.album.slug, this.album.images[currentIndex+1].path ) } } private prevImage(path: string) { let currentIndex: number = this.album.images.findIndex(image => image.path == path); if(0 < currentIndex) { this.displayImageService.activate( this.album.slug, this.album.images[currentIndex-1].path ) } } }