oaipmh-validator.component: Improvements, fixes and checks added & Added subscriptions and ngOnDestroy & Added real API call to validate | oaipmh-analysis.component.ts & oaipmh-history.component.ts & single-record-validator.component.ts: Added subscriptions and ngOnDestroy | oaipmh-validator.service.ts: In method "validate()" added real API call & if all sets are chosen, do not send the set parameter | topmenu.component.html: Added "Validate [demo]" option.
This commit is contained in:
parent
a8937de064
commit
7580f1b6e4
|
@ -93,7 +93,7 @@ export class OaipmhAnalysisComponent implements OnInit {
|
|||
|
||||
|
||||
public getAnalysis() {
|
||||
this.validator.getAnalysis(this.jobId).subscribe(
|
||||
this.subscriptions.push(this.validator.getAnalysis(this.jobId).subscribe(
|
||||
(result: RulePerJob[]) => {
|
||||
console.log(result);
|
||||
// this.analysisResult = result;
|
||||
|
@ -115,7 +115,7 @@ export class OaipmhAnalysisComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
public openWarningsModal(rule: RulePerJob) {
|
||||
|
@ -138,13 +138,13 @@ export class OaipmhAnalysisComponent implements OnInit {
|
|||
this.warnings = [];
|
||||
this.openWarningsModal(rule);
|
||||
this.warningsModalOpen = true;
|
||||
this.validator.getWarnings(this.jobId, rule.rule_name).subscribe(
|
||||
this.subscriptions.push(this.validator.getWarnings(this.jobId, rule.rule_name).subscribe(
|
||||
result => {
|
||||
this.warnings = result;
|
||||
console.log(result);
|
||||
// this.result = result;
|
||||
}
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
getErrors(rule: RulePerJob) {
|
||||
|
@ -154,17 +154,17 @@ export class OaipmhAnalysisComponent implements OnInit {
|
|||
this.errorsModalOpen = true;
|
||||
|
||||
if(rule.has_errors) {
|
||||
this.validator.getErrors(this.jobId, rule.rule_name).subscribe(
|
||||
this.subscriptions.push(this.validator.getErrors(this.jobId, rule.rule_name).subscribe(
|
||||
result => {
|
||||
this.errors = result;
|
||||
console.log(result);
|
||||
}
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public getJobResult() {
|
||||
this.validator.getJobResult(this.jobId).subscribe(
|
||||
this.subscriptions.push(this.validator.getJobResult(this.jobId).subscribe(
|
||||
(result: JobResult) => {
|
||||
this.jobResult = result;
|
||||
let startDate = new Date(this.jobResult.startDate);
|
||||
|
@ -179,7 +179,7 @@ export class OaipmhAnalysisComponent implements OnInit {
|
|||
this.jobDuration.months = Math.floor(this.jobDuration.days / 31);
|
||||
this.jobDuration.years = Math.floor(this.jobDuration.months / 12);
|
||||
}
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
protected readonly Status = Status;
|
||||
|
|
|
@ -42,11 +42,11 @@ export class OaipmhHistoryComponent implements OnInit {
|
|||
}
|
||||
|
||||
public getJobResult() {
|
||||
this.validator.getJobResult(this.jobId).subscribe(
|
||||
this.subscriptions.push(this.validator.getJobResult(this.jobId).subscribe(
|
||||
(result: JobResult) => {
|
||||
this.result = result;
|
||||
}
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
protected readonly Status = Status;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
<div class="uk-margin-large-bottom">
|
||||
<h6><span class="uk-text-secondary uk-margin-right">3.</span> Define the number of record to validate</h6>
|
||||
<div class="uk-margin-xsmall-left uk-margin-medium-top uk-margin-small-bottom">
|
||||
<div class="uk-disabled uk-text-muted uk-margin-xsmall-left uk-margin-medium-top uk-margin-small-bottom">
|
||||
<input id="all" type="radio" name="recordsNum" value="-1" formControlName="recordsNum">
|
||||
<label for="all" class="uk-margin-xsmall-left">All</label>
|
||||
</div>
|
||||
|
@ -31,15 +31,16 @@
|
|||
Custom
|
||||
</label>
|
||||
<span class="uk-margin-left uk-flex-inline uk-flex-middle">
|
||||
<icon class="clickable" name="do_not_disturb_on" flex="true" ratio="0.9" [class.uk-disabled]="recordsNum <= 10" (click)="updateRecordsNum(false)"></icon>
|
||||
<icon class="clickable" name="remove_circle_outline" flex="true" ratio="0.9" type="outlined"
|
||||
[ngClass]="recordsNum <= 10 ? 'uk-disabled uk-text-muted' : ''" (click)="updateRecordsNum(false)"></icon>
|
||||
<span class="uk-margin-small-left uk-margin-small-right">{{recordsNum}}</span>
|
||||
<icon class="clickable" name="add_circle" flex="true" ratio="0.9" [class.uk-disabled]="recordsNum >= 100" (click)="updateRecordsNum(true)"></icon>
|
||||
<icon class="clickable" name="add_circle_outline" flex="true" ratio="0.9" type="outlined"
|
||||
[ngClass]="recordsNum >= 20 ? 'uk-disabled uk-text-muted' : ''" (click)="updateRecordsNum(true)"></icon>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div input type="select" placeholder="Select validation set" inputClass="flat x-small"
|
||||
<div [disabled]="loadingSets || sets.length == 1" input type="select" placeholder="Select validation set" inputClass="flat x-small"
|
||||
[options]="sets" [formInput]="form.get('set')" class="uk-width-large uk-margin-medium-top uk-margin-xsmall-left"></div>
|
||||
<!-- [options]="sets" [value]="form.get('set').value" [formInput]="form.get('set')" class="uk-width-large uk-margin-medium-top uk-margin-xsmall-left"></div>-->
|
||||
</div>
|
||||
|
||||
<div class="uk-margin-medium-top uk-margin-xsmall-left">
|
||||
|
|
|
@ -3,6 +3,9 @@ import {OaipmhValidatorService} from "../../../services/oaipmh-validator.service
|
|||
import {UntypedFormBuilder, UntypedFormGroup, Validators} from "@angular/forms";
|
||||
import {Option} from "../../../openaire-library/sharedComponents/input/input.component";
|
||||
import {StringUtils} from "../../../openaire-library/utils/string-utils.class";
|
||||
import {JobResult} from "../../entities/JobResult";
|
||||
import {Router} from "@angular/router";
|
||||
import {Subscriber} from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'app-oaipmh-validator',
|
||||
|
@ -19,37 +22,64 @@ export class OaipmhValidatorComponent implements OnInit {
|
|||
public form: UntypedFormGroup;
|
||||
public sets: Option[] = [{label: 'All sets', value: 'all'}];
|
||||
public recordsNum: number = 10;
|
||||
public loadingSets: boolean = false;
|
||||
|
||||
constructor(private fb: UntypedFormBuilder, private validator: OaipmhValidatorService) {
|
||||
subscriptions = [];
|
||||
|
||||
constructor(private fb: UntypedFormBuilder, private router: Router, private validator: OaipmhValidatorService) {
|
||||
this.form = this.fb.group({
|
||||
url: this.fb.control("", StringUtils.urlValidator()),//[Validators.required/*, Validators.email*/]),
|
||||
guidelines: this.fb.control("", Validators.required),
|
||||
recordsNum: this.fb.control(null, Validators.required),
|
||||
set: this.fb.control('', Validators.required)
|
||||
set: this.fb.control('all', Validators.required)
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(subscription => {
|
||||
if (subscription instanceof Subscriber) {
|
||||
subscription.unsubscribe();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateRecordsNum(increase: boolean = true) {
|
||||
this.recordsNum = this.recordsNum + (increase ? 10 : -10);
|
||||
this.form.get('recordsNum').setValue(this.recordsNum);
|
||||
}
|
||||
|
||||
getSets() {
|
||||
this.loadingSets = true;
|
||||
let options: Option[] = [{label: 'All sets', value: 'all'}];
|
||||
if(this.form.get('setName')) {
|
||||
this.form.get('setName').setValue('all');
|
||||
}
|
||||
if(this.form.get('url') && this.form.get('url').value && StringUtils.isValidUrl(this.form.get('url').value)) {
|
||||
this.validator.getSets(this.form.get('url').value).subscribe(sets => {
|
||||
this.subscriptions.push(this.validator.getSets(this.form.get('url').value).subscribe(sets => {
|
||||
for(let set of sets) {
|
||||
options.push({label: set['setName'], value: set['setSpec']});
|
||||
}
|
||||
this.sets = options;
|
||||
});
|
||||
this.loadingSets = false;
|
||||
}, error => {
|
||||
this.sets = options;
|
||||
this.loadingSets = false;
|
||||
}));
|
||||
} else {
|
||||
this.sets = options;
|
||||
this.loadingSets = false;
|
||||
}
|
||||
}
|
||||
|
||||
validate() {
|
||||
console.log(this.form.value);
|
||||
this.validator.validate(this.form.get('guidelines').value, this.form.get('url').value, this.form.get('recordsNum').value, this.form.get('set').value);
|
||||
this.subscriptions.push(this.validator.validate(this.form.get('guidelines').value, this.form.get('url').value, this.form.get('recordsNum').value, this.form.get('set').value).subscribe(
|
||||
(result: JobResult) => {
|
||||
this.router.navigate(['/oaipmh-history'], {
|
||||
queryParams: { 'jobId': result.id }
|
||||
});
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import {SingleRecordValidatorService} from "../../services/single-record-validat
|
|||
import {RuleInfo} from "../entities/RuleInfo";
|
||||
import {XmlValidationResponse} from "../entities/XmlValidationResponse";
|
||||
import {Option} from "../../openaire-library/sharedComponents/input/input.component";
|
||||
import {Subscriber} from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'app-single-record-validator',
|
||||
|
@ -26,6 +27,8 @@ export class SingleRecordValidatorComponent implements OnInit {
|
|||
public viewResults: boolean = false;
|
||||
public validationAnalysis: boolean = true;
|
||||
|
||||
subscriptions = [];
|
||||
|
||||
constructor(private fb: UntypedFormBuilder, private validator: SingleRecordValidatorService) {
|
||||
this.form = this.fb.group({
|
||||
guidelines: this.fb.control("", Validators.required),
|
||||
|
@ -35,12 +38,20 @@ export class SingleRecordValidatorComponent implements OnInit {
|
|||
|
||||
ngOnInit(): void {}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(subscription => {
|
||||
if (subscription instanceof Subscriber) {
|
||||
subscription.unsubscribe();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public validate() {
|
||||
this.validator.validateRecord(this.form.get('xml')?.getRawValue(), this.form.get('guidelines')?.getRawValue()).subscribe(
|
||||
this.subscriptions.push(this.validator.validateRecord(this.form.get('xml')?.getRawValue(), this.form.get('guidelines')?.getRawValue()).subscribe(
|
||||
result => {
|
||||
this.result = result;
|
||||
}
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
public openMessagesModal(rule: RuleInfo) {
|
||||
|
|
|
@ -37,7 +37,8 @@ export class OaipmhValidatorService {
|
|||
|
||||
validate(guidelines: string, baseUrl: string, numberOfRecords: string, set: string) {
|
||||
let url: string = environment.validatorAPI + "realValidator?guidelines="+guidelines+"&baseUrl="+baseUrl
|
||||
+(numberOfRecords ? ("&numberOfRecords="+numberOfRecords) : "") + (set ? ("&set="+set) : "");
|
||||
+(numberOfRecords ? ("&numberOfRecords="+numberOfRecords) : "") + (set && set != 'all' ? ("&set="+set) : "");
|
||||
console.log(url);
|
||||
return this.http.get(url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,6 +102,9 @@
|
|||
<li class="uk-parent">
|
||||
<a routerLink="/single-record-validate">Singe Record</a>
|
||||
</li>
|
||||
<li class="uk-parent">
|
||||
<a routerLink="/oaipmh">Validate [demo]</a>
|
||||
</li>
|
||||
<li class="uk-parent">
|
||||
<a routerLink="/oaipmh-history" [queryParams]="{jobId: 825}">History [demo]</a>
|
||||
</li>
|
||||
|
|
Loading…
Reference in New Issue