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){ return this.http.post(properties.logServiceUrl, new UploadLog(dois) ); } logLink(properties: EnvProperties){ return this.http.post(properties.logServiceUrl, new LinkLog() ); } logOrcidLink(properties: EnvProperties, action:'added'|'removed', title: string, doi: string){ return this.http.post(properties.logServiceUrl, new OrcidLinkLog(action, title, doi) ); } }