Fixing various details in the control-panel
Change-Id: Ib4c5d420e9a9f8fe25d30c1923dff288a623d06d
Issue-ID: NONRTRIC-599
Signed-off-by: maximesson <maxime.bonneau@est.tech>
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 @@
</mat-header-cell>
<mat-cell *matCellDef="let job"> {{job.targetUri}} </mat-cell>
</ng-container>
- <mat-header-row *matHeaderRowDef="['jobId', 'prodIds', 'typeId', 'owner', 'targetUri']"></mat-header-row>
- <mat-row *matRowDef="let row; columns: ['jobId', 'prodIds', 'typeId', 'owner', 'targetUri'];"></mat-row>
+ <ng-container matColumnDef="status">
+ <mat-header-cell *matHeaderCellDef mat-sort-header>
+ <div (click)="stopSort($event)">
+ <form style="display: flex" [formGroup]="jobForm">
+ <mat-form-field>
+ <input id="jobStatusFilter" matInput formControlName="status">
+ <mat-placeholder>Status</mat-placeholder>
+ </mat-form-field>
+ </form>
+ </div>
+ </mat-header-cell>
+ <mat-cell *matCellDef="let job"> {{job.status}} </mat-cell>
+ </ng-container>
+ <mat-header-row *matHeaderRowDef="['jobId', 'prodIds', 'typeId', 'owner', 'targetUri', 'status']"></mat-header-row>
+ <mat-row *matRowDef="let row; columns: ['jobId', 'prodIds', 'typeId', 'owner', 'targetUri', 'status'];"></mat-row>
</mat-table>
<mat-paginator [length]="jobs()?.length" [pageSize]="10" [pageSizeOptions]="[5, 10, 25, 100]" showFirstLastButtons
class="ei-coordinator-table mat-elevation-z8"></mat-paginator>
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 @@
owner: "owner1",
targetUri: "http://one",
prodIds: ["producer1"],
+ status: "ENABLED"
} as Job;
const job2 = {
jobId: "job2",
@@ -76,6 +77,7 @@
owner: "owner1",
targetUri: "http://one",
prodIds: ["producer1"],
+ status: "ENABLED"
} as Job;
describe("JobsListComponent", () => {
@@ -117,6 +119,7 @@
typeId: "type1",
owner: "owner1",
targetUri: "http://one",
+ status: "ENABLED"
};
it("should create", () => {
@@ -151,6 +154,7 @@
typeId: "Type ID",
owner: "Owner",
targetUri: "Target URI",
+ status: "Status"
});
});
});
@@ -188,6 +192,7 @@
typeId: "type1",
owner: "owner1",
targetUri: "http://one",
+ status: "ENABLED"
},
];
@@ -239,6 +244,7 @@
typeId: "< No type >",
owner: "< No owner >",
targetUri: "http://one",
+ status: "ENABLED",
};
loader
@@ -335,6 +341,26 @@
});
});
});
+
+ 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 @@
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 @@
typeId: "type1",
owner: "owner1",
targetUri: "http://one",
+ status: "ENABLED"
};
setServiceSpy();
@@ -496,6 +523,23 @@
});
});
});
+ 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 @@
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 { 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 @@
targetUri: string;
owner: string;
prodIds: string[];
+ status: OperationalState;
}
@Component({
@@ -64,6 +66,7 @@
owner: new FormControl(""),
targetUri: new FormControl(""),
prodIds: new FormControl(""),
+ status: new FormControl("")
});
}
@@ -81,7 +84,8 @@
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 @@
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 @@
this.loadingSubject$.next(false);
this.jobsSubject$.next(this.jobList);
})
-
);
const whenToRefresh$ = of('').pipe(
@@ -158,6 +165,7 @@
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 @@
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 @@
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 @@
private extractJobs(res: any) {
this.clearFilter();
res.forEach(element => {
- 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"];
- this.jobList = this.jobList.concat(jobObj);
+ if (element[0] != -1) {
+ 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"];
+ jobObj.status = element[2].info_job_status;
+ this.jobList = this.jobList.concat(jobObj);
+ } else {
+ let jobObj = <Job>{};
+ 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";