Files
cloudron-box/dashboard/src/models/EventlogsModel.js
T

37 lines
909 B
JavaScript
Raw Normal View History

2025-01-25 17:09:53 +01:00
import { fetcher } from 'pankow';
2025-03-03 11:22:56 +01:00
import { API_ORIGIN } from '../constants.js';
2025-01-25 17:09:53 +01:00
2025-01-31 21:02:48 +01:00
function create() {
const accessToken = localStorage.token;
2025-01-25 17:09:53 +01:00
return {
async search(actions, search, page, per_page) {
let error, result;
try {
2025-03-03 11:22:56 +01:00
result = await fetcher.get(`${API_ORIGIN}/api/v1/eventlog`, { actions, search, page, per_page, access_token: accessToken });
2025-01-25 17:09:53 +01:00
} catch (e) {
error = e;
}
if (error || result.status !== 200) return [error || result];
return [null, result.body.eventlogs];
},
async get(id) {
let error, result;
try {
2025-03-03 11:22:56 +01:00
result = await fetcher.get(`${API_ORIGIN}/api/v1/eventlog/${id}`, { access_token: accessToken });
2025-01-25 17:09:53 +01:00
} catch (e) {
error = e;
}
if (error || result.status !== 200) return [error || result];
return [null, result.body.event];
},
};
}
export default {
create,
};