A simple webpage to document employees and their leaves over the year. Made with EJS, CSS and JS.
npm install
- Set up MySQL database (named leaf-db)
- Load dummy database leaf-db.sql into created database
npm start
in terminal to launch pages- localhost:3000 to access pages
- localhost:3000/
- localhost:3000/login
- localhost:3000/leave
- localhost:3000/leave-form
- localhost:3000/employee
- localhost:3000/emp-form
- localhost:3000/approval
- localhost:3000/notauthorized
[GET] /login
Parameters: None
[GET] /logout
Parameters: None
Response: User logout; Redirect to login page
[GET] /
Parameters: None
Response:
No login:
- can view dashboard only
Staff:
- dashboard says welcome with logged in name
- can access dashboard and leave
Admin (Manager, Director, HR):
- dashboard says welcome with logged in name
- can access every page (dashboard, leave, employee and approval)
Only users who have logged in can access this page
[GET] /leave
Parameters: None
[GET] /leave?success=true
Parameters: None
[GET] /leave-form
Parameters: None
[POST] /leave-submit
Parameters:
- employee_id -> int
- department -> text
- submit_time -> timestamp
- reason -> text
- explanation -> text
- start_date -> date
- end_date -> date
- total_days -> int
- status -> text
- created_at -> timestamp
- created_by -> text
Response:
{
id: 26,
department: 'IT',
submit_time: 2022-01-07T07:06:58.000Z,
reason: 'Sick',
explanation: 'Death is upon me, fellas',
start_date: 1901-12-11T16:52:48.000Z,
end_date: 1901-12-29T16:52:48.000Z,
total_days: 18,
created_at: 2022-01-07T07:06:58.000Z,
updated_at: null,
created_by: bloop,
updated_by: null,
employee_id: 2,
status: 'pending',
name: 'bloop',
email: '[email protected]',
phone: '321543765',
dob: 2021-10-07T17:00:00.000Z,
password: 'password',
position: 'Manager',
pfp: 'https://media.moddb.com/images/members/5/4550/4549205/duck.jpg'
}
Only users with positions of Manager, Director or HR can access this page
[GET] /employee
Parameters: None
[GET] /employee?success=true
Parameters: None
[GET] /emp-form
Parameters: None
[POST] /employee-submit
Parameters:
- name -> text
- password -> text
- email -> text
- phone -> text
- dob -> date
- position -> text
- pfp -> text
- created_at -> timestamp
- created_by -> timestamp
Response:
{
id: 29,
name: 'Jom',
email: '[email protected]',
phone: '12345654234',
dob: 2022-01-06T17:00:00.000Z,
password: 'password',
position: 'Staff',
pfp: 'random.jpg',
created_at: 2022-01-07T08:17:35.000Z,
updated_at: null,
created_by: 'bloop',
updated_by: null
}
Only users with positions of Manager, Director or HR can access this page
[GET] /approval
Parameters: None
[POST] /approve
Parameters:
- status -> text
Response:
{
id: 26,
department: 'IT',
submit_time: 2022-01-07T07:06:58.000Z,
reason: 'Sick',
explanation: 'Death is upon me, fellas',
start_date: 1901-12-11T16:52:48.000Z,
end_date: 1901-12-29T16:52:48.000Z,
total_days: 18,
created_at: 2022-01-07T07:06:58.000Z,
updated_at: 2022-01-07T15:20:15.000Z,
created_by: bloop,
updated_by: bloop,
employee_id: 2,
status: 'approved',
name: 'bloop',
email: '[email protected]',
phone: '321543765',
dob: 2021-10-07T17:00:00.000Z,
password: 'password',
position: 'Manager',
pfp: 'https://media.moddb.com/images/members/5/4550/4549205/duck.jpg'
}
[POST] /decline
Parameters:
- status -> text
Response:
{
id: 26,
department: 'IT',
submit_time: 2022-01-07T07:06:58.000Z,
reason: 'Sick',
explanation: 'Death is upon me, fellas',
start_date: 1901-12-11T16:52:48.000Z,
end_date: 1901-12-29T16:52:48.000Z,
total_days: 18,
created_at: 2022-01-07T07:06:58.000Z,
updated_at: 2022-01-07T15:21:27.000Z,
created_by: bloop,
updated_by: bloop,
employee_id: 2,
status: 'declined',
name: 'bloop',
email: '[email protected]',
phone: '321543765',
dob: 2021-10-07T17:00:00.000Z,
password: 'password',
position: 'Manager',
pfp: 'https://media.moddb.com/images/members/5/4550/4549205/duck.jpg'
}
Pages that aren't part of the main project page
[GET] /notauthorized
Parameters: None
[GET] /error or anything that isn't part of the main get functions
Parameters: None
- HTML/EJS
- npm
- Passport.js
- SweetAlert2
- CSS
- Bootstrap