Merge branch 'feature/audit-logs' of github.com:Budibase/budibase into feature/audit-logs
This commit is contained in:
commit
ae05611d91
|
@ -33,8 +33,8 @@
|
||||||
.tooltip {
|
.tooltip {
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 85%;
|
top: 75%;
|
||||||
left: calc(90% - 8px);
|
left: 120%;
|
||||||
transform: translateX(-100%) translateY(-50%);
|
transform: translateX(-100%) translateY(-50%);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|
|
@ -29,10 +29,10 @@
|
||||||
import { cloneDeep } from "lodash"
|
import { cloneDeep } from "lodash"
|
||||||
|
|
||||||
const schema = {
|
const schema = {
|
||||||
date: { width: "auto" },
|
date: { width: "0.8fr" },
|
||||||
user: { width: "auto" },
|
user: { width: "0.5fr" },
|
||||||
app: { width: "auto" },
|
app: { width: "1.5fr" },
|
||||||
name: { width: "0.8fr" },
|
name: { width: "2fr" },
|
||||||
view: { width: "0.1fr", borderLeft: true, displayName: "" },
|
view: { width: "0.1fr", borderLeft: true, displayName: "" },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
let selectedLog
|
let selectedLog
|
||||||
let sidePanelVisible = false
|
let sidePanelVisible = false
|
||||||
let wideSidePanel = false
|
let wideSidePanel = false
|
||||||
|
let timer
|
||||||
let startDate = new Date()
|
let startDate = new Date()
|
||||||
startDate.setDate(startDate.getDate() - 30)
|
startDate.setDate(startDate.getDate() - 30)
|
||||||
let endDate = new Date()
|
let endDate = new Date()
|
||||||
|
@ -86,8 +86,22 @@
|
||||||
$: userPage = $userPageInfo.page
|
$: userPage = $userPageInfo.page
|
||||||
$: logsPage = $logsPageInfo.page
|
$: logsPage = $logsPageInfo.page
|
||||||
|
|
||||||
$: enrichedList = enrich($users.data || [], selectedUsers)
|
$: enrichedList = enrich($users.data || [], selectedUsers, "_id")
|
||||||
$: sortedList = sort(enrichedList)
|
$: sortedList = sort(enrichedList, "email")
|
||||||
|
|
||||||
|
$: sortedEvents = sort(
|
||||||
|
enrich(parseEventObject($auditLogs.events), selectedEvents, "id"),
|
||||||
|
"id"
|
||||||
|
)
|
||||||
|
// below is not sorting yet
|
||||||
|
$: sortedApps = enrich($apps, selectedApps, "appId")
|
||||||
|
|
||||||
|
const debounce = value => {
|
||||||
|
clearTimeout(timer)
|
||||||
|
timer = setTimeout(() => {
|
||||||
|
logSearchTerm = value
|
||||||
|
}, 400)
|
||||||
|
}
|
||||||
|
|
||||||
const fetchUsers = async (userPage, search) => {
|
const fetchUsers = async (userPage, search) => {
|
||||||
if ($userPageInfo.loading) {
|
if ($userPageInfo.loading) {
|
||||||
|
@ -146,20 +160,20 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const enrich = (list, selected) => {
|
const enrich = (list, selected, key) => {
|
||||||
return list.map(item => {
|
return list.map(item => {
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
selected: selected.find(x => x === item._id) != null,
|
selected: selected.find(x => x === item[key]) != null,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const sort = list => {
|
const sort = (list, key) => {
|
||||||
let sortedList = list.slice()
|
let sortedList = list.slice()
|
||||||
sortedList?.sort((a, b) => {
|
sortedList?.sort((a, b) => {
|
||||||
if (a.selected === b.selected) {
|
if (a.selected === b.selected) {
|
||||||
return a["email"] < b["email"] ? -1 : 1
|
return a[key] < b[key] ? -1 : 1
|
||||||
} else if (a.selected) {
|
} else if (a.selected) {
|
||||||
return -1
|
return -1
|
||||||
} else if (b.selected) {
|
} else if (b.selected) {
|
||||||
|
@ -170,6 +184,16 @@
|
||||||
return sortedList
|
return sortedList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const parseEventObject = obj => {
|
||||||
|
// convert obj which is an object of key value pairs to an array of objects
|
||||||
|
// with the key as the id and the value as the name
|
||||||
|
if (obj) {
|
||||||
|
return Object.entries(obj).map(([id, label]) => {
|
||||||
|
return { id, label }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const viewDetails = detail => {
|
const viewDetails = detail => {
|
||||||
selectedLog = detail
|
selectedLog = detail
|
||||||
sidePanelVisible = true
|
sidePanelVisible = true
|
||||||
|
@ -250,7 +274,7 @@
|
||||||
label="App"
|
label="App"
|
||||||
getOptionValue={app => app.instance._id}
|
getOptionValue={app => app.instance._id}
|
||||||
getOptionLabel={app => app.name}
|
getOptionLabel={app => app.name}
|
||||||
options={$apps}
|
options={sortedApps}
|
||||||
bind:value={selectedApps}
|
bind:value={selectedApps}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -258,9 +282,9 @@
|
||||||
<Multiselect
|
<Multiselect
|
||||||
customPopoverHeight="500px"
|
customPopoverHeight="500px"
|
||||||
autocomplete
|
autocomplete
|
||||||
getOptionValue={event => event[0]}
|
getOptionValue={event => event.id}
|
||||||
getOptionLabel={event => event[1]}
|
getOptionLabel={event => event.label}
|
||||||
options={Object.entries($auditLogs.events)}
|
options={sortedEvents}
|
||||||
placeholder="All events"
|
placeholder="All events"
|
||||||
label="Event"
|
label="Event"
|
||||||
bind:value={selectedEvents}
|
bind:value={selectedEvents}
|
||||||
|
@ -286,7 +310,7 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="freeSearch">
|
<div class="freeSearch">
|
||||||
<Search placeholder="Search" bind:value={logSearchTerm} />
|
<Search placeholder="Search" on:change={e => debounce(e.detail)} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="">
|
<div class="">
|
||||||
|
|
|
@ -35,7 +35,7 @@ const buildOpts = ({
|
||||||
if (appIds.length) {
|
if (appIds.length) {
|
||||||
opts.appIds = appIds
|
opts.appIds = appIds
|
||||||
}
|
}
|
||||||
console.log(opts)
|
|
||||||
return opts
|
return opts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue