Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rm model from code button #2540

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 0 additions & 84 deletions packages/client/hmi-client/src/components/code/tera-code.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,8 @@
/>
<Button outlined label="Save" @click="saveCode()" />
<Button outlined label="Save as new" @click="isCodeNamingModalVisible = true" />
<Button
label="Create model from code"
@click="isModelNamingModalVisible = true"
:loading="isCodeToModelLoading"
/>
</template>
<template v-else>
<Button
label="Create model from code"
@click="isModelNamingModalVisible = true"
:loading="isCodeToModelLoading"
/>
<Button label="Download Zip" />
</template>
</section>
Expand Down Expand Up @@ -96,44 +86,6 @@
<a v-if="repoUrl" :href="repoUrl" target="_blank" rel="noreferrer noopener">{{ repoUrl }}</a>
</div>
<Teleport to="body">
<tera-modal
v-if="isModelNamingModalVisible"
@modal-mask-clicked="isModelDiagramModalVisible = false"
@modal-enter-press="isModelDiagramModalVisible = false"
>
<template #header>
<h4>New model</h4>
</template>
<template #default>
<form @submit.prevent>
<label for="model-name">Enter a unique name for your model</label>
<InputText id="model-name" type="text" v-model="newModelName" />
<label for="model-description">Enter a description (optional)</label>
<Textarea v-model="newModelDescription" />
<div class="form-checkbox">
<Checkbox v-model="willGenerateFromDynamics" binary />
<label>Generate from dynamics</label>
</div>
</form>
</template>
<template #footer>
<Button
label="Create model"
@click="
() => {
isModelNamingModalVisible = false;
extractModel();
}
"
/>
<Button
label="Cancel"
severity="secondary"
outlined
@click="isModelNamingModalVisible = false"
/>
</template>
</tera-modal>
<tera-modal
v-if="isDynamicsModalVisible"
@modal-mask-clicked="isDynamicsModalVisible = false"
Expand Down Expand Up @@ -211,7 +163,6 @@ import 'ace-builds/src-noconflict/mode-python';
import 'ace-builds/src-noconflict/mode-julia';
import 'ace-builds/src-noconflict/mode-r';
import Button from 'primevue/button';
import Checkbox from 'primevue/checkbox';
import {
getCodeFileAsText,
getCodeAsset,
Expand All @@ -221,7 +172,6 @@ import {
getProgrammingLanguage
} from '@/services/code';
import { useToastService } from '@/services/toast';
import { codeToAMR } from '@/services/knowledge';
import type { Code, CodeFile } from '@/types/Types';
import { AssetType, ProgrammingLanguage } from '@/types/Types';
import TeraModal from '@/components/widgets/tera-modal.vue';
Expand Down Expand Up @@ -260,15 +210,9 @@ const editor = ref<VAceEditorInstance['_editor'] | null>(null);
const selectedText = ref('');
const selectionRange = ref<Ace.Range | null>(null);
const progress = ref(0);
const isCodeToModelLoading = ref(false);
const willGenerateFromDynamics = ref(false);
const isModelDiagramModalVisible = ref(false);
const isModelNamingModalVisible = ref(false);
const isCodeNamingModalVisible = ref(false);
const isDynamicsModalVisible = ref(false);
const newCodeName = ref('');
const newModelName = ref('');
const newModelDescription = ref('');
const newDynamicsName = ref('');
const newDynamicsDescription = ref('');
const programmingLanguage = ref<ProgrammingLanguage>(ProgrammingLanguage.Python);
Expand Down Expand Up @@ -428,34 +372,6 @@ async function refreshCodeAsset(codeId: string) {
}
}

async function extractModel() {
await saveCode();
if (codeAsset.value?.id) {
isCodeToModelLoading.value = true;
const extractedModelId = await codeToAMR(
codeAsset.value.id,
newModelName.value,
newModelDescription.value,
willGenerateFromDynamics.value
);
isCodeToModelLoading.value = false;
if (extractedModelId) {
await useProjects().addAsset(
AssetType.Models,
extractedModelId,
useProjects().activeProject.value?.id
);
router.push({
name: RouteName.Project,
params: {
pageType: AssetType.Models,
assetId: extractedModelId
}
});
}
}
}

async function onFileOpen(event) {
const file = event.files[0];
const reader = new FileReader();
Expand Down
Loading