diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/css/events.css b/css/events.css new file mode 100644 index 0000000..2b7251d --- /dev/null +++ b/css/events.css @@ -0,0 +1,2 @@ +@import url('./header.css'); +@import url('./table.css'); \ No newline at end of file diff --git a/css/header.css b/css/header.css new file mode 100644 index 0000000..f4fd263 --- /dev/null +++ b/css/header.css @@ -0,0 +1,61 @@ +:root { + --new-black: #1f2833; /* Dark blueish black */ + --light-orange: #66ffcc; /* Turquoise */ + --new-white: #eef5db; /* Pale greenish white */ + --light-brown: #9a8c98; /* Dusty lavender */ + --background-color: #e0e0e0; +} + +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body, +html { + background-color: var(--background-color); + height: 100%; + font-family: monospace; +} + +.page-container { + text-align: center; + padding: 1%; + position: relative; +} + +.title-header { + font-family: Georgia, "Times New Roman", Times, serif, Courier, monospace; + font-size: 2.3rem; + font-weight: bold; + color: var(--new-black); +} + +.todo-header { + width: 100%; + background-color: var(--new-black); + color: var(--light-orange); + padding: 2%; +} + +.contents-div { + margin: 20px auto; + font-size: large; + font-weight: bold; + width: 80%; + max-width: 600px; + border-radius: 5px; +} + +.warning-popup { + position: absolute; + top: 50%; + border-radius: 20px; + left: 50%; + transform: translate(-50%, 50%); + background-color: #32e0c4; + font-size: 15px; + font-weight: bold; + border: none; +} diff --git a/styles.css b/css/styles.css similarity index 61% rename from styles.css rename to css/styles.css index e4bbd37..08a0ba1 100644 --- a/styles.css +++ b/css/styles.css @@ -1,37 +1,4 @@ -:root { - --new-black: #1f2833; /* Dark blueish black */ - --light-orange: #66ffcc; /* Turquoise */ - --new-white: #eef5db; /* Pale greenish white */ - --light-brown: #9a8c98; /* Dusty lavender */ - --background-color: #e0e0e0; -} - -* { - margin: 0; - padding: 0; - box-sizing: border-box; -} - -body, -html { - background-color: var(--background-color); - height: 100%; - font-family: monospace; -} - -.page-container { - text-align: center; - padding: 5%; -} - -.csv-input-div { - margin: 20px auto; - font-size: large; - font-weight: bold; - width: 80%; - max-width: 600px; - border-radius: 5px; -} +@import url("./header.css"); .upload-csv-div { background-color: var(--new-black); @@ -41,11 +8,16 @@ html { padding: 10px; } -.title-header { - font-family: Georgia, "Times New Roman", Times, serif, Courier, monospace; - font-size: 2.3rem; +.warning-popup { + position: absolute; + top: 50%; + border-radius: 20px; + left: 50%; + transform: translate(-50%, 50%); + background-color: #32e0c4; + font-size: 15px; font-weight: bold; - color: var(--new-black); + border: none; } .input-file { @@ -70,11 +42,30 @@ html { margin-top: 20px; } +.goto-button { + background-color: var(--new-black); + border-radius: 5px; + border: 2px solid var(--light-orange); + width: 50%; + color: var(--light-orange); + max-width: 200px; + height: 35px; + font-weight: bold; + margin-bottom: 20px; + margin-top: 20px; +} + .submit-csv-button:hover { background-color: var(--new-white); border: 1px solid var(--light-orange); } +.goto-button:hover { + background-color: var(--new-white); + border: 3px solid var(--new-black); + color: var(--new-black); +} + .csv-type-select { width: 80%; max-width: 300px; @@ -88,9 +79,15 @@ html { font-family: Arial, Helvetica, sans-serif; } -.todo-header { - width: 100%; - background-color: var(--new-black); - color: var(--light-orange); - padding: 2%; +.close-btn { + width: 90px; + margin-top: 5px; + background-color: red; + color: #32e0c4; + font-weight: bold; + border: 1px solid red; + border-radius: 20px; + padding: 5px; + text-align: center; + cursor: pointer; } diff --git a/css/table.css b/css/table.css new file mode 100644 index 0000000..54d7830 --- /dev/null +++ b/css/table.css @@ -0,0 +1,28 @@ +/* code pen table */ +table { + border-collapse: collapse; + width: 100%; + } + + td, th { + border: 1px solid #dddddd; + text-align: center; + padding:6px 20px; + } + tr th { + border: 1px solid #dddddd; + text-align: center; + padding:6px 20px; + background-color: #ad1e23; + color:#fff; + } + + tr:hover { + background-color: #dddddd; + cursor: pointer; + } + + .content td, .content th { + border-top: 1px solid transparent; + padding: 2px 10px 2px 15px; + } \ No newline at end of file diff --git a/css/tasks.css b/css/tasks.css new file mode 100644 index 0000000..30175e1 --- /dev/null +++ b/css/tasks.css @@ -0,0 +1,11 @@ +@import url('./header.css'); +@import url('./table.css'); + +.confirm-button{ + width: 100px; + height: 20px; + border-radius: 20px; + background-color: black; + color: azure; + margin-top: 50px; +} \ No newline at end of file diff --git a/events.html b/events.html new file mode 100644 index 0000000..c8f591c --- /dev/null +++ b/events.html @@ -0,0 +1,33 @@ + + + + Event Manager + + + +
+

EVENT MANAGER

+
+
+
EVENTS
+
+
+ + + + + + + + + +
Event IdEvent NameStart dateEnd dateProgressAction
+
+
+
+
+
+
+ + + diff --git a/index.html b/index.html index 6bad33c..748e709 100644 --- a/index.html +++ b/index.html @@ -2,7 +2,7 @@ Event Manager - +
@@ -10,7 +10,7 @@

EVENT MANAGER

UPLOAD CSV
-
+
EVENT MANAGER onclick="submitCsv()" />
+
+ +
+
+
+
- + diff --git a/script.js b/script.js deleted file mode 100644 index bc35f96..0000000 --- a/script.js +++ /dev/null @@ -1,104 +0,0 @@ -class Event { - constructor(eventId, eventName, startDate, endDate) { - this.eventName = eventName; - this.eventId = eventId; - this.startDate = startDate; - this.endDate = endDate; - } -} - -class Task { - constructor(eventId, taskName) { - this.eventId = eventId; - this.taskName = taskName; - } -} - -function submitCsv() { - let csvType = document.getElementById("csv-type-select").value; - let csvFile = document.getElementById("input-file").files[0]; - localStorage.setItem("csvFile", csvFile); - console.log(csvFile); - if (csvFile == "" || csvFile == null) { - alert("Please select a CSV file."); - return; - } else { - if (!csvFile["name"].toLowerCase().endsWith(".csv")) { - alert("Please select a file with a .csv extension."); - document.getElementById("input-file").value = ""; - return; - } - } - - if (csvFile) { - const reader = new FileReader(); - - reader.onload = function (e) { - const contents = e.target.result; - if (csvType == "events") { - if (parseToEvent(contents)) { - alert("Events added successfully"); - } - } else { - if (parseToTask(contents)) { - alert("Tasks added successfully"); - } - } - }; - - reader.readAsText(csvFile); - } -} - -function parseToEvent(contents) { - let eventList = []; - const rows = contents.split("\n"); - const header = rows[0]; - if (validateHeader(header, "events")) { - return false; - } - rows.forEach((row) => { - const columns = row.split(","); - const event = new Event(columns[0], columns[1], columns[2], columns[3]); - eventList.push(event); - }); - console.log(eventList); - localStorage.setItem("events", eventList); - return eventList; -} - -function parseToTask(contents) { - let taskList = []; - const rows = contents.split("\n"); - const header = rows[0]; - if (validateHeader(header, "tasks")) { - return false; - } - rows.forEach((row) => { - const columns = row.split(","); - const event = new Task(columns[0], columns[1]); - taskList.push(event); - }); - console.log(taskList); - localStorage.setItem("tasks", taskList); - return taskList; -} - -function validateHeader(header, type) { - console.log(header); - if (type == "events") { - if (header.trim() == "eventid,eventname,start_date,end_date") { - alert("Correct row"); - } else { - alert("Incorrect event headers"); - return true; - } - } else if (type == "tasks") { - if (header.trim() == "eventid,task_name") { - alert("Correct row"); - } else { - alert("Incorrect task headers"); - return true; - } - } -} diff --git a/scripts/events.js b/scripts/events.js new file mode 100644 index 0000000..e8bd386 --- /dev/null +++ b/scripts/events.js @@ -0,0 +1,69 @@ +const eventJson = localStorage.getItem("events"); +let events=JSON.parse(eventJson); +console.log(events); +let eventsTable = document.getElementById("events-table"); + +events.forEach((element) => { + let eventName = element["eventName"]; + let eventId = element["eventId"]; + let startDate = element["startDate"]; + let endDate = element["endDate"]; + + let eventColumn = createRow(eventId, eventName, startDate, endDate); + + eventsTable.appendChild(eventColumn); + localStorage.setItem('status-event-'+eventId,'Not Started'); +}); + +function createRow(eventId, eventName, startDate, endDate) { + let idRow = document.createElement("td"); + let nameRow = document.createElement("td"); + let startDateRow = document.createElement("td"); + let endDateRow = document.createElement("td"); + let progressRow=document.createElement("td"); + let actionRow=createAction(eventId); + + idRow.textContent = eventId; + nameRow.textContent = eventName; + startDateRow.textContent = startDate; + endDateRow.textContent = endDate; + progressRow.textContent="Not Started"; + + + let eventColumn = document.createElement("tr"); + eventColumn.id = eventId; + + eventColumn.appendChild(idRow); + eventColumn.appendChild(nameRow); + eventColumn.appendChild(startDateRow); + eventColumn.appendChild(endDateRow); + eventColumn.appendChild(progressRow); + eventColumn.appendChild(actionRow); + + return eventColumn; +} + + +function createAction(eventId){ + let actionRow=document.createElement("td"); + let actionAnchor=document.createElement("a"); + actionAnchor.onclick=function(){ + goToTasks(eventId); + } + let actionButton=document.createElement("button"); + + actionButton.textContent="TASK"; + actionAnchor.appendChild(actionButton); + actionRow.appendChild(actionAnchor); + + return actionRow; +} + +function goToTasks(eventId){ + localStorage.setItem("eventId",eventId); + window.location.href="./tasks.html"; +} + +function checkProgress(){ + +} \ No newline at end of file diff --git a/scripts/script.js b/scripts/script.js new file mode 100644 index 0000000..a719834 --- /dev/null +++ b/scripts/script.js @@ -0,0 +1,121 @@ +class Event { + constructor(eventId, eventName, startDate, endDate) { + this.eventName = eventName; + this.eventId = eventId; + this.startDate = startDate; + this.endDate = endDate; + } +} + +class Task { + constructor(eventId, taskName) { + this.eventId = eventId; + this.taskName = taskName; + } +} + +function submitCsv() { + let csvType = document.getElementById("csv-type-select").value; + let csvFile = document.getElementById("input-file").files[0]; + if (csvFile == "" || csvFile == null) { + setWarningPopup("Please select a CSV file."); + return; + } else { + if (!csvFile["name"].toLowerCase().endsWith(".csv")) { + setWarningPopup("Please select a file with a .csv extension."); + document.getElementById("input-file").value = ""; + return; + } + } + + if (csvFile) { + const reader = new FileReader(); + + reader.onload = function (e) { + const contents = e.target.result; + if (csvType == "events") { + if (parseToEvent(contents)) { + setWarningPopup("Events added successfully"); + } + } else { + if (parseToTask(contents)) { + setWarningPopup("Tasks added successfully"); + } + } + }; + + reader.readAsText(csvFile); + } +} + +function parseToEvent(contents) { + let eventList = []; + const rows = contents.split("\n"); + const header = rows.shift(); + + if (validateHeader(header, "events")) { + return false; + } + + rows.forEach((row) => { + if (row.trim() !== "") { + const columns = row.split(","); + const event = new Event(columns[0], columns[1], columns[2], columns[3]); + eventList.push(event); + } + }); + localStorage.setItem("events", JSON.stringify(eventList)); + return eventList; +} + +function parseToTask(contents) { + let taskList = []; + const rows = contents.split("\n"); + const header = rows.shift(); + if (validateHeader(header, "tasks")) { + return false; + } + rows.forEach((row) => { + const columns = row.split(","); + const event = new Task(columns[0], columns[1]); + taskList.push(event); + }); + localStorage.setItem("tasks", JSON.stringify(taskList)); + return taskList; +} + +function validateHeader(header, type) { + if (type == "events") { + if (!(header.trim() == "eventid,eventname,start_date,end_date")) { + setWarningPopup("Incorrect event headers"); + document.getElementById("input-file").value = ""; + return true; + } + } else if (type == "tasks") { + if (!(header.trim() == "eventid,task_name")) { + setWarningPopup("Incorrect task headers"); + document.getElementById("input-file").value = ""; + return true; + } + } +} + +function setWarningPopup(msg) { + document.getElementById("warning-msg").innerText = "MESSAGE\n" + msg; + document.getElementById("warning-popup").style.padding = "20px"; + let closeButton = document.createElement("input"); + closeButton.className = "close-btn"; + closeButton.id = "close"; + closeButton.value = "CLOSE"; + closeButton.addEventListener("click", reverseInvoice); + document.getElementById("warning-popup").appendChild(closeButton); + document.getElementById("warning-popup").style.border = "2px solid black"; + document.getElementById("csv-input-div").style.opacity = "10%"; +} +function reverseInvoice() { + document.getElementById("warning-msg").innerText = ""; + document.getElementById("close").remove(); + document.getElementById("warning-popup").style.border = "none"; + document.getElementById("csv-input-div").style.opacity = "100%"; + document.getElementById("warning-popup").style.padding = "0px"; +} diff --git a/scripts/tasks.js b/scripts/tasks.js new file mode 100644 index 0000000..9a2206a --- /dev/null +++ b/scripts/tasks.js @@ -0,0 +1,88 @@ +document.addEventListener("DOMContentLoaded", function () { + const taskJson = localStorage.getItem("tasks"); + tasks = JSON.parse(taskJson); + tasksTable = document.getElementById("tasks-table"); + requiredEvent = localStorage.getItem("eventId"); + taskCount = 0; + statusArray = []; + + tasks.forEach((element) => { + let taskId = element["eventId"]; + if (taskId == requiredEvent) { + let taskName = element["taskName"]; + let taskColumn = createRow(taskId, taskName); + tasksTable.appendChild(taskColumn); + } + }); + if (localStorage.getItem("task-status-" + requiredEvent) == null) { + localStorage.setItem("task-status-" + requiredEvent, statusArray); + } + updateStatus(); +}); + +function createRow(taskId, taskName) { + let idRow = document.createElement("td"); + let nameRow = document.createElement("td"); + let statusRow = createStatusSelect(); + + idRow.textContent = taskId; + nameRow.textContent = taskName; + + let taskColumn = document.createElement("tr"); + taskColumn.id = taskId; + + taskColumn.appendChild(idRow); + taskColumn.appendChild(nameRow); + taskColumn.appendChild(statusRow); + + return taskColumn; +} + +function createStatusSelect() { + taskCount += 1; + let statusRow = document.createElement("td"); + let statusSelect = document.createElement("select"); + statusSelect.id = "task" + taskCount; + + let notStartedOption = document.createElement("option"); + notStartedOption.textContent = "Not Started"; + notStartedOption.value = "Not Started"; + + let progressOption = document.createElement("option"); + progressOption.textContent = "In Progress"; + progressOption.value = "In Progress"; + + let startedOption = document.createElement("option"); + startedOption.textContent = "Started"; + startedOption.value = "Started"; + + statusSelect.appendChild(notStartedOption); + statusSelect.appendChild(progressOption); + statusSelect.appendChild(startedOption); + + statusRow.appendChild(statusSelect); + statusArray.push("Not Started"); + return statusRow; +} + +function confirmStatus() { + statusList = []; + let statusSelects = tasksTable.querySelectorAll("select"); + statusSelects.forEach((select) => { + let status = select.value; + statusList.push(status); + }); + + let statusListJson = JSON.stringify(statusList); + localStorage.setItem("task-status-" + requiredEvent, statusListJson); +} +function updateStatus() { + let statusListJson = localStorage.getItem("task-status-" + requiredEvent); + let statusList = JSON.parse(statusListJson); + + for (let i = 0; i < statusList.length; i++) { + let taskId = "task" + (i + 1); + let statusSelect = document.getElementById(taskId); + statusSelect.value = statusList[i]; + } +} diff --git a/tasks.html b/tasks.html new file mode 100644 index 0000000..b8c38e2 --- /dev/null +++ b/tasks.html @@ -0,0 +1,31 @@ + + + + Event Manager + + + +
+

EVENT MANAGER

+
+
+
TASKS
+
+
+ + + + + +
Event IdTask Name + Status
+
+ +
+
+
+
+
+ + +