Hari-Prasath-M91 commited on
Commit
42ec7d6
·
verified ·
1 Parent(s): f118068

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -8
app.py CHANGED
@@ -60,7 +60,8 @@ app = FastAPI(
60
  def process_task_data():
61
  data = session_state["data"]
62
  for day in data["schedule"]:
63
- for subject in day["subjects"]:
 
64
  for task in subject["tasks"]:
65
  task["task_completed"] = False
66
  task["completion_timestamp"] = None
@@ -1287,13 +1288,25 @@ def task_form():
1287
  <title>Task Scheduler</title>
1288
  <style>
1289
  body { font-family: Arial; padding: 20px; }
1290
- .subject-block, .task-block { border: 1px solid #ccc; padding: 15px; margin-top: 10px; border-radius: 5px; }
1291
  .task-block { margin-left: 20px; }
1292
- input, select { margin: 5px; }
 
 
 
 
 
 
 
 
 
 
 
 
1293
  </style>
1294
  </head>
1295
  <body>
1296
- <h2>Task Scheduler</h2>
1297
  <label>From Date: <input type="date" id="from_date"></label>
1298
  <label>To Date: <input type="date" id="to_date"></label>
1299
  <div id="subjects_container"></div>
@@ -1314,6 +1327,11 @@ def task_form():
1314
  subjectSelect.appendChild(opt);
1315
  });
1316
 
 
 
 
 
 
1317
  const tasksContainer = document.createElement('div');
1318
  tasksContainer.className = 'tasks-container';
1319
 
@@ -1322,7 +1340,8 @@ def task_form():
1322
  addTaskBtn.type = 'button';
1323
  addTaskBtn.onclick = () => addTask(tasksContainer);
1324
 
1325
- subjectBlock.appendChild(document.createTextNode("Subject: "));
 
1326
  subjectBlock.appendChild(subjectSelect);
1327
  subjectBlock.appendChild(addTaskBtn);
1328
  subjectBlock.appendChild(tasksContainer);
@@ -1334,11 +1353,12 @@ def task_form():
1334
  function addTask(container) {
1335
  const taskBlock = document.createElement('div');
1336
  taskBlock.className = 'task-block';
1337
- taskBlock.innerHTML = `
 
1338
  Chapter: <input type="text" class="chapter">
1339
  Description: <input type="text" class="description">
1340
  Time (hrs): <input type="number" class="time" min="1">
1341
- `;
1342
  container.appendChild(taskBlock);
1343
  }
1344
 
@@ -1359,7 +1379,9 @@ def task_form():
1359
  estimated_time: parseInt(task.querySelector('.time').value)
1360
  }));
1361
 
1362
- subjects.push({ subject: subjectName, tasks });
 
 
1363
  });
1364
 
1365
  const data = {
 
60
  def process_task_data():
61
  data = session_state["data"]
62
  for day in data["schedule"]:
63
+ for subject in
64
+ day["subjects"]:
65
  for task in subject["tasks"]:
66
  task["task_completed"] = False
67
  task["completion_timestamp"] = None
 
1288
  <title>Task Scheduler</title>
1289
  <style>
1290
  body { font-family: Arial; padding: 20px; }
1291
+ .subject-block, .task-block { border: 1px solid #ccc; padding: 15px; margin-top: 10px; border-radius: 5px; position: relative; }
1292
  .task-block { margin-left: 20px; }
1293
+ .remove-btn {
1294
+ position: absolute;
1295
+ top: 5px;
1296
+ right: 5px;
1297
+ background: red;
1298
+ color: white;
1299
+ border: none;
1300
+ border-radius: 50%;
1301
+ width: 25px;
1302
+ height: 25px;
1303
+ font-weight: bold;
1304
+ cursor: pointer;
1305
+ }
1306
  </style>
1307
  </head>
1308
  <body>
1309
+ <h2>📅 Task Scheduler</h2>
1310
  <label>From Date: <input type="date" id="from_date"></label>
1311
  <label>To Date: <input type="date" id="to_date"></label>
1312
  <div id="subjects_container"></div>
 
1327
  subjectSelect.appendChild(opt);
1328
  });
1329
 
1330
+ const removeSubjectBtn = document.createElement('button');
1331
+ removeSubjectBtn.className = 'remove-btn';
1332
+ removeSubjectBtn.innerText = '✕';
1333
+ removeSubjectBtn.onclick = () => subjectBlock.remove();
1334
+
1335
  const tasksContainer = document.createElement('div');
1336
  tasksContainer.className = 'tasks-container';
1337
 
 
1340
  addTaskBtn.type = 'button';
1341
  addTaskBtn.onclick = () => addTask(tasksContainer);
1342
 
1343
+ subjectBlock.appendChild(removeSubjectBtn);
1344
+ subjectBlock.appendChild(document.createTextNode(" Subject: "));
1345
  subjectBlock.appendChild(subjectSelect);
1346
  subjectBlock.appendChild(addTaskBtn);
1347
  subjectBlock.appendChild(tasksContainer);
 
1353
  function addTask(container) {
1354
  const taskBlock = document.createElement('div');
1355
  taskBlock.className = 'task-block';
1356
+ taskBlock.innerHTML =
1357
+ <button class="remove-btn" onclick="this.parentElement.remove()">✕</button>
1358
  Chapter: <input type="text" class="chapter">
1359
  Description: <input type="text" class="description">
1360
  Time (hrs): <input type="number" class="time" min="1">
1361
+ ;
1362
  container.appendChild(taskBlock);
1363
  }
1364
 
 
1379
  estimated_time: parseInt(task.querySelector('.time').value)
1380
  }));
1381
 
1382
+ if (tasks.length > 0) {
1383
+ subjects.push({ subject: subjectName, tasks });
1384
+ }
1385
  });
1386
 
1387
  const data = {