Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Zorin95670 committed Sep 30, 2024
1 parent 3651420 commit c6f8252
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/boot/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/components/card/ComponentDefinitionCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion src/components/card/TemplateCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ const templateIcon = ref(null);
* @returns {Promise<void>} 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;
})
Expand Down
5 changes: 4 additions & 1 deletion src/components/dialog/CreateProjectTemplateDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ async function addProject(projectId) {
* @returns {Promise<void>} 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;
})
Expand Down
5 changes: 4 additions & 1 deletion src/components/dialog/ImportModelTemplateDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ let dialogEventSubscription;
* @returns {Promise<void>} 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;
})
Expand Down
2 changes: 2 additions & 0 deletions src/components/drawer/AIChatDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div
data-cy="ai-chat-panel"
class="column full-height full-width"
style="overflow-x: hidden"
>
<div class="row q-px-md justify-between items-center">
<span class="text-overline q-item__label--header">
Expand All @@ -19,6 +20,7 @@
<div
ref="scrollContainer"
class="flex-1 q-pa-sm scroll-y"
style="word-break: break-all;"
>
<div class="flex justify-center q-mb-md">
<q-btn
Expand Down
5 changes: 4 additions & 1 deletion src/components/form/CreateProjectTemplateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ async function onSubmit() {
return addProject
.then(async () => {
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}`
Expand Down
5 changes: 4 additions & 1 deletion src/components/form/ImportModelTemplateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion src/components/grid/TemplateGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion src/components/list/LibraryList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion src/composables/PluginManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/ModelizerDrawLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<q-page-container>
<q-splitter
v-model="splitter"
:limits="[50, 100]"
:limits="[25, 100]"
separator-class="separator-class"
:class="isVisible ? '' : 'splitter-invisible'"
:style="{ height: `calc(100vh - ${reservedHeight + 70}px)` }"
Expand Down Expand Up @@ -134,7 +134,7 @@ function onDrawerEvent({ key, type, id }) {
componentId.value = id || null;
splitterKey.value = key;
isVisible.value = type === 'open';
splitter.value = type === 'open' ? 75 : 100;
splitter.value = type === 'open' ? 60 : 100;
}
onMounted(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/ModelizerTextLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<q-page-container>
<q-splitter
v-model="splitter"
:limits="[50, 100]"
:limits="[30, 100]"
separator-class="separator-class"
:style="{ height: `calc(100vh - ${reservedHeight + 70}px)` }"
>
Expand Down
12 changes: 6 additions & 6 deletions src/services/AIService.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function generateDiagram(plugin, description) {
plugin,
description,
type: 'diagram',
}, options);
}, options).then(({ data }) => data);
}

/**
Expand Down Expand Up @@ -73,7 +73,7 @@ export async function manageConversation(project, diagram, plugin, files) {
plugin,
checksum,
files,
}, options);
}, options).then(({ data }) => data);
}

const aiConversation = content[0];
Expand All @@ -85,7 +85,7 @@ export async function manageConversation(project, diagram, plugin, files) {
plugin,
checksum,
files,
}, options);
}, options).then(({ data }) => data);
}

return aiConversation;
Expand All @@ -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),
}));
Expand Down Expand Up @@ -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,
Expand All @@ -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);
}

0 comments on commit c6f8252

Please sign in to comment.