ciyidogan commited on
Commit
39138d2
Β·
verified Β·
1 Parent(s): 71774aa

Update static/js/project.js

Browse files
Files changed (1) hide show
  1. static/js/project.js +9 -47
static/js/project.js CHANGED
@@ -26,9 +26,13 @@ function loadProjectDetails() {
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
 
@@ -73,51 +77,9 @@ function removeIntent(name) {
73
  }
74
 
75
  function saveProject() {
76
- const project = document.getElementById('project-select').value;
77
- if (!project) return;
78
-
79
- apiGet(`/project/${project}/latest`)
80
- .then(data => {
81
- const newData = {
82
- intents: data.intents,
83
- llm: data.llm
84
- };
85
- apiPost('/project/update', {
86
- project_name: project,
87
- client_last_updated: data.last_updated,
88
- new_data: newData
89
- })
90
- .then(resp => {
91
- showResult('project-result', resp);
92
- loadProjectDetails();
93
- })
94
- .catch(err => {
95
- console.error(err);
96
- alert('Failed to save project.');
97
- });
98
- })
99
- .catch(err => console.error(err));
100
  }
101
 
102
  function publishProject() {
103
- const project = document.getElementById('project-select').value;
104
- if (!project) return;
105
-
106
- apiGet(`/project/${project}/latest`)
107
- .then(data => {
108
- apiPost('/project/publish', {
109
- project_name: project,
110
- client_last_updated: data.last_updated
111
- })
112
- .then(resp => {
113
- showResult('project-result', resp);
114
- loadProjectDetails();
115
- })
116
- .catch(err => {
117
- console.error(err);
118
- alert('Failed to publish project.');
119
- });
120
- })
121
- .catch(err => console.error(err));
122
  }
123
-
 
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
+ if (Array.isArray(data.intents) && data.intents.length > 0) {
30
+ data.intents.forEach(intent => {
31
+ html += `<li>${intent.name} <button class="btn btn-sm btn-danger ml-2" onclick="removeIntent('${intent.name}')">–</button></li>`;
32
+ });
33
+ } else {
34
+ html += `<li>No intents defined.</li>`;
35
+ }
36
  html += `</ul><button class="btn btn-sm btn-success" onclick="addIntent()">+ Add Intent</button></div>`;
37
  info.innerHTML = html;
38
 
 
77
  }
78
 
79
  function saveProject() {
80
+ alert('Save logic will be implemented here.');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  }
82
 
83
  function publishProject() {
84
+ alert('Publish logic will be implemented here.');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  }