[angular-16-irish-monitor | WIP] logService and properties

This commit is contained in:
argirok 2023-11-28 18:42:21 +02:00
parent 550c27a464
commit f27b8e11f7
3 changed files with 72 additions and 0 deletions

View File

@ -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 { }

47
utils/log/log.service.ts Normal file
View File

@ -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) );
}
}

View File

@ -145,6 +145,10 @@ export interface EnvProperties {
eoscDataTransferLoginUrl?;
eoscDataTransferDestinations?;
hasMachineCache?: boolean;
// irish
logFilesPath?:string;
logServiceUrl?:string;
}
export function checkPropertyValues(properties:EnvProperties){