diff --git a/src/boot/axios.js b/src/boot/axios.js index b1d0e38ee..e718d4f25 100644 --- a/src/boot/axios.js +++ b/src/boot/axios.js @@ -92,7 +92,7 @@ async function prepareApiRequest() { const currentTime = new Date().getTime(); if (!csrfStore.expirationDate || csrfStore.expirationDate < currentTime) { - const csrf = await api.get('/csrf'); + const { data: csrf } = await api.get('/csrf'); csrfStore.headerName = csrf.headerName; csrfStore.token = csrf.token; diff --git a/src/components/card/ComponentDefinitionCard.vue b/src/components/card/ComponentDefinitionCard.vue index 87f864aa3..288444f5e 100644 --- a/src/components/card/ComponentDefinitionCard.vue +++ b/src/components/card/ComponentDefinitionCard.vue @@ -116,7 +116,10 @@ const componentIcon = ref(null); */ async function loadTemplateIcon() { if (props.definition.isTemplate) { - componentIcon.value = await getTemplateIcon(process.env, props.definition); + componentIcon.value = await getTemplateIcon({ + HAS_BACKEND: process.env.HAS_BACKEND, + TEMPLATE_LIBRARY_BASE_URL: process.env.TEMPLATE_LIBRARY_BASE_URL, + }, props.definition); return; } diff --git a/src/components/card/TemplateCard.vue b/src/components/card/TemplateCard.vue index dcccd7488..844c33235 100644 --- a/src/components/card/TemplateCard.vue +++ b/src/components/card/TemplateCard.vue @@ -48,7 +48,10 @@ const templateIcon = ref(null); * @returns {Promise} Promise with nothing on success. */ async function loadTemplateIcon() { - return getTemplateIcon(process.env, props.template) + return getTemplateIcon({ + HAS_BACKEND: process.env.HAS_BACKEND, + TEMPLATE_LIBRARY_BASE_URL: process.env.TEMPLATE_LIBRARY_BASE_URL, + }, props.template) .then((icon) => { templateIcon.value = icon; }) diff --git a/src/components/dialog/CreateProjectTemplateDialog.vue b/src/components/dialog/CreateProjectTemplateDialog.vue index 00249cebd..9ba2ac907 100644 --- a/src/components/dialog/CreateProjectTemplateDialog.vue +++ b/src/components/dialog/CreateProjectTemplateDialog.vue @@ -83,7 +83,10 @@ async function addProject(projectId) { * @returns {Promise} Promise with nothing on success otherwise an error. */ async function loadTemplateSchema(template, index) { - return getTemplateSchema(process.env, template, index) + return getTemplateSchema({ + HAS_BACKEND: process.env.HAS_BACKEND, + TEMPLATE_LIBRARY_BASE_URL: process.env.TEMPLATE_LIBRARY_BASE_URL, + }, template, index) .then((icon) => { schemas.value[index] = icon; }) diff --git a/src/components/dialog/ImportModelTemplateDialog.vue b/src/components/dialog/ImportModelTemplateDialog.vue index 590840f06..ffba80b69 100644 --- a/src/components/dialog/ImportModelTemplateDialog.vue +++ b/src/components/dialog/ImportModelTemplateDialog.vue @@ -75,7 +75,10 @@ let dialogEventSubscription; * @returns {Promise} Promise with nothing on success otherwise an error. */ async function loadTemplateSchema(template) { - return getTemplateSchema(process.env, template, 0) + return getTemplateSchema({ + HAS_BACKEND: process.env.HAS_BACKEND, + TEMPLATE_LIBRARY_BASE_URL: process.env.TEMPLATE_LIBRARY_BASE_URL, + }, template, 0) .then((image) => { schema.value = image; }) diff --git a/src/components/drawer/AIChatDrawer.vue b/src/components/drawer/AIChatDrawer.vue index 90ed75b6d..9a14507b2 100644 --- a/src/components/drawer/AIChatDrawer.vue +++ b/src/components/drawer/AIChatDrawer.vue @@ -2,6 +2,7 @@
@@ -19,6 +20,7 @@
{ - const files = await getTemplateFiles(process.env, props.template); + const files = await getTemplateFiles({ + HAS_BACKEND: process.env.HAS_BACKEND, + TEMPLATE_LIBRARY_BASE_URL: process.env.TEMPLATE_LIBRARY_BASE_URL, + }, props.template); await Promise.allSettled(files.map((file) => { file.path = `${project.id}/${props.template.basePath}/${file.path}` diff --git a/src/components/form/ImportModelTemplateForm.vue b/src/components/form/ImportModelTemplateForm.vue index 5b363661e..a56f66549 100644 --- a/src/components/form/ImportModelTemplateForm.vue +++ b/src/components/form/ImportModelTemplateForm.vue @@ -133,7 +133,10 @@ async function onSubmit() { props.template.plugins[0], `${baseFolder.value}${modelName.value || ''}${props.template.files[0]}`, ); - const files = await getTemplateFiles(process.env, props.template); + const files = await getTemplateFiles({ + HAS_BACKEND: process.env.HAS_BACKEND, + TEMPLATE_LIBRARY_BASE_URL: process.env.TEMPLATE_LIBRARY_BASE_URL, + }, props.template); return Promise.allSettled(files.map((file) => { if (file.path.indexOf('leto-modelizer.config.json') !== -1) { diff --git a/src/components/grid/TemplateGrid.vue b/src/components/grid/TemplateGrid.vue index d4425ce9e..ecb3b95e8 100644 --- a/src/components/grid/TemplateGrid.vue +++ b/src/components/grid/TemplateGrid.vue @@ -135,7 +135,10 @@ async function loadTemplates({ pagination: newPagination }) { loading.value = true; - return getTemplatesByType(process.env, props.type, { + return getTemplatesByType({ + HAS_BACKEND: process.env.HAS_BACKEND, + TEMPLATE_LIBRARY_BASE_URL: process.env.TEMPLATE_LIBRARY_BASE_URL, + }, props.type, { page: page - 1, count: rowsPerPage, name, diff --git a/src/components/list/LibraryList.vue b/src/components/list/LibraryList.vue index 321629d98..044aee8d6 100644 --- a/src/components/list/LibraryList.vue +++ b/src/components/list/LibraryList.vue @@ -153,7 +153,10 @@ async function loadTemplates(page) { currentPage.value = page; const name = definitionFilter.value ? definitionFilter.value.trim() : ''; - return getTemplatesByType(process.env, 'COMPONENT', { + return getTemplatesByType({ + HAS_BACKEND: process.env.HAS_BACKEND, + TEMPLATE_LIBRARY_BASE_URL: process.env.TEMPLATE_LIBRARY_BASE_URL, + }, 'COMPONENT', { plugin: props.plugin.data.name, count: 15, page: currentPage.value, diff --git a/src/composables/PluginManager.js b/src/composables/PluginManager.js index eccca437e..90e914c47 100644 --- a/src/composables/PluginManager.js +++ b/src/composables/PluginManager.js @@ -387,7 +387,10 @@ export async function addNewTemplateComponent( path, templateDefinition, ) { - const templateFiles = await getTemplateFiles(process.env, templateDefinition); + const templateFiles = await getTemplateFiles({ + HAS_BACKEND: process.env.HAS_BACKEND, + TEMPLATE_LIBRARY_BASE_URL: process.env.TEMPLATE_LIBRARY_BASE_URL, + }, templateDefinition); await Promise.allSettled( templateFiles.map((file) => { diff --git a/src/layouts/ModelizerDrawLayout.vue b/src/layouts/ModelizerDrawLayout.vue index 6d9bba6a0..44b710b3f 100644 --- a/src/layouts/ModelizerDrawLayout.vue +++ b/src/layouts/ModelizerDrawLayout.vue @@ -13,7 +13,7 @@ { diff --git a/src/layouts/ModelizerTextLayout.vue b/src/layouts/ModelizerTextLayout.vue index e430d5f86..d1d26c5a9 100644 --- a/src/layouts/ModelizerTextLayout.vue +++ b/src/layouts/ModelizerTextLayout.vue @@ -7,7 +7,7 @@ diff --git a/src/services/AIService.js b/src/services/AIService.js index 3f6604847..043497f7c 100644 --- a/src/services/AIService.js +++ b/src/services/AIService.js @@ -21,7 +21,7 @@ export async function generateDiagram(plugin, description) { plugin, description, type: 'diagram', - }, options); + }, options).then(({ data }) => data); } /** @@ -73,7 +73,7 @@ export async function manageConversation(project, diagram, plugin, files) { plugin, checksum, files, - }, options); + }, options).then(({ data }) => data); } const aiConversation = content[0]; @@ -85,7 +85,7 @@ export async function manageConversation(project, diagram, plugin, files) { plugin, checksum, files, - }, options); + }, options).then(({ data }) => data); } return aiConversation; @@ -102,7 +102,7 @@ export async function sendMessage(conversationId, pluginName, message) { const api = await prepareApiRequest(); return api.post(`/ai/conversations/${conversationId}/messages`, { plugin: pluginName, message }, options) - .then((data) => ({ + .then(({ data }) => ({ ...data, message: uncompress(data.message), })); @@ -156,7 +156,7 @@ export async function retrieveMessages(project, diagram, plugin, date = null) { }); return makeFilterRequest(api, `/ai/conversations/${aiConversation.id}/messages${queryParameters}`) - .then((data) => ({ + .then(({ data }) => ({ ...data, content: data.content.map((c) => ({ ...c, @@ -181,5 +181,5 @@ export async function deleteConversation(project, diagram, plugin) { const api = await prepareApiRequest(); - return api.delete(`/ai/conversations/${content[0].id}`); + return api.delete(`/ai/conversations/${content[0].id}`).then(({ data }) => data); }