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 {
import { Germplasm, GermplasmData, GermplasmResult, Institute, Origin, Site } from './models/gnpis.germplasm.model';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { Util } from 'leaflet';
describe('BrapiService', () => {
......@@ -379,7 +378,7 @@ describe('BrapiService', () => {
});
it('should fetch the germplasm progeny', () => {
/*it('should fetch the germplasm progeny', () => {
let fetchedGermplasmProgeny: GermplasmResult<BrapiGermplasmProgeny>;
const germplasmDbId: string = brapiGermplasmProgeny.result.germplasmDbId;
......@@ -391,7 +390,7 @@ describe('BrapiService', () => {
expect(fetchedGermplasmProgeny).toEqual(brapiGermplasmProgeny);
});
});*/
it('should fetch the germplasm attributes', () => {
......
......@@ -11,7 +11,7 @@ import {
BrapiStudy,
BrapiTrial
} 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';
......@@ -33,9 +33,9 @@ export class BrapiService {
.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`);
}
}*/
germplasmAttributes(germplasmDbId: string): Observable<GermplasmResult<GermplasmData<BrapiGermplasmAttributes[]>>> {
return this.http
......
......@@ -733,20 +733,29 @@
</gpds-card-row>
<gpds-card-row
label="Descendant"
label="Descendant :"
[test]="testProgeny()">
<ng-template>
</gpds-card-row>
<div class="content-overflow">
<ng-container *ngFor="let child of germplasmProgeny.progeny">
<a [routerLink]="'/germplasm'" [queryParams]="{id:child.germplasmDbId }">
{{ child.defaultDisplayName }}
</a>,
</ng-container>
</div>
<div class="content-overflow-big">
<ng-container *ngFor="let child of germplasmProgeny">
</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>
</ng-template>
......
......@@ -11,7 +11,6 @@ import {
BrapiDonor,
BrapiGermplasmAttributes,
BrapiGermplasmPedigree,
BrapiGermplasmProgeny,
BrapiSet,
BrapiSibling
} from '../models/brapi.germplasm.model';
......@@ -47,7 +46,7 @@ describe('GermplasmCardComponent', () => {
const brapiService = jasmine.createSpyObj(
'BrapiService', [
'germplasm',
'germplasmProgeny',
/*'germplasmProgeny',*/
'germplasmPedigree',
'germplasmAttributes'
]
......@@ -97,13 +96,13 @@ describe('GermplasmCardComponent', () => {
}
};
const brapiGermplasmProgeny: GermplasmResult<BrapiGermplasmProgeny> = {
/*const brapiGermplasmProgeny: GermplasmResult<BrapiGermplasmProgeny> = {
result: {
germplasmDbId: '11',
defaultDisplayName: '11',
progeny: [brapiSibling]
}
};
};*/
const brapiInstitute: Institute = {
instituteName: 'urgi',
......@@ -228,7 +227,7 @@ describe('GermplasmCardComponent', () => {
gnpisService.germplasm.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.germplasmAttributes.and.returnValue(of(brapiGermplasmAttributes));
......
......@@ -2,8 +2,8 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { BrapiService } from '../brapi.service';
import { GnpisService } from '../gnpis.service';
import { Germplasm } from '../models/gnpis.germplasm.model';
import { BrapiGermplasmAttributes, BrapiGermplasmPedigree, BrapiGermplasmProgeny } from '../models/brapi.germplasm.model';
import { Germplasm, GermplasmProgeny } from '../models/gnpis.germplasm.model';
import { BrapiGermplasmAttributes, BrapiGermplasmPedigree } from '../models/brapi.germplasm.model';
@Component({
selector: 'gpds-germplasm-card',
......@@ -19,7 +19,7 @@ export class GermplasmCardComponent implements OnInit {
germplasmGnpis: Germplasm;
germplasmPedigree: BrapiGermplasmPedigree;
germplasmProgeny: BrapiGermplasmProgeny;
germplasmProgeny: GermplasmProgeny[];
germplasmAttributes: BrapiGermplasmAttributes[];
germplasmId: string;
germplasmPuid: string;
......@@ -39,11 +39,12 @@ export class GermplasmCardComponent implements OnInit {
const germplasm$ = this.getGermplasm(this.germplasmId, this.germplasmPuid);
germplasm$.then(result => {
const germplasmId = this.germplasmId ? this.germplasmId : result.germplasmDbId;
const germplasmProgeny$ = this.brapiService.germplasmProgeny(germplasmId).toPromise();
/*const germplasmProgeny$ = this.brapiService.germplasmProgeny(germplasmId).toPromise();
germplasmProgeny$
.then(germplasmProgeny => {
this.germplasmProgeny = germplasmProgeny.result;
});
});*/
const germplasmPedigree$ = this.brapiService.germplasmPedigree(germplasmId).toPromise();
germplasmPedigree$
......@@ -75,6 +76,7 @@ export class GermplasmCardComponent implements OnInit {
germplasm$
.then(germplasmGnpis => {
this.germplasmGnpis = germplasmGnpis;
this.germplasmProgeny = germplasmGnpis.children;
});
} else {
germplasm$ = this.gnpisService.germplasmByPuid(pui).toPromise();
......@@ -89,8 +91,7 @@ export class GermplasmCardComponent implements OnInit {
// TODO: use a generic function to get path in object (or null if non-existent)
testProgeny() {
return (this.germplasmProgeny
&& this.germplasmProgeny.progeny
&& this.germplasmProgeny.progeny.length > 0);
&& this.germplasmProgeny.length > 0);
}
testPedigree() {
......
......@@ -8,6 +8,57 @@ export interface Site {
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 {
source: string;
url: string;
......@@ -43,7 +94,7 @@ export interface Germplasm {
holdingInstitute: Institute;
holdingGenbank: Institute;
presenceStatus: string;
children: string;
children: GermplasmProgeny[];
descriptors: BrapiDescriptor[];
originSite: Site;
collectingSite: Site;
......@@ -56,38 +107,6 @@ export interface Germplasm {
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> {
data: T;
}
......
......@@ -27,6 +27,11 @@ h3 {
overflow-y: auto;
}
.content-overflow-big {
max-height: 275px;
overflow-y: auto;
}
.display-spinner-front {
position: absolute;
top: 70px;
......
......@@ -15,7 +15,7 @@
],
"template-cyclomatic-complexity": [
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