-
Notifications
You must be signed in to change notification settings - Fork 2
/
myProjects.component.ts
51 lines (43 loc) · 1.3 KB
/
myProjects.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Component, OnInit } from '@angular/core';
import { ProjectService } from '../services/project.service';
import { AuthService } from '../services/auth.service';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-inner-page',
templateUrl: './myProjects.component.html',
styleUrls: ['./myProjects.component.css']
})
export class MyProjectsComponent implements OnInit {
projects: any[] = [];
page = 1;
Recpage = 1;
constructor(private authService: AuthService, private projectService: ProjectService, private http: HttpClient) {
}
ngOnInit() {
this.loadProjects();
}
loadProjects() {
this.projectService.getMyProjects(0).subscribe({
next: (projects) => {
this.projects = this.projects.concat(projects);
this.projects.forEach(project => {
this.loadProjectFirstImage(project);
});
},
error: (error) => {
console.error('Error loading the projects:', error);
}
});
}
loadProjectFirstImage(project: any) {
this.projectService.getProjectFirstImage(project.id).subscribe(
imageUrl => {
project.imageUrl = imageUrl;
},
error => {
console.error('Error fetching the first image of the project:', error);
project.imageUrl = null;
}
);
}
}