clone functionality added
This commit is contained in:
@@ -31,6 +31,7 @@ const router = createRouter({
|
||||
children: [
|
||||
{path: '', name: 'ks-git-repos', component: () => import('@/views/pages/KsGitRepos.vue')},
|
||||
{path: 'new', name: 'ks-git-repo-new', component: () => import('@/views/pages/KsNewGitRepoForm.vue')},
|
||||
{path: '/clone', name: 'ks-git-clone-repo', component: () => import('@/views/pages/KsGitCloneRepoForm.vue')},
|
||||
]
|
||||
},
|
||||
]
|
||||
|
||||
175
src/views/pages/KsGitCloneRepoForm.vue
Normal file
175
src/views/pages/KsGitCloneRepoForm.vue
Normal file
@@ -0,0 +1,175 @@
|
||||
<template>
|
||||
<Fluid>
|
||||
<div class="flex mt-6">
|
||||
<div class="card flex flex-col gap-4 w-full">
|
||||
<div>
|
||||
<h2 class="text-3xl font-bold mb-4">Clone Repository</h2>
|
||||
</div>
|
||||
<form @submit.prevent="submitForm" class="p-fluid">
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="repoName">Repo Name</label>
|
||||
<InputText id="repoName" v-model="formData.repoName" placeholder="Enter Repo Name" required class="w-full" />
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="group">Group Name</label>
|
||||
<InputText id="group" v-model="formData.group" placeholder="Enter Group Name" required class="w-full" />
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="source">Source Name</label>
|
||||
<InputText id="source" v-model="formData.source" placeholder="Enter Source base URL" required class="w-full" />
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="branch">Branch</label>
|
||||
<InputText id="branch" v-model="formData.branch" placeholder="Enter Branch" required class="w-full" />
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="commitId">CommitID</label>
|
||||
<InputText id="commitId" type="text" v-model="formData.commitId" required class="w-full" />
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="tokenType">Git Token Type</label>
|
||||
<InputText id="tokenType" type="text" v-model="formData.tokenType" required class="w-full" />
|
||||
</div>
|
||||
<div class="col-12 mb-4">
|
||||
<span class="p-float-label">
|
||||
<label for="repoPath">Repo Path</label>
|
||||
<InputText id="repoPath" v-model="formData.repoPath" required class="w-full" />
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="defaultChunkSize">Default Chunk Size</label>
|
||||
<InputNumber id="defaultChunkSize" v-model="formData.defaultChunkSize" required class="w-full" />
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="minChunkSize">Min Chunk Size</label>
|
||||
<InputNumber id="minChunkSize" v-model="formData.minChunkSize" required class="w-full" />
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="maxNumberOfChunks">Max Number of Chunks</label>
|
||||
<InputNumber id="maxNumberOfChunks" v-model="formData.maxNumberOfChunks" required class="w-full" />
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="minChunkSizeToEmbed">Min Chunk Size to Embed</label>
|
||||
<InputNumber id="minChunkSizeToEmbed" v-model="formData.minChunkSizeToEmbed" required class="w-full" />
|
||||
</div>
|
||||
</div>
|
||||
<Button type="submit" label="Submit" :disabled="isSubmitting" :fluid="false" class="p-button-rounded p-button-lg mt-4" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</Fluid>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useToast } from 'primevue/usetoast';
|
||||
import InputText from 'primevue/inputtext';
|
||||
import InputNumber from 'primevue/inputnumber';
|
||||
import Button from 'primevue/button';
|
||||
|
||||
const toast = useToast();
|
||||
const router = useRouter();
|
||||
const isSubmitting = ref(false);
|
||||
|
||||
const formData = ref({
|
||||
repoName: 'shellExecutionThroughAPI',
|
||||
group: 'automationtester23',
|
||||
source:'https://github.com',
|
||||
branch: 'master',
|
||||
commitId: 'latest',
|
||||
tokenType:'github',
|
||||
repoPath: 'C:\\repos\\olympus_ai\\gitClone',
|
||||
defaultChunkSize: 1988,
|
||||
minChunkSize: 200,
|
||||
maxNumberOfChunks: 1988,
|
||||
minChunkSizeToEmbed: 20
|
||||
});
|
||||
|
||||
const submitForm = async () => {
|
||||
if (isSubmitting.value) return; // Prevent duplicate submissions
|
||||
|
||||
isSubmitting.value = true;
|
||||
|
||||
const formDataToSend = new FormData();
|
||||
formDataToSend.append('repoName', formData.value.repoName);
|
||||
formDataToSend.append('group', formData.value.group);
|
||||
formDataToSend.append('source', formData.value.source);
|
||||
formDataToSend.append('branch', formData.value.branch);
|
||||
formDataToSend.append('commitId', formData.value.commitId);
|
||||
formDataToSend.append('tokenType', formData.value.tokenType);
|
||||
formDataToSend.append('repoPath', formData.value.repoPath);
|
||||
formDataToSend.append('defaultChunkSize', formData.value.defaultChunkSize);
|
||||
formDataToSend.append('minChunkSize', formData.value.minChunkSize);
|
||||
formDataToSend.append('maxNumberOfChunks', formData.value.maxNumberOfChunks);
|
||||
formDataToSend.append('minChunkSizeToEmbed', formData.value.minChunkSizeToEmbed);
|
||||
//console.log(formData);
|
||||
|
||||
const json = formDatatoJson(formDataToSend);
|
||||
console.log(json)
|
||||
|
||||
|
||||
|
||||
try {
|
||||
const response = await axios.post('/fe-api/ks_git_repos/clone', json, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
console.log('Submit successful:', response.data);
|
||||
toast.add({ severity: 'success', summary: 'Success', detail: 'Repository submitted successfully', life: 3000 });
|
||||
|
||||
// Redirect to desktop.vue
|
||||
router.push({ name: 'ks-git-repos' });
|
||||
} catch (error) {
|
||||
console.error('Submit failed:', error);
|
||||
toast.add({ severity: 'error', summary: 'Error', detail: 'Submission failed', life: 3000 });
|
||||
}
|
||||
};
|
||||
|
||||
function formDatatoJson(formData){
|
||||
const jsonObject ={};
|
||||
formData.forEach((value,key) => {
|
||||
jsonObject[key] = value;
|
||||
})
|
||||
return jsonObject;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.card-container {
|
||||
max-width: 800px;
|
||||
margin: 2rem auto;
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
:deep(.p-card) {
|
||||
background: linear-gradient(45deg, #45a049, #4caf50);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
:deep(.p-button:hover) {
|
||||
background: linear-gradient(45deg, #45a049, #4caf50);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
:deep(.p-inputtext:focus) {
|
||||
box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
|
||||
}
|
||||
|
||||
:deep(.p-dropdown:focus) {
|
||||
box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
|
||||
}
|
||||
|
||||
:deep(.p-inputnumber-input:focus) {
|
||||
box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
|
||||
}
|
||||
|
||||
.mt-4 {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,7 @@
|
||||
<template>
|
||||
<div class="card">
|
||||
<Toast/>
|
||||
<ConfirmPopup></ConfirmPopup>
|
||||
<div v-if="loading" class="loading-container">
|
||||
<div class="spinner-container">
|
||||
<ProgressSpinner class="spinner" />
|
||||
@@ -32,6 +34,7 @@
|
||||
</IconField>
|
||||
</div>
|
||||
<Button icon="pi pi-plus" rounded raised @click="newCodeRepoForm()" v-tooltip="'Add New Git Repo'" class="mr-2" />
|
||||
<Button icon="pi pi-bolt" rounded raised @click="cloneRepoForm()" v-tooltip="'Clone New Git Repo'" class="mr-2" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -95,8 +98,12 @@
|
||||
:class="{ 'p-button-danger': slotProps.data.ingestionStatus === 'INGESTED' }"
|
||||
/>
|
||||
|
||||
<Button type="button" icon="pi pi-forward" severity="danger" rounded @click="reIngestWithPullChanges(slotProps.data)" v-tooltip="'Ingest Repo with latest changes from master branch'"/>
|
||||
|
||||
<Button type="button" icon="pi pi-trash" rounded @click="showConfirmDialog(slotProps.data.id)"
|
||||
v-tooltip="'Delete the Records'" />
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<Dialog header="Confirm Deletion" :visible="confirmDialogVisible" modal @hide="resetConfirmDialog"
|
||||
@@ -135,11 +142,13 @@ import Select from 'primevue/select';
|
||||
import Tag from 'primevue/tag';
|
||||
import Tooltip from 'primevue/tooltip';
|
||||
import ProgressSpinner from 'primevue/progressspinner';
|
||||
import { useConfirm } from "primevue/useconfirm";
|
||||
|
||||
const router = useRouter();
|
||||
const codeRepoInfo = ref(null);
|
||||
const loading = ref(true);
|
||||
const toast = useToast();
|
||||
const confirm = useConfirm();
|
||||
|
||||
const confirmDialogVisible = ref(false);
|
||||
const recordToDelete = ref(null);
|
||||
@@ -267,6 +276,11 @@ const newCodeRepoForm = () => {
|
||||
router.push({ name: 'ks-git-repo-new' });
|
||||
};
|
||||
|
||||
const cloneRepoForm = () =>{
|
||||
console.log("clone repo form");
|
||||
router.push({ name: 'ks-git-clone-repo' });
|
||||
}
|
||||
|
||||
function formatDate(dateString) {
|
||||
// Parse the date string using moment
|
||||
return moment(dateString).format('MM/DD/YYYY');
|
||||
@@ -328,6 +342,38 @@ const deleteRecordsFromVectorStore = (id) => {
|
||||
});
|
||||
}
|
||||
|
||||
const reIngestWithPullChanges = (data) =>{
|
||||
console.log("data",data);
|
||||
console.log("reponame",data.repoName);
|
||||
|
||||
confirm.require({
|
||||
target: event.currentTarget,
|
||||
message: 'Are you sure you want to proceed?',
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
rejectProps: {
|
||||
label: 'Cancel',
|
||||
severity: 'secondary',
|
||||
outlined: true
|
||||
},
|
||||
acceptProps: {
|
||||
label: 'Ingest Changes',
|
||||
severity: 'danger',
|
||||
},
|
||||
accept: () => {
|
||||
axios.get('/test/reingest_repo/'+data.repoName)
|
||||
.then(response => {
|
||||
console.log(response.data);
|
||||
toast.add({ severity: 'info', summary: 'Confirmed', detail: 'ReIngestion with latest pull from master started', life: 3000 });
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
toast.add({ severity: 'error', summary: 'Error', detail: 'Error in Reingestion', life: 3000 });
|
||||
})
|
||||
},
|
||||
reject: () => {
|
||||
toast.add({severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000})
|
||||
}
|
||||
})
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user