mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 18:52:56 +00:00
dev day #89
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user