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 = [ const routes: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full'}, { path: '', redirectTo: 'home', pathMatch: 'full'},
{ path: 'home', component: HomeComponent }, { path: 'home', component: HomeComponent },
{ path: 'entrevista', component: InterviewComponent }, { path: 'entrevistas', component: InterviewComponent },
{ path: 'entrevista/:id', component: InterviewComponent }, { path: 'entrevistas/:id', component: InterviewComponent },
{ path: ':id', component: PageComponent }, { path: ':id', component: PageComponent },
{ path: ':parent/intro', redirectTo:':parent'}, { path: ':parent/intro', redirectTo:':parent'},
{ path: ':parent/:id', component: PageComponent}, { path: ':parent/:id', component: PageComponent},

View File

@ -3,18 +3,25 @@ import { Http, Response, RequestOptions, Headers, URLSearchParams } from '@angul
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import { InterviewItem } from './interview'; import { InterviewItem } from './interview';
import { Entrevistas, Entrevista, ImageDedalo, Informant, Audiovisual} from './entrevista'
@Injectable() @Injectable()
export class DedaloService { export class DedaloService {
apiUrl : string = "https://localhost:3000/interview" apiUrl : string = "http://api.industriapaisaia.eus/interviews"
entrevistas : Entrevista[]
constructor( constructor(
private http: Http private http: Http
) { } ) {}
getInterviews() : Observable<InterviewItem> { getInterviews() : Observable<Entrevistas> {
return this.http.get(this.apiUrl); 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="row" *ngFor="let entrevista of entrevistas">
<div class="item-container"> <div class="col-md-12">
<h3>Trabajo</h3> <div *ngIf="entrevista.audiovisual">
<div class="thumbnail-image"> <div *ngFor="let audiovisual of entrevista.audiovisual" [innerHTML]="audiovisual.rsc36"></div>
<a href="item.html"><h2>Juan Garcia</h2></a> </div>
</div> <video controls src="https://media.">
<div class="content"> </video>
<p>Breve intro de la entrevista aquí disponible.</p>
</div>
</div> </div>
</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 [routerLink]="entrevista.id"><h2>X{{entrevista.title}}</h2></a>
</div>
<div class="content">
<h3 [innerHTML]="entrevista.abstract"></h3>
</div>
</div>
</div>
</section>

View File

@ -1,5 +1,7 @@
import { Component, OnInit, Input} from '@angular/core'; import { Component, OnInit, Input} from '@angular/core';
import { InterviewItem } from '../interview'; import { InterviewItem } from '../interview';
import { Entrevista } from '../entrevista';
@Component({ @Component({
selector: 'app-interview-grid', selector: 'app-interview-grid',
@ -8,11 +10,11 @@ import { InterviewItem } from '../interview';
}) })
export class InterviewGridComponent implements OnInit { 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> </div>
<!--colcontent--> <!--colcontent-->
<div class="col-md-7"> <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>
</div> </div>
</article> </article>

View File

@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core';
import { PageItem } from '../page'; import { PageItem } from '../page';
import { InterviewItem } from '../interview'; import { InterviewItem } from '../interview';
import { DedaloService } from '../dedalo.service'; import { DedaloService } from '../dedalo.service';
import { Entrevista } from '../entrevista';
import { ActivatedRoute,Router, NavigationEnd } from "@angular/router";
@Component({ @Component({
selector: 'app-interview', selector: 'app-interview',
@ -12,9 +14,13 @@ export class InterviewComponent implements OnInit {
pages : PageItem[]; pages : PageItem[];
interviews : InterviewItem[]; interviews : InterviewItem[];
entrevistas : Entrevista[]
entrevistaID: string
single: boolean = false
constructor( constructor(
private dedaloService : DedaloService private entrevistaService : DedaloService,
private route: ActivatedRoute,
) { ) {
let p = new PageItem( let p = new PageItem(
'0', '0',
@ -25,6 +31,11 @@ export class InterviewComponent implements OnInit {
'0' '0'
); );
this.pages = [p]; this.pages = [p];
this.getEntrevistas()
this.route.params.subscribe( params => {
this.entrevistaID = params.id
if (params.id) this.single = true
});
} }
ngOnInit() { ngOnInit() {
@ -34,4 +45,20 @@ export class InterviewComponent implements OnInit {
this.interviews = []; 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 { Component, OnInit } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { PageService } from '../page.service'; import { PageService } from '../page.service';
import { DedaloService } from '../dedalo.service';
import { Entrevista } from '../entrevista';
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,SafeUrl } from '@angular/platform-browser'; import { SafeResourceUrl, DomSanitizer,SafeUrl } from '@angular/platform-browser';
@ -34,7 +36,8 @@ import * as $ from 'jquery';
}) })
export class PageComponent implements OnInit { export class PageComponent implements OnInit {
pages : PageItem[] = []; pages : PageItem[] = []
entrevistas : Entrevista[]
slug : string; slug : string;
parent : string; parent : string;
imageIndex = 1; imageIndex = 1;
@ -47,12 +50,14 @@ export class PageComponent implements OnInit {
private pageService: PageService, private pageService: PageService,
private galleryService: GalleryService, private galleryService: GalleryService,
private sanitizer: DomSanitizer, private sanitizer: DomSanitizer,
private router: Router private router: Router,
private entrevistaService : DedaloService
){ ){
this.route.params.subscribe( params => { this.route.params.subscribe( params => {
this.slug = params.id; this.slug = params.id;
this.parent = params.parent; this.parent = params.parent
this.getPage(); 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() { getPage() {
// console.log(this.slug); // console.log(this.slug);
this.pageService.getPage(this.slug) this.pageService.getPage(this.slug)