Commit aa082b64 authored by s7_spruge_k's avatar s7_spruge_k
Browse files

basic stat info

parent f44d5662
......@@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import com.example.calendar.models.Calendar;
import com.example.calendar.models.Event;
import com.example.calendar.models.StatHelper2;
import com.example.calendar.helpers.StatHelper;
import com.example.calendar.models.User;
import com.example.calendar.repo.CalendarRepo;
......@@ -126,7 +125,7 @@ public class GraphController {
@GetMapping(value = "/choose-cal")
public String chooseCalGet(Model model, StatHelper2 statHelper, String calName)
public String chooseCalGet(Model model, StatHelper statHelper, String calName)
{
User currUser = findCurrentUser();
......@@ -171,21 +170,13 @@ public class GraphController {
}
@PostMapping(value ="/choose-cal")
public String chooseCalPost(Model models, StatHelper2 statHelper, String calName)
public String chooseCalPost(Model models, StatHelper statHelper, String calName)
{
statHelper.setChosenCalendar(calName);
System.out.println(statHelper);
User currUser = findCurrentUser();
currUser.setStats(statHelper);
userRepo.save(currUser);
System.out.println(currUser.getStats());
return "redirect:/stat";
models.addAttribute("statHelper", statHelper);
return "statsTest";
}
}
package com.example.calendar.models;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity
@Table(name = "statTable")
public class StatHelper2 {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID_st")
private int stat_ID;
@Column(name = "Calendar")
private String chosenCalendar;
@Column(name = "analysisType")
private String analysisType;
@Column(name = "graphType")
private String graphType;
@OneToOne
@JoinColumn(name = "currUser")
private User currUser;
public StatHelper2() {}
public StatHelper2(String chosenCalendar, String analysisType, String graphType) {
super();
this.chosenCalendar = chosenCalendar;
this.analysisType = analysisType;
this.graphType = graphType;
}
public String getChosenCalendar() {
return chosenCalendar;
}
public void setChosenCalendar(String chosenCalendar) {
this.chosenCalendar = chosenCalendar;
}
public String getAnalysisType() {
return analysisType;
}
public void setAnalysisType(String analysisType) {
this.analysisType = analysisType;
}
public String getGraphType() {
return graphType;
}
public void setGraphType(String graphType) {
this.graphType = graphType;
}
@Override
public String toString() {
return "StatHelper [chosenCalendar=" + chosenCalendar + ", analysisType=" + analysisType + ", graphType="
+ graphType + "]";
}
}
......@@ -44,8 +44,6 @@ public class User {
@Column(name = "activeCalendar")
private String activeCalendar = "";
@OneToOne(mappedBy = "currUser",cascade = {CascadeType.ALL})
private StatHelper2 stats;
public User() {
......@@ -117,16 +115,7 @@ public class User {
this.activeCalendar = activeCalendar;
}
public StatHelper2 getStats() {
return stats;
}
public void setStats(StatHelper2 stats) {
this.stats = stats;
}
@Override
public String toString() {
......
......@@ -13,7 +13,7 @@
<div class="container w-50 ">
<br><br><br> <form action="#" th:action="@{/choose-cal}" th:object="${statHelper2}" method="post">
<br><br><br> <form action="#" th:action="@{/choose-cal}" th:object="${statHelper}" method="post">
<h2 class="form-signin-heading text-center">Your calendars</h2><br>
<div class="form-group">
......@@ -23,7 +23,7 @@
</div>
<div class="form-group">
</div>
<select th:field="*{analysisType}">
<select th:field="*{statMethod}">
<option
th:each="dropdownValue: ${analysisTypes}"
th:value="${dropdownValue}"
......@@ -33,10 +33,9 @@
<ul>
<li th:each="radioValue: ${graphTypes}">
<input type="radio"
th:field="*{graphType}"
th:field="*{graphMethod}"
th:value="${radioValue}" />
<label
th:for="${#ids.prev('graphType')}"
th:text="${radioValue}"></label>
</li>
</ul>
......
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<Head><title>StatHelper test</title></Head>
<body>
<h1 th:text="${statHelper.getChosenCalendar()}"></h1>
<h1 th:text="${statHelper.getGraphMethod()}"></h1>
<h1 th:text="${statHelper.getStatMethod()}"></h1>
</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