Wired frontend for logs

This commit is contained in:
Vladyslav Matsiiako
2023-01-02 09:57:02 -08:00
parent 4af839040e
commit 03b7d3a5ce
4 changed files with 63 additions and 19 deletions
+33 -8
View File
@@ -5,7 +5,8 @@ interface workspaceProps {
workspaceId: string;
offset: number;
limit: number;
filters: object;
userId: string;
actionNames: string;
}
/**
@@ -14,17 +15,41 @@ interface workspaceProps {
* @param {string} obj.workspaceId - workspace id for which we are trying to get project log
* @param {object} obj.offset - teh starting point of logs that we want to pull
* @param {object} obj.limit - how many logs will we output
* @param {object} obj.filters
* @param {object} obj.userId - optional userId filter - will only query logs for that user
* @param {string} obj.actionNames - optional actionNames filter - will only query logs for those actions
* @returns
*/
const getProjectLogs = async ({ workspaceId, offset, limit, filters }: workspaceProps) => {
const getProjectLogs = async ({ workspaceId, offset, limit, userId, actionNames }: workspaceProps) => {
let payload;
if (userId != "" && actionNames != '') {
payload = {
offset: String(offset),
limit: String(limit),
userId: JSON.stringify(userId),
actionNames: actionNames
}
} else if (userId != "") {
payload = {
offset: String(offset),
limit: String(limit),
userId: JSON.stringify(userId)
}
} else if (actionNames != "") {
payload = {
offset: String(offset),
limit: String(limit),
actionNames: actionNames
}
} else {
payload = {
offset: String(offset),
limit: String(limit)
}
}
return SecurityClient.fetchCall(
'/api/v1/workspace/' + workspaceId + '/logs?' +
new URLSearchParams({
offset: String(offset),
limit: String(limit),
filters: JSON.stringify(filters)
}),
new URLSearchParams(payload),
{
method: 'GET',
headers: {