From 143f1c0ba16889c8486a084122fdd6c8956d2b84 Mon Sep 17 00:00:00 2001 From: argirok Date: Wed, 13 Dec 2023 17:41:38 +0200 Subject: [PATCH] [develop | DONE | ADDED] add public logs page --- src/app/app-routing.module.ts | 1 + src/app/app.component.ts | 2 + .../public-logs/public-logs-routing.module.ts | 16 +++ src/app/public-logs/public-logs.component.ts | 97 +++++++++++++++++++ src/app/public-logs/public-logs.module.ts | 15 +++ 5 files changed, 131 insertions(+) create mode 100644 src/app/public-logs/public-logs-routing.module.ts create mode 100644 src/app/public-logs/public-logs.component.ts create mode 100644 src/app/public-logs/public-logs.module.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 629335d..fc04606 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -53,6 +53,7 @@ const routes: Routes = [ }, {path: 'orcid', loadChildren: () => import('./orcid/orcid.module').then(m => m.LibOrcidModule)}, {path: 'my-orcid-links', loadChildren: () => import('./orcid/my-orcid-links/myOrcidLinks.module').then(m => m.LibMyOrcidLinksModule)}, + {path: 'public-logs', loadChildren: () => import('./public-logs/public-logs.module').then(m => m.PublicLogsModule)}, {path: 'error', component: ErrorPageComponent}, {path: '**', pathMatch: 'full', component: ErrorPageComponent} ]; diff --git a/src/app/app.component.ts b/src/app/app.component.ts index cb9949f..205886d 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -108,6 +108,8 @@ export class AppComponent extends ResearcherBaseComponent implements OnInit { new MenuItem("rfo", this.stakeholderUtils.entities.funder + ' ' + this.stakeholderUtils.entities.stakeholders, "", "/rfo", false, [], null, {}, null, null, null, "/rfo"), new MenuItem("researcher", "Researcher Monitors", "", "/researcher", false, [], null, {}, null, null, null, "/researcher"), new MenuItem("repository", "Repository Monitors", "", "/repository", false, [], null, {}, null, null, null, "/repository"), + new MenuItem("resources", "Resources", "", "", false, [], null, {}, null, null, null, + "/resources","_blank", "internal", false, [new MenuItem("public-logs", "Public logs", "", "/public-logs", false, [], null, {}, null, null, null, "/repository")]), ]; if (this.user) { this.userMenuItems = []; diff --git a/src/app/public-logs/public-logs-routing.module.ts b/src/app/public-logs/public-logs-routing.module.ts new file mode 100644 index 0000000..cbb0df3 --- /dev/null +++ b/src/app/public-logs/public-logs-routing.module.ts @@ -0,0 +1,16 @@ +import {NgModule} from "@angular/core"; +import {RouterModule} from "@angular/router"; +import {PublicLogsComponent} from "./public-logs.component"; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { + path: '', + component: PublicLogsComponent + } + ]) + ] +}) +export class PublicLogsRoutingModule { +} diff --git a/src/app/public-logs/public-logs.component.ts b/src/app/public-logs/public-logs.component.ts new file mode 100644 index 0000000..027c245 --- /dev/null +++ b/src/app/public-logs/public-logs.component.ts @@ -0,0 +1,97 @@ +import {Component, OnInit} from '@angular/core'; +import {BaseComponent} from '../openaireLibrary/sharedComponents/base/base.component'; +import {ActivatedRoute, Router} from '@angular/router'; +import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service'; +import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service'; +import {Meta, Title} from '@angular/platform-browser'; +import {LogService} from "../openaireLibrary/utils/log/log.service"; + +@Component({ + selector: 'public-logs', + template: ` +
+

Public logs

+ + + + +
+ +
Viewing last {{logs.length}} actions.
+
+ On {{log.date | date: 'd/M/yyyy, hh:mm':'GMT' }} {{log.message}} +
+ +
+ + ` +}) +export class PublicLogsComponent extends BaseComponent implements OnInit { + allLogs; + uploadDoisLogs; + claimsLogs; + orcidClaimsLogs; + constructor(protected _router: Router, + protected _route: ActivatedRoute, + protected seoService: SEOService, + protected _piwikService: PiwikService, + protected _title: Title, + protected _meta: Meta, + private _logService:LogService) { + super(); + } + + ngOnInit() { + this.title = 'Public logs'; + this.description = 'Public logs of user actions in OA monitor - Ireland'; + this.setMetadata(); + this.subscriptions.push(this._logService.getLogs(this.properties).subscribe(logs => { + this.allLogs = logs.slice(logs.length -10 ,logs.length); + this.uploadDoisLogs = []; + this.claimsLogs = []; + this.orcidClaimsLogs = []; + for(let i=logs.length; i--; i==0){ + let log = logs[i]; + log.date = new Date(log.date); + + if(log.action == 'upload-dois' && this.uploadDoisLogs.length <10){ + this.uploadDoisLogs.push(log); + }else if(log.action == 'link' && this.claimsLogs.length <10){ + this.claimsLogs.push(log); + } else if(log.action == 'orcid-link' && this.orcidClaimsLogs.length <10){ + this.orcidClaimsLogs.push(log); + } + } + + })); + } + + +} diff --git a/src/app/public-logs/public-logs.module.ts b/src/app/public-logs/public-logs.module.ts new file mode 100644 index 0000000..c99c621 --- /dev/null +++ b/src/app/public-logs/public-logs.module.ts @@ -0,0 +1,15 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {PublicLogsComponent} from "./public-logs.component"; +import {PublicLogsRoutingModule} from "./public-logs-routing.module"; +import {LogServiceModule} from "../openaireLibrary/utils/log/LogService.module"; + + +@NgModule({ + declarations: [PublicLogsComponent], + imports: [ + CommonModule, PublicLogsRoutingModule, LogServiceModule + + ], +}) +export class PublicLogsModule { }