|
@ -1,7 +1,8 @@ |
|
|
import { Component, OnInit } from '@angular/core' |
|
|
|
|
|
|
|
|
import { Component, OnInit, ViewChild } from '@angular/core' |
|
|
import { Router, NavigationEnd, NavigationStart, ActivatedRoute } from '@angular/router' |
|
|
import { Router, NavigationEnd, NavigationStart, ActivatedRoute } from '@angular/router' |
|
|
import { DomSanitizer } from '@angular/platform-browser' |
|
|
import { DomSanitizer } from '@angular/platform-browser' |
|
|
import { Location } from '@angular/common' |
|
|
import { Location } from '@angular/common' |
|
|
|
|
|
import { NgxImageGalleryComponent, GALLERY_IMAGE, GALLERY_CONF } from "ngx-image-gallery" |
|
|
import { ApisService } from '../services/apis.service' |
|
|
import { ApisService } from '../services/apis.service' |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
@ -11,11 +12,21 @@ import { ApisService } from '../services/apis.service' |
|
|
}) |
|
|
}) |
|
|
export class DetailComponent implements OnInit { |
|
|
export class DetailComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
|
|
@ViewChild(NgxImageGalleryComponent) ngxImageGallery: NgxImageGalleryComponent |
|
|
|
|
|
|
|
|
public details: any = {} |
|
|
public details: any = {} |
|
|
public section: string = '' |
|
|
public section: string = '' |
|
|
public id: number = 0 |
|
|
public id: number = 0 |
|
|
private history: string[] = [] |
|
|
private history: string[] = [] |
|
|
|
|
|
|
|
|
|
|
|
public conf: GALLERY_CONF = { |
|
|
|
|
|
imageOffset: '0px', |
|
|
|
|
|
showDeleteControl: false, |
|
|
|
|
|
showImageTitle: false, |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public galleryImages: GALLERY_IMAGE[] = [] |
|
|
|
|
|
|
|
|
constructor( |
|
|
constructor( |
|
|
private apisService: ApisService, |
|
|
private apisService: ApisService, |
|
|
private router: Router, |
|
|
private router: Router, |
|
@ -43,6 +54,15 @@ export class DetailComponent implements OnInit { |
|
|
e.embed = this.sanitizer.bypassSecurityTrustResourceUrl(`https://www.youtube.com/embed/${e.code}`) |
|
|
e.embed = this.sanitizer.bypassSecurityTrustResourceUrl(`https://www.youtube.com/embed/${e.code}`) |
|
|
}) |
|
|
}) |
|
|
detail.gallery = detail.gallery ? JSON.parse(detail.gallery) : [] |
|
|
detail.gallery = detail.gallery ? JSON.parse(detail.gallery) : [] |
|
|
|
|
|
|
|
|
|
|
|
detail.gallery.forEach((e) => { |
|
|
|
|
|
this.galleryImages.push({ |
|
|
|
|
|
url: e.url, |
|
|
|
|
|
altText: e.title, |
|
|
|
|
|
title: e.title, |
|
|
|
|
|
thumbnailUrl: e.url |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
this.details = detail |
|
|
this.details = detail |
|
|
console.log(response.item) |
|
|
console.log(response.item) |
|
|
|
|
|
|
|
@ -65,4 +85,70 @@ export class DetailComponent implements OnInit { |
|
|
this.location.back() |
|
|
this.location.back() |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openGallery(index: number = 0) { |
|
|
|
|
|
this.ngxImageGallery.open(index); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// close gallery
|
|
|
|
|
|
closeGallery() { |
|
|
|
|
|
this.ngxImageGallery.close(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// set new active(visible) image in gallery
|
|
|
|
|
|
newImage(index: number = 0) { |
|
|
|
|
|
this.ngxImageGallery.setActiveImage(index); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// next image in gallery
|
|
|
|
|
|
nextImage(index: number = 0) { |
|
|
|
|
|
this.ngxImageGallery.next(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// prev image in gallery
|
|
|
|
|
|
prevImage(index: number = 0) { |
|
|
|
|
|
this.ngxImageGallery.prev(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
// EVENTS
|
|
|
|
|
|
// callback on gallery opened
|
|
|
|
|
|
galleryOpened(index) { |
|
|
|
|
|
console.info('Gallery opened at index ', index); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// callback on gallery closed
|
|
|
|
|
|
galleryClosed() { |
|
|
|
|
|
console.info('Gallery closed.'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// callback on gallery image clicked
|
|
|
|
|
|
galleryImageClicked(index) { |
|
|
|
|
|
console.info('Gallery image clicked with index ', index); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// callback on gallery image changed
|
|
|
|
|
|
galleryImageChanged(index) { |
|
|
|
|
|
console.info('Gallery image changed to index ', index); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// callback on user clicked delete button
|
|
|
|
|
|
deleteImage(index) { |
|
|
|
|
|
console.info('Delete image at index ', index); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|