This commit is contained in:
Tomas Dvorak
2025-11-11 10:29:30 +01:00
parent d5b4faea61
commit 8762bde4bf
139 changed files with 7240 additions and 2870 deletions
+9 -29
View File
@@ -1,5 +1,4 @@
import axios from 'axios';
import { API_URL } from './api';
import api from './api';
// Use shared API_URL which already resolves to '/api/v1' under current origin
@@ -62,46 +61,32 @@ export const getAllFiles = async (params?: {
sort_by?: string;
sort_order?: string;
}): Promise<FileInfo[]> => {
const response = await axios.get(`${API_URL}/admin/files`, {
params,
withCredentials: true,
});
const response = await api.get(`/admin/files`, { params });
return response.data;
};
export const getUnusedFiles = async (): Promise<FileInfo[]> => {
const response = await axios.get(`${API_URL}/admin/files/unused`, {
withCredentials: true,
});
const response = await api.get(`/admin/files/unused`);
return response.data;
};
export const getDuplicateFiles = async (): Promise<DuplicateFiles> => {
const response = await axios.get(`${API_URL}/admin/files/duplicates`, {
withCredentials: true,
});
const response = await api.get(`/admin/files/duplicates`);
return response.data;
};
export const getStorageUsage = async (): Promise<StorageUsage> => {
const response = await axios.get(`${API_URL}/admin/files/usage`, {
withCredentials: true,
});
const response = await api.get(`/admin/files/usage`);
return response.data;
};
export const getFileUsages = async (fileId: number): Promise<any[]> => {
const response = await axios.get(`${API_URL}/admin/files/${fileId}/usages`, {
withCredentials: true,
});
const response = await api.get(`/admin/files/${fileId}/usages`);
return response.data;
};
export const deleteFile = async (fileId: number, force: boolean = false): Promise<void> => {
await axios.delete(`${API_URL}/admin/files/${fileId}`, {
params: { force },
withCredentials: true,
});
await api.delete(`/admin/files/${fileId}`, { params: { force } });
};
export const scanAndSyncFiles = async (): Promise<{
@@ -113,9 +98,7 @@ export const scanAndSyncFiles = async (): Promise<{
new_files_list?: string[];
orphaned_list?: string[];
}> => {
const response = await axios.post(`${API_URL}/admin/files/scan`, {}, {
withCredentials: true,
});
const response = await api.post(`/admin/files/scan`, {});
return response.data;
};
@@ -131,10 +114,7 @@ export const refreshFileTracking = async (entityType?: string): Promise<{
settings_scanned: number;
};
}> => {
const response = await axios.post(`${API_URL}/admin/files/refresh-tracking`, {}, {
params: entityType ? { entity_type: entityType } : {},
withCredentials: true,
});
const response = await api.post(`/admin/files/refresh-tracking`, {}, { params: entityType ? { entity_type: entityType } : {} });
return response.data;
};