diff --git a/application/main.py b/application/main.py index a792b1a..d81ca46 100644 --- a/application/main.py +++ b/application/main.py @@ -19,6 +19,7 @@ auth = VerifyToken() data = TodoDatabase() printer = ThermalPrinter(data) # printer.print_default() #temp debug +printer.print_qrcode() @@ -28,7 +29,7 @@ class Todo(BaseModel): recurring: bool class TodoList(BaseModel): - date: str #Always current date OLD TEXT: #Either current date in %Y-%m-%d format or "recurring" for a recurring task + date: str #Always selected date OLD TEXT: #Either current date in %Y-%m-%d format or "recurring" for a recurring task todos: list[Todo] diff --git a/application/qrcode.png b/application/qrcode.png new file mode 100644 index 0000000..14c0121 Binary files /dev/null and b/application/qrcode.png differ diff --git a/application/static/scripts.js b/application/static/scripts.js index 4c41e65..98d750b 100644 --- a/application/static/scripts.js +++ b/application/static/scripts.js @@ -254,6 +254,16 @@ function addTask(defaultTimeRange="", defaultTaskText="New Task", editable=true) timeButtonDisplay.innerHTML = defaultTimeRange timePickerWindowButton.appendChild(timeButtonDisplay) + let recButtonDiv = document.createElement("div") + recButtonDiv.className = "recurringButton hover:bg-slate-200 cursor-pointer rounded-md flex flex-row space-x-1 items-center" + secondContainer.appendChild(recButtonDiv) + + let recButtonSpan = document.createElement("span") + recButtonSpan.className = "w-8 h-8 flex space-x-2 space-y-2 items-center justify-center" + recButtonSpan.innerHTML += "" + recButtonDiv.appendChild(recButtonSpan) + + row.appendChild(secondContainer) @@ -566,6 +576,36 @@ function savePrintButtonListener(e) { if (spbt.innerHTML === "Save") { setsavePrintButton(save=false) + + let todo_list = [] + + for (let row of document.getElementsByClassName("task-row")) { + todos_list.push({"time": row.querySelector("#timeButtonDisplay").innerHTML, "task": row.querySelector("#task").innerHTML, "recurring": row.dataset.recurring}) + } + + fetch("/api/todos/write", { + method: "post", + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': "Bearer " + jToken + }, + + //make sure to serialize your JSON body + body: JSON.stringify({ + "date": dayjs(document.getElementById("date-view").innerHTML.slice(4), "MMM D, YYYY").format("YYYY-MM-DD"), + "todos": todo_list + }) + }) + .then( (response) => { + response.json().then(r => { + console.log(r.status) + }) + //do something awesome that makes the world a better place + }); + + + //TODO: send api request to save todos to database } else if (spbt.innerHTML === "Print") { diff --git a/application/thermal_print.py b/application/thermal_print.py index a02be2e..50ea604 100644 --- a/application/thermal_print.py +++ b/application/thermal_print.py @@ -233,6 +233,10 @@ class ThermalPrinter(): def finished_printing(self): self.p.cut() #move paper up enough to tear off (probably a better way, but this works.) + def print_qrcode(self): + self.p.text("\n") + self.p.set(align="center") + self.p.image("application/qrcode.png") # class SyncData(): # def __init__(self):