The purpose of this project was to help Bolk company resolve one of their problems in the warehouse.
If the order has less than 13 pallets, then the warehouse employee should measure all the pallets, write down the information and then bring to the management, for a management to manually process an order and send to a distributor like DHL or DPD.
In order to help Bolk with their problem, it was decided to come up with an Order API or simply a web interface, which would optimise the time-wasting process of gathering data, then bringing it to the management...
Now, the employee doesn't need to care about writing down and delivering the measurements or other data related to an order, everything will be in one place.
The interface works in the following way:
- It receives the data from Bolk database and provides the overview of the list of orders
Note: Unfortunately, Bolk couldn't provide us the access to their database, so for the prototype it was decided to use local database
- According to the role (Employee/Admin), the interface would have different options to work with data, let's consider depending on a role:
- Employee: this role is dedicated for a warehouse employee, who's primary task is to measure the pallets (length, width, height, etc.), and then save this data to the database. For this purpose we've created a form, where the employee can easily provide all the necessary data for each unit per order, and then simply submit the data. No other action is provided.
- Admin: this role is dedicated strictly to the management of a warehouse. Admin role is granted the same actions as employee, but admin can also edit the order, edit the saved units of order, delete order, delete units, register new employees.
Note: For the sake of security it was decided for admin to register people only with 'employee' role.
This is a quick overview to provide an understanding of the purpose of the interface and its functionality. In the next section, a more detailed description will be provided.
In order to run the application, multiple steps are needed to be made.
Note: Since this is a prototype and the actual application is not deployed, you will need to install several applications on your computer.
In the list below, you will find a guide of how to run and test the application.
- In order to run the application, since it is a Java application, you will need the following things to be installed:
- Java related:
- JDK to install Java on your machine.
- To run Java applications install IDE Intellij Ultimate.
-
Note: it is extremely important to install IDE with running Server functionality, since this web app will run on local server.
- Database related:
- Install PostgreSQL for database to work on your local machine.
- Install pdAdmin4 to work with database. Create a new database with any database name of your preference, username and password.
-
Note: Remember the credentials that you have entered when created new database, namely name of db, username and password. You will need them later in the project to connect and use database.
- Follow the instructions on websites to install the aforementioned apps.
- Java related:
- When you are all set up with installed apps, you need to open the project file in Intellij.
- Follow
bolk/src/main/resourcesfolder and findapplication.yml. There you will need to fill in 3 parameters.username:enter your usernamepassword:enter your password if you provided anyurl:enter your database after jdbc:postgresql://localhost:5432/ url.-
Example: jdbc:postgresql://localhost:5432/postgres
- In the same folder find data.sql file. This is a DDL source file with hardcoded data to test the application.
- To run this DDL source you have to connect to your local database with Intellij. Find Database tab in Intellij, find
+symbol, find PostgreSQL, enter needed data, test connection. - After that, navigate to data.sql. There you will be able to run it and save hardcoded data into the database.
- To run this DDL source you have to connect to your local database with Intellij. Find Database tab in Intellij, find
Now you are all set up. Navigate to src/main/java/bolk_app and find Main.java file.
Open the file and click on a green triangle to run the application.
The next thing to do is to open any browser of your preferences and enter localhost:8080 in the search bar. If everything was done correctly,
you will be navigated to the login page. As you may have noticed, when running data.sql, you didn't save users' information
into the database. In order to save users' data, there are two ways. For testing purposes, the easiest option is to:
- Navigate to
src/main/java/bolk_app/reg_login/servicesand findLoginService.java. Comment out lines 42-45. To comment out a line two slashes should be placed in front of the line.
Should look like this:
// String passwordEncoded = PasswordEncoder.getPasswordEncoded(password);
// if (!user.getPassword().equals(passwordEncoded)) {
// throw new IllegalStateException("wrong password");
// }
- Open Database tab, on the same line where you found '+' symbol find a console symbol (symbol after 2 blue arrows). Open the console. Copy and paste these lines:
INSERT INTO users (id, email, name, password, role, token)
VALUES
(1, 'emp@gmail.com', 'name1', '12345', 'EMPLOYEE', ''),
(2, 'admin@gmail.com', 'name2', '1234', 'ADMIN', '')
- Run the console. Now rerun the application, try to log in. Try both log in with
emp@gmail.comandadmin@gmail.com.
The other option of adding credentials data for employee and admin will help you keep the password to be hashed in the database, but it will require more steps to perform:
- Download Postman
- Run the application bolk app (with
Main.java) - Open Postman
- In Postman open the window to make requests (you should see this window)
- Choose POST method to make request, and paste this code into 'Body'
{
"name" : "Michael",
"email" : "emp@gmail.com",
"password" : "12345"
}
- Paste this
localhost:8080/registerintourlfield - Click send to send request
- If you did everything correct, you will receive email as a response, if you made a mistake, you will see error message
- You've added employee email, now paste below code instead of employee's one and send request one more time
{
"name" : "John",
"email" : "admin@gmail.com",
"password" : "12345"
}
- If for both emails you've got email as a response, now open the Intellij and then open the console in Database tab.
- Paste this code into console and run it, you should see table of users as a response.
SELECT * FROM users
- Look at the column
idof the row where the email isadmin@gmail.com. Remember thisidvalue - Open the console again. Paste this and insert your
idfrom the previous step instead of a question mark?and run the console:
UPDATE users
SET role = 'ADMIN'
WHERE id = ?
- Now you have two emails, for employee and for admin, with their passwords being hashed.
Note: Regarding the css styling. This project uses css framework called Tailwind. In order to use it and have a beautiful styling, follow this link to check for its documentation and guide of how to install it.
As it was said earlier, the application has 2 roles, namely 'Employee' and 'Admin'.
- If you logged in as 'employee' with emp@gmail.com/12345 in login page, you should be redirected to the main page with overview of the orders
- There you should see
ALL,PENDING,FINISHED,LOGOUTtabs, all of them provide functionality according to its names. PENDINGandFINISHEDare statuses of orders- As you logged in as employee, you are able only to edit
PENDINGorders. - By clicking on
Editbutton you will be redirected to the page with order's form, where you need to provide measurements for pallets. As you enetered measurements, click onNextbutton until you save all units. Then clickSubmitto save units for order. - You will be redirected to overview page again.
That is all that user with EMPLOYEE role can perform.
Now, let's consider functionalities that ADMIN has.
ADMINcan perform the same actions asEMPLOYEE, namely savingPENDINGorders.- Apart from it,
ADMINcan register new employees withEMPLOYEErole. This can be done by clicking onREGISTERtab in the overview page. - Moreover,
ADMINcan edit pallets for orders withFINISHEDstatus. Click onEditbutton to do this. - Lastly,
ADMINcan delete both orders and units. If he deletes orders, all units associated with this order will be deleted as well.
Note: When the user (both
ADMINandEMPLOYEE) logs in, he will receive a token. This token expires the same date at 10pm (can be changed to the preferred value). While the app is running, this token will be checked every hour, if it has expired or not, If the token has expired, the user be automatically logged out and navigated to login page. However, the token is not checked for being expired on form pages, for a user to finish editing orders/units and not interrupting this process.