feat(label): add label page
This commit is contained in:
66
components/label/api/sync/index.ts
Normal file
66
components/label/api/sync/index.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import httpFetch from "@/api/fetch"
|
||||
import { BASE_LABEL_API } from "../const"
|
||||
import { Params, Response } from "./typing"
|
||||
|
||||
// 获取同步服务列表
|
||||
export const getDataSyncServerList = (params: Params.ServerRequest) => {
|
||||
return httpFetch<Response.SyncServerRes>({
|
||||
url: BASE_LABEL_API + "/api/v1/label_server/data_sync/list",
|
||||
method: "GET",
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
// 更新同步服务所在地
|
||||
export const updateSyncServerLocation = (location: string, id: number) => {
|
||||
return httpFetch({
|
||||
url: BASE_LABEL_API + `/api/v1/label_server/data_sync/update/${id}`,
|
||||
method: "PUT",
|
||||
body: JSON.stringify({ location }),
|
||||
})
|
||||
}
|
||||
|
||||
// 获取所有同步服务
|
||||
export const getAllSyncServerList = () => {
|
||||
return httpFetch<
|
||||
{
|
||||
id: number
|
||||
ip: string
|
||||
is_online: 0 | 1
|
||||
}[]
|
||||
>({
|
||||
url: BASE_LABEL_API + "/api/v1/label_server/data_sync/all",
|
||||
method: "GET",
|
||||
})
|
||||
}
|
||||
|
||||
// 获取同步任务列表
|
||||
export const getDataSyncTaskList = (params: Params.TaskRequest) => {
|
||||
return httpFetch<Response.SyncTaskRes>({
|
||||
url: BASE_LABEL_API + "/api/v1/label_server/data_sync/sync_task_list",
|
||||
method: "GET",
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
// 新增同步任务
|
||||
export const newSyncTask = (data: {
|
||||
project_id: number
|
||||
sync_server_id: number
|
||||
}) => {
|
||||
return httpFetch<any>({
|
||||
url: BASE_LABEL_API + "/api/v1/label_server/data_sync/add_sync_task",
|
||||
method: "POST",
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
}
|
||||
|
||||
// 更新同步任务状态
|
||||
export const updateSyncTaskStatus = (id: number, status: number) => {
|
||||
return httpFetch({
|
||||
url:
|
||||
BASE_LABEL_API + `/api/v1/label_server/data_sync/update_sync_task/${id}`,
|
||||
method: "PUT",
|
||||
body: JSON.stringify({ status }),
|
||||
})
|
||||
}
|
||||
64
components/label/api/sync/typing.ts
Normal file
64
components/label/api/sync/typing.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
export interface TimeFilter {
|
||||
start_date: string
|
||||
end_date: string
|
||||
}
|
||||
|
||||
export namespace Params {
|
||||
export interface ServerRequest {
|
||||
is_online?: boolean
|
||||
location?: string
|
||||
page_number: number
|
||||
page_size: number
|
||||
[property: string]: any
|
||||
}
|
||||
|
||||
export interface TaskRequest {
|
||||
location?: string
|
||||
page_number: number
|
||||
page_size: number
|
||||
project_id?: number
|
||||
status?: number
|
||||
sync_server_id?: number
|
||||
[property: string]: any
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Response {
|
||||
export interface SyncServerRes {
|
||||
sync_servers: SyncServer[]
|
||||
total_items: number
|
||||
total_pages: number
|
||||
[property: string]: any
|
||||
}
|
||||
|
||||
export interface SyncServer {
|
||||
create_at?: string
|
||||
id?: number
|
||||
ip?: string
|
||||
is_online?: boolean
|
||||
location?: string
|
||||
update_at?: string
|
||||
[property: string]: any
|
||||
}
|
||||
|
||||
export interface SyncTaskRes {
|
||||
sync_tasks: SyncTask[]
|
||||
total_items: number
|
||||
total_pages: number
|
||||
[property: string]: any
|
||||
}
|
||||
|
||||
export interface SyncTask {
|
||||
create_at?: string
|
||||
id?: number
|
||||
ip?: string
|
||||
location?: string
|
||||
project_id?: number
|
||||
project_name?: string
|
||||
status?: number
|
||||
sync_server_id?: number
|
||||
update_at?: string
|
||||
uuid?: string
|
||||
[property: string]: any
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user