From 3ee775c98e03fb575e58ef0fed4e6aa00bb8d80a Mon Sep 17 00:00:00 2001 From: maximesson Date: Mon, 18 Oct 2021 09:04:57 +0200 Subject: [PATCH] Fixing various details in the control-panel Change-Id: Ib4c5d420e9a9f8fe25d30c1923dff288a623d06d Issue-ID: NONRTRIC-599 Signed-off-by: maximesson --- .../jobs-list/jobs-list.component.html | 17 ++++++- .../jobs-list/jobs-list.component.spec.ts | 47 ++++++++++++++++++- .../jobs-list/jobs-list.component.ts | 52 +++++++++++++++++----- .../policy/policy-type/policy-type.component.ts | 2 +- 4 files changed, 102 insertions(+), 16 deletions(-) diff --git a/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.html b/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.html index d2d8bf9..619011d 100644 --- a/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.html +++ b/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.html @@ -90,8 +90,21 @@ limitations under the License. {{job.targetUri}} - - + + +
+
+ + + Status + +
+
+
+ {{job.status}} +
+ + diff --git a/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.spec.ts b/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.spec.ts index 6e815af..fe7fa22 100644 --- a/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.spec.ts +++ b/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.spec.ts @@ -69,6 +69,7 @@ const job1 = { owner: "owner1", targetUri: "http://one", prodIds: ["producer1"], + status: "ENABLED" } as Job; const job2 = { jobId: "job2", @@ -76,6 +77,7 @@ const job2 = { owner: "owner1", targetUri: "http://one", prodIds: ["producer1"], + status: "ENABLED" } as Job; describe("JobsListComponent", () => { @@ -117,6 +119,7 @@ describe("JobsListComponent", () => { typeId: "type1", owner: "owner1", targetUri: "http://one", + status: "ENABLED" }; it("should create", () => { @@ -151,6 +154,7 @@ describe("JobsListComponent", () => { typeId: "Type ID", owner: "Owner", targetUri: "Target URI", + status: "Status" }); }); }); @@ -188,6 +192,7 @@ describe("JobsListComponent", () => { typeId: "type1", owner: "owner1", targetUri: "http://one", + status: "ENABLED" }, ]; @@ -239,6 +244,7 @@ describe("JobsListComponent", () => { typeId: "< No type >", owner: "< No owner >", targetUri: "http://one", + status: "ENABLED", }; loader @@ -335,6 +341,26 @@ describe("JobsListComponent", () => { }); }); }); + + loader + .getHarness( + MatInputHarness.with({ selector: "#jobStatusFilter" }) + ) + .then((statusFilter) => { + tick(10); + statusFilter.setValue("ENA").then((_) => { + loadTable.getRows().then((jobRows) => { + expect(jobRows.length).toEqual(2); + jobRows[0].getCellTextByColumnName().then((value) => { + expect(expectedJob1Row).toEqual( + jasmine.objectContaining(value) + ); + statusFilter.setValue(""); + flushMicrotasks(); + }); + }); + }); + }); }); discardPeriodicTasks(); })); @@ -349,7 +375,7 @@ describe("JobsListComponent", () => { sort.then((value) => { value.getSortHeaders({ sortDirection: "" }).then((headers) => { - expect(headers.length).toBe(5); + expect(headers.length).toBe(6); headers[0].click(); tick(10); @@ -423,6 +449,7 @@ describe("JobsListComponent", () => { typeId: "type1", owner: "owner1", targetUri: "http://one", + status: "ENABLED" }; setServiceSpy(); @@ -496,6 +523,23 @@ describe("JobsListComponent", () => { }); }); }); + loader + .getHarness( + MatInputHarness.with({ selector: "#jobStatusFilter" }) + ) + .then((statusFilter) => { + tick(10); + statusFilter.setValue("").then((_) => { + loadTable.getRows().then((jobRows) => { + expect(jobRows.length).toEqual(2); + jobRows[1].getCellTextByColumnName().then((value) => { + expect(expectedJobRow).toEqual( + jasmine.objectContaining(value) + ); + }); + }); + }); + }); }); discardPeriodicTasks(); })); @@ -536,6 +580,7 @@ describe("JobsListComponent", () => { typeId: "type1", owner: "owner1", targetUri: "http://one", + status: "ENABLED", }; discardPeriodicTasks(); expect(expectedRow).toEqual(jasmine.objectContaining(value)); 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 ce6c9a7..097e450 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 @@ -27,6 +27,7 @@ import { BehaviorSubject } from "rxjs/BehaviorSubject"; 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 { OperationalState } from '@app/interfaces/consumer.types'; export interface Job { jobId: string; @@ -34,6 +35,7 @@ export interface Job { targetUri: string; owner: string; prodIds: string[]; + status: OperationalState; } @Component({ @@ -64,6 +66,7 @@ export class JobsListComponent implements OnInit { owner: new FormControl(""), targetUri: new FormControl(""), prodIds: new FormControl(""), + status: new FormControl("") }); } @@ -81,7 +84,8 @@ export class JobsListComponent implements OnInit { this.isDataIncluding(data.jobId, searchTerms.jobId) && this.isDataIncluding(data.owner, searchTerms.owner) && this.isDataIncluding(data.typeId, searchTerms.typeId) && - this.isArrayIncluding(data.prodIds, searchTerms.prodIds) + this.isArrayIncluding(data.prodIds, searchTerms.prodIds) && + this.isDataIncluding(data.status, searchTerms.status) ); }) as (data: Job, filter: any) => boolean; }); @@ -103,7 +107,11 @@ export class JobsListComponent implements OnInit { mergeMap((jobIds) => forkJoin(jobIds.map((jobId) => { return forkJoin([ - of(jobId), + of(jobId).pipe( + catchError(err => { + return of([-1]); + }) + ), this.consumerService.getJobInfo(jobId).pipe( catchError(err => { return of([-1]); @@ -119,7 +127,6 @@ export class JobsListComponent implements OnInit { this.loadingSubject$.next(false); this.jobsSubject$.next(this.jobList); }) - ); const whenToRefresh$ = of('').pipe( @@ -158,6 +165,7 @@ export class JobsListComponent implements OnInit { this.jobForm.get("owner").setValue(""); this.jobForm.get("targetUri").setValue(""); this.jobForm.get("prodIds").setValue(""); + this.jobForm.get("status").setValue(""); } sortJobs(sort: Sort) { @@ -175,6 +183,8 @@ export class JobsListComponent implements OnInit { return this.compare(a.targetUri, b.targetUri, isAsc); case "prodIds": return this.compare(a.prodIds, b.prodIds, isAsc); + case "status": + return this.compare(a.status, b.status, isAsc); default: return 0; } @@ -185,7 +195,9 @@ export class JobsListComponent implements OnInit { stopPolling(checked) { this.checked = checked; this.polling$.next(this.jobs().length); - this.refreshDataClick(); + if (this.checked) { + this.refreshDataClick(); + } } compare(a: any, b: any, isAsc: boolean) { @@ -230,14 +242,30 @@ export class JobsListComponent implements OnInit { private extractJobs(res: any) { this.clearFilter(); res.forEach(element => { - 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"]; - this.jobList = this.jobList.concat(jobObj); + if (element[0] != -1) { + 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"]; + jobObj.status = element[2].info_job_status; + this.jobList = this.jobList.concat(jobObj); + } else { + let jobObj = {}; + jobObj.jobId = element[0]; + if (element[1] == -1) { + jobObj.owner = "--Missing information--"; + jobObj.targetUri = "--Missing information--"; + jobObj.typeId = "--Missing information--"; + } + if (element[2] == -1) { + jobObj.prodIds = "--Missing information--" as unknown as []; + jobObj.status = "--Missing information--" as OperationalState; + } + this.jobList = this.jobList.concat(jobObj); + } } }); diff --git a/webapp-frontend/src/app/policy/policy-type/policy-type.component.ts b/webapp-frontend/src/app/policy/policy-type/policy-type.component.ts index f6c8d2a..bf94ad2 100644 --- a/webapp-frontend/src/app/policy/policy-type/policy-type.component.ts +++ b/webapp-frontend/src/app/policy/policy-type/policy-type.component.ts @@ -18,7 +18,7 @@ * ========================LICENSE_END=================================== */ -import { Component, Input, OnInit, OnChanges, SimpleChanges} from "@angular/core"; +import { Component, Input, OnInit, OnChanges, SimpleChanges } from "@angular/core"; import { BehaviorSubject } from "rxjs"; import { PolicyType, PolicyTypeSchema } from "@interfaces/policy.types"; import { PolicyService } from "@services/policy/policy.service"; -- 2.16.6