Compare commits

...

2 Commits

Author SHA1 Message Date
Siroco
305cd0cb6c Gestion del PDF desde el atributo ACF en Wordpress.
Visionado del proceso de carga del documento en el mismo objeto.
2018-10-05 23:18:56 +02:00
Siroco
a535ed9a8e Add page.publitas_link for read PDF.
Nginx configuration for CORS https://www.industriapaisaia.eus
2018-10-05 18:16:19 +02:00
4 changed files with 26 additions and 13 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]="'../assets/'+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

@ -3,7 +3,7 @@ import { BrowserModule } from '@angular/platform-browser';
import { PageService } from '../page.service'; import { PageService } from '../page.service';
import { PageItem } from '../page'; import { PageItem } from '../page';
import { ActivatedRoute,Router, NavigationEnd } from "@angular/router"; import { ActivatedRoute,Router, NavigationEnd } from "@angular/router";
import { SafeResourceUrl, DomSanitizer } from '@angular/platform-browser'; import { SafeResourceUrl, DomSanitizer,SafeUrl } from '@angular/platform-browser';
import { import {
AccessibilityConfig, AccessibilityConfig,
Action, Action,
@ -34,12 +34,13 @@ import * as $ from 'jquery';
}) })
export class PageComponent implements OnInit { export class PageComponent implements OnInit {
pages : PageItem[]; pages : PageItem[] = [];
slug : string; slug : string;
parent : string; parent : string;
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
@ -69,11 +69,17 @@ export class PageComponent implements OnInit {
} }
getPage() { getPage() {
console.log(this.slug); // console.log(this.slug);
this.pageService.getPage(this.slug) this.pageService.getPage(this.slug)
.subscribe(data => { .subscribe(data => {
this.pages = data; this.pages = data;
//console.log(data); this.pages.forEach( (p) => {
var safeUrl:SafeUrl;
safeUrl = this.sanitizer.bypassSecurityTrustUrl('https://backend.industriapaisaia.eus/wp-content/uploads/2018/10/test.pdf');
p['publitas_link_sanitize'] = safeUrl;
if (p['pdf']) { p['pdfUrl'] = p['pdf']['url']; };
})
}); });
} }
@ -127,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) });
} }
@ -141,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.