Gestion del PDF desde el atributo ACF en Wordpress.

Visionado del proceso de carga del documento en el mismo objeto.
This commit is contained in:
Siroco 2018-10-05 23:18:56 +02:00
parent a535ed9a8e
commit 305cd0cb6c
4 changed files with 17 additions and 11 deletions

View File

@ -73,6 +73,9 @@ export class PageService {
page['parent_title']=item['parentTitle']['title']; page['parent_title']=item['parentTitle']['title'];
page['parent_link']=item['parentTitle']['link']; page['parent_link']=item['parentTitle']['link'];
if (item['acf']['pdf']) { page['pdf']=item['acf']['pdf']; }
else { page['pdf']=null; }
/* chilsd */ /* chilsd */
page["hasChild"]=item["hasChild"]; page["hasChild"]=item["hasChild"];
// if (item["hasChild"]) { // if (item["hasChild"]) {
@ -86,8 +89,6 @@ export class PageService {
/* featured images */ /* featured images */
if ( !childs && item["_embedded"]["wp:featuredmedia"]) { if ( !childs && item["_embedded"]["wp:featuredmedia"]) {
console.log('featured image: '+item.id);
console.log(item["_embedded"]["wp:featuredmedia"])
page["featuredmedia"] = item["_embedded"]["wp:featuredmedia"]; page["featuredmedia"] = item["_embedded"]["wp:featuredmedia"];
if (item["_embedded"]["wp:featuredmedia"][0]["media_details"]["sizes"]["large"]) { if (item["_embedded"]["wp:featuredmedia"][0]["media_details"]["sizes"]["large"]) {

View File

@ -36,11 +36,11 @@
<ks-modal-gallery [id]="0" [slideConfig]="{infinite: true, sidePreviews: {show: false}}" [buttonsConfig]="buttonsConfigIndustria" [previewConfig]="{visible: false}" [dotsConfig]="{visible: false}" [currentImageConfig]="{downloadable: true, description: {imageText:''}}" [modalImages]="page.gallery" [plainGalleryConfig]="customPlainGalleryRowDescConfig"></ks-modal-gallery> <ks-modal-gallery [id]="0" [slideConfig]="{infinite: true, sidePreviews: {show: false}}" [buttonsConfig]="buttonsConfigIndustria" [previewConfig]="{visible: false}" [dotsConfig]="{visible: false}" [currentImageConfig]="{downloadable: true, description: {imageText:''}}" [modalImages]="page.gallery" [plainGalleryConfig]="customPlainGalleryRowDescConfig"></ks-modal-gallery>
</section> </section>
<section class="section-publitas"> <section class="section-publitas">
<div class="row" *ngIf="page.publitas_link"> <div class="row" *ngIf="page.pdf">
<div class="col-md-12"> <div class="col-md-12">
<simple-pdf-viewer #pdfViewer [src]="page.publitas_link" [removePageBorders]="true"></simple-pdf-viewer> <simple-pdf-viewer #pdfViewer [src]="page.pdf.url" [removePageBorders]="true" (onProgress)="onProgressPDF($event,page.pdf.filesize)"></simple-pdf-viewer>
<div class="pdf-buttons" *ngIf="!pdfViewer.isDocumentLoaded()"> <div class="pdf-buttons" *ngIf="!pdfViewer.isDocumentLoaded()">
<button>Cargando documento</button> <button>Cargando documento {{loaderPDF}}%</button>
</div> </div>
<div class="pdf-buttons" style="" *ngIf="pdfViewer.isDocumentLoaded()"> <div class="pdf-buttons" style="" *ngIf="pdfViewer.isDocumentLoaded()">
<button (click)="pdfViewer.firstPage()">First Page</button> <button (click)="pdfViewer.firstPage()">First Page</button>

View File

@ -40,6 +40,7 @@ export class PageComponent implements OnInit {
imageIndex = 1; imageIndex = 1;
galleryId = 1; galleryId = 1;
gallery: Image[]; gallery: Image[];
loaderPDF: number;
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
@ -56,7 +57,6 @@ export class PageComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
console.log('init')
// $('html body').animate( // $('html body').animate(
// {scrollTop:0}, 1000); // {scrollTop:0}, 1000);
document.documentElement.scrollTop = 0 document.documentElement.scrollTop = 0
@ -78,9 +78,8 @@ export class PageComponent implements OnInit {
var safeUrl:SafeUrl; var safeUrl:SafeUrl;
safeUrl = this.sanitizer.bypassSecurityTrustUrl('https://backend.industriapaisaia.eus/wp-content/uploads/2018/10/test.pdf'); safeUrl = this.sanitizer.bypassSecurityTrustUrl('https://backend.industriapaisaia.eus/wp-content/uploads/2018/10/test.pdf');
p['publitas_link_sanitize'] = safeUrl; p['publitas_link_sanitize'] = safeUrl;
console.log(p['publitas_link_sanitize']); if (p['pdf']) { p['pdfUrl'] = p['pdf']['url']; };
}) })
//console.log(data);
}); });
} }
@ -134,12 +133,12 @@ buttonsConfigIndustria: ButtonsConfig = {
// } // }
onVisibleIndex(event: ImageModalEvent) { onVisibleIndex(event: ImageModalEvent) {
console.log('onVisibleIndex action: ' + Action[event.action]); // console.log('onVisibleIndex action: ' + Action[event.action]);
console.log('onVisibleIndex result:' + event.result); // console.log('onVisibleIndex result:' + event.result);
} }
openImageModalRowDescription(image: Image) { openImageModalRowDescription(image: Image) {
console.log('Opening modal gallery from custom plain gallery row and description, with image: ', image); // console.log('Opening modal gallery from custom plain gallery row and description, with image: ', image);
const index: number = this.getCurrentIndexCustomLayout(image, this.pages[0].gallery); const index: number = this.getCurrentIndexCustomLayout(image, this.pages[0].gallery);
this.customPlainGalleryRowDescConfig = Object.assign({}, this.customPlainGalleryRowDescConfig, { layout: new AdvancedLayout(index, true) }); this.customPlainGalleryRowDescConfig = Object.assign({}, this.customPlainGalleryRowDescConfig, { layout: new AdvancedLayout(index, true) });
} }
@ -148,4 +147,10 @@ private getCurrentIndexCustomLayout(image: Image, images: Image[]): number {
return image ? images.indexOf(image) : -1; return image ? images.indexOf(image) : -1;
} }
onProgressPDF(event,total) {
let loadInt = parseInt(event.loaded, 10);
let totalInt = parseInt(total,10);
this.loaderPDF = Math.floor(loadInt/totalInt*100);
}
} }

Binary file not shown.