Skip to content

Commit 39110a2

Browse files
committed
update frontend regarding the api contract yaml file changes (url changed, and the Model was changed for Government translation)
1 parent 3195f2b commit 39110a2

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

frontend/src/app/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import {FormsModule} from "@angular/forms";
1212
const routes: Routes = [
1313
{path: ':languageShortName/api/admin/governments', component: GovernmentListComponent},
1414
{path: ':languageShortName/api/admin/gov-representatives', component: RepresentativeListComponent },
15-
{path: ':languageShortName/api/admin/gov-representatives/government', component: RepresentativeListComponent },
16-
{path: ':languageShortName/api/admin/gov-representatives/government/:governmentId', component: RepresentativeListComponent },
15+
{path: ':languageShortName/api/admin/gov-representatives/governments', component: RepresentativeListComponent },
16+
{path: ':languageShortName/api/admin/gov-representatives/governments/:governmentId', component: RepresentativeListComponent },
1717
{path: '', redirectTo: '/hu/api/admin/gov-representatives', pathMatch: 'full' },
1818
{path: '**', redirectTo: '/hu/api/admin/gov-representatives', pathMatch: 'full' }
1919
];

frontend/src/app/government-service/components/government-list/government-list/government-list.component.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { Component, OnInit } from '@angular/core';
2-
import { GovernmentAdminModel, GovernmentService } from '../../../../../../build/openapi/government-service';
2+
import {
3+
GovernmentAdminModel,
4+
GovernmentService,
5+
GovernmentTranslationModel
6+
} from '../../../../../../build/openapi/government-service';
37
import {ActivatedRoute, Router} from '@angular/router';
48

59
@Component({
@@ -9,7 +13,7 @@ import {ActivatedRoute, Router} from '@angular/router';
913
})
1014
export class GovernmentListComponent implements OnInit {
1115

12-
public governments: GovernmentAdminModel[] = [];
16+
public governments: GovernmentTranslationModel[] = [];
1317
public languageShortName?: string;
1418

1519
constructor(
@@ -25,7 +29,7 @@ export class GovernmentListComponent implements OnInit {
2529
this.governmentService.renderAllGovernments(this.activatedRoute.snapshot.paramMap.get('languageShortName')!).subscribe(
2630
(response) => {
2731
// filter governments by languageShortName
28-
this.governments = response.filter(government => government.languageShortName === this.languageShortName);
32+
this.governments = response.filter(government => government.language_short_name === this.languageShortName);
2933
},
3034
(error) => {
3135
console.error(error);

frontend/src/app/government-service/components/representative-list/representative-list.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66

77
import {
88
Availability, GovernmentAdminModel,
9-
GovernmentRepresentativeService, GovernmentService
9+
GovernmentRepresentativeService, GovernmentService, GovernmentTranslationModel
1010
} from '../../../../../build/openapi/government-service';
1111
import {map, Observable} from "rxjs";
1212

@@ -19,7 +19,7 @@ import {map, Observable} from "rxjs";
1919
export class RepresentativeListComponent implements OnInit {
2020
representatives: SanitizedRepresentativeAdminModel[] = [];
2121
currentLanguage: string;
22-
governments$: Observable<GovernmentAdminModel[]>;
22+
governments$: Observable<GovernmentTranslationModel[]>;
2323
currentGovernmentId?: number;
2424

2525
constructor(
@@ -33,7 +33,7 @@ export class RepresentativeListComponent implements OnInit {
3333
this.currentLanguage = window.localStorage.getItem('lang') || 'hu';
3434
// Update governments$ to only fetch governments for the current language
3535
this.governments$ = this.governmentService.renderAllGovernments(this.currentLanguage).pipe(
36-
map(governments => governments.filter(government => government.languageShortName === this.currentLanguage))
36+
map(governments => governments.filter(government => government.language_short_name === this.currentLanguage))
3737
);
3838
}
3939

government-service/src/main/java/com/csaba79coder/bestprotocol/controller/GovernmentController.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.csaba79coder.bestprotocol.controller;
22

33
import com.csaba79coder.bestprotocol.api.GovernmentApi;
4-
import com.csaba79coder.bestprotocol.model.GovernmentAdminModel;
54
import com.csaba79coder.bestprotocol.model.GovernmentTranslationModel;
65
import com.csaba79coder.bestprotocol.model.government.service.GovernmentService;
76
import lombok.RequiredArgsConstructor;
@@ -25,11 +24,11 @@ public ResponseEntity<List<GovernmentAdminModel>> renderAllGovernments() {
2524

2625
@Override
2726
public ResponseEntity<List<GovernmentTranslationModel>> renderAllGovernments(String languageShortName) {
28-
return ResponseEntity.status(200).body(governmentService.findAllGovernmentsByLang(languageShortName));
27+
return ResponseEntity.status(200).body(governmentService.findAllGovernmentsByLangAndGovernmentId(languageShortName));
2928
}
3029

3130
@Override
3231
public ResponseEntity<List<GovernmentTranslationModel>> renderAllGovernmentsById(String languageShortName, Long governmentId) {
33-
return null;
32+
return ResponseEntity.status(200).body(governmentService.findAllGovernmentsByLangAndGovernmentId(languageShortName, governmentId));
3433
}
3534
}

government-service/src/main/java/com/csaba79coder/bestprotocol/model/government/service/GovernmentService.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,22 @@ public class GovernmentService {
1919

2020
private final GovernmentTranslationRepository governmentTranslationRepository;
2121

22-
public List<GovernmentTranslationModel> findAllGovernmentsByLang(String lang) {
22+
public List<GovernmentTranslationModel> findAllGovernmentsByLangAndGovernmentId(String lang) {
2323
// TODO from Translation creating immediately the Model!
2424
return governmentTranslationRepository.findGovernmentTranslationByLanguageShortName(lang)
2525
.stream()
2626
.map(Mapper::mapGovernmentTranslationToGovernmentAdminModel)
2727
.collect(Collectors.toList());
2828
}
2929

30+
public List<GovernmentTranslationModel> findAllGovernmentsByLangAndGovernmentId(String lang, Long id) {
31+
// TODO from Translation creating immediately the Model!
32+
return governmentTranslationRepository.findGovernmentTranslationByLanguageShortNameAndGovernmentId(lang, id)
33+
.stream()
34+
.map(Mapper::mapGovernmentTranslationToGovernmentAdminModel)
35+
.collect(Collectors.toList());
36+
}
37+
3038
public GovernmentTranslation findGovernmentById(Long id) {
3139
return governmentTranslationRepository.findGovernmentTranslationById(id)
3240
.orElseThrow(() -> {

0 commit comments

Comments
 (0)