flare / static /js /project.js
ciyidogan's picture
Upload 6 files
dbc8392 verified
raw
history blame
3.27 kB
function listProjects() {
apiGet('/project/list')
.then(data => {
document.getElementById('projects-json').value = JSON.stringify(data, null, 2);
})
.catch(err => console.error(err));
}
function addProject() {
const projectName = document.getElementById('new-project-name').value;
apiPost('/project/add', { project_name: projectName })
.then(data => showResult('project-result', data))
.catch(err => console.error(err));
}
function updateProject() {
const projectName = document.getElementById('update-project-name').value;
const clientLastUpdated = document.getElementById('update-last-updated').value;
apiPost('/project/update', { project_name: projectName, client_last_updated: clientLastUpdated })
.then(data => showResult('project-result', data))
.catch(err => console.error(err));
}
function publishProject() {
const projectName = document.getElementById('publish-project-name').value;
const clientLastUpdated = document.getElementById('publish-last-updated').value;
apiPost('/project/publish', { project_name: projectName, client_last_updated: clientLastUpdated })
.then(data => showResult('project-result', data))
.catch(err => console.error(err));
}
function addIntent() {
const projectName = document.getElementById('intent-project-name').value;
const versionNumber = parseInt(document.getElementById('intent-version-number').value);
const intentName = document.getElementById('intent-name').value;
const clientLastUpdated = document.getElementById('intent-last-updated').value;
const intent = { name: intentName, examples: [], parameters: [], action: '', humanization_prompt: '' };
apiPost('/project/add_intent', { project_name: projectName, version_number: versionNumber, intent, client_last_updated: clientLastUpdated })
.then(data => showResult('intent-result', data))
.catch(err => console.error(err));
}
function deleteIntent() {
const projectName = document.getElementById('delete-intent-project-name').value;
const versionNumber = parseInt(document.getElementById('delete-intent-version-number').value);
const intentName = document.getElementById('delete-intent-name').value;
const clientLastUpdated = document.getElementById('delete-intent-last-updated').value;
apiPost('/project/delete_intent', { project_name: projectName, version_number: versionNumber, intent_name: intentName, client_last_updated: clientLastUpdated })
.then(data => showResult('intent-result', data))
.catch(err => console.error(err));
}
function addApi() {
const apiName = document.getElementById('api-name').value;
const apiDef = JSON.parse(document.getElementById('api-def').value);
apiPost('/project/add_api', { api_name: apiName, api_def: apiDef })
.then(data => showResult('api-result', data))
.catch(err => console.error(err));
}
function deleteApi() {
const apiName = document.getElementById('delete-api-name').value;
apiPost('/project/delete_api', { api_name: apiName })
.then(data => showResult('api-result', data))
.catch(err => console.error(err));
}