GUI stoppig when plenty of deletions 13/6813/2
authormaximesson <maxime.bonneau@est.tech>
Thu, 30 Sep 2021 09:50:14 +0000 (11:50 +0200)
committermaximesson <maxime.bonneau@est.tech>
Tue, 5 Oct 2021 06:39:33 +0000 (08:39 +0200)
Change-Id: If39748ad5a9cfdf1a5262419a56a007dd5288efd
Issue-ID: NONRTRIC-599
Signed-off-by: maximesson <maxime.bonneau@est.tech>
webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.ts
webapp-frontend/src/app/interceptor.mock.ts
webapp-frontend/src/app/interceptor.ts
webapp-frontend/src/app/services/ei/consumer.service.ts

index c0e437d..95d1040 100644 (file)
@@ -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 = <Job>{};
-      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 = <Job>{};
+        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);
index d40a0fc..844513b 100644 (file)
@@ -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;
   }
+
 }
index db5f447..65ce887 100644 (file)
@@ -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<HttpEvent<any>>;
     }
index 19ec3cb..cbafb52 100644 (file)
@@ -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<string[]> {