summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
d3ff005)
Issue-ID: NONRTRIC-555
Signed-off-by: ychacon <yennifer.chacon@est.tech>
Change-Id: I24c6a3d25a8fff352d9979d6f2703a6e3e19ab1f
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 { 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;
export interface Job {
jobId: string;
subscription: Subscription;
checked: boolean = false;
firstTime: boolean = true;
subscription: Subscription;
checked: boolean = false;
firstTime: boolean = true;
constructor(private consumerService: ConsumerService, private ui: UiService) {
this.jobForm = new FormGroup({
constructor(private consumerService: ConsumerService, private ui: UiService) {
this.jobForm = new FormGroup({
dataSubscription(): Subscription {
const jobsInfo$ = this.consumerService.getJobIds().pipe(
dataSubscription(): Subscription {
const jobsInfo$ = this.consumerService.getJobIds().pipe(
+ tap((_) => {
+ this.jobList = [] as Job[];
+ }),
mergeMap((jobIds) =>
forkJoin(jobIds.map((jobId) => {
return forkJoin([
mergeMap((jobIds) =>
forkJoin(jobIds.map((jobId) => {
return forkJoin([
- this.loadingSubject$.next(false)
+ this.loadingSubject$.next(false);
+ this.jobsSubject$.next(this.jobList);
concatMap((value) => {
let pollCondition = value == 0 || this.checked;
return pollCondition ? refreshedJobs$ : EMPTY;
concatMap((value) => {
let pollCondition = value == 0 || this.checked;
return pollCondition ? refreshedJobs$ : EMPTY;
private extractJobs(res: any) {
this.clearFilter();
private extractJobs(res: any) {
this.clearFilter();
res.forEach(element => {
if(element[1] != -1 && element[2] != -1){
let jobObj = <Job>{};
res.forEach(element => {
if(element[1] != -1 && element[2] != -1){
let jobObj = <Job>{};
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.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.jobList = this.jobList.concat(jobObj);
- this.jobsSubject$.next(jobList);
- if (this.firstTime && jobList.length > 0) {
- this.polling$.next(jobList.length);
+ if (this.firstTime && this.jobList.length > 0) {
+ this.polling$.next(this.jobList.length);
this.firstTime = false;
}
this.firstTime = false;
}
}
refreshDataClick() {
this.refresh$.next("");
}
}
refreshDataClick() {
this.refresh$.next("");
}
+
+ hasJobs(): boolean {
+ return this.jobs().length > 0;
+ }
+
it('should contain data after initialization', async () => {
setServiceSpy();
it('should contain data after initialization', async () => {
setServiceSpy();
const expectedProducerRows = [
expectedProducer1Row,
{ id: 'producer2', types: 'type2,type3', status: 'DISABLED' }
const expectedProducerRows = [
expectedProducer1Row,
{ id: 'producer2', types: 'type2,type3', status: 'DISABLED' }
producerServiceSpy.getProducer.and.returnValues(of({} as ProducerRegistrationInfo));
producerServiceSpy.getProducerStatus.and.returnValues(of({} as ProducerStatus));
producerServiceSpy.getProducer.and.returnValues(of({} as ProducerRegistrationInfo));
producerServiceSpy.getProducerStatus.and.returnValues(of({} as ProducerStatus));
const expectedProducerRow = { id: 'producer1', types: '< No types >', status: '< No status >' };
const expectedProducerRow = { id: 'producer1', types: '< No types >', status: '< No status >' };
let producersTable = await loader.getHarness(MatTableHarness.with({ selector: '#producersTable' }));
let producerRows = await producersTable.getRows();
expect(await producerRows[0].getCellTextByColumnName()).toEqual(expectedProducerRow);
let producersTable = await loader.getHarness(MatTableHarness.with({ selector: '#producersTable' }));
let producerRows = await producersTable.getRows();
expect(await producerRows[0].getCellTextByColumnName()).toEqual(expectedProducerRow);
it('filtering', async () => {
setServiceSpy();
it('filtering', async () => {
setServiceSpy();
let producersTable = await loader.getHarness(MatTableHarness.with({ selector: '#producersTable' }));
let idFilterInput = await loader.getHarness(MatInputHarness.with({ selector: '#producerIdFilter' }));
let producersTable = await loader.getHarness(MatTableHarness.with({ selector: '#producersTable' }));
let idFilterInput = await loader.getHarness(MatInputHarness.with({ selector: '#producerIdFilter' }));
- finalize(() => this.loadingSubject.next(false)),
+ finalize(() => {
+ this.loadingSubject.next(false);
+ this.producerSubject.next(producers);
+ })
).subscribe(result => {
producers = result.map(producer => {
let producerObj = <Producer>{};
).subscribe(result => {
producers = result.map(producer => {
let producerObj = <Producer>{};
}
return producerObj;
});
}
return producerObj;
});
- this.producerSubject.next(producers);
}, err => {
console.error("Subscribe function error:" + err);
});
}
}, err => {
console.error("Subscribe function error:" + err);
});
}
+
+ hasProducers(): boolean {
+ return this.producers().length > 0;
+ }
+
- finalize(() => this.loadingSubject$.next(false))
+ finalize(() => {
+ this.loadingSubject$.next(false);
+ this.policyInstanceSubject.next(this.policyInstances);
+ })
)
.subscribe((res) => {
this.policyInstances = res.map((policy) => {
)
.subscribe((res) => {
this.policyInstances = res.map((policy) => {
policyInstance.lastModified = policy[1].last_modified;
return policyInstance;
});
policyInstance.lastModified = policy[1].last_modified;
return policyInstance;
});
- this.policyInstanceSubject.next(this.policyInstances);
}
instanceCount(): number {
}
instanceCount(): number {
- return this.policyInstances.length;
+ return this.instanceDataSource.data.length;
}
toLocalTime(utcTime: string): string {
}
toLocalTime(utcTime: string): string {