Skip to content

jimthejelly/project-leaf

Repository files navigation

Project Leaf

A simple webpage to document employees and their leaves over the year. Made with EJS, CSS and JS.

How to Use

  • 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

Routes:

  • 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

Authorization

Login

[GET] /login

Parameters: None

Response:

Logout

[GET] /logout

Parameters: None

Response: User logout; Redirect to login page

Dashboard

[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)

Leave

Only users who have logged in can access this page

Leave List

[GET] /leave

Parameters: None

Response:

[GET] /leave?success=true

Parameters: None

Response:

Leave Form

[GET] /leave-form

Parameters: None

Response:

[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: 'bloop@gmail.com',
    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'
}

Employee

Only users with positions of Manager, Director or HR can access this page

Employee List

[GET] /employee

Parameters: None

Response:

[GET] /employee?success=true

Parameters: None

Response:

Employee Form

[GET] /emp-form

Parameters: None

Response:

[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: 'jimjom@gmail.com',
    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
}

Approval

Only users with positions of Manager, Director or HR can access this page

[GET] /approval

Parameters: None

Response:

Approve

[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: 'bloop@gmail.com',
    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'
}

Decline

[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: 'bloop@gmail.com',
    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'
}

Other

Pages that aren't part of the main project page

Not Authorized page

[GET] /notauthorized

Parameters: None

Response:

Error page

[GET] /error or anything that isn't part of the main get functions

Parameters: None

Response:

Created with

Tech

Framework

Functionality

Style