playing with the selected date
This commit is contained in:
		| @@ -11,6 +11,8 @@ import org.springframework.context.annotation.Bean; | ||||
| import org.springframework.context.annotation.Configuration; | ||||
| import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; | ||||
|  | ||||
| import de.jottyfan.timetrack.spring.done.DoneModel; | ||||
|  | ||||
| /** | ||||
|  *  | ||||
|  * @author henkej | ||||
| @@ -21,6 +23,11 @@ public class InitialConfiguration { | ||||
| 	@Autowired | ||||
| 	private DataSource dataSource; | ||||
|  | ||||
| 	@Bean | ||||
| 	public DoneModel getDoneModel() { | ||||
| 		return new DoneModel(); | ||||
| 	} | ||||
| 	 | ||||
| 	@Bean | ||||
| 	public DataSourceConnectionProvider connectionProvider() { | ||||
| 		return new DataSourceConnectionProvider(new TransactionAwareDataSourceProxy(dataSource)); | ||||
|   | ||||
| @@ -21,7 +21,7 @@ import org.springframework.security.web.authentication.session.SessionAuthentica | ||||
| @ComponentScan(basePackageClasses = KeycloakSpringBootConfigResolver.class) | ||||
| @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, jsr250Enabled = true) | ||||
| public class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter { | ||||
|  | ||||
| 	 | ||||
| 	@Autowired | ||||
| 	public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { | ||||
| 		KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider(); | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package de.jottyfan.timetrack.spring.done; | ||||
|  | ||||
| import java.time.Duration; | ||||
| import java.time.LocalDate; | ||||
| import java.util.List; | ||||
|  | ||||
| import javax.annotation.security.RolesAllowed; | ||||
| @@ -30,6 +31,9 @@ public class DoneController { | ||||
|  | ||||
| 	@Autowired | ||||
| 	private IDoneService doneService; | ||||
| 	 | ||||
| 	@Autowired | ||||
| 	private DoneModel doneModel; | ||||
|  | ||||
| 	@Autowired | ||||
| 	public DoneController(HttpServletRequest request) { | ||||
| @@ -41,10 +45,12 @@ public class DoneController { | ||||
| 	public String getList(@ModelAttribute DoneModel doneModel, Model model) { | ||||
| 		String username = doneService.getCurrentUser(request); | ||||
| 		Duration maxWorkTime = Duration.ofHours(8); // TODO: to the configuration file | ||||
| 		List<DoneBean> list = doneService.getList(doneModel.getDay(), username); | ||||
| 		LocalDate day = doneModel.getDay(); | ||||
| 		this.doneModel.setDay(day); | ||||
| 		List<DoneBean> list = doneService.getList(day, username); | ||||
| 		model.addAttribute("doneList", list); | ||||
| 		model.addAttribute("doneModel", doneModel); | ||||
| 		model.addAttribute("sum", new SummaryBean(list, doneModel.getDay(), maxWorkTime)); | ||||
| 		model.addAttribute("doneModel", this.doneModel); | ||||
| 		model.addAttribute("sum", new SummaryBean(list, day, maxWorkTime)); | ||||
| 		model.addAttribute("projectList", doneService.getProjects(false)); | ||||
| 		model.addAttribute("moduleList", doneService.getModules(false)); | ||||
| 		model.addAttribute("jobList", doneService.getJobs(false)); | ||||
| @@ -78,9 +84,8 @@ public class DoneController { | ||||
| 	public String doUpsert(Model model, @ModelAttribute DoneBean bean) { | ||||
| 		String username = doneService.getCurrentUser(request); | ||||
| 		Integer amount = doneService.doUpsert(bean, username); | ||||
| 		DoneModel doneModel = new DoneModel(); | ||||
| 		doneModel.setDay(bean.getLocalDate()); | ||||
| 		return amount.equals(1) ? getList(doneModel, model) : toItem(bean.getPk(), model); | ||||
| 		this.doneModel.setDay(bean.getLocalDate()); | ||||
| 		return amount.equals(1) ? getList(this.doneModel, model) : toItem(bean.getPk(), model); | ||||
| 	} | ||||
|  | ||||
| 	@RolesAllowed("timetrack_user") | ||||
| @@ -88,8 +93,7 @@ public class DoneController { | ||||
| 	public String doDelete(@PathVariable Integer id, Model model) { | ||||
| 		DoneBean bean = doneService.getBean(id); | ||||
| 		Integer amount = doneService.doDelete(id); | ||||
| 		DoneModel doneModel = new DoneModel(); | ||||
| 		doneModel.setDay(bean.getLocalDate()); | ||||
| 		return amount.equals(1) ? getList(doneModel, model) : toItem(id, model); | ||||
| 		this.doneModel.setDay(bean.getLocalDate()); | ||||
| 		return amount.equals(1) ? getList(this.doneModel, model) : toItem(id, model); | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user