| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| async function getProjects(skip = 0, limit = 100, name_search = null, category = null, status = null, order_by = 'created_at', order = 'desc') { |
| const params = new URLSearchParams(); |
| params.append('skip', skip); |
| params.append('limit', limit); |
| if (name_search) params.append('name_search', name_search); |
| if (category) params.append('category', category); |
| if (status) params.append('status', status); |
| if (order_by) params.append('order_by', order_by); |
| if (order) params.append('order', order); |
|
|
| return await apiGet(`/projects/?${params.toString()}`); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| async function getProject(projectId, include_datasets = false, include_configs = false) { |
| const params = new URLSearchParams(); |
| if (include_datasets) params.append('include_datasets', 'true'); |
| if (include_configs) params.append('include_configs', 'true'); |
|
|
| const queryString = params.toString(); |
| const url = queryString ? `/projects/${projectId}?${queryString}` : `/projects/${projectId}`; |
| return await apiGet(url); |
| } |
|
|
| |
| |
| |
| |
| |
| async function createProject(projectData) { |
| return await apiPost('/projects/', projectData); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| async function updateProject(projectId, projectData) { |
| return await apiPut(`/projects/${projectId}`, projectData); |
| } |
|
|
| |
| |
| |
| |
| |
| async function deleteProject(projectId) { |
| return await apiDelete(`/projects/${projectId}`); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| async function getProjectDatasets(projectId, skip = 0, limit = 100) { |
| const params = new URLSearchParams(); |
| params.append('skip', skip); |
| params.append('limit', limit); |
|
|
| return await apiGet(`/projects/${projectId}/datasets?${params.toString()}`); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| async function addDatasetToProject(projectId, datasetId) { |
| return await apiPost(`/projects/${projectId}/datasets/${datasetId}`); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| async function removeDatasetFromProject(projectId, datasetId) { |
| return await apiDelete(`/projects/${projectId}/datasets/${datasetId}`); |
| } |
|
|
| |
| |
| |
| |
| |
| async function getProjectConfigs(projectId) { |
| return await apiGet(`/projects/${projectId}/configs`); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| async function addConfigToProject(projectId, configId) { |
| return await apiPost(`/projects/${projectId}/configs/${configId}`); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| async function removeConfigFromProject(projectId, configId) { |
| return await apiDelete(`/projects/${projectId}/configs/${configId}`); |
| } |
|
|
| |
| |
| |
| |
| |
| async function getProjectStats(projectId) { |
| return await apiGet(`/projects/${projectId}/stats`); |
| } |
|
|
| |
| |
| |
| |
| |
| async function importProject(formData) { |
| const url = `${API_BASE_URL}/projects/import`; |
|
|
| |
| const headers = {}; |
| const token = getToken(); |
| if (token) { |
| headers['Authorization'] = `Bearer ${token}`; |
| } |
|
|
| const config = { |
| method: 'POST', |
| headers: headers, |
| body: formData |
| }; |
|
|
| try { |
| const response = await fetch(url, config); |
| return await handleResponse(response); |
| } catch (error) { |
| |
| if (error.status === 401) { |
| clearToken(); |
| const currentPath = window.location.pathname; |
| if (currentPath !== '/auth') { |
| const redirectUrl = encodeURIComponent(window.location.href); |
| window.location.href = `/auth?redirect=${redirectUrl}`; |
| } |
| } |
| throw error; |
| } |
| } |
|
|
| |
| |
| |
| |
| |
| async function getProjectAnnotationAnalysis(projectId) { |
| return await apiGet(`/analysis/projects/${projectId}/annotation-stats`); |
| } |
|
|