diff --git a/src/services/dataService.js b/src/services/dataService.js index 08a1f19..5df69df 100644 --- a/src/services/dataService.js +++ b/src/services/dataService.js @@ -35,12 +35,14 @@ export const dataService = { return response.data }, - getAssetsByCharacterId: async (charId, limit, offset) => { - const response = await api.get(`/characters/${charId}/assets`, { params: { limit, offset } }) + getAssetsByCharacterId: async (charId, limit, offset, type) => { + const params = { limit, offset } + if (type && type !== 'all') params.type = type + const response = await api.get(`/characters/${charId}/assets`, { params }) return response.data }, - uploadAsset: async (file, linkedCharId) => { + uploadAsset: async (file, linkedCharId, onProgress) => { const formData = new FormData() formData.append('file', file) if (linkedCharId) formData.append('linked_char_id', linkedCharId) @@ -48,6 +50,12 @@ export const dataService = { const response = await api.post('/assets/upload', formData, { headers: { 'Content-Type': 'multipart/form-data' + }, + onUploadProgress: (progressEvent) => { + if (onProgress && progressEvent.total) { + const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total) + onProgress(percentCompleted) + } } }) return response.data @@ -63,6 +71,28 @@ export const dataService = { return response.data }, + // Environments + getEnvironments: async (characterId) => { + if (!characterId) return [] + const response = await api.get(`/environments/character/${characterId}`) + return response.data + }, + + createEnvironment: async (envData) => { + const response = await api.post('/environments/', envData) + return response.data + }, + + updateEnvironment: async (id, envData) => { + const response = await api.put(`/environments/${id}`, envData) + return response.data + }, + + deleteEnvironment: async (id) => { + const response = await api.delete(`/environments/${id}`) + return response.data + }, + generatePromptFromImage: async (files, prompt) => { const formData = new FormData() diff --git a/src/views/CharacterDetailView.vue b/src/views/CharacterDetailView.vue index 5ea5aff..1abce55 100644 --- a/src/views/CharacterDetailView.vue +++ b/src/views/CharacterDetailView.vue @@ -1,5 +1,5 @@