Skip to content

Commit ff473cb

Browse files
authored
Merge pull request #197 from UoA-eResearch/rc2.5.1
Rc2.5.1
2 parents 5f6b268 + 4a34b12 commit ff473cb

File tree

8 files changed

+59
-14
lines changed

8 files changed

+59
-14
lines changed

cer-graphql/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cer-graphql",
3-
"version": "2.4.0",
3+
"version": "2.5.0",
44
"description": "A GraphQL server used to proxy and authorise requests to external data sources.",
55
"main": "build/index.js",
66
"scripts": {

hub-search-proxy/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hub-search-proxy",
3-
"version": "2.4.0",
3+
"version": "2.5.0",
44
"description": "Serverless Framework Lambda functions to interact with AWS ElasticSearch Service.",
55
"main": "handler.js",
66
"scripts": {

research-hub-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "research-hub-web",
3-
"version": "2.4.0",
3+
"version": "2.5.0",
44
"license": "MIT",
55
"scripts": {
66
"ng": "ng",

research-hub-web/src/app/app.module.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,26 @@ export class AppModule {
9292
const error = onError(({ response, networkError, graphQLErrors }) => {
9393
const hasErrors = networkError || graphQLErrors;
9494
if (networkError) {
95-
console.log("API returned networkError", networkError);
96-
return;
95+
if (
96+
// When the server picks up an authentication error before the graphql resolver stage,
97+
// the error will be returned as a networkError but in a similar format as a graphQLError
98+
// which is why we currently have to handle the error as follows:
99+
networkError['error'] &&
100+
networkError['error']['errors'] &&
101+
networkError['error']['errors'][0] &&
102+
networkError['error']['errors'][0]['extensions']['code'] === 'UNAUTHENTICATED') {
103+
this.loginService.doLogin(this.router.url).then((result) => {
104+
// Workaround fix for blank page load issue
105+
// when auth library returns a token instead of navigating to target url
106+
if (result) {
107+
location.reload();
108+
}
109+
});
110+
return;
111+
} else {
112+
console.error("API returned networkError", networkError);
113+
return;
114+
}
97115
}
98116
if (graphQLErrors) {
99117
console.log("API returned graphQLErrors", graphQLErrors);

research-hub-web/src/app/components/activities-page/activities-page.component.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Observable, Subscription } from 'rxjs';
1010
import { map } from 'rxjs/operators';
1111
import { PageTitleService } from '@services/page-title.service';
1212
import { notEmpty } from '@app/global/notEmpty';
13+
import { Router } from '@angular/router';
1314

1415
@Component({
1516
selector: 'app-activities-page',
@@ -26,7 +27,8 @@ export class ActivitiesPageComponent implements OnInit, OnDestroy {
2627
public allStagesGQL: AllStagesGQL,
2728
private getHomepageGQL: GetHomepageGQL,
2829
public searchService: SearchService,
29-
public pageTitleService: PageTitleService
30+
public pageTitleService: PageTitleService,
31+
private router: Router
3032
) { }
3133

3234
ngOnInit() {
@@ -35,8 +37,15 @@ export class ActivitiesPageComponent implements OnInit, OnDestroy {
3537
this.subscriptions.add(
3638
this.getHomepageGQL.fetch().pipe(
3739
map(x => x?.data?.homepageCollection?.items[0])
38-
).subscribe(result => {
39-
this.description = result?.researchActivities;
40+
).subscribe({
41+
next: result => {
42+
this.description = result?.researchActivities;
43+
},
44+
error: err => {
45+
console.error(err);
46+
const status: number = err['status'] ? err['status'] : 500;
47+
this.router.navigate(['error', status]);
48+
}
4049
})
4150
)
4251
}

research-hub-web/src/app/components/categories-page/categories-page.component.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,15 @@ export class CategoriesPageComponent implements OnInit, OnDestroy {
3737
this.subscriptions.add(
3838
this.getHomepageGQL.fetch().pipe(
3939
map(x => x?.data?.homepageCollection?.items[0])
40-
).subscribe(result => {
41-
this.description = result?.researchCategories;
40+
).subscribe({
41+
next: result => {
42+
this.description = result?.researchCategories;
43+
},
44+
error: err => {
45+
console.error(err);
46+
const status: number = err['status'] ? err['status'] : 500;
47+
this.router.navigate(['error', status]);
48+
}
4249
})
4350
)
4451
}

research-hub-web/src/app/components/home/home.component.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { HomeComponent } from './home.component';
77
import { BannerImageComponent } from './banner-image/banner-image.component';
88
import { ContactComponent } from './contact/contact.component';
99
import { PageTitleService } from '@services/page-title.service';
10+
import { RouterTestingModule } from '@angular/router/testing';
1011

1112

1213
describe('HomeComponent', () => {
@@ -23,6 +24,9 @@ describe('HomeComponent', () => {
2324
MockComponent(BannerImageComponent),
2425
MockComponent(ContactComponent)
2526
],
27+
imports: [
28+
RouterTestingModule.withRoutes([]),
29+
],
2630
providers: [
2731
MockProvider(PageTitleService),
2832
]
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Component, OnInit } from '@angular/core';
2+
import { Router } from '@angular/router';
23
import { GetHomepageGQL, Homepage } from '@app/graphql/schema';
34
import { PageTitleService } from '@services/page-title.service';
4-
import { Observable } from 'rxjs';
5-
import { map } from 'rxjs/operators';
5+
import { Observable, throwError } from 'rxjs';
6+
import { catchError, map } from 'rxjs/operators';
67

78
@Component({
89
selector: 'app-home',
@@ -14,13 +15,19 @@ export class HomeComponent implements OnInit {
1415

1516
constructor(
1617
private getHomepageGQL: GetHomepageGQL,
17-
public pageTitleService: PageTitleService
18+
public pageTitleService: PageTitleService,
19+
public router: Router
1820
) { }
1921

2022
ngOnInit(): void {
2123
this.pageTitleService.title = '';
2224
this.homePage$ = this.getHomepageGQL.fetch().pipe(
23-
map(x => x?.data?.homepageCollection?.items[0])
25+
map(x => x?.data?.homepageCollection?.items[0]),
26+
catchError(err => {
27+
const status: number = err['status'] ? err['status'] : 500;
28+
this.router.navigate(['error', status]);
29+
return throwError(err);
30+
})
2431
) as Observable<Homepage>;
2532
}
2633
}

0 commit comments

Comments
 (0)