From b22a5395ab6e16e0a2d48f3af13ed33df5133652 Mon Sep 17 00:00:00 2001 From: maximesson Date: Thu, 30 Sep 2021 11:50:14 +0200 Subject: [PATCH] GUI stoppig when plenty of deletions Change-Id: If39748ad5a9cfdf1a5262419a56a007dd5288efd Issue-ID: NONRTRIC-599 Signed-off-by: maximesson --- .../jobs-list/jobs-list.component.ts | 38 ++++++++++++++-------- webapp-frontend/src/app/interceptor.mock.ts | 6 ++-- webapp-frontend/src/app/interceptor.ts | 8 ++--- .../src/app/services/ei/consumer.service.ts | 6 ++-- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.ts b/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.ts index c0e437d..95d1040 100644 --- a/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.ts +++ b/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.ts @@ -22,11 +22,12 @@ import { FormControl, FormGroup } from "@angular/forms"; import { MatPaginator } from "@angular/material/paginator"; import { Sort } from "@angular/material/sort"; import { MatTableDataSource } from "@angular/material/table"; -import { EMPTY, forkJoin, of, pipe, Subscription, concat } from "rxjs"; +import { EMPTY, forkJoin, of, pipe, Subscription, concat, Observable } from "rxjs"; import { BehaviorSubject } from "rxjs/BehaviorSubject"; -import { mergeMap, finalize, map, tap, concatMap, delay, skip } from "rxjs/operators"; +import { mergeMap, finalize, map, tap, concatMap, delay, skip, catchError } from "rxjs/operators"; import { ConsumerService } from "@services/ei/consumer.service"; import { UiService } from "@services/ui/ui.service"; +import { EmptyObservable } from 'rxjs/observable/EmptyObservable'; export interface Job { jobId: string; @@ -100,12 +101,21 @@ export class JobsListComponent implements OnInit { forkJoin(jobIds.map((jobId) => { return forkJoin([ of(jobId), - this.consumerService.getJobInfo(jobId), - this.consumerService.getConsumerStatus(jobId) + this.consumerService.getJobInfo(jobId).pipe( + catchError(err => { + return of([-1]); + })), + this.consumerService.getConsumerStatus(jobId).pipe( + catchError(err => { + return of([-1]); + })), ]) })) ), - finalize(() => this.loadingSubject$.next(false)) + finalize(() => { + this.loadingSubject$.next(false) + }) + ); const whenToRefresh$ = of('').pipe( @@ -188,7 +198,7 @@ export class JobsListComponent implements OnInit { } isArrayIncluding(data: string[], filter: string): boolean { - if(!data) + if (!data) return true; for (let i = 0; i < data.length; i++) { return this.isDataIncluding(data[i], filter); @@ -217,13 +227,15 @@ export class JobsListComponent implements OnInit { this.clearFilter(); let jobList = []; res.forEach(element => { - let jobObj = {}; - jobObj.jobId = element[0]; - jobObj.owner = element[1].job_owner; - jobObj.targetUri = element[1].job_result_uri; - jobObj.typeId = element[1].info_type_id; - jobObj.prodIds = (element[2].producers) ? element[2].producers : ["No Producers"]; - jobList = jobList.concat(jobObj); + if(element[1] != -1 && element[2] != -1){ + let jobObj = {}; + jobObj.jobId = element[0]; + jobObj.owner = element[1].job_owner; + jobObj.targetUri = element[1].job_result_uri; + jobObj.typeId = element[1].info_type_id; + jobObj.prodIds = (element[2].producers) ? element[2].producers : ["No Producers"]; + jobList = jobList.concat(jobObj); + } }); this.jobsSubject$.next(jobList); diff --git a/webapp-frontend/src/app/interceptor.mock.ts b/webapp-frontend/src/app/interceptor.mock.ts index d40a0fc..844513b 100644 --- a/webapp-frontend/src/app/interceptor.mock.ts +++ b/webapp-frontend/src/app/interceptor.mock.ts @@ -19,6 +19,7 @@ */ import { + HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, @@ -26,7 +27,7 @@ import { HttpResponse, } from "@angular/common/http"; import { Injectable, Injector } from "@angular/core"; -import { Observable, of } from "rxjs"; +import { Observable, of, throwError } from "rxjs"; import * as policyinstance1 from "./mock/policy-instance-1.json"; import * as noTypePolicies from "./mock/no-type-policies.json"; import * as type0Policies from "./mock/type0-policies.json"; @@ -228,7 +229,7 @@ export class HttpMockRequestInterceptor implements HttpInterceptor { } } - if (result) { + if (result) { console.log( "Mock answering http call :" + request.method + " " + request.url, request.method === "PUT" ? request.body : null @@ -258,4 +259,5 @@ export class HttpMockRequestInterceptor implements HttpInterceptor { } return result; } + } diff --git a/webapp-frontend/src/app/interceptor.ts b/webapp-frontend/src/app/interceptor.ts index db5f447..65ce887 100644 --- a/webapp-frontend/src/app/interceptor.ts +++ b/webapp-frontend/src/app/interceptor.ts @@ -33,11 +33,11 @@ export class HttpRequestInterceptor implements HttpInterceptor { console.log('Interceptor Invoked' + request.url); return next.handle(request).pipe( catchError((error: HttpErrorResponse) => { - console.error("Error from error interceptor", error); + console.error("Error from error interceptor", error); - // show dialog for error message - this.notificationService.error(error.message); - return throwError(error); + // show dialog for error message + this.notificationService.error(error.message); + return throwError(error); }) ) as Observable>; } diff --git a/webapp-frontend/src/app/services/ei/consumer.service.ts b/webapp-frontend/src/app/services/ei/consumer.service.ts index 19ec3cb..cbafb52 100644 --- a/webapp-frontend/src/app/services/ei/consumer.service.ts +++ b/webapp-frontend/src/app/services/ei/consumer.service.ts @@ -19,7 +19,7 @@ */ import { Injectable } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; +import { HttpBackend, HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { ConsumerStatus, JobInfo } from '@interfaces/consumer.types'; @@ -34,6 +34,7 @@ export class ConsumerService { private basePath = '/data-consumer/v1'; readonly jobsPath = 'info-jobs'; readonly consumerStatusPath = 'status'; + private customHttpClient: HttpClient; private buildPath(...args: any[]) { let result = this.basePath; @@ -43,8 +44,9 @@ export class ConsumerService { return result; } - constructor(private httpClient: HttpClient) { + constructor(private httpClient: HttpClient, backend: HttpBackend) { // injects to variable httpClient + this.customHttpClient = new HttpClient(backend); } getJobIds(): Observable { -- 2.16.6