ervu-lkrp-fl/frontend/src/ts/ervu/service/AuditService.ts
2025-01-29 15:36:07 +03:00

43 lines
No EOL
1 KiB
TypeScript

import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http";
import {Router} from "@angular/router";
@Injectable({
providedIn: 'root'
})
export class AuditService {
constructor(private httpClient: HttpClient, private router: Router) {
}
public logActionAudit(eventType: string, fileName?: string): void {
const currentRoute = this.router.url;
const sourceUrl = window.location.href;
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
const data: AuditAction = {
eventType: eventType,
sourceUrl: sourceUrl,
route: currentRoute,
fileName: fileName
};
this.httpClient.post("audit/action", data, {
headers: {
"Client-Time-Zone": timeZone,
}
}).toPromise();
}
}
export interface AuditAction {
eventType: string;
sourceUrl: string;
route: string;
fileName?: string;
}
export class AuditConstants {
public static readonly OPEN_PAGE_EVENT = "Открытие страницы";
}