Skip to content

Commit

Permalink
Merge pull request #112 from cepdnaclk/revert-107-main
Browse files Browse the repository at this point in the history
Revert "project management"
  • Loading branch information
kasundie30 authored Sep 18, 2024
2 parents 8201c95 + 40bde33 commit d581326
Show file tree
Hide file tree
Showing 8,498 changed files with 124 additions and 3,499,376 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 0 additions & 4 deletions back-end/src/main/java/com/example/demo/appuser/AppUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public AppUser( String firstName,
* This method is used by Spring Security to determine the roles of the user
*/
@Override
@JsonIgnore
public Collection<? extends GrantedAuthority> getAuthorities() {
SimpleGrantedAuthority authority = new SimpleGrantedAuthority(appUserRole.name());
return Collections.singletonList(authority);
Expand All @@ -98,19 +97,16 @@ public String getUsername() {
}

@Override
@JsonIgnore
public boolean isAccountNonExpired() {
return true;
}

@Override
@JsonIgnore
public boolean isAccountNonLocked() {
return !locked;
}

@Override
@JsonIgnore
public boolean isCredentialsNonExpired() {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
Expand All @@ -30,7 +33,4 @@ public List<AppUser> getUserList(){
public AppUser getUser(@PathVariable Integer userID){
return appUserService.getUser(userID);
}

@PostMapping("/getUserByEmail")
public AppUser getUserByEmail(@RequestBody EmailRequest email){return appUserService.getUserAndCheckingByEmail(email);}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
* Users can have either the USER role or the ADMIN role.
*/
public enum AppUserRole {
USER, ADMIN, COORDINATOR, MANAGER, SUPER_ADMIN;
USER, ADMIN;
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,6 @@ public List<AppUser> getAllUsers(){
public AppUser getUser(long userID){
return appUserRepository.findById(userID).get();
}

//checking if a user exists
public AppUser getUserAndCheckingByEmail(EmailRequest emailRequest) {
Optional<AppUser> appUser = appUserRepository.findByEmail(emailRequest.getEmail());
return appUser.orElse(null);
}
}


16 changes: 0 additions & 16 deletions back-end/src/main/java/com/example/demo/appuser/EmailRequest.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
@RestController
@RequestMapping("/api/v1/files")
@AllArgsConstructor

public class FileController {

private final FileService fileService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.authorizeHttpRequests(authz -> authz

.requestMatchers("/api/v*/registration/**", "/api/v1/news/**", "/api/v1/gallery/**", "/api/v*/files/**",
"/api/v*/registration/login/**", "/oauth2/**","/api/v1/tasks/**", "/api/v1/users/**", "/deliverable/**", "/workplan/**","/api/v1/users/**")
"/api/v*/registration/login/**", "/oauth2/**","/api/v1/tasks/**", "/api/v1/users/**", "/deliverable/**", "/workplan/**")

.permitAll()
.anyRequest().authenticated()
Expand Down
9 changes: 6 additions & 3 deletions back-end/src/main/java/com/example/demo/task/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,13 @@ public void assignMember(AppUser user) {
assignedUsers.add(user);
}

public void deleteAssignMembers() {
assignedUsers.clear();
public void deleteAssignMember(AppUser user) {
assignedUsers.remove(user);
}


public void setAssignedMembers(Set<AppUser> taskMembers){
for (AppUser taskMember : taskMembers) {
assignMember(taskMember);}
}

}
30 changes: 1 addition & 29 deletions back-end/src/main/java/com/example/demo/task/TaskController.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,6 @@ public TaskResponse addTask(@RequestBody Task newTask){
return new TaskResponse(s);
}

@PostMapping("/addWithUsers")
public ResponseEntity<String> addTaskWithUsers(@RequestBody TaskDTO taskDTO){
try {
Task task = taskDTO.getTask();
Set<AppUser> taskMembers = taskDTO.getTaskMembers();
taskService.addTaskWithUsers(task,taskMembers);
return ResponseEntity.ok("Task added successfully");
}catch (Exception e) {
return ResponseEntity.status(500).body("Failed to add task");
}
}

@PostMapping("/updateWithUsers")
public ResponseEntity<String> updateTaskWithUsers(@RequestBody TaskDTO taskDTO){
try {
Task task = taskDTO.getTask();
Set<AppUser> taskMembers = taskDTO.getTaskMembers();
taskService.updateTaskWithUsers(task,taskMembers);
return ResponseEntity.ok("Task updated successfully");
}catch (Exception e) {
return ResponseEntity.status(500).body("Failed to update task");
}
}

@PutMapping("/update")
public void updateTask(@RequestBody Task updateTask){
taskService.updateTask(updateTask);
Expand All @@ -82,10 +58,6 @@ public TaskResponse addUserToTask(@PathVariable Integer taskID,@PathVariable Lon
return new TaskResponse("Assigned user with id "+userID+" to task with id "+taskID);
}

@DeleteMapping("/{taskID}/users/{userID}")
public TaskResponse deleteUserToTask(@PathVariable Integer taskID,@PathVariable Long userID){
taskService.deleteTaskUsers(taskID,userID);
return new TaskResponse("Deleted user with id "+userID+" to task with id "+taskID);
}


}
28 changes: 0 additions & 28 deletions back-end/src/main/java/com/example/demo/task/TaskDTO.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ public interface TaskRepository extends JpaRepository<Task, Integer> {
@Query("SELECT t FROM Task t where ?1 member of t.assignedUsers")
List<Task> findTasksByUser(AppUser user);

@Transactional
@Modifying
// @Query(nativeQuery = true, value = "UPDATE Task t SET t.assignedUsers = t.assignedUsers - ?1 WHERE t IN (SELECT t FROM Task t WHERE ?1 member of t.assignedUsers)")
@Query(nativeQuery = true, value = "DELETE FROM assigned_tasks where task_id=?1 AND user_id=?2")
void deleteUserFromTasks(int taskID,Long userID);
// @Modifying
// @Query("UPDATE Task t SET t.assignedUsers = t.assignedUsers - ?1 WHERE t IN (SELECT t FROM Task t WHERE ?1 member of t.assignedUsers)")
// void deleteUserFromTasks(AppUser user);

}

22 changes: 4 additions & 18 deletions back-end/src/main/java/com/example/demo/task/TaskService.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.example.demo.appuser.AppUserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -45,25 +44,12 @@ public void addUserToTask(int task_ID, long userID){
taskRepository.save(task);
}

@Transactional
public void addTaskWithUsers(Task task, Set<AppUser> taskMembers){

task.setAssignedMembers(taskMembers);
taskRepository.save(task);
for (AppUser taskMember : taskMembers) {
task.assignMember(taskMember);
}
taskRepository.save(task);

}

@Transactional
public void updateTaskWithUsers(Task task, Set<AppUser> taskMembers){
task.deleteAssignMembers();
for (AppUser taskMember : taskMembers) {
task.assignMember(taskMember);
}
taskRepository.save(task);
}

public void deleteTask(int task_ID){
taskRepository.deleteById(task_ID);
Expand All @@ -75,9 +61,9 @@ public List<Task> findUserTasks(Long userID) {
return taskRepository.findTasksByUser(user);
}

public void deleteTaskUsers(int taskID,Long userID){
taskRepository.deleteUserFromTasks(taskID,userID);
}
// public void deleteTaskUsers(int taskID,Long userID){
// taskRepository.deleteUserFromTasks(taskID,userID);
// }
}


98 changes: 45 additions & 53 deletions back-end/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,45 @@
server:
error:
include-message: always
include-binding-errors: always

spring:
datasource:
url: jdbc:mysql://localhost:3306/cycle
password: "&*531cW9/?"
username: root
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
hibernate:
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.MySQLDialect
format_sql: true
show-sql: true

mail:
host: localhost
port: 1025
username: hello
password: hello
properties:
mail:
smtp:
ssl:
trust: "*"
auth: true
starttls:
enable: true
connection timeout: 5000
timeout: 3000
write timeout: 5000

security:
oauth2:
client:
registration:
google:
client-id: "257276141541-av8vs5jp5u7e9f3am8dllo761kg7abo8.apps.googleusercontent.com"
client-secret: "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"

servlet:
multipart:
max-file-size: 100MB # Increase size for large files
max-request-size: 100MB # Increase size for large files

tomcat:
max-http-header-size: 16384 # Adjust if needed for large headers
max-swallow-size: 104857600 # 100MB, adjust according to file size needs
server:
error:
include-message: always
include-binding-errors: always

spring:
datasource:
url: jdbc:mysql://localhost:3306/cycle
password:
username: root
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
hibernate:
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.MySQLDialect
format_sql: true
show-sql: true

mail:
host: localhost
port: 1025
username: hello
password: hello
properties:
mail:
smtp:
ssl:
trust: "*"
auth: true
starttls:
enable: true
connection timeout: 5000
timeout: 3000
write timeout: 5000

servlet:
multipart:
max-file-size: 100MB # Increase size for large files
max-request-size: 100MB # Increase size for large files

tomcat:
max-http-header-size: 16384 # Adjust if needed for large headers
max-swallow-size: 104857600 # 100MB, adjust according to file size needs
27 changes: 2 additions & 25 deletions front-end/src/Pages/Dashboard.jsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,11 @@
import style from "../components/Dashboard.module.css";
function Dashboard() {



/*Dashboard Page */
function Dashboard() {
return(
<>
<div className={style["DashboardTitle"]}>
<h3>Dashboard</h3>

{/* <div className="tasks-container">
{tasks.map((item) => (
<div key={item.taskID} className="task-tile">
<h2>{item.taskName}</h2>
<b><p>Date: {item.startDate}</p></b>
<b><p>Date: {item.endDtae}</p></b>
<b><p>Author: {item.newsAuthor}</p></b>
<a href={item.newsUrl} target="_blank" rel="noopener noreferrer">Financial Report</a> {/* Link to fiancial report */}

{/* Show edit and delete buttons only if user is logged in */}
{/* {loggedInUser.isLoggedIn && (
<div>
<button className="actionButton" onClick={() => onEditClick(item)}><FontAwesomeIcon icon={faPen}/></button>
<button className="actionButton" onClick={() => onViewClick(item)}><FontAwesomeIcon icon={faEye}/></button>
<button className="actionButton" onClick={() => onDeleteClick(item.newsID)}><FontAwesomeIcon icon={faTrash} /></button>
</div>
)}
</div> */}
{/* ))}
</div> */}

</div>
</>
);
Expand Down
Loading

0 comments on commit d581326

Please sign in to comment.