audit log handlers mock
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { handlers as auditLogHandlers } from './handlers/audit-log.handlers.js';
|
||||
import { handlers as dataTypeHandlers } from './handlers/data-type/index.js';
|
||||
import { handlers as relationTypeHandlers } from './handlers/relation-type.handlers.js';
|
||||
import { handlers as documentTypeHandlers } from './handlers/document-type/index.js';
|
||||
@@ -37,6 +38,7 @@ import { handlers as scriptHandlers } from './handlers/scripts.handlers.js';
|
||||
|
||||
const handlers = [
|
||||
serverHandlers.serverVersionHandler,
|
||||
...auditLogHandlers,
|
||||
...configHandlers,
|
||||
...cultureHandlers,
|
||||
...dataTypeHandlers,
|
||||
|
||||
@@ -1,3 +1,47 @@
|
||||
import { AuditLogResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { data as userData } from './user/user.data.js';
|
||||
import { data as documentData } from './document.data.js';
|
||||
import { AuditLogResponseModel, AuditTypeModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
|
||||
export const logs: Array<AuditLogResponseModel> = [];
|
||||
const userId = userData[0].id;
|
||||
const userName = userData[0].name;
|
||||
|
||||
const documentId = documentData[0].id;
|
||||
|
||||
export const logs: Array<AuditLogResponseModel> = [
|
||||
{
|
||||
userId: userId,
|
||||
entityId: documentId,
|
||||
entityType: 'Document',
|
||||
timestamp: '2021-09-14T09:32:49.0000000Z',
|
||||
logType: AuditTypeModel.SAVE,
|
||||
comment: undefined,
|
||||
parameters: undefined,
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
entityId: documentId,
|
||||
entityType: 'Document',
|
||||
timestamp: '2022-09-14T11:30:49.0000000Z',
|
||||
logType: AuditTypeModel.SAVE,
|
||||
comment: undefined,
|
||||
parameters: undefined,
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
entityId: documentId,
|
||||
entityType: 'Document',
|
||||
timestamp: '2022-09-15T09:35:49.0000000Z',
|
||||
logType: AuditTypeModel.SAVE,
|
||||
comment: undefined,
|
||||
parameters: undefined,
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
entityId: documentId,
|
||||
entityType: 'Document',
|
||||
timestamp: '2023-01-09T12:00:00.0000000Z',
|
||||
logType: AuditTypeModel.PUBLISH,
|
||||
comment: undefined,
|
||||
parameters: undefined,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { handlers as auditLogHandlers } from './handlers/audit-log.handlers.js';
|
||||
import { handlers as dataTypeHandlers } from './handlers/data-type/index.js';
|
||||
import { handlers as documentTypeHandlers } from './handlers/document-type/index.js';
|
||||
import { handlers as installHandlers } from './handlers/install.handlers.js';
|
||||
@@ -21,6 +22,7 @@ export const handlers = [
|
||||
serverHandlers.serverRunningHandler,
|
||||
serverHandlers.serverVersionHandler,
|
||||
manifestsHandlers.manifestEmptyHandler,
|
||||
...auditLogHandlers,
|
||||
...installHandlers,
|
||||
...upgradeHandlers,
|
||||
...userHandlers,
|
||||
|
||||
@@ -8,12 +8,34 @@ import {
|
||||
|
||||
export const handlers = [
|
||||
rest.get(umbracoPath('/audit-log'), (_req, res, ctx) => {
|
||||
return res(ctx.status(200), ctx.json<PagedAuditLogWithUsernameResponseModel>({ total: 0, items: [] }));
|
||||
PagedAuditLog = {
|
||||
total: logs.length,
|
||||
items: logs,
|
||||
};
|
||||
return res(ctx.status(200), ctx.json<PagedAuditLogWithUsernameResponseModel>(PagedAuditLog));
|
||||
}),
|
||||
rest.get(umbracoPath('/audit-log/:id'), (_req, res, ctx) => {
|
||||
return res(ctx.status(200), ctx.json<PagedAuditLogResponseModel>({ total: 0, items: [] }));
|
||||
const id = _req.params.id as string;
|
||||
if (!id) return;
|
||||
|
||||
const foundLogs = logs.filter((log) => log.entityId === id);
|
||||
PagedAuditLog = {
|
||||
total: foundLogs.length,
|
||||
items: foundLogs,
|
||||
};
|
||||
|
||||
return res(ctx.status(200), ctx.json<PagedAuditLogResponseModel>(PagedAuditLog));
|
||||
}),
|
||||
rest.get(umbracoPath('/audit-log/type/:logType'), (_req, res, ctx) => {
|
||||
return res(ctx.status(200), ctx.json<PagedAuditLogResponseModel>({ total: 0, items: [] }));
|
||||
const logType = _req.params.logType as string;
|
||||
if (!logType) return;
|
||||
|
||||
const foundLogs = logs.filter((log) => log.entityType === logType);
|
||||
PagedAuditLog = {
|
||||
total: foundLogs.length,
|
||||
items: foundLogs,
|
||||
};
|
||||
|
||||
return res(ctx.status(200), ctx.json<PagedAuditLogResponseModel>(PagedAuditLog));
|
||||
}),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user