2023-11-28 17:42:21 +01:00
import { HttpClient } from "@angular/common/http" ;
import { EnvProperties } from '../properties/env-properties' ;
import { Injectable } from "@angular/core" ;
export abstract class Log {
action :string ;
message :string ;
protected constructor ( action , message ) {
this . action = action ;
this . message = message ;
}
}
export class LinkLog extends Log {
constructor ( ) {
super ( "linking" , "a user linked" ) ;
}
}
export class OrcidLinkLog extends Log {
constructor ( action : 'added' | 'removed' , title : string , doi : string ) {
super ( "orcid-claim" , "user with ORCID iD " + action + " research product \"" + title + "\" (" + doi + ") " + ( action == 'added' ? 'to' : 'from' )
+ " their ORCID record." ) ;
}
}
export class UploadLog extends Log {
constructor ( dois :number ) {
super ( "upload-dois" , "a user uploaded a list of " + dois + " DOIs to the Irish Monitor to check their presence and retrieve the Open Access types and additional key metadata" ) ;
}
}
@Injectable ( )
export class LogService {
constructor ( private http : HttpClient ) {
}
logUploadDOIs ( properties : EnvProperties , dois :number ) {
2023-11-28 17:49:42 +01:00
return this . http . post ( properties . logServiceUrl , new UploadLog ( dois ) ) ;
2023-11-28 17:42:21 +01:00
}
logLink ( properties : EnvProperties ) {
2023-11-28 17:49:42 +01:00
return this . http . post ( properties . logServiceUrl , new LinkLog ( ) ) ;
2023-11-28 17:42:21 +01:00
}
logOrcidLink ( properties : EnvProperties , action : 'added' | 'removed' , title : string , doi : string ) {
2023-11-28 17:49:42 +01:00
return this . http . post ( properties . logServiceUrl , new OrcidLinkLog ( action , title , doi ) ) ;
2023-11-28 17:42:21 +01:00
}
}