Commit 64ccbd2a authored by Jérémy Destin's avatar Jérémy Destin Committed by Célia Michotey
Browse files

feat: Use components (card-section, card-row and card-table) to display the...

feat: Use components (card-section, card-row and card-table) to display the parents of the progeny. Use the germplasm GnpIS call for progeny.GNP-5490
parent a2a9eb38
...@@ -22,7 +22,6 @@ import { ...@@ -22,7 +22,6 @@ import {
import { Germplasm, GermplasmData, GermplasmResult, Institute, Origin, Site } from './models/gnpis.germplasm.model'; import { Germplasm, GermplasmData, GermplasmResult, Institute, Origin, Site } from './models/gnpis.germplasm.model';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { Util } from 'leaflet';
describe('BrapiService', () => { describe('BrapiService', () => {
...@@ -379,7 +378,7 @@ describe('BrapiService', () => { ...@@ -379,7 +378,7 @@ describe('BrapiService', () => {
}); });
it('should fetch the germplasm progeny', () => { /*it('should fetch the germplasm progeny', () => {
let fetchedGermplasmProgeny: GermplasmResult<BrapiGermplasmProgeny>; let fetchedGermplasmProgeny: GermplasmResult<BrapiGermplasmProgeny>;
const germplasmDbId: string = brapiGermplasmProgeny.result.germplasmDbId; const germplasmDbId: string = brapiGermplasmProgeny.result.germplasmDbId;
...@@ -391,7 +390,7 @@ describe('BrapiService', () => { ...@@ -391,7 +390,7 @@ describe('BrapiService', () => {
expect(fetchedGermplasmProgeny).toEqual(brapiGermplasmProgeny); expect(fetchedGermplasmProgeny).toEqual(brapiGermplasmProgeny);
}); });*/
it('should fetch the germplasm attributes', () => { it('should fetch the germplasm attributes', () => {
......
...@@ -11,7 +11,7 @@ import { ...@@ -11,7 +11,7 @@ import {
BrapiStudy, BrapiStudy,
BrapiTrial BrapiTrial
} from './models/brapi.model'; } from './models/brapi.model';
import { BrapiGermplasmAttributes, BrapiGermplasmPedigree, BrapiGermplasmProgeny } from './models/brapi.germplasm.model'; import { BrapiGermplasmAttributes, BrapiGermplasmPedigree } from './models/brapi.germplasm.model';
export const BASE_URL = 'brapi/v1'; export const BASE_URL = 'brapi/v1';
...@@ -33,9 +33,9 @@ export class BrapiService { ...@@ -33,9 +33,9 @@ export class BrapiService {
.get<GermplasmResult<BrapiGermplasmPedigree>>(`${BASE_URL}/germplasm/${germplasmDbId}/pedigree`); .get<GermplasmResult<BrapiGermplasmPedigree>>(`${BASE_URL}/germplasm/${germplasmDbId}/pedigree`);
} }
germplasmProgeny(germplasmDbId: string): Observable<GermplasmResult<BrapiGermplasmProgeny>> { /*germplasmProgeny(germplasmDbId: string): Observable<GermplasmResult<BrapiGermplasmProgeny>> {
return this.http.get<GermplasmResult<BrapiGermplasmProgeny>>(`${BASE_URL}/germplasm/${germplasmDbId}/progeny`); return this.http.get<GermplasmResult<BrapiGermplasmProgeny>>(`${BASE_URL}/germplasm/${germplasmDbId}/progeny`);
} }*/
germplasmAttributes(germplasmDbId: string): Observable<GermplasmResult<GermplasmData<BrapiGermplasmAttributes[]>>> { germplasmAttributes(germplasmDbId: string): Observable<GermplasmResult<GermplasmData<BrapiGermplasmAttributes[]>>> {
return this.http return this.http
......
...@@ -733,20 +733,29 @@ ...@@ -733,20 +733,29 @@
</gpds-card-row> </gpds-card-row>
<gpds-card-row <gpds-card-row
label="Descendant" label="Descendant :"
[test]="testProgeny()"> [test]="testProgeny()">
<ng-template> </gpds-card-row>
<div class="content-overflow"> <div class="content-overflow-big">
<ng-container *ngFor="let child of germplasmProgeny.progeny"> <ng-container *ngFor="let child of germplasmProgeny">
<a [routerLink]="'/germplasm'" [queryParams]="{id:child.germplasmDbId }">
{{ child.defaultDisplayName }}
</a>,
</ng-container>
</div>
</ng-template> <gpds-card-row
</gpds-card-row> [label]="'Child of ' + child.firstParentName + ' and ' + child.secondParentName"
[test]="testProgeny()">
<ng-template>
<ng-container *ngFor="let sibling of child.sibblings">
<a [routerLink]="'/germplasm'" [queryParams]="{pui:sibling.pui}">
{{ sibling.name }}
</a>,
</ng-container>
</ng-template>
</gpds-card-row>
</ng-container>
</div>
</div> </div>
</ng-template> </ng-template>
......
...@@ -11,7 +11,6 @@ import { ...@@ -11,7 +11,6 @@ import {
BrapiDonor, BrapiDonor,
BrapiGermplasmAttributes, BrapiGermplasmAttributes,
BrapiGermplasmPedigree, BrapiGermplasmPedigree,
BrapiGermplasmProgeny,
BrapiSet, BrapiSet,
BrapiSibling BrapiSibling
} from '../models/brapi.germplasm.model'; } from '../models/brapi.germplasm.model';
...@@ -47,7 +46,7 @@ describe('GermplasmCardComponent', () => { ...@@ -47,7 +46,7 @@ describe('GermplasmCardComponent', () => {
const brapiService = jasmine.createSpyObj( const brapiService = jasmine.createSpyObj(
'BrapiService', [ 'BrapiService', [
'germplasm', 'germplasm',
'germplasmProgeny', /*'germplasmProgeny',*/
'germplasmPedigree', 'germplasmPedigree',
'germplasmAttributes' 'germplasmAttributes'
] ]
...@@ -97,13 +96,13 @@ describe('GermplasmCardComponent', () => { ...@@ -97,13 +96,13 @@ describe('GermplasmCardComponent', () => {
} }
}; };
const brapiGermplasmProgeny: GermplasmResult<BrapiGermplasmProgeny> = { /*const brapiGermplasmProgeny: GermplasmResult<BrapiGermplasmProgeny> = {
result: { result: {
germplasmDbId: '11', germplasmDbId: '11',
defaultDisplayName: '11', defaultDisplayName: '11',
progeny: [brapiSibling] progeny: [brapiSibling]
} }
}; };*/
const brapiInstitute: Institute = { const brapiInstitute: Institute = {
instituteName: 'urgi', instituteName: 'urgi',
...@@ -228,7 +227,7 @@ describe('GermplasmCardComponent', () => { ...@@ -228,7 +227,7 @@ describe('GermplasmCardComponent', () => {
gnpisService.germplasm.and.returnValue(of(germplasmTest)); gnpisService.germplasm.and.returnValue(of(germplasmTest));
gnpisService.germplasmByPuid.and.returnValue(of(germplasmTest)); gnpisService.germplasmByPuid.and.returnValue(of(germplasmTest));
brapiService.germplasmProgeny.and.returnValue(of(brapiGermplasmProgeny)); /*brapiService.germplasmProgeny.and.returnValue(of(brapiGermplasmProgeny));*/
brapiService.germplasmPedigree.and.returnValue(of(brapiGermplasmPedigree)); brapiService.germplasmPedigree.and.returnValue(of(brapiGermplasmPedigree));
brapiService.germplasmAttributes.and.returnValue(of(brapiGermplasmAttributes)); brapiService.germplasmAttributes.and.returnValue(of(brapiGermplasmAttributes));
......
...@@ -2,8 +2,8 @@ import { Component, OnInit } from '@angular/core'; ...@@ -2,8 +2,8 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { BrapiService } from '../brapi.service'; import { BrapiService } from '../brapi.service';
import { GnpisService } from '../gnpis.service'; import { GnpisService } from '../gnpis.service';
import { Germplasm } from '../models/gnpis.germplasm.model'; import { Germplasm, GermplasmProgeny } from '../models/gnpis.germplasm.model';
import { BrapiGermplasmAttributes, BrapiGermplasmPedigree, BrapiGermplasmProgeny } from '../models/brapi.germplasm.model'; import { BrapiGermplasmAttributes, BrapiGermplasmPedigree } from '../models/brapi.germplasm.model';
@Component({ @Component({
selector: 'gpds-germplasm-card', selector: 'gpds-germplasm-card',
...@@ -19,7 +19,7 @@ export class GermplasmCardComponent implements OnInit { ...@@ -19,7 +19,7 @@ export class GermplasmCardComponent implements OnInit {
germplasmGnpis: Germplasm; germplasmGnpis: Germplasm;
germplasmPedigree: BrapiGermplasmPedigree; germplasmPedigree: BrapiGermplasmPedigree;
germplasmProgeny: BrapiGermplasmProgeny; germplasmProgeny: GermplasmProgeny[];
germplasmAttributes: BrapiGermplasmAttributes[]; germplasmAttributes: BrapiGermplasmAttributes[];
germplasmId: string; germplasmId: string;
germplasmPuid: string; germplasmPuid: string;
...@@ -39,11 +39,12 @@ export class GermplasmCardComponent implements OnInit { ...@@ -39,11 +39,12 @@ export class GermplasmCardComponent implements OnInit {
const germplasm$ = this.getGermplasm(this.germplasmId, this.germplasmPuid); const germplasm$ = this.getGermplasm(this.germplasmId, this.germplasmPuid);
germplasm$.then(result => { germplasm$.then(result => {
const germplasmId = this.germplasmId ? this.germplasmId : result.germplasmDbId; const germplasmId = this.germplasmId ? this.germplasmId : result.germplasmDbId;
const germplasmProgeny$ = this.brapiService.germplasmProgeny(germplasmId).toPromise();
/*const germplasmProgeny$ = this.brapiService.germplasmProgeny(germplasmId).toPromise();
germplasmProgeny$ germplasmProgeny$
.then(germplasmProgeny => { .then(germplasmProgeny => {
this.germplasmProgeny = germplasmProgeny.result; this.germplasmProgeny = germplasmProgeny.result;
}); });*/
const germplasmPedigree$ = this.brapiService.germplasmPedigree(germplasmId).toPromise(); const germplasmPedigree$ = this.brapiService.germplasmPedigree(germplasmId).toPromise();
germplasmPedigree$ germplasmPedigree$
...@@ -75,6 +76,7 @@ export class GermplasmCardComponent implements OnInit { ...@@ -75,6 +76,7 @@ export class GermplasmCardComponent implements OnInit {
germplasm$ germplasm$
.then(germplasmGnpis => { .then(germplasmGnpis => {
this.germplasmGnpis = germplasmGnpis; this.germplasmGnpis = germplasmGnpis;
this.germplasmProgeny = germplasmGnpis.children;
}); });
} else { } else {
germplasm$ = this.gnpisService.germplasmByPuid(pui).toPromise(); germplasm$ = this.gnpisService.germplasmByPuid(pui).toPromise();
...@@ -89,8 +91,7 @@ export class GermplasmCardComponent implements OnInit { ...@@ -89,8 +91,7 @@ export class GermplasmCardComponent implements OnInit {
// TODO: use a generic function to get path in object (or null if non-existent) // TODO: use a generic function to get path in object (or null if non-existent)
testProgeny() { testProgeny() {
return (this.germplasmProgeny return (this.germplasmProgeny
&& this.germplasmProgeny.progeny && this.germplasmProgeny.length > 0);
&& this.germplasmProgeny.progeny.length > 0);
} }
testPedigree() { testPedigree() {
......
...@@ -8,6 +8,57 @@ export interface Site { ...@@ -8,6 +8,57 @@ export interface Site {
siteType: string; siteType: string;
} }
export interface Institute {
instituteName: string;
instituteCode: string;
acronym: string;
organisation: string;
instituteType: string;
webSite: string;
address: string;
logo: string;
}
export interface Origin extends Institute {
institute: Institute;
germplasmPUI: string;
accessionNumber: string;
accessionCreationDate: string;
materialType: string;
collectors: string;
registrationYear: string;
deregistrationYear: string;
distributionStatus: string;
}
export interface Photo {
copyright: string;
description: string;
fileName: string;
photoName: string;
thumbnailFileName: string;
}
export interface GermplasmProgeny {
crossingPlan: string;
crossingYear: string;
familyCode: string;
firstParentName: string;
firstParentPUI: string;
firstParentType: string;
secondParentName: string;
secondParentPUI: string;
secondParentType: string;
sibblings: {
name: string;
pui: string;
value: string;
}[];
}
export interface Germplasm { export interface Germplasm {
source: string; source: string;
url: string; url: string;
...@@ -43,7 +94,7 @@ export interface Germplasm { ...@@ -43,7 +94,7 @@ export interface Germplasm {
holdingInstitute: Institute; holdingInstitute: Institute;
holdingGenbank: Institute; holdingGenbank: Institute;
presenceStatus: string; presenceStatus: string;
children: string; children: GermplasmProgeny[];
descriptors: BrapiDescriptor[]; descriptors: BrapiDescriptor[];
originSite: Site; originSite: Site;
collectingSite: Site; collectingSite: Site;
...@@ -56,38 +107,6 @@ export interface Germplasm { ...@@ -56,38 +107,6 @@ export interface Germplasm {
population: BrapiSet[]; population: BrapiSet[];
} }
export interface Institute {
instituteName: string;
instituteCode: string;
acronym: string;
organisation: string;
instituteType: string;
webSite: string;
address: string;
logo: string;
}
export interface Origin extends Institute {
institute: Institute;
germplasmPUI: string;
accessionNumber: string;
accessionCreationDate: string;
materialType: string;
collectors: string;
registrationYear: string;
deregistrationYear: string;
distributionStatus: string;
}
export interface Photo {
copyright: string;
description: string;
fileName: string;
photoName: string;
thumbnailFileName: string;
}
export interface GermplasmData<T> { export interface GermplasmData<T> {
data: T; data: T;
} }
......
...@@ -27,6 +27,11 @@ h3 { ...@@ -27,6 +27,11 @@ h3 {
overflow-y: auto; overflow-y: auto;
} }
.content-overflow-big {
max-height: 275px;
overflow-y: auto;
}
.display-spinner-front { .display-spinner-front {
position: absolute; position: absolute;
top: 70px; top: 70px;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
], ],
"template-cyclomatic-complexity": [ "template-cyclomatic-complexity": [
true, true,
11 12
] ]
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment