完善部分平台治理功能,及修改看板缺陷
This commit is contained in:
38
frontend/src/api/modules/gpu.ts
Normal file
38
frontend/src/api/modules/gpu.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { del, get, post } from '../request'
|
||||
|
||||
export interface GpuAssignment {
|
||||
id: string
|
||||
node_id: string
|
||||
gpu_index: number
|
||||
user_id: string
|
||||
assigned_by?: string | null
|
||||
assigned_at?: string
|
||||
username?: string
|
||||
display_name?: string
|
||||
node_code?: string
|
||||
node_name?: string
|
||||
gpu_name?: string
|
||||
}
|
||||
|
||||
export interface MyGpu {
|
||||
node_id: string
|
||||
gpu_index: number
|
||||
node_code: string
|
||||
node_name: string
|
||||
gpu_name?: string
|
||||
uuid?: string
|
||||
memory_total_gb?: number
|
||||
}
|
||||
|
||||
/** 查看全部分配关系(admin) */
|
||||
export const getGpuAssignments = () => get<GpuAssignment[]>('/compute/gpu-assignments')
|
||||
|
||||
/** 批量分配 GPU(admin) */
|
||||
export const assignGpus = (assignments: Array<{ node_id: string; gpu_index: number; user_id: string }>) =>
|
||||
post<GpuAssignment[]>('/compute/gpu-assignments', { assignments })
|
||||
|
||||
/** 撤销 GPU 分配(admin) */
|
||||
export const unassignGpu = (id: string) => del(`/compute/gpu-assignments/${id}`)
|
||||
|
||||
/** 查看当前用户可用的 GPU 列表 */
|
||||
export const getMyGpus = () => get<MyGpu[]>('/compute/my-gpus')
|
||||
@@ -42,3 +42,10 @@ export const resetUserPassword = (id: string, password?: string) =>
|
||||
/** 删除用户(protected 管理员账号不允许删除) */
|
||||
export const deleteUser = (id: string) =>
|
||||
del<{ deleted: string }>(`/users/${encodeURIComponent(id)}`)
|
||||
|
||||
/** 用户自行修改密码 */
|
||||
export const changeMyPassword = (oldPassword: string, newPassword: string) =>
|
||||
post<{ changed: boolean }>('/users/me/password', {
|
||||
old_password: oldPassword,
|
||||
new_password: newPassword,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user