Skip to content

Commit

Permalink
Taxhub v2 : suppression appel à la route bibnoms (#3214)
Browse files Browse the repository at this point in the history
  • Loading branch information
amandine-sahl authored Oct 8, 2024
1 parent f667a48 commit 0a6c1de
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 46 deletions.
18 changes: 4 additions & 14 deletions frontend/src/app/GN2CommonModule/form/data-form.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,15 @@ export class DataFormService {
});
}

getTaxonInfo(cd_nom: number, areasStatus?: Array<string>) {
getTaxonInfo(cd_nom: number, fields?: Array<string>, areasStatus?: Array<string>) {
let query_string = new HttpParams();
if (areasStatus) {
query_string = query_string.append('areas_status', areasStatus.join(','));
}
return this._http.get<Taxon>(`${this.config.API_TAXHUB}/taxref/${cd_nom}`, {
params: query_string,
});
}

getTaxonAttributsAndMedia(cd_nom: number, id_attributs?: Array<number>) {
let query_string = new HttpParams();
if (id_attributs) {
id_attributs.forEach((id) => {
query_string = query_string.append('id_attribut', id.toString());
});
if (fields) {
query_string = query_string.append('fields', fields.join(','));
}

return this._http.get<any>(`${this.config.API_TAXHUB}/bibnoms/taxoninfo/${cd_nom}`, {
return this._http.get<Taxon>(`${this.config.API_TAXHUB}/taxref/${cd_nom}`, {
params: query_string,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,10 @@ <h5 class="underlined underlined-sm main-color">Attribut(s) Taxonomique(s) locau
<table class="font-xs table table-striped table-sm">
<tr
class="font-xs"
*ngFor="let attr of selectObsTaxonInfo?.attributs"
*ngFor="let attr of selectedObsTaxonDetail?.attributs"
>
<td>
<b>{{ attr.label_attribut }}</b>
<b>{{ attr?.bib_attribut?.label_attribut }}</b>
</td>
<td>{{ attr.valeur_attribut }}</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export class SyntheseInfoObsComponent implements OnInit, OnChanges {
public profileDataChecks: any;
public showValidation = false;

public selectObsTaxonInfo;
public selectCdNomenclature;
public formatedAreas = [];
public isLoading = false;
Expand Down Expand Up @@ -195,22 +194,19 @@ export class SyntheseInfoObsComponent implements OnInit, OnChanges {
this.formatedAreas.push({ area_type: key, areas: areaDict[key] });
}

this._gnDataService
.getTaxonAttributsAndMedia(
this.selectedObs.cd_nom,
this.config.SYNTHESE.ID_ATTRIBUT_TAXHUB
)
.subscribe((taxAttr) => {
this.selectObsTaxonInfo = taxAttr;
});

if (this.selectedObs['unique_id_sinp']) {
this.loadValidationHistory(this.selectedObs['unique_id_sinp']);
}
let cdNom = this.selectedObs['cd_nom'];
let areasStatus = this.selectedObs['areas'].map((area) => area.id_area);
this._gnDataService.getTaxonInfo(cdNom, areasStatus).subscribe((taxInfo) => {
const taxhubFields = ['attributs', 'attributs.bib_attribut.label_attribut', 'status'];
this._gnDataService.getTaxonInfo(cdNom, taxhubFields, areasStatus).subscribe((taxInfo) => {
this.selectedObsTaxonDetail = taxInfo;
// filter attributs
this.selectedObsTaxonDetail.attributs = taxInfo['attributs'].filter((v) =>
this.config.SYNTHESE.ID_ATTRIBUT_TAXHUB.includes(v.id_attribut)
);

if (this.selectedObs.cor_observers) {
this.email = this.selectedObs.cor_observers
.map((el) => el.email)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,10 @@ <h5 class="underlined underlined-sm main-color">Attribut(s) Taxonomique(s) locau
<table class="table table-striped table-sm">
<tr
class="font-xs"
*ngFor="let attr of selectObsTaxonInfo?.attributs"
*ngFor="let attr of selectedObsTaxonDetail?.attributs"
>
<td>
<b>{{ attr.label_attribut }}</b>
<b>{{ attr.bib_attribut.label_attribut }}</b>
</td>
<td>{{ attr.valeur_attribut }}</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { ConfigService } from '@geonature/services/config.service';
})
export class ModalInfoObsComponent implements OnInit {
@Input() syntheseObs: any;
public selectObsTaxonInfo;
public selectedObs;
public selectedObsTaxonDetail;
public formatedAreas = [];
Expand Down Expand Up @@ -64,14 +63,14 @@ export class ModalInfoObsComponent implements OnInit {
// this.selectedObs['cd_nom']
// }/fr_light_l93,fr_light_mer_l93,fr_lit_l93)`;
});
this._gnDataService
.getTaxonAttributsAndMedia(syntheseObs.cd_nom, this.SYNTHESE_CONFIG.ID_ATTRIBUT_TAXHUB)
.subscribe((data) => {
this.selectObsTaxonInfo = data;
});

this._gnDataService.getTaxonInfo(syntheseObs.cd_nom).subscribe((data) => {
this.selectedObsTaxonDetail = data;
const taxhubFields = ['attributs', 'attributs.bib_attribut.label_attribut', 'status'];
this._gnDataService.getTaxonInfo(syntheseObs.cd_nom, taxhubFields).subscribe((taxInfo) => {
this.selectedObsTaxonDetail = taxInfo;
// filter attributs
this.selectedObsTaxonDetail.attributs = taxInfo['attributs'].filter((v) =>
this.config.SYNTHESE.ID_ATTRIBUT_TAXHUB.includes(v.id_attribut)
);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { Router } from '@angular/router';
export class SyntheseListComponent implements OnInit, OnChanges, AfterContentChecked {
public SYNTHESE_CONFIG = null;
public selectedObs: any;
public selectObsTaxonInfo: any;
public selectedObsTaxonDetail: any;
public previousRow: any;
public rowNumber: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ export class InfosComponent implements OnInit {
if (!this.taxon) {
return;
}
this._ds.getTaxonAttributsAndMedia(this.taxon.cd_ref).subscribe((taxonAttrAndMedias) => {
const media = taxonAttrAndMedias.medias.find(
(m) => m.id_type == this._config['TAXHUB']['ID_TYPE_MAIN_PHOTO']
);
if (media) {
this.mediaUrl = `${this._config.API_TAXHUB}/tmedias/thumbnail/${media.id_media}?h=300&w300`;
}
});
this._ds
.getTaxonInfo(this.taxon.cd_ref, ['medias', 'cd_nom'])
.subscribe((taxonAttrAndMedias) => {
const media = taxonAttrAndMedias['medias'].find(
(m) => m.id_type == this._config.TAXHUB.ID_TYPE_MAIN_PHOTO
);
if (media) {
this.mediaUrl = `${this._config.API_TAXHUB}/tmedias/thumbnail/${media.id_media}?h=300&w300`;
}
});
});
}
}

0 comments on commit 0a6c1de

Please sign in to comment.