diff --git a/utils/log/LogService.module.ts b/utils/log/LogService.module.ts new file mode 100644 index 00000000..dd7332bb --- /dev/null +++ b/utils/log/LogService.module.ts @@ -0,0 +1,21 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import {LogService} from "./log.service"; + + + +@NgModule({ + imports: [ + CommonModule, FormsModule, + + ], + declarations: [ + + ], + providers: [ LogService ], + exports: [ + + ] +}) +export class LogServiceModule { } diff --git a/utils/log/log.service.ts b/utils/log/log.service.ts new file mode 100644 index 00000000..216e0931 --- /dev/null +++ b/utils/log/log.service.ts @@ -0,0 +1,47 @@ +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.logFilesService, new UploadLog(dois) ); + } + logLink(properties: EnvProperties){ + return this.http.post(properties.logFilesService, new LinkLog() ); + } + logOrcidLink(properties: EnvProperties, action:'added'|'removed', title: string, doi: string){ + return this.http.post(properties.logFilesService, new OrcidLinkLog(action, title, doi) ); + } +} diff --git a/utils/properties/env-properties.ts b/utils/properties/env-properties.ts index 36c25353..92eb3c2a 100644 --- a/utils/properties/env-properties.ts +++ b/utils/properties/env-properties.ts @@ -145,6 +145,10 @@ export interface EnvProperties { eoscDataTransferLoginUrl?; eoscDataTransferDestinations?; hasMachineCache?: boolean; + +// irish + logFilesPath?:string; + logServiceUrl?:string; } export function checkPropertyValues(properties:EnvProperties){