This commit is contained in:
@@ -20,6 +20,7 @@ export type AdminAccount = {
|
||||
lastLoginAt?: string | null;
|
||||
sessions?: AdminSession[];
|
||||
sshKeys?: AdminSshKey[];
|
||||
appPermissions?: string[];
|
||||
};
|
||||
|
||||
export type AdminRoleOption = {
|
||||
@@ -81,8 +82,17 @@ export type LauncherNotice = {
|
||||
};
|
||||
|
||||
export async function loadAdmins() {
|
||||
const response = await apiRequest<AdminAccount[] | { admins?: AdminAccount[] }>('/admins');
|
||||
return Array.isArray(response) ? response : response.admins ?? [];
|
||||
type RawAdminAccount = Omit<AdminAccount, 'appPermissions'> & {
|
||||
appPermissions?: Array<string | { appId: string }>;
|
||||
};
|
||||
const response = await apiRequest<RawAdminAccount[] | { admins?: RawAdminAccount[] }>('/admins');
|
||||
const admins = Array.isArray(response) ? response : response.admins ?? [];
|
||||
return admins.map((admin) => ({
|
||||
...admin,
|
||||
appPermissions: (admin.appPermissions ?? []).map((permission) => (
|
||||
typeof permission === 'string' ? permission : permission.appId
|
||||
))
|
||||
}));
|
||||
}
|
||||
|
||||
export function loadAdminRoles() {
|
||||
@@ -138,6 +148,18 @@ export function deleteAdminSshKey(adminId: string, keyId: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function loadAdminAppPermissions(adminId: string) {
|
||||
const response = await apiRequest<{ appIds?: string[] }>(`/admins/${adminId}/app-permissions`);
|
||||
return response.appIds ?? [];
|
||||
}
|
||||
|
||||
export function updateAdminAppPermissions(adminId: string, appIds: string[]) {
|
||||
return apiRequest<{ appIds?: string[] }>(`/admins/${adminId}/app-permissions`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ appIds })
|
||||
});
|
||||
}
|
||||
|
||||
export async function loadUserSessions() {
|
||||
const response = await apiRequest<{ sessions?: UserSession[] }>('/users/sessions');
|
||||
return (response.sessions ?? []).map((session) => ({
|
||||
|
||||
Reference in New Issue
Block a user