refac: usage event handling

This commit is contained in:
Timothy Jaeryang Baek
2025-06-16 10:42:34 +04:00
parent deaa7133a2
commit 423a35782b
12 changed files with 219 additions and 152 deletions

View File

@@ -1271,6 +1271,33 @@ export const updatePipelineValves = async (
return res;
};
export const getUsage = async (token: string = '') => {
let error = null;
const res = await fetch(`${WEBUI_BASE_URL}/api/usage`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
...(token && { Authorization: `Bearer ${token}` })
}
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.error(err);
error = err;
return null;
});
if (error) {
throw error;
}
return res;
};
export const getBackendConfig = async () => {
let error = null;

View File

@@ -348,6 +348,33 @@ export const getAndUpdateUserLocation = async (token: string) => {
}
};
export const getUserActiveStatusById = async (token: string, userId: string) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/users/${userId}/active`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.error(err);
error = err.detail;
return null;
});
if (error) {
throw error;
}
return res;
};
export const deleteUserById = async (token: string, userId: string) => {
let error = null;