Spaces:
Running
Running
Update static/js/project.js
Browse files- static/js/project.js +58 -66
static/js/project.js
CHANGED
@@ -1,66 +1,58 @@
|
|
1 |
-
function listProjects() {
|
2 |
-
apiGet('/project/list')
|
3 |
-
.then(data => {
|
4 |
-
document.getElementById('
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
.catch(err => console.error(err));
|
14 |
-
}
|
15 |
-
|
16 |
-
function
|
17 |
-
const
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
.
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
}
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
}
|
60 |
-
|
61 |
-
function deleteApi() {
|
62 |
-
const apiName = document.getElementById('delete-api-name').value;
|
63 |
-
apiPost('/project/delete_api', { api_name: apiName })
|
64 |
-
.then(data => showResult('api-result', data))
|
65 |
-
.catch(err => console.error(err));
|
66 |
-
}
|
|
|
1 |
+
function listProjects() {
|
2 |
+
apiGet('/project/list')
|
3 |
+
.then(data => {
|
4 |
+
const select = document.getElementById('project-select');
|
5 |
+
select.innerHTML = '<option value="">-- Select a project --</option>';
|
6 |
+
Object.keys(data).forEach(project => {
|
7 |
+
const option = document.createElement('option');
|
8 |
+
option.value = project;
|
9 |
+
option.text = project;
|
10 |
+
select.appendChild(option);
|
11 |
+
});
|
12 |
+
})
|
13 |
+
.catch(err => console.error(err));
|
14 |
+
}
|
15 |
+
|
16 |
+
function loadProjectDetails() {
|
17 |
+
const project = document.getElementById('project-select').value;
|
18 |
+
if (!project) return;
|
19 |
+
|
20 |
+
apiGet(`/project/${project}/latest`)
|
21 |
+
.then(data => {
|
22 |
+
const details = document.getElementById('project-details');
|
23 |
+
const info = document.getElementById('project-info');
|
24 |
+
details.classList.remove('d-none');
|
25 |
+
|
26 |
+
let html = `<p><strong>Version:</strong> ${data.version_number}</p>`;
|
27 |
+
html += `<p><strong>Published:</strong> ${data.published ? '✅ Yes' : '❌ No'}</p>`;
|
28 |
+
html += `<div><strong>Intents:</strong><ul>`;
|
29 |
+
data.intents.forEach(intent => {
|
30 |
+
html += `<li>${intent.name} <button class="btn btn-sm btn-danger ml-2" onclick="removeIntent('${intent.name}')">–</button></li>`;
|
31 |
+
});
|
32 |
+
html += `</ul><button class="btn btn-sm btn-success" onclick="addIntent()">+ Add Intent</button></div>`;
|
33 |
+
info.innerHTML = html;
|
34 |
+
|
35 |
+
if (data.published) {
|
36 |
+
document.querySelectorAll('#project-info input, #project-info button').forEach(el => {
|
37 |
+
el.disabled = true;
|
38 |
+
});
|
39 |
+
}
|
40 |
+
})
|
41 |
+
.catch(err => console.error(err));
|
42 |
+
}
|
43 |
+
|
44 |
+
function saveProject() {
|
45 |
+
alert('Save logic will be implemented here.');
|
46 |
+
}
|
47 |
+
|
48 |
+
function publishProject() {
|
49 |
+
alert('Publish logic will be implemented here.');
|
50 |
+
}
|
51 |
+
|
52 |
+
function addIntent() {
|
53 |
+
alert('Add Intent logic will be implemented here.');
|
54 |
+
}
|
55 |
+
|
56 |
+
function removeIntent(name) {
|
57 |
+
alert(`Remove Intent '${name}' logic will be implemented here.`);
|
58 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|