oaipmh-analysis.component: Added methods public getKeys(map) and public getValues(map) to solve ExpressionChangedAfterItHasBeenCheckedError | oaipmh-history.component.html: [Bug fix] Changed <ng-container> with <span> because styling (class) was needed | oaipmh-history.component.ts: Updated method "getJobResult()" to repeat the query every 5 seconds until result.progress !== Progress.IN_PROGRESS.

This commit is contained in:
Konstantina Galouni 2023-07-26 17:18:32 +03:00
parent 7580f1b6e4
commit 401ce63989
7 changed files with 46 additions and 29 deletions

@ -1 +1 @@
Subproject commit 6ecde003afe2cc7f4917b1d0f616d8c4b6355346
Subproject commit 056faac88fd45f2ebcf48a550f21517455b8a80c

View File

@ -74,12 +74,12 @@
</div>
<div *ngIf="validationResult?.size > 0">
<ul uk-tab>
<li *ngFor="let result of validationResult.keys()" class="uk-width-auto@l uk-width-medium">
<li *ngFor="let result of getKeys(validationResult)" class="uk-width-auto@l uk-width-medium">
<a><span class="uk-text-truncate" [attr.uk-tooltip]="result">{{result}}</span></a></li>
</ul>
<ul class="uk-switcher uk-margin">
<li *ngFor="let result of validationResult.values()">
<li *ngFor="let result of getValues(validationResult)">
<ul class="uk-subnav uk-subnav-pill-alt uk-margin" uk-switcher>
<li class="uk-active"><a>All Rules ({{result.analysisResult.length | number}})</a></li>
<li><a>Successful ({{result.successfulAnalysisResult.length | number}})</a></li>

View File

@ -1,4 +1,4 @@
import {Component, OnInit, ViewChild} from '@angular/core';
import {ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core';
import {UntypedFormGroup} from "@angular/forms";
import {OaipmhValidatorService} from "../../../services/oaipmh-validator.service";
import {Subscriber} from "rxjs";
@ -53,14 +53,13 @@ export class OaipmhAnalysisComponent implements OnInit {
['OpenAIRE FAIR Guidelines for Data Repositories Profile', 'oai_datacite']
]);
constructor(private route: ActivatedRoute, private validator: OaipmhValidatorService) {
}
constructor(private route: ActivatedRoute, private cdr: ChangeDetectorRef, private validator: OaipmhValidatorService) {}
ngOnInit(): void {
this.subscriptions.push(this.route.queryParams.subscribe(params => {
this.jobId = params['jobId'];
this.validationResult = new Map<string, {"analysisResult": RulePerJob[], "successfulAnalysisResult": RulePerJob[], "warningAnalysisResult": RulePerJob[], "failedAnalysisResult": RulePerJob[] }>;
// this.validationResult = new Map<string, {"analysisResult": RulePerJob[], "successfulAnalysisResult": RulePerJob[], "warningAnalysisResult": RulePerJob[], "failedAnalysisResult": RulePerJob[] }>;
// this.analysisResult = [];
// this.successfulAnalysisResult = [];
// this.warningAnalysisResult = [];
@ -95,25 +94,30 @@ export class OaipmhAnalysisComponent implements OnInit {
public getAnalysis() {
this.subscriptions.push(this.validator.getAnalysis(this.jobId).subscribe(
(result: RulePerJob[]) => {
console.log(result);
// this.analysisResult = result;
let validationResult: Map<string, { "analysisResult": RulePerJob[], "successfulAnalysisResult": RulePerJob[], "warningAnalysisResult": RulePerJob[], "failedAnalysisResult": RulePerJob[] }> =
new Map<string, {"analysisResult": RulePerJob[], "successfulAnalysisResult": RulePerJob[], "warningAnalysisResult": RulePerJob[], "failedAnalysisResult": RulePerJob[] }>;
for(let rulePerJob of result) {
if(!this.validationResult.has(rulePerJob.guidelines)) {
this.validationResult.set(rulePerJob.guidelines, {analysisResult: [], successfulAnalysisResult: [], warningAnalysisResult: [], failedAnalysisResult: []});
if(!validationResult.has(rulePerJob.guidelines)) {
validationResult.set(rulePerJob.guidelines, {analysisResult: [], successfulAnalysisResult: [], warningAnalysisResult: [], failedAnalysisResult: []});
}
this.validationResult.get(rulePerJob.guidelines).analysisResult.push(rulePerJob);
validationResult.get(rulePerJob.guidelines).analysisResult.push(rulePerJob);
if(rulePerJob.rule_status == Status.FAILURE || rulePerJob.rule_status == Status.ERROR) {
this.validationResult.get(rulePerJob.guidelines).failedAnalysisResult.push(rulePerJob);
validationResult.get(rulePerJob.guidelines).failedAnalysisResult.push(rulePerJob);
} else {
if(rulePerJob.has_warnings || rulePerJob.has_errors || rulePerJob.internal_error) {
this.validationResult.get(rulePerJob.guidelines).warningAnalysisResult.push(rulePerJob);
validationResult.get(rulePerJob.guidelines).warningAnalysisResult.push(rulePerJob);
} else {
this.validationResult.get(rulePerJob.guidelines).successfulAnalysisResult.push(rulePerJob);
validationResult.get(rulePerJob.guidelines).successfulAnalysisResult.push(rulePerJob);
}
}
}
this.validationResult = validationResult;
this.cdr.detectChanges();
}
));
}
@ -182,5 +186,13 @@ export class OaipmhAnalysisComponent implements OnInit {
));
}
public getKeys(map) {
return Array.from(map.keys());
}
public getValues(map) {
return Array.from(map.values());
}
protected readonly Status = Status;
}

View File

@ -38,10 +38,10 @@
class="uk-label" [ngClass]="result.status == Status.SUCCESS ? 'uk-label-success' : 'uk-label-danger'">
{{result.status}}
</span>
<ng-container *ngIf="result.progress != Progress.COMPLETED"
class="uk-label" [ngClass]="result.progress == Progress.IN_PROGRESS ? 'uk-label-warning' : 'uk-label-danger'">
<span *ngIf="result.progress != Progress.COMPLETED"
class="uk-label" [ngClass]="result.progress == Progress.IN_PROGRESS ? 'uk-label-warning' : 'uk-label-danger'">
{{result.progress}}
</ng-container>
</span>
</td>
<td>
<a class="uk-button-link uk-flex uk-flex-middle" [ngClass]="result.progress != Progress.COMPLETED ? 'uk-disabled uk-link-muted' : ''"

View File

@ -1,10 +1,10 @@
import {Component, OnInit, ViewChild} from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {OaipmhValidatorService} from "../../../services/oaipmh-validator.service";
import {Status} from "../../entities/RuleInfo";
import {JobResult, Progress} from "../../entities/JobResult";
import {JobResult, Progress, Status} from "../../entities/JobResult";
import {ActivatedRoute} from "@angular/router";
import {Subscriber} from "rxjs";
import {Breadcrumb} from "../../../openaire-library/utils/breadcrumbs/breadcrumbs.component";
import {filter, repeat, take} from "rxjs/operators";
@Component({
selector: 'app-oaipmh-history',
@ -28,8 +28,7 @@ export class OaipmhHistoryComponent implements OnInit {
if(!this.jobId) {
this.jobId = "825";
}
this.getJobResult();
this.getJobResult();
}));
}
@ -42,11 +41,17 @@ export class OaipmhHistoryComponent implements OnInit {
}
public getJobResult() {
this.subscriptions.push(this.validator.getJobResult(this.jobId).subscribe(
(result: JobResult) => {
this.result = result;
}
));
this.subscriptions.push(this.validator.getJobResult(this.jobId)
.pipe(
repeat({ delay: 5000 }),
filter((result: JobResult) => {
this.result = result;
return result.progress !== Progress.IN_PROGRESS
}),
take(1)
)
.subscribe()
);
}
protected readonly Status = Status;

View File

@ -47,7 +47,7 @@
<button class="uk-button uk-flex uk-flex-middle uk-flex-wrap"
[class.uk-button-primary]="form.valid" [class.uk-disabled]="!form.valid"
(click)="validate();">
<span class="uk-margin-small-left">Start Validation</span>
<span>Start Validation</span>
</button>
</div>
</ng-container>

@ -1 +1 @@
Subproject commit cf3dab89f7356b88abfe6f125930076466e8a780
Subproject commit 5268f277246347aad42349a06eecb915a452841b