Skip to content

Commit ea55561

Browse files
committed
Merge branch 'developer'
2 parents 372e8e1 + a898f45 commit ea55561

File tree

234 files changed

+21712
-70
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+21712
-70
lines changed

api-gateway/src/main/java/com/csaba79coder/apigateway/ApiGatewayApplication.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
66

7+
// added @EnableDiscoveryClient for this to work as a discovery client
78
@SpringBootApplication
89
@EnableDiscoveryClient
910
public class ApiGatewayApplication {

discovery-server/src/main/java/com/csaba79coder/discoveryserver/DiscoveryServerApplication.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
66

7+
// added @EnableEurekaServer for this to work as a discovery server
78
@SpringBootApplication
89
@EnableEurekaServer
910
public class DiscoveryServerApplication {
0 Bytes
Binary file not shown.

frontend/src/app/app.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import {Component, OnInit} from '@angular/core';
66
styleUrls: ['./app.component.css']
77
})
88
export class AppComponent implements OnInit {
9+
title: string;
10+
11+
constructor() {
12+
this.title = "BestProtocol Frontend"; // initialized in the constructor
13+
}
914

1015
ngOnInit(): void {
1116

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

Lines changed: 170 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,89 @@ import {
1010
} from '../../../../../build/openapi/government-service';
1111
import {map, Observable} from "rxjs";
1212

13+
/**
14+
* Component that displays a list of sanitized government representatives.
15+
* The list is fetched from the API and displayed in a template.
16+
*/
1317
@Component({
1418
selector: 'app-representative-list',
1519
templateUrl: './representative-list.component.html',
1620
styleUrls: ['./representative-list.component.css'],
1721
})
1822

1923
export class RepresentativeListComponent implements OnInit {
24+
/**
25+
* The list of sanitized government representatives fetched from the API.
26+
*/
2027
representatives: SanitizedRepresentativeAdminModel[] = [];
28+
/**
29+
* The current language of the component.
30+
*/
2131
currentLanguage: string;
32+
/**
33+
* An observable that emits a list of government translations in the current language.
34+
*/
2235
governments$: Observable<GovernmentTranslationModel[]>;
36+
/**
37+
* The ID of the current government.
38+
*/
2339
currentGovernmentId?: number;
40+
/**
41+
* The translation of the "all" button.
42+
*/
2443
public allTranslation?: string;
44+
/**
45+
* The translation of the "modify" button.
46+
*/
2547
public modifyButton?: string;
48+
/**
49+
* The translation of the "delete" button.
50+
*/
2651
public deleteButton?: string;
52+
/**
53+
* The search query entered by the user.
54+
*/
2755
searchQuery: string = '';
28-
56+
/**
57+
* The translation of the "Introduction" menu item.
58+
*/
2959
public introductionMenu?: string;
60+
/**
61+
* The translation of the "Contact" menu item.
62+
*/
3063
public contactMenu?: string;
64+
/**
65+
* The translation of the "Service" menu item.
66+
*/
3167
public serviceMenu?: string;
68+
/**
69+
* The translation of the "Question" menu item.
70+
*/
3271
public questionMenu?: string;
33-
72+
/**
73+
* The placeholder text of the search input field.
74+
*/
3475
public searchPlaceholder?: string;
76+
/**
77+
* The translation of the "Search" button.
78+
*/
3579
public searchButton?: string;
80+
/**
81+
* The list of government translations in the current language.
82+
*/
3683
public governments: GovernmentTranslationModel[] = [];
3784

85+
/**
86+
* Creates a new instance of RepresentativeListComponent.
87+
* @param representativeService The service that fetches the list of government representatives.
88+
* @param governmentService The service that fetches the list of governments.
89+
* @param menuService The service that fetches the translations of the menu items.
90+
* @param sanitizer The Angular sanitizer used to sanitize the image URLs.
91+
* @param route The Angular route used to retrieve the route parameters.
92+
* @param router The Angular router used to navigate to other routes.
93+
* @param activatedRoute The Angular route used to retrieve the query parameters.
94+
* @param cdr The Angular change detector used to detect changes in the component.
95+
*/
3896
constructor(
3997
private readonly representativeService: GovernmentRepresentativeService,
4098
private readonly governmentService: GovernmentService,
@@ -53,6 +111,18 @@ export class RepresentativeListComponent implements OnInit {
53111
);
54112
}
55113

114+
/**
115+
* Lifecycle hook that is called after Angular has initialized all data-bound properties
116+
* of the component. It is used to perform initialization tasks such as fetching data
117+
* from a server, setting up event listeners, or subscribing to observables.
118+
*
119+
* In this component, ngOnInit() does the following:
120+
* - calls getMenuTranslation() and listRepresentatives() to initialize the component's data
121+
* - subscribes to the paramMap observable to get the current language from the URL
122+
* - filters the list of governments by language and saves them to the governments array
123+
* - subscribes to the queryParams and params observables to update the list of representatives
124+
* - detects changes to the component's view and updates it
125+
*/
56126
ngOnInit(): void {
57127
this.getMenuTranslation();
58128
this.listRepresentatives();
@@ -83,6 +153,16 @@ export class RepresentativeListComponent implements OnInit {
83153
this.cdr.detectChanges();
84154
}
85155

156+
/**
157+
* Updates the language of the component and its dependencies to the specified language.
158+
*
159+
* This method does the following:
160+
* - sets the currentLanguage property to the selected language
161+
* - saves the currentLanguage to local storage
162+
* - updates the URL to reflect the new language
163+
* - updates the list of representatives and the menu translation
164+
* - updates the list of governments by subscribing to a new observable that filters them by language
165+
*/
86166
changeLang(lang: string): void {
87167
// Set currentLanguage to the selected language
88168
this.currentLanguage = lang;
@@ -112,6 +192,13 @@ export class RepresentativeListComponent implements OnInit {
112192
});
113193
}
114194

195+
/**
196+
197+
Retrieves a list of governments based on the language specified in the route parameter.
198+
Filters the response to only include governments with the specified language_short_name.
199+
Sets the governments property to the filtered list of governments.
200+
@private
201+
*/
115202
private governmentList() {
116203
this.activatedRoute.paramMap.subscribe(paramMap => {
117204
const languageShortName = paramMap.get('languageShortName');
@@ -127,12 +214,25 @@ export class RepresentativeListComponent implements OnInit {
127214
});
128215
}
129216

217+
/**
218+
219+
Called when the user performs a search. Updates the searchQuery property and calls listAllRepresentatives.
220+
Also updates the URL with the new search query.
221+
@public
222+
*/
130223
onSearch(): void {
131224
console.log('Search query:', this.searchQuery);
132225
this.updateSearchQuery(this.searchQuery);
133226
this.cdr.detectChanges(); // add this line to detect changes
134227
}
135228

229+
/**
230+
231+
Updates the searchQuery property with the provided query and calls listAllRepresentatives to update the displayed data.
232+
Also updates the URL with the new search query and calls governmentList to update the list of governments.
233+
@public
234+
@param query The search query entered by the user.
235+
*/
136236
public updateSearchQuery(query: string): void {
137237
this.searchQuery = query;
138238
this.listAllRepresentatives(this.searchQuery);
@@ -141,6 +241,12 @@ export class RepresentativeListComponent implements OnInit {
141241
this.governmentList();
142242
}
143243

244+
/**
245+
246+
Lists all representatives if governmentId is not provided, otherwise lists representatives by governmentId.
247+
If searchQuery is provided, filters the results based on the provided query.
248+
@param searchQuery Optional search query to filter the list of representatives
249+
*/
144250
private listRepresentatives() {
145251
this.route.params.subscribe(params => {
146252
const governmentId = params['governmentId'];
@@ -153,6 +259,12 @@ export class RepresentativeListComponent implements OnInit {
153259
});
154260
}
155261

262+
/**
263+
264+
Lists all representatives regardless of government if searchQuery is not provided,
265+
otherwise lists all representatives that match the provided searchQuery.
266+
@param searchQuery Optional search query to filter the list of representatives
267+
*/
156268
private listAllRepresentatives(searchQuery?: string) {
157269
this.representativeService.renderAllRepresentatives(this.currentLanguage!, searchQuery!).subscribe(
158270
(data) => {
@@ -183,6 +295,13 @@ export class RepresentativeListComponent implements OnInit {
183295
});
184296
}
185297

298+
/**
299+
300+
Lists all representatives that belong to a specific government.
301+
If searchQuery is provided, filters the results based on the provided query.
302+
@param governmentId ID of the government whose representatives will be listed
303+
@param searchQuery Optional search query to filter the list of representatives
304+
*/
186305
private listRepresentativesByGovId(governmentId: number, searchQuery?: string) {
187306
this.currentGovernmentId = governmentId;
188307
this.representativeService
@@ -214,6 +333,16 @@ export class RepresentativeListComponent implements OnInit {
214333
this.cdr.detectChanges();
215334
}
216335

336+
/**
337+
338+
Checks if a given entity matches a search query. The search query is compared against several
339+
fields of the entity to see if there is a match. If there is a match, the function returns true.
340+
If there is no match, the function returns false.
341+
There is a special check in case of null fields (if translation does not exist!)
342+
@param model - The entity to be checked for a match with the search query.
343+
@param search - The search query to be used to search for a match.
344+
@returns true if the entity matches the search query, false otherwise.
345+
*/
217346
private entityMatchesSearchCriteria(model: any, search: string): boolean {
218347
const lowercaseSearch = search.toLowerCase();
219348
if (model.governmentName && model.governmentName.toLowerCase().includes(lowercaseSearch)) {
@@ -253,7 +382,15 @@ export class RepresentativeListComponent implements OnInit {
253382
return false;
254383
}
255384

385+
/**
386+
387+
Retrieves translations for menu items from the menuService and sets their corresponding class properties.
388+
If no translation is found for a given item, a default value is assigned.
389+
The language is retrieved from the localStorage.
390+
@returns void
391+
*/
256392
public getMenuTranslation() {
393+
// Retrieves translation for "All" menu item
257394
this.menuService.renderAllMenuTranslations(this.currentLanguage, 'all')
258395
.subscribe((data: MenuTranslationModel[]) => {
259396
if (data.length > 0) {
@@ -262,6 +399,7 @@ export class RepresentativeListComponent implements OnInit {
262399
this.allTranslation = 'All'; // Or any default value you choose
263400
}
264401
});
402+
// Retrieves translation for "Modify" button
265403
this.menuService.renderAllMenuTranslations(this.currentLanguage, 'modify_button')
266404
.subscribe((data: MenuTranslationModel[]) => {
267405
if (data.length > 0) {
@@ -270,6 +408,7 @@ export class RepresentativeListComponent implements OnInit {
270408
this.modifyButton = 'Modify'; // Or any default value you choose
271409
}
272410
});
411+
// Retrieves translation for "Delete" button
273412
this.menuService.renderAllMenuTranslations(this.currentLanguage, 'delete_button')
274413
.subscribe((data: MenuTranslationModel[]) => {
275414
if (data.length > 0) {
@@ -278,7 +417,7 @@ export class RepresentativeListComponent implements OnInit {
278417
this.deleteButton = 'Delete'; // Or any default value you choose
279418
}
280419
});
281-
420+
// Retrieves translation for search input placeholder
282421
this.menuService.renderAllMenuTranslations(this.currentLanguage, 'search_placeholder')
283422
.subscribe((data: MenuTranslationModel[]) => {
284423
if (data.length > 0) {
@@ -287,7 +426,7 @@ export class RepresentativeListComponent implements OnInit {
287426
this.searchPlaceholder = 'Data search ...'; // Or any default value you choose
288427
}
289428
});
290-
429+
// Retrieves translation for "Search" button
291430
this.menuService.renderAllMenuTranslations(this.currentLanguage, 'search_button')
292431
.subscribe((data: MenuTranslationModel[]) => {
293432
if (data.length > 0) {
@@ -296,7 +435,7 @@ export class RepresentativeListComponent implements OnInit {
296435
this.searchButton = 'Search'; // Or any default value you choose
297436
}
298437
});
299-
438+
// Retrieves translation for "Introduction" menu item
300439
this.menuService.renderAllMenuTranslations(this.currentLanguage, 'introduction')
301440
.subscribe((data: MenuTranslationModel[]) => {
302441
if (data.length > 0) {
@@ -305,7 +444,7 @@ export class RepresentativeListComponent implements OnInit {
305444
this.introductionMenu = 'Introduction'; // Or any default value you choose
306445
}
307446
});
308-
447+
// Retrieves translation for "Contact" menu item
309448
this.menuService.renderAllMenuTranslations(this.currentLanguage, 'contact')
310449
.subscribe((data: MenuTranslationModel[]) => {
311450
if (data.length > 0) {
@@ -314,7 +453,7 @@ export class RepresentativeListComponent implements OnInit {
314453
this.contactMenu = 'Contact'; // Or any default value you choose
315454
}
316455
});
317-
456+
// Retrieves translation for "Services" menu item
318457
this.menuService.renderAllMenuTranslations(this.currentLanguage, 'service')
319458
.subscribe((data: MenuTranslationModel[]) => {
320459
if (data.length > 0) {
@@ -323,7 +462,7 @@ export class RepresentativeListComponent implements OnInit {
323462
this.serviceMenu = 'Services'; // Or any default value you choose
324463
}
325464
});
326-
465+
// Retrieves translation for "Frequently Asked Questions" menu item
327466
this.menuService.renderAllMenuTranslations(this.currentLanguage, 'question')
328467
.subscribe((data: MenuTranslationModel[]) => {
329468
if (data.length > 0) {
@@ -335,6 +474,29 @@ export class RepresentativeListComponent implements OnInit {
335474
}
336475
}
337476

477+
/**
478+
479+
Interface for the sanitized representative admin model, which represents the sanitized version
480+
of the full representative admin model without any sensitive or unnecessary data. This interface
481+
includes the following properties:
482+
@param {string | undefined} id - The ID of the representative admin.
483+
@param {string | undefined} name - The name of the representative admin.
484+
@param {string | undefined} email - The email address of the representative admin.
485+
@param {string | undefined} phoneNumber - The phone number of the representative admin.
486+
@param {string | undefined} address - The address of the representative admin.
487+
@param {string | undefined} country - The country of the representative admin.
488+
@param {SafeUrl} image - The safe URL of the representative admin's image.
489+
@param {string | undefined} jobTitle - The job title of the representative admin.
490+
@param {string | undefined} note - The note associated with the representative admin.
491+
@param {Availability | undefined} availability - The availability status of the representative admin.
492+
@param {string | undefined} governmentName - The government name of the representative admin.
493+
@param {string | undefined} secretairat - The secretariat information of the representative admin.
494+
@param {string | undefined} secretNote - The secret note associated with the representative admin.
495+
@param {string | undefined} createdAt - The date and time when the representative admin was created.
496+
@param {string | undefined} updatedAt - The date and time when the representative admin was last updated.
497+
@param {string | undefined} createdBy - The user who created the representative admin.
498+
@param {string | undefined} updatedBy - The user who last updated the representative admin.
499+
*/
338500
interface SanitizedRepresentativeAdminModel {
339501
id?: string;
340502
name?: string;

0 commit comments

Comments
 (0)