1
0
mirror of https://gitlab.com/bramw/baserow.git synced 2024-11-21 23:37:55 +00:00
bramw_baserow/enterprise/web-frontend/modules/baserow_enterprise/services/auditLog.js
2023-08-25 15:31:05 +00:00

58 lines
1.7 KiB
JavaScript

import baseService from '@baserow/modules/core/crudTable/baseService'
import jobService from '@baserow/modules/core/services/job'
export default (client) => {
return Object.assign(baseService(client, `/audit-log/`), {
fetchUsers(page, search, workspaceId = null) {
const usersUrl = `/audit-log/users/`
const userPaginatedService = baseService(client, usersUrl)
const filters = {}
if (workspaceId) {
filters.workspace_id = workspaceId
}
return userPaginatedService.fetch(usersUrl, page, search, [], filters)
},
fetchWorkspaces(page, search) {
const workspacesUrl = `/audit-log/workspaces/`
const workspacePaginatedService = baseService(client, workspacesUrl)
return workspacePaginatedService.fetch(
workspacesUrl,
page,
search,
[],
{}
)
},
fetchActionTypes(page, search, workspaceId = null) {
const actionTypesUrl = `/audit-log/action-types/`
const actionTypePaginatedService = baseService(client, actionTypesUrl)
const filters = {}
if (workspaceId) {
filters.workspace_id = workspaceId
}
return actionTypePaginatedService.fetch(
actionTypesUrl,
page,
search,
[],
filters
)
},
startExportCsvJob(data) {
return client.post(`/audit-log/export/`, data)
},
getExportJobInfo(jobId) {
return jobService(client).get(jobId)
},
async getLastExportJobs(maxCount = 3) {
const { data } = await jobService(client).fetchAll({
states: ['!failed'],
})
const jobs = data.jobs || []
return jobs
.filter((job) => job.type === 'audit_log_export')
.slice(0, maxCount)
},
})
}