2023-09-13 14:04:18 +02:00
import { ChangeDetectorRef , Component , OnInit , ViewChild } from '@angular/core' ;
2023-07-14 17:22:25 +02:00
import { OaipmhValidatorService } from "../../../services/oaipmh-validator.service" ;
2023-07-25 10:58:23 +02:00
import { UntypedFormBuilder , UntypedFormGroup , Validators } from "@angular/forms" ;
2023-07-25 12:39:39 +02:00
import { Option } from "../../../openaire-library/sharedComponents/input/input.component" ;
import { StringUtils } from "../../../openaire-library/utils/string-utils.class" ;
2023-07-25 15:58:41 +02:00
import { JobResult } from "../../entities/JobResult" ;
import { Router } from "@angular/router" ;
import { Subscriber } from "rxjs" ;
2023-07-14 17:22:25 +02:00
[Validator]: Updates & improvements.
1. JobResult.ts: Added "set:string" and "exceptionMessage: string" fields.
2. RulePerJob.ts: Removed "rule_description" field and added fields "requirement_level: string, description: string, fair_principles: string, fair_principles_tooltip: string, link: string;".
3. oaipmh-analysis.component.html: Added cards on the right for base url and set | Added requirement level to the rule name, updated field for description, added fair principles.
4. oaipmh-analysis.component.ts: Added "requirementLevelMapping" and initialize tooltip of fair principles.
5. oaipmh-history.component.html: Updated table to show multiple validations | Updated columns of table - removed actions and updated status (view results - gets us to the analysis, in progress, stoppes, error, errors - opens a modal with the exception message).
6. oaipmh-history.component.ts: Added method "getJobResults()" and methods for error modal | Added a limit of 120 requests (10 minutes) for repetable requests of getting jobResult to update status when status is in progress.
7. oaipmh-validator.component.ts: Updated label for guidelines | Updated validation checks | Added exception catch in getSets().
8. oaipmh-validator.service.ts: Added method "getJobResults(limit: number = 200)".
9. topmenu.component.html: Removed jobId from history demo page.
10. package-lock.json: Updated uikit version.
2023-10-03 16:00:58 +02:00
declare var UIkit : any ;
2023-07-14 17:22:25 +02:00
@Component ( {
selector : 'app-oaipmh-validator' ,
templateUrl : './oaipmh-validator.component.html' ,
styleUrls : [ './oaipmh-validator.component.less' ]
} )
export class OaipmhValidatorComponent implements OnInit {
2023-09-13 14:04:18 +02:00
@ViewChild ( "right_sidebar" ) right_sidebar ;
@ViewChild ( "right_sidebar_header" ) right_sidebar_header ;
@ViewChild ( "right_sidebar_footer" ) right_sidebar_footer ;
2023-07-25 10:58:23 +02:00
public options : Option [ ] = [
[Validator]: Updates & improvements.
1. JobResult.ts: Added "set:string" and "exceptionMessage: string" fields.
2. RulePerJob.ts: Removed "rule_description" field and added fields "requirement_level: string, description: string, fair_principles: string, fair_principles_tooltip: string, link: string;".
3. oaipmh-analysis.component.html: Added cards on the right for base url and set | Added requirement level to the rule name, updated field for description, added fair principles.
4. oaipmh-analysis.component.ts: Added "requirementLevelMapping" and initialize tooltip of fair principles.
5. oaipmh-history.component.html: Updated table to show multiple validations | Updated columns of table - removed actions and updated status (view results - gets us to the analysis, in progress, stoppes, error, errors - opens a modal with the exception message).
6. oaipmh-history.component.ts: Added method "getJobResults()" and methods for error modal | Added a limit of 120 requests (10 minutes) for repetable requests of getting jobResult to update status when status is in progress.
7. oaipmh-validator.component.ts: Updated label for guidelines | Updated validation checks | Added exception catch in getSets().
8. oaipmh-validator.service.ts: Added method "getJobResults(limit: number = 200)".
9. topmenu.component.html: Removed jobId from history demo page.
10. package-lock.json: Updated uikit version.
2023-10-03 16:00:58 +02:00
{ label : 'OpenAIRE Guidelines for Data Archives Profile v2 & OpenAIRE FAIR Guidelines for Data Repositories Profile' , value : 'OpenAIRE Guidelines for Data Archives Profile v2' } ,
2023-07-25 10:58:23 +02:00
{ label : 'OpenAIRE Guidelines for Literature Repositories Profile v3' , value : 'OpenAIRE Guidelines for Literature Repositories Profile v3' } ,
{ label : 'OpenAIRE Guidelines for Literature Repositories Profile v4' , value : 'OpenAIRE Guidelines for Literature Repositories Profile v4' } ,
{ label : 'OpenAIRE FAIR Guidelines for Data Repositories Profile' , value : 'OpenAIRE FAIR Guidelines for Data Repositories Profile' }
] ;
public form : UntypedFormGroup ;
public sets : Option [ ] = [ { label : 'All sets' , value : 'all' } ] ;
public recordsNum : number = 10 ;
2023-07-25 15:58:41 +02:00
public loadingSets : boolean = false ;
2023-07-14 17:22:25 +02:00
2023-08-25 11:02:46 +02:00
public offset : number = 0 ;
public help : boolean = false ;
2023-09-13 14:04:18 +02:00
public right_sidebar_body_height : number = 0 ;
2023-09-13 14:42:24 +02:00
public right_sidebar_card_height : number = 0 ;
2023-09-13 14:04:18 +02:00
2023-07-25 15:58:41 +02:00
subscriptions = [ ] ;
2023-09-13 14:04:18 +02:00
constructor ( private fb : UntypedFormBuilder , private router : Router ,
private cdr : ChangeDetectorRef ,
private validator : OaipmhValidatorService ) {
2023-07-25 10:58:23 +02:00
this . form = this . fb . group ( {
[Validator]: Updates & improvements.
1. JobResult.ts: Added "set:string" and "exceptionMessage: string" fields.
2. RulePerJob.ts: Removed "rule_description" field and added fields "requirement_level: string, description: string, fair_principles: string, fair_principles_tooltip: string, link: string;".
3. oaipmh-analysis.component.html: Added cards on the right for base url and set | Added requirement level to the rule name, updated field for description, added fair principles.
4. oaipmh-analysis.component.ts: Added "requirementLevelMapping" and initialize tooltip of fair principles.
5. oaipmh-history.component.html: Updated table to show multiple validations | Updated columns of table - removed actions and updated status (view results - gets us to the analysis, in progress, stoppes, error, errors - opens a modal with the exception message).
6. oaipmh-history.component.ts: Added method "getJobResults()" and methods for error modal | Added a limit of 120 requests (10 minutes) for repetable requests of getting jobResult to update status when status is in progress.
7. oaipmh-validator.component.ts: Updated label for guidelines | Updated validation checks | Added exception catch in getSets().
8. oaipmh-validator.service.ts: Added method "getJobResults(limit: number = 200)".
9. topmenu.component.html: Removed jobId from history demo page.
10. package-lock.json: Updated uikit version.
2023-10-03 16:00:58 +02:00
url : this.fb.control ( "" , [ Validators . required , StringUtils . urlValidator ( ) ] ) , //[Validators.required/*, Validators.email*/]),
2023-07-25 10:58:23 +02:00
guidelines : this.fb.control ( "" , Validators . required ) ,
recordsNum : this.fb.control ( null , Validators . required ) ,
2023-07-25 15:58:41 +02:00
set : this . fb . control ( 'all' , Validators . required )
2023-07-25 10:58:23 +02:00
} ) ;
}
ngOnInit() { }
2023-08-25 11:02:46 +02:00
ngAfterViewInit() {
if ( typeof document !== 'undefined' ) {
if ( document . getElementById ( "main-menu" ) ) {
this . offset = Number . parseInt ( getComputedStyle ( document . documentElement ) . getPropertyValue ( '--header-height' ) ) ;
} else {
this . offset = 0 ;
}
}
}
2023-07-25 15:58:41 +02:00
ngOnDestroy() {
this . subscriptions . forEach ( subscription = > {
if ( subscription instanceof Subscriber ) {
subscription . unsubscribe ( ) ;
}
} ) ;
}
2023-09-13 14:04:18 +02:00
openHelp() {
this . help = true ;
this . cdr . detectChanges ( ) ;
if ( typeof document !== 'undefined' ) {
console . log ( this . right_sidebar . nativeElement . offsetHeight ) ;
console . log ( this . right_sidebar_header . nativeElement . offsetHeight ) ;
console . log ( this . right_sidebar_footer . nativeElement . offsetHeight ) ;
2023-09-13 14:42:24 +02:00
this . right_sidebar_card_height = this . right_sidebar . nativeElement . offsetHeight - this . right_sidebar_header . nativeElement . offsetHeight + 1 ;
this . right_sidebar_body_height = this . right_sidebar_card_height - this . right_sidebar_footer . nativeElement . offsetHeight ;
2023-09-13 14:04:18 +02:00
}
}
2023-07-25 10:58:23 +02:00
updateRecordsNum ( increase : boolean = true ) {
this . recordsNum = this . recordsNum + ( increase ? 10 : - 10 ) ;
this . form . get ( 'recordsNum' ) . setValue ( this . recordsNum ) ;
}
getSets() {
2023-07-25 15:58:41 +02:00
this . loadingSets = true ;
2023-07-25 10:58:23 +02:00
let options : Option [ ] = [ { label : 'All sets' , value : 'all' } ] ;
2023-07-25 15:58:41 +02:00
if ( this . form . get ( 'setName' ) ) {
this . form . get ( 'setName' ) . setValue ( 'all' ) ;
}
2023-07-25 10:58:23 +02:00
if ( this . form . get ( 'url' ) && this . form . get ( 'url' ) . value && StringUtils . isValidUrl ( this . form . get ( 'url' ) . value ) ) {
2023-07-25 15:58:41 +02:00
this . subscriptions . push ( this . validator . getSets ( this . form . get ( 'url' ) . value ) . subscribe ( sets = > {
2023-07-25 10:58:23 +02:00
for ( let set of sets ) {
options . push ( { label : set [ 'setName' ] , value : set [ 'setSpec' ] } ) ;
}
this . sets = options ;
2023-07-25 15:58:41 +02:00
this . loadingSets = false ;
} , error = > {
this . sets = options ;
this . loadingSets = false ;
} ) ) ;
} else {
this . sets = options ;
this . loadingSets = false ;
2023-07-25 10:58:23 +02:00
}
}
validate() {
2023-07-25 15:58:41 +02:00
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 }
} ) ;
[Validator]: Updates & improvements.
1. JobResult.ts: Added "set:string" and "exceptionMessage: string" fields.
2. RulePerJob.ts: Removed "rule_description" field and added fields "requirement_level: string, description: string, fair_principles: string, fair_principles_tooltip: string, link: string;".
3. oaipmh-analysis.component.html: Added cards on the right for base url and set | Added requirement level to the rule name, updated field for description, added fair principles.
4. oaipmh-analysis.component.ts: Added "requirementLevelMapping" and initialize tooltip of fair principles.
5. oaipmh-history.component.html: Updated table to show multiple validations | Updated columns of table - removed actions and updated status (view results - gets us to the analysis, in progress, stoppes, error, errors - opens a modal with the exception message).
6. oaipmh-history.component.ts: Added method "getJobResults()" and methods for error modal | Added a limit of 120 requests (10 minutes) for repetable requests of getting jobResult to update status when status is in progress.
7. oaipmh-validator.component.ts: Updated label for guidelines | Updated validation checks | Added exception catch in getSets().
8. oaipmh-validator.service.ts: Added method "getJobResults(limit: number = 200)".
9. topmenu.component.html: Removed jobId from history demo page.
10. package-lock.json: Updated uikit version.
2023-10-03 16:00:58 +02:00
} ,
error = > {
// if(error.status == 400) {
UIkit . notification ( ( error . error && error . error . message ) ? error.error.message : error.message , {
status : 'danger' ,
timeout : 4000 ,
pos : 'bottom-right'
} ) ;
// }
// if(error.status == 422) {
// this.router.navigate(['/oaipmh-history'], {
// queryParams: { 'jobId': error.error.id }
// })
// }
2023-07-25 15:58:41 +02:00
}
) ) ;
2023-07-14 17:22:25 +02:00
}
}