Skip to content

Commit 102137c

Browse files
committed
rendering with the template all fields requested!
1 parent 2860bc0 commit 102137c

File tree

3 files changed

+77
-7
lines changed

3 files changed

+77
-7
lines changed

frontend/src/app/app.module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import { BrowserModule } from '@angular/platform-browser';
33

44
import { AppComponent } from './app.component';
55
import {HttpClientModule} from "@angular/common/http";
6-
import {ApiModule} from "../../build/openapi/governemnt-service";
6+
import {ApiModule, GovernmentRepresentativeService, RepresentativeModel} from "../../build/openapi/governemnt-service";
77
import { RepresentativeListComponent } from './government-service/components/representative-list/representative-list.component';
88

99
@NgModule({
1010
declarations: [
1111
AppComponent,
1212
RepresentativeListComponent
1313
],
14-
providers: [],
1514
imports: [
1615
BrowserModule,
1716
HttpClientModule,
18-
ApiModule
17+
ApiModule,
1918
],
19+
providers: [GovernmentRepresentativeService],
2020
bootstrap: [AppComponent]
2121
})
2222
export class AppModule { }
Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,37 @@
1-
<p>representative-list works!</p>
1+
<div class="main-content">
2+
<div class="section-content section-content-p30">
3+
<div class="container-fluid">
4+
<div class="row">
5+
<!--loop over the collection of donees-->
6+
<div *ngFor="let tempRepresentative of representatives" class="col-md-3">
7+
<div class="representative-name-box">
8+
<img [src]="tempRepresentative.image" alt="{{ tempRepresentative.name}}" class="img-responsive">
9+
<h1>{{ tempRepresentative.name }}</h1>
10+
<div class="description">
11+
{{ tempRepresentative.jobTitle }}
12+
</div>
13+
<div class="description">
14+
{{ tempRepresentative.government }}
15+
</div>
16+
<div class="description">
17+
{{ tempRepresentative.email }}
18+
</div>
19+
<div class="description">
20+
{{ tempRepresentative.phoneNumber }}
21+
</div>
22+
<div class="description">
23+
{{ tempRepresentative.address }}
24+
</div>
25+
<div class="description">
26+
{{ tempRepresentative.note }}
27+
</div>
28+
<div style="display: flex; gap: 10px;">
29+
<a href="#" class="primary-btn">Módosít</a>
30+
<a href="#" class="primary-btn">Töröl</a>
31+
</div>
32+
</div>
33+
</div>
34+
</div>
35+
</div>
36+
</div>
37+
</div>
Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import {Component, OnInit} from '@angular/core';
2-
import {GovernmentRepresentativeService} from "../../../../../build/openapi/governemnt-service";
2+
import {
3+
Availability,
4+
GovernmentRepresentativeService
5+
} from "../../../../../build/openapi/governemnt-service";
6+
import {DomSanitizer, SafeUrl} from "@angular/platform-browser";
37

48
@Component({
59
selector: 'app-representative-list',
@@ -8,9 +12,39 @@ import {GovernmentRepresentativeService} from "../../../../../build/openapi/gove
812
})
913
export class RepresentativeListComponent implements OnInit {
1014

11-
$representatives = this.representativeService.renderAllRepresentatives()
12-
constructor(private readonly representativeService: GovernmentRepresentativeService) {}
15+
representatives: SanitizedRepresentativeModel[] = [];
16+
17+
constructor(private readonly representativeService: GovernmentRepresentativeService, private sanitizer: DomSanitizer) {}
1318

1419
ngOnInit(): void {
20+
this.listRepresentatives();
21+
}
22+
23+
private listRepresentatives() {
24+
this.representativeService.renderAllRepresentatives().subscribe(
25+
data => {
26+
this.representatives = data.map(representative => ({
27+
...representative,
28+
image: this.sanitizer.bypassSecurityTrustUrl(`data:image/png;base64,${representative.image}`)
29+
}));
30+
}
31+
);
1532
}
1633
}
34+
35+
interface SanitizedRepresentativeModel {
36+
id?: string;
37+
name?: string;
38+
email?: string;
39+
phoneNumber?: string;
40+
address?: string;
41+
image: SafeUrl;
42+
jobTitle?: string;
43+
note?: string;
44+
availability?: Availability;
45+
government?: string;
46+
createdAt?: string;
47+
updatedAt?: string;
48+
createdBy?: string;
49+
updatedBy?: string;
50+
}

0 commit comments

Comments
 (0)