Construcción de los módulos de visionado de las entrevistas en base a la conexión con la API de dedalo.

This commit is contained in:
Siroco 2018-10-09 00:51:33 +02:00
parent 305cd0cb6c
commit 24541ba0d9
8 changed files with 151 additions and 26 deletions

View File

@ -8,8 +8,8 @@ import { InterviewComponent } from './interview/interview.component';
const routes: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full'},
{ path: 'home', component: HomeComponent },
{ path: 'entrevista', component: InterviewComponent },
{ path: 'entrevista/:id', component: InterviewComponent },
{ path: 'entrevistas', component: InterviewComponent },
{ path: 'entrevistas/:id', component: InterviewComponent },
{ path: ':id', component: PageComponent },
{ path: ':parent/intro', redirectTo:':parent'},
{ path: ':parent/:id', component: PageComponent},

View File

@ -3,18 +3,25 @@ import { Http, Response, RequestOptions, Headers, URLSearchParams } from '@angul
import { Observable } from 'rxjs';
import 'rxjs/add/operator/map';
import { InterviewItem } from './interview';
import { Entrevistas, Entrevista, ImageDedalo, Informant, Audiovisual} from './entrevista'
@Injectable()
export class DedaloService {
apiUrl : string = "https://localhost:3000/interview"
apiUrl : string = "http://api.industriapaisaia.eus/interviews"
entrevistas : Entrevista[]
constructor(
private http: Http
) { }
) {}
getInterviews() : Observable<InterviewItem> {
return this.http.get(this.apiUrl);
getInterviews() : Observable<Entrevistas> {
return this.http.get(this.apiUrl)
.map( (res: Response)=> {
//console.log('response :')
console.log(res.json())
return res.json()
})
}
}

42
src/app/entrevista.ts Normal file
View File

@ -0,0 +1,42 @@
export class Entrevistas {
constructor (
public count: number,
public result: Entrevista[]
) {}
}
export class Entrevista {
constructor(
public id : string,
public lang? : string,
public title? : string,
public abstract? : string,
public date? : string,
public informant?: Informant[],
public image?: ImageDedalo[],
public audiovisual?: Audiovisual[],
) {}
}
export class Informant {
constructor(
public id: string,
public name: string,
public surname: string
) {}
}
export class ImageDedalo {
constructor(
public id: string,
public src: string
){}
}
export class Audiovisual {
constructor(
public id: string,
public video: string,
public rsc36: string
){}
}

View File

@ -1,11 +1,42 @@
<div class="row item-container-wrapper">
<div class="item-container">
<h3>Trabajo</h3>
<!-- <div class="row" *ngFor="let entrevista of entrevistas">
<div class="col-md-12">
<div *ngIf="entrevista.audiovisual">
<div *ngFor="let audiovisual of entrevista.audiovisual" [innerHTML]="audiovisual.rsc36"></div>
</div>
<video controls src="https://media.">
</video>
</div>
</div> -->
<section class="entrevista" *ngIf="entrevistas && single">
<div class="row" *ngFor="let entrevista of entrevistas">
<div *ngFor="let i of entrevista">
<img [src]="i.src"/>
</div>
<h1>{{entrevista.title}}</h1>
<h3>{{entrevista.date}}</h3>
<blockquote>{{entrevista.abstract}}</blockquote>
<!-- informant -->
<ul class="informant">
<li *ngFor="let i of entrevista.informant">{{i.surname}}, {{i.name}}</li>
</ul>
<!-- audiovisual -->
<div *ngFor="let video of entrevista.audiovisual">
<video controls>
<source [src]="'http://media.anorgatarrak.eus'+video.video" type="video/mp4">
</video>
<div class="transcrip" [innerHTML]="video.rsc36"></div>
</div>
</div>
</section>
<section class="entrevista" *ngIf="entrevistas && !single">
<div class="row item-container-wrapper">
<div class="item-container" *ngFor="let entrevista of entrevistas">
<div class="thumbnail-image">
<a href="item.html"><h2>Juan Garcia</h2></a>
<a [routerLink]="entrevista.id"><h2>X{{entrevista.title}}</h2></a>
</div>
<div class="content">
<p>Breve intro de la entrevista aquí disponible.</p>
<h3 [innerHTML]="entrevista.abstract"></h3>
</div>
</div>
</div>
</section>

View File

@ -1,5 +1,7 @@
import { Component, OnInit, Input} from '@angular/core';
import { InterviewItem } from '../interview';
import { Entrevista } from '../entrevista';
@Component({
selector: 'app-interview-grid',
@ -8,11 +10,11 @@ import { InterviewItem } from '../interview';
})
export class InterviewGridComponent implements OnInit {
@Input() interviews : InterviewItem[]
@Input() entrevistas : Entrevista[]
@Input() single: boolean
constructor() { }
constructor() {}
ngOnInit() {
}
ngOnInit() {}
}

View File

@ -14,7 +14,7 @@
</div>
<!--colcontent-->
<div class="col-md-7">
<app-interview-grid [interviews]=interviews></app-interview-grid>
<app-interview-grid [entrevistas]="entrevistas" [single]="single"></app-interview-grid>
</div>
</div>
</article>

View File

@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core';
import { PageItem } from '../page';
import { InterviewItem } from '../interview';
import { DedaloService } from '../dedalo.service';
import { Entrevista } from '../entrevista';
import { ActivatedRoute,Router, NavigationEnd } from "@angular/router";
@Component({
selector: 'app-interview',
@ -12,9 +14,13 @@ export class InterviewComponent implements OnInit {
pages : PageItem[];
interviews : InterviewItem[];
entrevistas : Entrevista[]
entrevistaID: string
single: boolean = false
constructor(
private dedaloService : DedaloService
private entrevistaService : DedaloService,
private route: ActivatedRoute,
) {
let p = new PageItem(
'0',
@ -25,6 +31,11 @@ export class InterviewComponent implements OnInit {
'0'
);
this.pages = [p];
this.getEntrevistas()
this.route.params.subscribe( params => {
this.entrevistaID = params.id
if (params.id) this.single = true
});
}
ngOnInit() {
@ -34,4 +45,20 @@ export class InterviewComponent implements OnInit {
this.interviews = [];
}
getEntrevistas() {
this.entrevistaService.getInterviews()
.subscribe(data => {
// data.result.forEach( (e) => {
// e.audiovisal.forEach( (v) => {
// v.video = v.video.replace(/^.*[\\\/]/, '')
// })
// })
this.entrevistas = data.result
this.entrevistas = this.entrevistas.filter(entrevista => entrevista.lang == 'lg-spa')
if (this.entrevistaID) {
this.entrevistas = this.entrevistas.filter(entrevista => entrevista.id == this.entrevistaID)
}
})
}
}

View File

@ -1,6 +1,8 @@
import { Component, OnInit } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { PageService } from '../page.service';
import { DedaloService } from '../dedalo.service';
import { Entrevista } from '../entrevista';
import { PageItem } from '../page';
import { ActivatedRoute,Router, NavigationEnd } from "@angular/router";
import { SafeResourceUrl, DomSanitizer,SafeUrl } from '@angular/platform-browser';
@ -34,7 +36,8 @@ import * as $ from 'jquery';
})
export class PageComponent implements OnInit {
pages : PageItem[] = [];
pages : PageItem[] = []
entrevistas : Entrevista[]
slug : string;
parent : string;
imageIndex = 1;
@ -47,12 +50,14 @@ export class PageComponent implements OnInit {
private pageService: PageService,
private galleryService: GalleryService,
private sanitizer: DomSanitizer,
private router: Router
private router: Router,
private entrevistaService : DedaloService
){
this.route.params.subscribe( params => {
this.slug = params.id;
this.parent = params.parent;
this.getPage();
this.parent = params.parent
this.getPage()
// this.getEntrevistas()
} );
}
@ -68,6 +73,17 @@ export class PageComponent implements OnInit {
});
}
get diagnosticEntrevistas() {
return JSON.stringify(this.entrevistas)
}
// getEntrevistas() {
// this.entrevistaService.getInterviews()
// .subscribe(data => {
// this.entrevistas = data.result
// })
// }
getPage() {
// console.log(this.slug);
this.pageService.getPage(this.slug)