LiamKhoaLe commited on
Commit
17906e0
·
1 Parent(s): 18b46d7

Resolve error with UI demo on proj update (file upload) and proj deletion

Browse files
Files changed (4) hide show
  1. .DS_Store +0 -0
  2. static/auth.js +6 -0
  3. static/projects.js +22 -0
  4. static/script.js +13 -0
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
static/auth.js CHANGED
@@ -24,6 +24,12 @@
24
  // Trigger project loading after successful auth
25
  if (window.__sb_load_projects) {
26
  window.__sb_load_projects();
 
 
 
 
 
 
27
  }
28
  } else {
29
  userInfo.style.display = 'none';
 
24
  // Trigger project loading after successful auth
25
  if (window.__sb_load_projects) {
26
  window.__sb_load_projects();
27
+ // Update upload button after a short delay to ensure projects are loaded
28
+ setTimeout(() => {
29
+ if (window.__sb_update_upload_button) {
30
+ window.__sb_update_upload_button();
31
+ }
32
+ }, 100);
33
  }
34
  } else {
35
  userInfo.style.display = 'none';
static/projects.js CHANGED
@@ -34,6 +34,14 @@
34
  deleteProjectBtn.addEventListener('click', handleDeleteProject);
35
  }
36
 
 
 
 
 
 
 
 
 
37
  async function loadProjects() {
38
  const user = window.__sb_get_user();
39
  if (!user) return;
@@ -52,6 +60,11 @@
52
  // Select first project by default
53
  selectProject(projects[0]);
54
  }
 
 
 
 
 
55
  }
56
  } catch (error) {
57
  console.error('Failed to load projects:', error);
@@ -130,6 +143,15 @@
130
  if (window.__sb_update_page_title) {
131
  window.__sb_update_page_title(`Project: ${project.name}`);
132
  }
 
 
 
 
 
 
 
 
 
133
  }
134
 
135
  function showWelcomeScreen() {
 
34
  deleteProjectBtn.addEventListener('click', handleDeleteProject);
35
  }
36
 
37
+ function handleDeleteProject() {
38
+ if (!currentProject) return;
39
+
40
+ if (confirm(`Are you sure you want to delete "${currentProject.name}"? This will remove all associated files and chat history.`)) {
41
+ deleteProject(currentProject.project_id);
42
+ }
43
+ }
44
+
45
  async function loadProjects() {
46
  const user = window.__sb_get_user();
47
  if (!user) return;
 
60
  // Select first project by default
61
  selectProject(projects[0]);
62
  }
63
+
64
+ // Update upload button after projects are loaded
65
+ if (window.__sb_update_upload_button) {
66
+ window.__sb_update_upload_button();
67
+ }
68
  }
69
  } catch (error) {
70
  console.error('Failed to load projects:', error);
 
143
  if (window.__sb_update_page_title) {
144
  window.__sb_update_page_title(`Project: ${project.name}`);
145
  }
146
+
147
+ // Dispatch custom event to notify other scripts that project has changed
148
+ const event = new CustomEvent('projectChanged', { detail: { project } });
149
+ document.dispatchEvent(event);
150
+
151
+ // Update upload button if the function exists
152
+ if (window.__sb_update_upload_button) {
153
+ window.__sb_update_upload_button();
154
+ }
155
  }
156
 
157
  function showWelcomeScreen() {
static/script.js CHANGED
@@ -29,6 +29,14 @@
29
  setupFileDropZone();
30
  setupEventListeners();
31
  checkUserAuth();
 
 
 
 
 
 
 
 
32
  }
33
 
34
  function setupFileDropZone() {
@@ -422,8 +430,13 @@
422
  enableChat();
423
  }
424
  }
 
 
425
  }
426
 
 
 
 
427
  // Listen for project changes
428
  window.addEventListener('projectChanged', () => {
429
  updateUploadButton();
 
29
  setupFileDropZone();
30
  setupEventListeners();
31
  checkUserAuth();
32
+
33
+ // Listen for project changes
34
+ document.addEventListener('projectChanged', () => {
35
+ updateUploadButton();
36
+ });
37
+
38
+ // Initial button state update
39
+ updateUploadButton();
40
  }
41
 
42
  function setupFileDropZone() {
 
430
  enableChat();
431
  }
432
  }
433
+ // Always update upload button state
434
+ updateUploadButton();
435
  }
436
 
437
+ // Public API
438
+ window.__sb_update_upload_button = updateUploadButton;
439
+
440
  // Listen for project changes
441
  window.addEventListener('projectChanged', () => {
442
  updateUploadButton();