Skip to content
This repository was archived by the owner on Jan 29, 2025. It is now read-only.

Commit 3ef29f8

Browse files
authored
Merge pull request #440 from sinfo/389-change-download-cvs-error-for-companies
Error changed so companies know what happened
2 parents 5cd78f7 + fae81ed commit 3ef29f8

File tree

8 files changed

+82
-16
lines changed

8 files changed

+82
-16
lines changed

src/app/session/session.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { SessionService } from './session.service'
66
import { Session } from './session.model'
77
import { SpeakerService } from '../speakers/speaker.service'
88
import { Speaker } from '../speakers/speaker.model'
9-
import { EventService } from './../events/event.service'
9+
import { EventService } from '../events/event.service'
1010
import {
1111
trigger,
1212
style,

src/app/sponsor/sponsor.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { SessionService } from '../session/session.service';
1010
import { Session } from '../session/session.model'
1111
import { Company } from '../company/company.model';
1212
import { CompanyService } from '../company/company.service';
13-
import { EventService } from './../events/event.service'
13+
import { EventService } from '../events/event.service'
1414
import { Event } from '../events/event.model';
1515
import { Sponsor } from '../landing-page/sponsors/sponsor.model';
1616

src/app/static/static.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, OnInit } from '@angular/core'
22
import { Title } from '@angular/platform-browser'
33

4-
import { EventService } from './../events/event.service'
4+
import { EventService } from '../events/event.service'
55

66
@Component({
77
selector: 'app-code-of-conduct',

src/app/user/cv/cv.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { HttpEventType, HttpResponse } from '@angular/common/http'
55
import { EventService } from '../../events/event.service'
66
import { UserService } from '../user.service'
77
import { User } from '../user.model'
8-
import { environment } from './../../../environments/environment'
8+
import { environment } from '../../../environments/environment'
99
import { AuthService } from '../../auth/auth.service'
1010
import { File as CV } from './file'
1111
import { MatDialog } from '@angular/material/dialog'

src/app/user/downloads/downloads.component.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
.btn {
2-
margin: 0;
2+
margin: 0 auto;
33
margin-bottom: 10px;
44
letter-spacing: 3px;
55
min-width: 250px;
66
padding: 15px;
7-
font-size: 12px;;
7+
font-size: 12px;
88
}
9+
910
.btn-info {
1011
background-color: #428bca;
1112
border-color: #357ebd;

src/app/user/downloads/downloads.component.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,18 @@ <h6 class="lead">
3030

3131
<div class="row">
3232
<div class="col-sm-12">
33-
<a href="{{ cvsDownloadUrl }}" target="_blank" class="btn btn-info">
33+
<button (click)="downloadCVs()" class="btn btn-info">
3434
<span class="glyphicon glyphicon-cloud-download"></span>
3535
Download CVs
36-
</a>
36+
</button>
3737
</div>
3838
<div *ngIf="me && me.role === 'company'" class="col-sm-12">
39-
<a href="{{ linksCVsDownloadUrl }}" target="_blank" class="btn btn-info">
40-
<span class="glyphicon glyphicon-link"></span>
41-
Download Links' CVs
42-
</a>
39+
<button (click)="downloadLinksCVs()" class="btn btn-info">
40+
<span class="glyphicon glyphicon-link"></span>
41+
Download Links' CVs
42+
</button>
4343
</div>
44+
4445
</div>
4546

4647
</div>

src/app/user/downloads/downloads.component.ts

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ import { environment } from '../../../environments/environment'
99
import { AuthService } from '../../auth/auth.service'
1010
import { EventService } from '../../events/event.service'
1111

12+
import { catchError } from 'rxjs/operators';
13+
import { Observable } from 'rxjs';
14+
15+
16+
import { HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
17+
1218
@Component({
1319
selector: 'app-downloads',
1420
templateUrl: './downloads.component.html',
@@ -26,9 +32,11 @@ export class DownloadsComponent implements OnInit {
2632
private companyService: CompanyService,
2733
private authService: AuthService,
2834
private eventService: EventService,
29-
private titleService: Title
35+
private titleService: Title,
36+
private http: HttpClient
3037
) { }
3138

39+
3240
ngOnInit () {
3341
this.userService.getMe()
3442
.subscribe(me => {
@@ -45,11 +53,10 @@ export class DownloadsComponent implements OnInit {
4553
const company = me.company.find(c => {
4654
return c.edition === event.id
4755
})
48-
4956
this.companyService.getCompany(company.company)
5057
.subscribe(_company => {
5158
this.company = _company
52-
})
59+
});
5360

5461
this.linksCVsDownloadUrl = `${environment.cannonUrl}/company/${company.company}` +
5562
`/files/download?editionId=${event.id}&links=true` +
@@ -62,4 +69,61 @@ export class DownloadsComponent implements OnInit {
6269
})
6370
})
6471
}
72+
73+
downloadCVs() {
74+
if (this.cvsDownloadUrl) {
75+
const httpOptions = {
76+
headers: new HttpHeaders({
77+
'Content-Type': 'application/json'
78+
}),
79+
observe: 'response' as 'response'
80+
};
81+
82+
this.http.get(this.cvsDownloadUrl, httpOptions)
83+
.pipe(
84+
catchError(err => {
85+
console.error('Failed to download CVs:', err);
86+
alert('Unable to dowload CVs at this time. When available the team will contact you.');
87+
throw err; // Re-throw the error if needed for further handling
88+
})
89+
)
90+
.subscribe({
91+
next: response => {
92+
// Success, open the download URL
93+
window.open(this.cvsDownloadUrl, '_blank');
94+
}
95+
});
96+
} else {
97+
alert('CV download URL is not available.');
98+
}
99+
}
100+
101+
downloadLinksCVs() {
102+
if (this.linksCVsDownloadUrl) {
103+
const httpOptions = {
104+
headers: new HttpHeaders({
105+
'Content-Type': 'application/json'
106+
}),
107+
observe: 'response' as 'response'
108+
};
109+
110+
this.http.get(this.linksCVsDownloadUrl, httpOptions)
111+
.pipe(
112+
catchError(err => {
113+
console.error('Failed to download linked CVs:', err);
114+
alert('Unable to dowload links CVs at this time. When available the team will contact you.');
115+
throw err; // Re-throw the error if needed for further handling
116+
})
117+
)
118+
.subscribe({
119+
next: response => {
120+
// Success, open the download URL
121+
window.open(this.linksCVsDownloadUrl, '_blank');
122+
}
123+
});
124+
} else {
125+
alert('Links CV download URL is not available.');
126+
}
127+
}
128+
65129
}

src/app/user/my-profile/my-profile.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Title } from '@angular/platform-browser'
44

55
import { UserService } from '../user.service'
66
import { User } from '../user.model'
7-
import { environment } from './../../../environments/environment'
7+
import { environment } from '../../../environments/environment'
88
import { CompanyService } from '../../company/company.service'
99
import { Company } from '../../company/company.model'
1010
import { AuthService } from '../../auth/auth.service'

0 commit comments

Comments
 (0)