Automatic code tidying

This commit is contained in:
neviyn 2021-03-31 22:42:20 +01:00
parent 50741a8953
commit 9357299fcd
10 changed files with 76 additions and 57 deletions

View File

@ -30,7 +30,7 @@ open class User(
) )
var projects: MutableSet<Project> = mutableSetOf(), var projects: MutableSet<Project> = mutableSetOf(),
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null
) {} )
@Entity @Entity
class Project( class Project(

View File

@ -8,7 +8,7 @@ interface UserRepository : CrudRepository<User, Long>{
fun findByIdNotIn(ids: List<Long>): List<User> fun findByIdNotIn(ids: List<Long>): List<User>
} }
interface ProjectRepository : CrudRepository<Project, Long>{} interface ProjectRepository : CrudRepository<Project, Long>
interface EventRepository : CrudRepository<Event, Long> { interface EventRepository : CrudRepository<Event, Long> {
fun findByStartAfterAndProject(start: Instant, project: Project): Set<Event> fun findByStartAfterAndProject(start: Instant, project: Project): Set<Event>
@ -16,6 +16,6 @@ interface EventRepository : CrudRepository<Event, Long>{
fun findByStartAfterAndEndBeforeAndProjectIs(start: Instant, end: Instant, project: Project): Set<Event> fun findByStartAfterAndEndBeforeAndProjectIs(start: Instant, end: Instant, project: Project): Set<Event>
} }
interface TagRepository : CrudRepository<Tag, Long>{} interface TagRepository : CrudRepository<Tag, Long>
interface CommentRepository : CrudRepository<Comment, Long>{} interface CommentRepository : CrudRepository<Comment, Long>

View File

@ -64,7 +64,7 @@ class UserDetailsServiceImpl @Autowired constructor(val userRepository: UserRepo
@Configuration @Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true) @EnableGlobalMethodSecurity(prePostEnabled = true)
class MethodSecurityConfig @Autowired constructor(val userRepository: UserRepository, val customPermissionEvaluator: CustomPermissionEvaluator) : GlobalMethodSecurityConfiguration() { class MethodSecurityConfig @Autowired constructor(val customPermissionEvaluator: CustomPermissionEvaluator) : GlobalMethodSecurityConfiguration() {
override fun createExpressionHandler(): MethodSecurityExpressionHandler { override fun createExpressionHandler(): MethodSecurityExpressionHandler {
val expressionHandler = DefaultMethodSecurityExpressionHandler() val expressionHandler = DefaultMethodSecurityExpressionHandler()

View File

@ -5,33 +5,38 @@
<title th:replace="${title}">Base Title</title> <title th:replace="${title}">Base Title</title>
<!-- Common styles and scripts --> <!-- Common styles and scripts -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous"> <link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" rel="stylesheet">
<link rel="shortcut icon" th:href="@{/images/favicon.ico}"> <link rel="shortcut icon" th:href="@{/images/favicon.ico}">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script> <script crossorigin="anonymous"
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.4.0/font/bootstrap-icons.css"> integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf"
src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.4.0/font/bootstrap-icons.css" rel="stylesheet">
</head> </head>
<body> <body>
<div th:fragment="navbar"> <div th:fragment="navbar">
<form id="logoutForm" method="POST" th:action="@{/logout}"> <form id="logoutForm" method="POST" th:action="@{/logout}">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/> <input name="${_csrf.parameterName}" type="hidden" value="${_csrf.token}"/>
</form> </form>
<nav class="navbar navbar-expand-lg navbar-light bg-light"> <nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" href="/"> <a class="navbar-brand" href="/">
<i class="bi bi-calendar3 me-1"></i>Project Planner <i class="bi bi-calendar3 me-1"></i>Project Planner
</a> </a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation"> <button aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation" class="navbar-toggler"
data-bs-target="#navbarNavAltMarkup" data-bs-toggle="collapse" type="button">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup"> <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav"> <div class="navbar-nav">
<a class="nav-link" aria-current="page" href="/projects">Projects</a> <a aria-current="page" class="nav-link" href="/projects">Projects</a>
<a class="nav-link" href="/profile">Profile</a> <a class="nav-link" href="/profile">Profile</a>
</div> </div>
</div> </div>
<div class="navbar-nav navbar-right"> <div class="navbar-nav navbar-right">
<a class="nav-link" onclick="document.forms['logoutForm'].submit()" style="cursor: pointer"><i class="bi bi-box-arrow-right me-1"></i>Logout</a> <a class="nav-link" onclick="document.forms['logoutForm'].submit()" style="cursor: pointer"><i
class="bi bi-box-arrow-right me-1"></i>Logout</a>
</div> </div>
</div> </div>
</nav> </nav>

View File

@ -7,7 +7,7 @@
<div class="container-fluid"> <div class="container-fluid">
<div class="row justify-content-center mt-3"> <div class="row justify-content-center mt-3">
<div class="col text-center"> <div class="col text-center">
<img th:src="@{/landing_1.jpg}" class="w-25 rounded-3" alt="landing page" src=""/> <img alt="landing page" class="w-25 rounded-3" src="" th:src="@{/landing_1.jpg}"/>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@ -24,8 +24,8 @@
</div> </div>
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col text-center"> <div class="col text-center">
<a href="/login" class="btn btn-primary btn-lg" role="button">Login</a> <a class="btn btn-primary btn-lg" href="/login" role="button">Login</a>
<a href="/register" class="btn btn-secondary btn-lg" role="button">Register</a> <a class="btn btn-secondary btn-lg" href="/register" role="button">Register</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -19,16 +19,16 @@
<div class="form-group mt-3"> <div class="form-group mt-3">
<span th:text="${message}"></span> <span th:text="${message}"></span>
<div class="form-floating mb-3"> <div class="form-floating mb-3">
<input type="text" class="form-control form-control-lg" id="username" name="username" autofocus> <input autofocus class="form-control form-control-lg" id="username" name="username" type="text">
<label for="username">Username</label> <label for="username">Username</label>
</div> </div>
<div class="form-floating mb-3"> <div class="form-floating mb-3">
<input type="password" class="form-control form-control-lg" id="password" name="password"> <input class="form-control form-control-lg" id="password" name="password" type="password">
<label for="password">Password</label> <label for="password">Password</label>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<span class="has-error text-danger" th:text="${error}"></span> <span class="has-error text-danger" th:text="${error}"></span>
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/> <input name="${_csrf.parameterName}" type="hidden" value="${_csrf.token}"/>
<div> <div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Log In</button> <button class="btn btn-lg btn-primary btn-block" type="submit">Log In</button>

View File

@ -12,10 +12,10 @@
</div> </div>
</div> </div>
<form th:action="@{/profile}" th:object="${userData}" method="post"> <form method="post" th:action="@{/profile}" th:object="${userData}">
<div class="row justify-content-center mb-3"> <div class="row justify-content-center mb-3">
<div class="col-8"> <div class="col-8">
<input type="hidden" th:field="*{id}"/> <input th:field="*{id}" type="hidden"/>
<div class="input-group mb-3"> <div class="input-group mb-3">
<span class="input-group-text">Username</span> <span class="input-group-text">Username</span>
<input aria-label="Username" class="form-control" readonly th:field="*{username}" type="text"> <input aria-label="Username" class="form-control" readonly th:field="*{username}" type="text">
@ -31,14 +31,14 @@
<p>Please enter your existing password to update your profile.</p> <p>Please enter your existing password to update your profile.</p>
<div class="input-group mb-3"> <div class="input-group mb-3">
<span class="input-group-text">Existing Password</span> <span class="input-group-text">Existing Password</span>
<input aria-label="Existing Password" type="password" class="form-control form-control-lg" <input aria-label="Existing Password" class="form-control form-control-lg" th:field="*{oldPassword}"
th:field="*{oldPassword}"> type="password">
</div> </div>
</div> </div>
</div> </div>
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-2 d-grid"> <div class="col-2 d-grid">
<button type="submit" class="btn btn-primary btn-lg">Update</button> <button class="btn btn-primary btn-lg" type="submit">Update</button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -7,8 +7,8 @@
<link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/fullcalendar@5.6.0/main.min.css" rel="stylesheet"> <link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/fullcalendar@5.6.0/main.min.css" rel="stylesheet">
<script crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/fullcalendar@5.6.0/main.min.js"></script> <script crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/fullcalendar@5.6.0/main.min.js"></script>
<script crossorigin="anonymous" src="https://cdnjs.cloudflare.com/ajax/libs/list.js/2.3.1/list.min.js"></script> <script crossorigin="anonymous" src="https://cdnjs.cloudflare.com/ajax/libs/list.js/2.3.1/list.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css" crossorigin="anonymous"> <link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/flatpickr" crossorigin="anonymous"></script> <script crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script th:inline="javascript"> <script th:inline="javascript">
let calendar; let calendar;
let addModal; let addModal;
@ -93,6 +93,7 @@
}; };
new List('user-list', options); new List('user-list', options);
}; };
function addEvent() { function addEvent() {
let myEvent = { let myEvent = {
title: document.getElementById('titleInput').value, title: document.getElementById('titleInput').value,
@ -102,6 +103,7 @@
} }
calendar.addEvent(myEvent) calendar.addEvent(myEvent)
} }
function editEvent() { function editEvent() {
let myEvent = calendar.getEventById(document.getElementById('idEdit').value) let myEvent = calendar.getEventById(document.getElementById('idEdit').value)
let title = document.getElementById('titleEdit').value let title = document.getElementById('titleEdit').value
@ -184,7 +186,7 @@
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Close</button> <button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Close</button>
<button class="btn btn-primary" type="button" onclick="addEvent();addModal.hide()">Add Event</button> <button class="btn btn-primary" onclick="addEvent();addModal.hide()" type="button">Add Event</button>
</div> </div>
</div> </div>
</div> </div>
@ -217,10 +219,15 @@
</div> </div>
</div> </div>
<div class="modal-footer justify-content-between"> <div class="modal-footer justify-content-between">
<button type="button" class="btn btn-danger" onclick="calendar.getEventById(document.getElementById('idEdit').value).remove();editModal.hide()">Delete Event</button> <button class="btn btn-danger"
onclick="calendar.getEventById(document.getElementById('idEdit').value).remove();editModal.hide()"
type="button">
Delete Event
</button>
<div> <div>
<button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Close</button> <button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Close</button>
<button class="btn btn-primary" type="button" onclick="editEvent();editModal.hide()">Save Changes</button> <button class="btn btn-primary" onclick="editEvent();editModal.hide()" type="button">Save Changes
</button>
</div> </div>
</div> </div>
</div> </div>
@ -240,7 +247,8 @@
<input class="search form-control w-100" placeholder="Search" type="search"/> <input class="search form-control w-100" placeholder="Search" type="search"/>
</label> </label>
<div class="list list-group"> <div class="list list-group">
<form class="list-group-item list-group-item-action" method="post" th:action="@{/project/{pid}/adduser(pid=${id})}" <form class="list-group-item list-group-item-action" method="post"
th:action="@{/project/{pid}/adduser(pid=${id})}"
th:each="member : ${nonMembers}"> th:each="member : ${nonMembers}">
<input name="uid" th:value="${member.id}" type="hidden"/> <input name="uid" th:value="${member.id}" type="hidden"/>
<button class="btn btn-block h-100 w-100 username" th:text="${member.username}" <button class="btn btn-block h-100 w-100 username" th:text="${member.username}"

View File

@ -17,7 +17,8 @@
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-xl-6 col-md-8 col-sm-12"> <div class="col-xl-6 col-md-8 col-sm-12">
<div class="list-group"> <div class="list-group">
<a th:each="project : ${projects}" class="list-group-item list-group-item-action" th:href="@{~/project/{id}(id=${project.id})}" <a class="list-group-item list-group-item-action" th:each="project : ${projects}"
th:href="@{~/project/{id}(id=${project.id})}"
th:text="${project.title}">Title th:text="${project.title}">Title
</a> </a>
</div> </div>
@ -42,14 +43,15 @@
<button aria-label="Close" class="btn-close" data-bs-dismiss="modal" type="button"></button> <button aria-label="Close" class="btn-close" data-bs-dismiss="modal" type="button"></button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form id="newProjectForm" class="form-floating mb-3" th:action="@{/newproject}" th:object="${newProject}" method="post"> <form class="form-floating mb-3" id="newProjectForm" method="post"
<input class="form-control" id="titleInput" type="text" th:field="*{title}" required> th:action="@{/newproject}" th:object="${newProject}">
<input class="form-control" id="titleInput" required th:field="*{title}" type="text">
<label for="titleInput">Project Title</label> <label for="titleInput">Project Title</label>
</form> </form>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Close</button> <button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Close</button>
<button class="btn btn-primary" type="submit" form="newProjectForm">Create Project</button> <button class="btn btn-primary" form="newProjectForm" type="submit">Create Project</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -12,29 +12,33 @@
</div> </div>
<div class="row justify-content-center mt-3"> <div class="row justify-content-center mt-3">
<div class="col-6 text-center"> <div class="col-6 text-center">
<form th:action="@{/register}" th:object="${user_details}" method="post" class="needs-validation" novalidate> <form class="needs-validation" method="post" novalidate th:action="@{/register}"
th:object="${user_details}">
<div class="mb-3"> <div class="mb-3">
<label for="emailInput" class="form-label">Email address</label> <label class="form-label" for="emailInput">Email address</label>
<input type="email" class="form-control form-control-lg" id="emailInput" th:field="*{email}" required/> <input class="form-control form-control-lg" id="emailInput" required th:field="*{email}"
type="email"/>
<div class="invalid-feedback"> <div class="invalid-feedback">
Please enter an email address. Please enter an email address.
</div> </div>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="usernameInput" class="form-label">Username</label> <label class="form-label" for="usernameInput">Username</label>
<input type="text" class="form-control form-control-lg" id="usernameInput" th:field="*{username}" required/> <input class="form-control form-control-lg" id="usernameInput" required th:field="*{username}"
type="text"/>
<div class="invalid-feedback"> <div class="invalid-feedback">
Please enter a username. Please enter a username.
</div> </div>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="passwordInput" class="form-label">Password</label> <label class="form-label" for="passwordInput">Password</label>
<input type="password" class="form-control form-control-lg" id="passwordInput" th:field="*{password}" required/> <input class="form-control form-control-lg" id="passwordInput" required
th:field="*{password}" type="password"/>
<div class="invalid-feedback"> <div class="invalid-feedback">
Please enter a password. Please enter a password.
</div> </div>
</div> </div>
<button type="submit" class="btn btn-primary btn-lg">Submit</button> <button class="btn btn-primary btn-lg" type="submit">Submit</button>
</form> </form>
</div> </div>
</div> </div>
@ -44,7 +48,7 @@
'use strict' 'use strict'
// Fetch all the forms we want to apply custom Bootstrap validation styles to // Fetch all the forms we want to apply custom Bootstrap validation styles to
var forms = document.querySelectorAll('.needs-validation') let forms = document.querySelectorAll('.needs-validation')
// Loop over them and prevent submission // Loop over them and prevent submission
Array.prototype.slice.call(forms) Array.prototype.slice.call(forms)