From 4998fc445e26d36d091d6f853648935fa47a3766 Mon Sep 17 00:00:00 2001 From: Ruben Date: Mon, 22 Jun 2020 10:54:43 +0200 Subject: [PATCH 1/7] Ignored http status codes for sentry logging --- src/app/interceptors/http.interceptor.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/app/interceptors/http.interceptor.ts b/src/app/interceptors/http.interceptor.ts index a7e67738..03ba115f 100644 --- a/src/app/interceptors/http.interceptor.ts +++ b/src/app/interceptors/http.interceptor.ts @@ -45,6 +45,7 @@ enum HttpMethods { 'PATCH' } + /** * Interceptor which handles error handling and displaying for http requests. */ @@ -60,6 +61,10 @@ export class HttpErrorInterceptor implements HttpInterceptor { { endpoint: 'wizard', method: HttpMethods.GET }, ]; + private readonly ignoredStatusCodes: number[] = [ + 404 + ]; + constructor( private alertService: AlertService ) { } @@ -105,10 +110,17 @@ export class HttpErrorInterceptor implements HttpInterceptor { this.alertService.pushAlert(this.createErrorAlertConfig(httpErrorResponse.error.title, httpErrorResponse.error.detail)); } - if (environment.production) { - // Log error to sentry. - Sentry.captureException(new Error(` http error:${httpErrorResponse.status} - ${httpErrorResponse.message}`)); + // Return if the status codes are ignored. + if (this.ignoredStatusCodes.includes(httpErrorResponse.status)) { + return EMPTY; + } + + if (!environment.production) { + // Stop error from continuing. + return EMPTY; } + // Log error to sentry. + Sentry.captureException(new Error(` http error:${httpErrorResponse.status} - ${httpErrorResponse.message}`)); // Stop error from continuing. return EMPTY; }) From 17caa0122a55b2b55cfe3ab5ff8c6dd8a669c1e0 Mon Sep 17 00:00:00 2001 From: Ruben Date: Mon, 22 Jun 2020 11:21:53 +0200 Subject: [PATCH 2/7] Ignored logging of 404 errors to Sentry --- src/app/interceptors/http.interceptor.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/interceptors/http.interceptor.ts b/src/app/interceptors/http.interceptor.ts index 03ba115f..68410b71 100644 --- a/src/app/interceptors/http.interceptor.ts +++ b/src/app/interceptors/http.interceptor.ts @@ -115,10 +115,11 @@ export class HttpErrorInterceptor implements HttpInterceptor { return EMPTY; } + // Stop error from continuing if application is not run in production. if (!environment.production) { - // Stop error from continuing. return EMPTY; } + // Log error to sentry. Sentry.captureException(new Error(` http error:${httpErrorResponse.status} - ${httpErrorResponse.message}`)); // Stop error from continuing. From 76a3f3ec160361a0473615b4a214bcdc919eacf5 Mon Sep 17 00:00:00 2001 From: Ruben Date: Mon, 22 Jun 2020 11:22:23 +0200 Subject: [PATCH 3/7] Added displaying of invalid id for project edit & details --- .../project/details/details.component.html | 13 +- .../project/details/details.component.ts | 8 +- .../modules/project/edit/edit.component.html | 163 +++++++++--------- .../modules/project/edit/edit.component.ts | 8 +- 4 files changed, 110 insertions(+), 82 deletions(-) diff --git a/src/app/modules/project/details/details.component.html b/src/app/modules/project/details/details.component.html index 9f3c5980..cb40e43e 100644 --- a/src/app/modules/project/details/details.component.html +++ b/src/app/modules/project/details/details.component.html @@ -17,7 +17,7 @@ --> -
+
-
\ No newline at end of file + + + +
+
+

Project details

+

No project could be found with id: {{invalidId}}

+
+
+
\ No newline at end of file diff --git a/src/app/modules/project/details/details.component.ts b/src/app/modules/project/details/details.component.ts index 7d5f93c3..3005334a 100644 --- a/src/app/modules/project/details/details.component.ts +++ b/src/app/modules/project/details/details.component.ts @@ -58,6 +58,11 @@ export class DetailsComponent implements OnInit { public displayHighlightButton = false; public displayEmbedButton = false; + /** + * Property for storting the invalidId if an invalid project id was entered. + */ + public invalidId: string; + private currentUser: User; constructor( @@ -77,7 +82,8 @@ export class DetailsComponent implements OnInit { return; } const id = Number(routeId); - if (id < 1) { + if (id == null || Number.isNaN(id) || id < 1) { + this.invalidId = routeId; return; } diff --git a/src/app/modules/project/edit/edit.component.html b/src/app/modules/project/edit/edit.component.html index fbe3be4d..5f20ca76 100644 --- a/src/app/modules/project/edit/edit.component.html +++ b/src/app/modules/project/edit/edit.component.html @@ -17,113 +17,120 @@ --> -

Edit project

-
-
-
-
-

Project name*

- + + + + +
+
+
+

Project name*

+ +
-
-
-
-

Project link*

- +
+
+

Project link*

+ +
-
-
-
-
-

Short description*

- +
+
+
+

Short description*

+ +
-
-
-
-
-

Describe your project in one sentence or 170 characters.

+
+
+
+

Describe your project in one sentence or 170 characters.

+
-
-
-
-
-

Description*

- - +
+
+
+

Description*

+ + +
-
- - - -
-
-
-

Add project collaborators

-
-
-
-

Collaborator full name

- + + + +
+
+
+

Add project collaborators

+
+
+
+

Collaborator full name

+ +
-
-
-
-

Collaborator role

- +
+
+

Collaborator role

+ +
+
+ +
+
-
- +
+

e.g.: developer, designer, etc...

-
-
-

e.g.: developer, designer, etc...

-
-
- + -
+
-
-

Collaborators

-
+
+

Collaborators

+
-
- -

{{collaborator?.fullName}}- {{collaborator?.role}}

-
+
+ +

{{collaborator?.fullName}}- {{collaborator?.role}}

+
+
-
-
-
- +
+
+ +
-
+ + +

No project could be found with id: {{invalidId}}

+
-
+
\ No newline at end of file diff --git a/src/app/modules/project/edit/edit.component.ts b/src/app/modules/project/edit/edit.component.ts index 107ffc91..fec59116 100644 --- a/src/app/modules/project/edit/edit.component.ts +++ b/src/app/modules/project/edit/edit.component.ts @@ -59,6 +59,11 @@ export class EditComponent implements OnInit { */ public modulesConfigration = QuillUtils.getDefaultModulesConfiguration(); + /** + * Property for storting the invalidId if an invalid project id was entered. + */ + public invalidId: string; + constructor( private router: Router, private formBuilder: FormBuilder, @@ -85,7 +90,8 @@ export class EditComponent implements OnInit { return; } const id = Number(routeId); - if (id < 1) { + if (id == null || Number.isNaN(id) || id < 1) { + this.invalidId = routeId; return; } From fda72d98a761bac051c87c64d0ae8d79f64472f8 Mon Sep 17 00:00:00 2001 From: Ruben Date: Mon, 22 Jun 2020 11:33:42 +0200 Subject: [PATCH 4/7] Added http error ignore for highlights & changed text if there are none --- src/app/interceptors/http.interceptor.ts | 3 ++- .../top-highlight-cards.component.html | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app/interceptors/http.interceptor.ts b/src/app/interceptors/http.interceptor.ts index 68410b71..57613386 100644 --- a/src/app/interceptors/http.interceptor.ts +++ b/src/app/interceptors/http.interceptor.ts @@ -57,6 +57,7 @@ export class HttpErrorInterceptor implements HttpInterceptor { * This can be used to not display error message for certain requests. */ private readonly ignoredEndpoints: IgnoredRequests[] = [ + { endpoint: 'highlight', method: HttpMethods.GET }, { endpoint: 'highlight/project/', method: HttpMethods.GET }, { endpoint: 'wizard', method: HttpMethods.GET }, ]; @@ -81,7 +82,7 @@ export class HttpErrorInterceptor implements HttpInterceptor { return request.url.includes(API_CONFIG.url + ignoredEndpoint.endpoint) && request.method === HttpMethods[ignoredEndpoint.method]; }); - + console.log(request); // If a ignored endpoint was found return with default behavior. if (foundIgnoredEndpoint != null) { return next.handle(request) diff --git a/src/app/modules/highlight/top-highlight-cards/top-highlight-cards.component.html b/src/app/modules/highlight/top-highlight-cards/top-highlight-cards.component.html index 72318b58..4f1e2b30 100644 --- a/src/app/modules/highlight/top-highlight-cards/top-highlight-cards.component.html +++ b/src/app/modules/highlight/top-highlight-cards/top-highlight-cards.component.html @@ -17,12 +17,21 @@ -->
+

Highlighted projects

-

Our top {{highlights.length}} projects

+ + +

Our top {{highlights.length}} projects

+
+ +

Currently there are no highlighted projects

+
+
+
@@ -34,4 +43,5 @@

{{highlight.project.name}}

+
\ No newline at end of file From 63888eb7bc9d744a50bf61dc3871cfbbf86489e3 Mon Sep 17 00:00:00 2001 From: Ruben Date: Mon, 22 Jun 2020 11:43:25 +0200 Subject: [PATCH 5/7] Updated changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fc4e65d..4fd842ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added localStorage Utils class to access the localStorage and it's keys from one central piece of code - [#238](https://github.com/DigitalExcellence/dex-frontend/issues/238) - Changed the wizard requests, fixed URL not supported error and added message - [#236](https://github.com/DigitalExcellence/dex-frontend/issues/236) - Changed styling of project overview filters and project add collaborators to match the designs - [#242](https://github.com/DigitalExcellence/dex-frontend/issues/242) +- Changed when Sentry logs http errors - [#231](https://github.com/DigitalExcellence/dex-frontend/issues/231) +- Changed text when there are no Highlights - [#221](https://github.com/DigitalExcellence/dex-frontend/issues/221) ### Deprecated @@ -74,5 +76,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed the layout of project embed pages breaking on smaller viewports - [#223](https://github.com/DigitalExcellence/dex-frontend/issues/223) - Fixed issue where beta banner was not dismissible - [#239](#https://github.com/DigitalExcellence/dex-frontend/issues/239) - Fixed styling to match the designs, replaced images on home and sign in - [#233](https://github.com/DigitalExcellence/dex-frontend/issues/233) +- Fixed issue where invalid project id would trigger error - [#235](https://github.com/DigitalExcellence/dex-frontend/issues/235) ### Security From 62dad0268e8166171de81d3ff3526656e0f8c7d4 Mon Sep 17 00:00:00 2001 From: Ruben Date: Mon, 22 Jun 2020 12:08:20 +0200 Subject: [PATCH 6/7] Removed console logs --- src/app/interceptors/http.interceptor.ts | 2 +- .../top-highlight-cards.component.ts | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/app/interceptors/http.interceptor.ts b/src/app/interceptors/http.interceptor.ts index 57613386..120c822b 100644 --- a/src/app/interceptors/http.interceptor.ts +++ b/src/app/interceptors/http.interceptor.ts @@ -82,7 +82,7 @@ export class HttpErrorInterceptor implements HttpInterceptor { return request.url.includes(API_CONFIG.url + ignoredEndpoint.endpoint) && request.method === HttpMethods[ignoredEndpoint.method]; }); - console.log(request); + // If a ignored endpoint was found return with default behavior. if (foundIgnoredEndpoint != null) { return next.handle(request) diff --git a/src/app/modules/highlight/top-highlight-cards/top-highlight-cards.component.ts b/src/app/modules/highlight/top-highlight-cards/top-highlight-cards.component.ts index aa16ade8..e17d193d 100644 --- a/src/app/modules/highlight/top-highlight-cards/top-highlight-cards.component.ts +++ b/src/app/modules/highlight/top-highlight-cards/top-highlight-cards.component.ts @@ -37,22 +37,15 @@ export class TopHighlightCardsComponent implements OnInit { * Boolean to determine whether the component is loading the information from the api. */ public highlightsLoading = true; - constructor(private router: Router, private projectService: HighlightService) {} + constructor(private router: Router, private projectService: HighlightService) { } ngOnInit(): void { this.projectService .getAll() .pipe(finalize(() => (this.highlightsLoading = false))) - .subscribe( - (result) => { - this.highlights = this.generateSampleSizeOf(result, 3); - }, - (error: HttpErrorResponse) => { - if (error.status !== 404) { - console.log('Could not retrieve the highlights'); - } - } - ); + .subscribe((result) => { + this.highlights = this.generateSampleSizeOf(result, 3); + }); } private generateSampleSizeOf(population: string | any[], k: number) { /* From 87112fc5c9428718d971a46ba4352d279aa3a9b1 Mon Sep 17 00:00:00 2001 From: Brend Smits Date: Mon, 22 Jun 2020 12:52:41 +0200 Subject: [PATCH 7/7] Update src/app/modules/project/details/details.component.html Co-authored-by: StijnGroenen --- src/app/modules/project/details/details.component.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/modules/project/details/details.component.html b/src/app/modules/project/details/details.component.html index cb40e43e..9fd5b8cb 100644 --- a/src/app/modules/project/details/details.component.html +++ b/src/app/modules/project/details/details.component.html @@ -110,7 +110,8 @@

{{ project.name }}

Project details

-

No project could be found with id: {{invalidId}}

+

The project with the identifier "{{invalidId}}" could not be found.

+
- \ No newline at end of file +