mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
fix(ui): allow admin to selectively add proxy admin viewers
This commit is contained in:
parent
ce46d11a37
commit
36f378c8e1
19 changed files with 252 additions and 100 deletions
|
@ -468,6 +468,46 @@ export const userGetRequesedtModelsCall = async (accessToken: String) => {
|
|||
}
|
||||
};
|
||||
|
||||
export interface User {
|
||||
user_role: string;
|
||||
user_id: string;
|
||||
user_email: string;
|
||||
[key: string]: string; // Include any other potential keys in the dictionary
|
||||
}
|
||||
|
||||
export const userGetAllUsersCall = async (
|
||||
accessToken: String,
|
||||
role: String
|
||||
) => {
|
||||
try {
|
||||
const url = proxyBaseUrl
|
||||
? `${proxyBaseUrl}/user/get_users?role=${role}`
|
||||
: `/user/get_users?role=${role}`;
|
||||
console.log("in userGetAllUsersCall:", url);
|
||||
const response = await fetch(url, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.text();
|
||||
message.error("Failed to delete key: " + errorData);
|
||||
throw new Error("Network response was not ok");
|
||||
}
|
||||
const data = await response.json();
|
||||
console.log(data);
|
||||
message.success("Got all users");
|
||||
return data;
|
||||
// Handle success - you might want to update some state or UI based on the created key
|
||||
} catch (error) {
|
||||
console.error("Failed to get requested models:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const teamCreateCall = async (
|
||||
accessToken: string,
|
||||
formValues: Record<string, any> // Assuming formValues is an object
|
||||
|
@ -549,3 +589,41 @@ export const teamMemberAddCall = async (
|
|||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const userUpdateUserCall = async (
|
||||
accessToken: string,
|
||||
formValues: any // Assuming formValues is an object
|
||||
) => {
|
||||
try {
|
||||
console.log("Form Values in userUpdateUserCall:", formValues); // Log the form values before making the API call
|
||||
|
||||
const url = proxyBaseUrl ? `${proxyBaseUrl}/user/update` : `/user/update`;
|
||||
const response = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
user_role: "proxy_admin_viewer",
|
||||
...formValues, // Include formValues in the request body
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.text();
|
||||
message.error("Failed to create key: " + errorData);
|
||||
console.error("Error response from the server:", errorData);
|
||||
throw new Error("Network response was not ok");
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log("API Response:", data);
|
||||
message.success("User role updated");
|
||||
return data;
|
||||
// Handle success - you might want to update some state or UI based on the created key
|
||||
} catch (error) {
|
||||
console.error("Failed to create key:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue