Lashtw commited on
Commit
7a2dde0
·
verified ·
1 Parent(s): 41572bd

Upload 10 files

Browse files
Files changed (1) hide show
  1. src/views/InstructorView.js +33 -28
src/views/InstructorView.js CHANGED
@@ -375,6 +375,37 @@ export async function renderInstructorView() {
375
 
376
  export function setupInstructorEvents() {
377
  console.log("Starting setupInstructorEvents...");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
378
  // Utility for cleaning prompt indentation
379
  // Utility for cleaning prompt indentation
380
  // Utility for cleaning text for display
@@ -1279,34 +1310,8 @@ export function setupInstructorEvents() {
1279
 
1280
 
1281
 
1282
- // --- Instructor Management Logic ---
1283
- async function loadInstructorList() {
1284
- const tbody = document.getElementById('instructor-list-body');
1285
- tbody.innerHTML = '<tr><td colspan="4" class="p-4 text-center">載入中...</td></tr>';
1286
- try {
1287
- const list = await getInstructors();
1288
- tbody.innerHTML = list.map(i => `
1289
- <tr class="border-b border-gray-700 hover:bg-gray-700/50">
1290
- <td class="p-3">${i.name || '-'}</td>
1291
- <td class="p-3 font-mono text-sm text-gray-400">${i.email}</td>
1292
- <td class="p-3">
1293
- <div class="flex flex-wrap gap-1">
1294
- ${(i.permissions || []).map(p => `<span class="text-xs bg-indigo-900 text-indigo-300 px-1 rounded">${p}</span>`).join('')}
1295
- </div>
1296
- </td>
1297
- <td class="p-3">
1298
- ${i.role !== 'admin' ?
1299
- `<button onclick="window.removeInst('${i.email}')" class="text-red-400 hover:text-white px-2 py-1 bg-red-900/30 rounded">移除</button>` :
1300
- '<span class="text-xs text-gray-600">Admin</span>'
1301
- }
1302
- </td>
1303
- </tr>
1304
- `).join('');
1305
- } catch (e) {
1306
- console.error(e);
1307
- tbody.innerHTML = '<tr><td colspan="4" class="p-4 text-center text-red-500">載入失敗</td></tr>';
1308
- }
1309
- }
1310
 
1311
  const btnAddInst = document.getElementById('btn-add-inst');
1312
  if (btnAddInst) {
 
375
 
376
  export function setupInstructorEvents() {
377
  console.log("Starting setupInstructorEvents...");
378
+
379
+ // --- Instructor Management Helper ---
380
+ async function loadInstructorList() {
381
+ const tbody = document.getElementById('instructor-list-body');
382
+ if (!tbody) return;
383
+ tbody.innerHTML = '<tr><td colspan="4" class="p-4 text-center">載入中...</td></tr>';
384
+
385
+ try {
386
+ const list = await getInstructors();
387
+ tbody.innerHTML = list.map(i => `
388
+ <tr class="border-b border-gray-700 hover:bg-gray-700/50">
389
+ <td class="p-3">${i.name || '-'}</td>
390
+ <td class="p-3 font-mono text-sm text-gray-400">${i.email}</td>
391
+ <td class="p-3">
392
+ <div class="flex flex-wrap gap-1">
393
+ ${(i.permissions || []).map(p => `<span class="text-xs bg-indigo-900 text-indigo-300 px-1 rounded">${p}</span>`).join('')}
394
+ </div>
395
+ </td>
396
+ <td class="p-3">
397
+ ${i.role !== 'admin' ?
398
+ `<button onclick="window.removeInst('${i.email}')" class="text-red-400 hover:text-white px-2 py-1 bg-red-900/30 rounded">移除</button>` :
399
+ '<span class="text-xs text-gray-600">Admin</span>'
400
+ }
401
+ </td>
402
+ </tr>
403
+ `).join('');
404
+ } catch (e) {
405
+ console.error(e);
406
+ tbody.innerHTML = '<tr><td colspan="4" class="p-4 text-center text-red-500">載入失敗</td></tr>';
407
+ }
408
+ }
409
  // Utility for cleaning prompt indentation
410
  // Utility for cleaning prompt indentation
411
  // Utility for cleaning text for display
 
1310
 
1311
 
1312
 
1313
+
1314
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1315
 
1316
  const btnAddInst = document.getElementById('btn-add-inst');
1317
  if (btnAddInst) {