diff --git a/analytics-ui/src/sample/list/sample.component.ts b/analytics-ui/src/sample/list/sample.component.ts index 99b018e..914521e 100644 --- a/analytics-ui/src/sample/list/sample.component.ts +++ b/analytics-ui/src/sample/list/sample.component.ts @@ -151,10 +151,10 @@ export class SampleGridComponent implements OnInit { ignoreBackdropClick: true, }); - modalRef.content.closeSubject.subscribe(async (conf) => { - console.log("Configuration after edit:", conf); - if (conf) { - const response = await this.repositoryService.saveRepositories(); + modalRef.content.closeSubject.subscribe(async (repositories) => { + console.log("Repositories after edit:", repositories); + if (repositories) { + const response = await this.repositoryService.saveRepositories(repositories); this.alertService.success( gettext(`Updated repositories successfully‚`) ); diff --git a/analytics-ui/src/shared/analytics.service.ts b/analytics-ui/src/shared/analytics.service.ts index 865ba8f..333c3a9 100644 --- a/analytics-ui/src/shared/analytics.service.ts +++ b/analytics-ui/src/shared/analytics.service.ts @@ -20,7 +20,7 @@ import { import { TranslateService } from "@ngx-translate/core"; import * as _ from "lodash"; -import { BehaviorSubject, Subscription } from "rxjs"; +import { BehaviorSubject, EMPTY, Subscription, throwError } from "rxjs"; import { CEP_Block, CEP_Extension, @@ -37,8 +37,8 @@ import { ENDPOINT_EXTENSION, Repository, } from "./analytics.model"; -import { filter, map, pairwise } from "rxjs/operators"; -import { HttpClient } from "@angular/common/http"; +import { catchError, filter, map, pairwise } from "rxjs/operators"; +import { HttpClient, HttpErrorResponse } from "@angular/common/http"; import { RepositoryService } from "../sample/editor/repository.service"; @Injectable({ providedIn: "root" }) @@ -192,12 +192,28 @@ export class AnalyticsService { b.repositoryName = rep.name; }); return name; - }) + }), + catchError(this.handleError), ) .toPromise(); return result; } + private handleError(error: HttpErrorResponse) { + if (error.status === 0) { + // A client-side or network error occurred. Handle it accordingly. + console.error('An error occurred. Ignoring repository:', error.error); + } else { + // The backend returned an unsuccessful response code. + // The response body may contain clues as to what went wrong. + console.error( + `Backend returned code ${error.status}. Ignoring repository. Error body was: `, error.error); + } + // Return an observable with a user-facing error message. + //return throwError(() => new Error('Something bad happened; please try again later.')); + return EMPTY + } + async getBlock_Sample_Content(name: string): Promise { const sampleUrl = `${GITHUB_BASE}/repos/${REPO_SAMPLES_OWNER}/${REPO_SAMPLES_NAME}/contents/${REPO_SAMPLES_PATH}/${name}`; const result: any = this.githubFetchClient