Commit 3716e167 authored by sapn1s's avatar sapn1s
Browse files

tbh idk

parent b6065cab
......@@ -124,9 +124,33 @@ public class GraphController {
@GetMapping(value = "/choose-cal")
public String chooseCalGet()
public String chooseCalGet(Model model)
{
User currUser = findCurrentUser();
//If user doesnt have calendar - redirected to create
try
{
calendarRepo.findAllByUser(currUser);
}
catch(Exception e)
{
return "redirect:/add-new-calendar";
}
ArrayList<Calendar> allUserCalendars = calendarRepo.findAllByUser(currUser);
JsonArray calendarArray = new JsonArray();
for (int i = 0; i < allUserCalendars.size(); i++) {
JsonObject calendarJson = new JsonObject();
calendarJson.addProperty("title", allUserCalendars.get(i).getName());
calendarArray.add(calendarJson);
}
model.addAttribute("calendarList", calendarArray);
return "chooseCal";
}
......
......@@ -21,9 +21,12 @@ var allEvents = JSON.parse(document.getElementById("events").value)
window.onload = function () {
var dataFromEvents = [];
for (i = 0; i < allEvents.length; i++) {
dataFromEvents[i] = { label: allEvents[i].name, y: allEvents[i].eventCount }
dataFromEvents[i] = {
label: allEvents[i].name,
y: allEvents[i].eventCount
}
}
console.log(dataFromEvents);
......@@ -38,12 +41,7 @@ window.onload = function () {
type: "column",
//dataPoints : dataFromEvents;
dataPoints: [
{ label: "apple", y: 3 },
{ label: "orange", y: 15 },
{ label: "banana", y: 25 },
{ label: "mango", y: 30 },
{ label: "grape", y: 28 }]
dataPoints: dataFromEvents
}
]
});
......
This source diff could not be displayed because it is too large. You can view the blob instead.
<!DOCTYPE html>
<html xmlns:th="www.tymeleaf.org" lang="en">
<head>
<meta charset="utf-8">
<title>Choose </title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.1.0/fullcalendar.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.7/semantic.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<div class="container w-50 ">
<br><br><br> <form action="#" th:action="@{/view-calendars}" th:object="${model}" method="post">
<h2 class="form-signin-heading text-center">Your calendars</h2><br>
<div class="form-group">
<label for="chooseCalendarForm">Choose a calendar</label>
<select multiple class="form-control" id="calendarSelection" th:value="${calName}" name="calName">
</select>
</div>
</form>
</div>
<input type="hidden" id="calendars" th:value="${calendarList}"/>
<script>
var x = document.getElementById("calendarSelection");
var allCalendars = JSON.parse(document.getElementById("calendars").value)
for(let i = 0; i < allCalendars.length; i++){
option = document.createElement("option");
option.text = allCalendars[i].title;
x.add(option);
}
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment