mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
feat(view_users.tsx): support filtering by sso user id
This commit is contained in:
parent
bacc2671e7
commit
76a82b0e04
3 changed files with 31 additions and 0 deletions
|
@ -951,6 +951,9 @@ async def get_users(
|
||||||
user_ids: Optional[str] = fastapi.Query(
|
user_ids: Optional[str] = fastapi.Query(
|
||||||
default=None, description="Get list of users by user_ids"
|
default=None, description="Get list of users by user_ids"
|
||||||
),
|
),
|
||||||
|
sso_user_ids: Optional[str] = fastapi.Query(
|
||||||
|
default=None, description="Get list of users by sso_user_id"
|
||||||
|
),
|
||||||
user_email: Optional[str] = fastapi.Query(
|
user_email: Optional[str] = fastapi.Query(
|
||||||
default=None, description="Filter users by partial email match"
|
default=None, description="Filter users by partial email match"
|
||||||
),
|
),
|
||||||
|
@ -981,6 +984,8 @@ async def get_users(
|
||||||
- internal_user_viewer
|
- internal_user_viewer
|
||||||
user_ids: Optional[str]
|
user_ids: Optional[str]
|
||||||
Get list of users by user_ids. Comma separated list of user_ids.
|
Get list of users by user_ids. Comma separated list of user_ids.
|
||||||
|
sso_ids: Optional[str]
|
||||||
|
Get list of users by sso_ids. Comma separated list of sso_ids.
|
||||||
user_email: Optional[str]
|
user_email: Optional[str]
|
||||||
Filter users by partial email match
|
Filter users by partial email match
|
||||||
team: Optional[str]
|
team: Optional[str]
|
||||||
|
@ -1028,6 +1033,12 @@ async def get_users(
|
||||||
"has": team # Array contains for string arrays in Prisma
|
"has": team # Array contains for string arrays in Prisma
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sso_user_ids is not None and isinstance(sso_user_ids, str):
|
||||||
|
sso_id_list = [sid.strip() for sid in sso_user_ids.split(",") if sid.strip()]
|
||||||
|
where_conditions["sso_user_id"] = {
|
||||||
|
"in": sso_id_list,
|
||||||
|
}
|
||||||
|
|
||||||
## Filter any none fastapi.Query params - e.g. where_conditions: {'user_email': {'contains': Query(None), 'mode': 'insensitive'}, 'teams': {'has': Query(None)}}
|
## Filter any none fastapi.Query params - e.g. where_conditions: {'user_email': {'contains': Query(None), 'mode': 'insensitive'}, 'teams': {'has': Query(None)}}
|
||||||
where_conditions = {k: v for k, v in where_conditions.items() if v is not None}
|
where_conditions = {k: v for k, v in where_conditions.items() if v is not None}
|
||||||
|
|
||||||
|
|
|
@ -679,6 +679,7 @@ export const userListCall = async (
|
||||||
userEmail: string | null = null,
|
userEmail: string | null = null,
|
||||||
userRole: string | null = null,
|
userRole: string | null = null,
|
||||||
team: string | null = null,
|
team: string | null = null,
|
||||||
|
sso_user_id: string | null = null,
|
||||||
sortBy: string | null = null,
|
sortBy: string | null = null,
|
||||||
sortOrder: 'asc' | 'desc' | null = null,
|
sortOrder: 'asc' | 'desc' | null = null,
|
||||||
) => {
|
) => {
|
||||||
|
@ -716,6 +717,10 @@ export const userListCall = async (
|
||||||
queryParams.append('team', team);
|
queryParams.append('team', team);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sso_user_id) {
|
||||||
|
queryParams.append('sso_user_ids', sso_user_id);
|
||||||
|
}
|
||||||
|
|
||||||
if (sortBy) {
|
if (sortBy) {
|
||||||
queryParams.append('sort_by', sortBy);
|
queryParams.append('sort_by', sortBy);
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,7 @@ interface FilterState {
|
||||||
email: string;
|
email: string;
|
||||||
user_id: string;
|
user_id: string;
|
||||||
user_role: string;
|
user_role: string;
|
||||||
|
sso_user_id: string;
|
||||||
team: string;
|
team: string;
|
||||||
model: string;
|
model: string;
|
||||||
min_spend: number | null;
|
min_spend: number | null;
|
||||||
|
@ -126,6 +127,7 @@ const ViewUserDashboard: React.FC<ViewUserDashboardProps> = ({
|
||||||
email: "",
|
email: "",
|
||||||
user_id: "",
|
user_id: "",
|
||||||
user_role: "",
|
user_role: "",
|
||||||
|
sso_user_id: "",
|
||||||
team: "",
|
team: "",
|
||||||
model: "",
|
model: "",
|
||||||
min_spend: null,
|
min_spend: null,
|
||||||
|
@ -189,6 +191,7 @@ const ViewUserDashboard: React.FC<ViewUserDashboardProps> = ({
|
||||||
filters.email || null,
|
filters.email || null,
|
||||||
filters.user_role || null,
|
filters.user_role || null,
|
||||||
filters.team || null,
|
filters.team || null,
|
||||||
|
filters.sso_user_id || null,
|
||||||
filters.sort_by,
|
filters.sort_by,
|
||||||
filters.sort_order
|
filters.sort_order
|
||||||
);
|
);
|
||||||
|
@ -493,6 +496,7 @@ const ViewUserDashboard: React.FC<ViewUserDashboardProps> = ({
|
||||||
user_id: "",
|
user_id: "",
|
||||||
user_role: "",
|
user_role: "",
|
||||||
team: "",
|
team: "",
|
||||||
|
sso_user_id: "",
|
||||||
model: "",
|
model: "",
|
||||||
min_spend: null,
|
min_spend: null,
|
||||||
max_spend: null,
|
max_spend: null,
|
||||||
|
@ -574,6 +578,17 @@ const ViewUserDashboard: React.FC<ViewUserDashboardProps> = ({
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* SSO ID Search */}
|
||||||
|
<div className="relative w-64">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Filter by SSO ID"
|
||||||
|
className="w-full px-3 py-2 pl-8 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
||||||
|
value={filters.sso_user_id}
|
||||||
|
onChange={(e) => handleFilterChange('sso_user_id', e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue