Skip to content

Commit

Permalink
frontend linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Corny committed Sep 13, 2024
1 parent be11dd7 commit 0da6603
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 26 deletions.
44 changes: 24 additions & 20 deletions frontend/app/services/hierarchy.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class HierarchyService {
public items: ItemModel[];
public rb_name: string;
public isLoading: boolean = false;
public warning: string = "";
public warning: string = '';

constructor(
private _dataService: ZhDataService,
Expand All @@ -41,27 +41,31 @@ export class HierarchyService {
// get current zone humides
getHierarchy(zhId, rb_name) {
this.isLoading = true;
this.warning = "";
this.warning = '';
this.rb_name = rb_name;
this._dataService.getHierZh(zhId, {
"not-to-handle": "1"
}).subscribe(
(data: HierarchyModel) => {
this.items = this.setItems(data);
},
(error) => {
this.isLoading = false;
this.items = [];
if (error.status === 404) {
this.warning = "La ZH n'est présente dans aucun bassin versant";
} else if (error.status === 400) {
this.warning = this._error['errors'].filter((i) => error.error['message'] === i.api)[0].front
this._dataService
.getHierZh(zhId, {
'not-to-handle': '1',
})
.subscribe(
(data: HierarchyModel) => {
this.items = this.setItems(data);
},
(error) => {
this.isLoading = false;
this.items = [];
if (error.status === 404) {
this.warning = "La ZH n'est présente dans aucun bassin versant";
} else if (error.status === 400) {
this.warning = this._error['errors'].filter(
(i) => error.error['message'] === i.api
)[0].front;
}
},
() => {
this.isLoading = false;
}
},
() => {
this.isLoading = false;
}
);
);
}

// set list of hierarchy items
Expand Down
7 changes: 3 additions & 4 deletions frontend/app/services/zh-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ export class ZhDataService {
return this._api.get(`${this.config.API_ENDPOINT}/zones_humides/${zhId}/taxa`);
}

getHierZh(zhId: string, headers?: HttpHeaders | { [header: string]: string | string[]; }) {
return this._api.get(
`${this.config.API_ENDPOINT}/zones_humides/${zhId}/hierarchy`, {
headers
getHierZh(zhId: string, headers?: HttpHeaders | { [header: string]: string | string[] }) {
return this._api.get(`${this.config.API_ENDPOINT}/zones_humides/${zhId}/hierarchy`, {
headers,
});
}

Expand Down
5 changes: 4 additions & 1 deletion frontend/app/zh-details/hierarchy/hierarchy.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<h4 class="tabsSubtitle">Bassin versant : {{ data?.river_basin_name }}</h4>
<div *ngIf="hierarchy.warning" class="alert alert-warning mat-alert">
<div
*ngIf="hierarchy.warning"
class="alert alert-warning mat-alert"
>
{{ hierarchy.warning }}
</div>
<zh-table
Expand Down
5 changes: 4 additions & 1 deletion frontend/app/zh-forms/tabs/tab9/zh-form-tab9.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ <h2 class="tabsTitle">Hiérarchisation</h2>

<div *ngIf="!hierarchy.isLoading">
<h4 class="tabsSubtitle">Bassin versant : {{ hierarchy.rb_name }}</h4>
<div *ngIf="hierarchy.warning" class="alert alert-warning mat-alert">
<div
*ngIf="hierarchy.warning"
class="alert alert-warning mat-alert"
>
{{ hierarchy.warning }}
</div>
<zh-table
Expand Down

0 comments on commit 0da6603

Please sign in to comment.