Administration Panel
Relevant source files
The following files were used as context for generating this wiki page:
- src/main/java/com/example/demo/controllers/AdminController.java
- src/main/java/com/example/demo/services/AdminService.java
- README.md
- src/main/java/com/example/demo/services/TaskService.java
- src/main/java/com/example/demo/controllers/AnalyticsController.java
- src/main/java/com/example/demo/services/AttachmentService.java
The Administration Panel is a restricted administrative interface within the Dashboard Task Management application, designed exclusively for users with the ADMIN role. It serves as the central hub for managing the organizational structure, user accounts, and high-level project configurations. While other roles like MANAGER or PM have limited administrative capabilities within their specific scopes, the Admin Panel provides unrestricted CRUD (Create, Read, Update, Delete) access to core system entities including Departments, Users, and Projects.
The panel ensures system integrity by enforcing business logic constraints, such as validating that Project Managers (PMs) belong to the same department as the projects they manage, and managing the active status of users to control system access. It interacts directly with the AdminService to execute these high-level operations, secured by Spring Security's @PreAuthorize("hasRole('ADMIN')") annotation to prevent unauthorized access.
Sources: src/main/java/com/example/demo/controllers/AdminController.java:23, README.md:144-162
System Architecture and Access Control
The Administration Panel follows a standard MVC architecture where the AdminController handles RESTful requests and delegates business logic to the AdminService. Access is strictly controlled via JWT-based authentication and role-based access control (RBAC).
This diagram illustrates the flow of administrative requests from the user interface through the controller and service layers to the persistence layer.
Sources: src/main/java/com/example/demo/controllers/AdminController.java:20-25, src/main/java/com/example/demo/services/AdminService.java:18-22, README.md:6
Role-Based Permissions
The system defines four primary roles: ADMIN, MANAGER, PM, and TEAM. The ADMIN role is unique in its ability to manage users and departments globally.
| Function | ADMIN | MANAGER | PM | TEAM |
|---|---|---|---|---|
| Manage Users | ✅ | ❌ | ❌ | ❌ |
| Manage Departments | ✅ | ❌ | ❌ | ❌ |
| Global Project CRUD | ✅ | ❌ | ❌ | ❌ |
| Full Task Deletion | ✅ | Partial | ❌ | ❌ |
Sources: README.md:15-34, src/main/java/com/example/demo/services/TaskService.java:274-288
Department Management
The Admin Panel allows for the creation and organization of company departments. Each department can be assigned a manager, who must possess the MANAGER role.
Logic and Constraints
- Manager Validation: When updating or creating a department, the system verifies that the assigned manager exists and has the
MANAGERrole. - Organizational Hierarchy: Departments serve as the primary filter for
MANAGERvisibility; a manager can generally only see projects and tasks within their assigned department.
Sources: src/main/java/com/example/demo/services/AdminService.java:49-59, README.md:146-148
Department API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/admin/departments | Retrieves all departments and their managers. |
| POST | /api/admin/departments | Creates a new department. |
| PATCH | /api/admin/departments/{id} | Updates department name or assigned manager. |
| DELETE | /api/admin/departments/{id} | Removes a department from the system. |
Sources: src/main/java/com/example/demo/controllers/AdminController.java:50-65
User Management
Administrators have full control over the user lifecycle, including onboarding, role assignment, and account deactivation.
User Lifecycle Flow
This sequence shows the process of creating a user, including mandatory password hashing before persistence.
Sources: src/main/java/com/example/demo/services/AdminService.java:99-114
Key User Management Features
- Search and Filter: Admins can search users by query strings, roles, and department IDs.
- Status Control: Users can be enabled or disabled via the
/api/admin/users/{id}/statusendpoint, which sets theactiveboolean flag. - Role Constraints: A
MANAGERrole cannot be assigned to a specific department within theUserUpdateDtoto maintain the hierarchy where managers oversee departments rather than being members of them.
Sources: src/main/java/com/example/demo/services/AdminService.java:92-97, src/main/java/com/example/demo/services/AdminService.java:122-125, src/main/java/com/example/demo/controllers/AdminController.java:82-85
Project Administration
While Managers can create projects for their own departments, Administrators have global CRUD access to all projects across the organization.
Project Constraints and Validation
The AdminService enforces specific business rules during project creation and updates:
- Role Verification: The user assigned as Project Manager (
pmId) must have thePMrole. - Department Alignment: The assigned PM must belong to the same department as the project they are managing.
Sources: src/main/java/com/example/demo/services/AdminService.java:188-203, README.md:158-162
Project API Summary
| Endpoint | Method | Data Requirement |
|---|---|---|
/api/admin/projects | GET | None (Returns all projects) |
/api/admin/projects | POST | ProjectCreateDto (Name, Desc, pmId, departmentId) |
/api/admin/projects/{id} | PATCH | ProjectUpdateDto (Optional fields) |
/api/admin/projects/{id} | DELETE | Path Variable ID |
Sources: src/main/java/com/example/demo/controllers/AdminController.java:95-120
Security and Global Overrides
The ADMIN role acts as a "super-user" across other modules, bypassing standard scope checks that restrict other roles.
Access Overrides
- Task Access: While
TEAMmembers only see assigned tasks,ADMINusers have global visibility and can delete any task regardless of creator or department. - Attachment Management: Admins can download and delete any attachment in the system, whereas other users are restricted to files they uploaded or files attached to tasks within their scope.
- Analytics: Global analytics (filtering by any department or project) is restricted to
ADMINandMANAGERroles.
Sources: src/main/java/com/example/demo/services/TaskService.java:278-282, src/main/java/com/example/demo/services/AttachmentService.java:158-165, src/main/java/com/example/demo/controllers/AnalyticsController.java:35-37
Conclusion
The Administration Panel provides the essential infrastructure for managing the Dashboard Task Management system. By centralizing department, user, and project management, it allows for a structured corporate environment where roles and permissions are strictly enforced, ensuring that data access remains secure and organizational boundaries are respected.