GithubHelp home page GithubHelp logo

john11d-payu-gpo / 04labarsw-i Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arsw-eci-archive/javascript-bootstrap-client-consumes-rest-api

0.0 1.0 0.0 114 KB

Java 74.20% HTML 7.73% CSS 5.26% JavaScript 12.80%

04labarsw-i's Introduction

Part 3 - 6

FrontEnd - JavaScript Base Client

Create a simple front end using the following frameworks:

Part 1: Create a basic html page using a Bootstrap template

  1. Go to the boostrap examples and download the code and extract the following template: https://getbootstrap.com/docs/4.0/examples/cover/

  2. Update your html code to have the following menu items:

  • orders
  • new order
  1. Update the content of your page (where the learn more button is located) with a table that will display the order with hardcoded values:

Order 1:

Product Quantity Price
PIZZA 3 $10000
HOTDOG 1 $3000
COKE 4 $1300

Part 2: Implement the FrontEnd controller

  1. Create a JavaScript file called OrdersController.js
  2. Create a JavaScript object list that represents the table on Part 1 on the Order OrdersController.js (Do not forget to add an id attribute to the Order object).
{
	"order_id": 1,
	"table_id": 1,
	"products": [{
			"product": "PIZZA",
			"quantity": 3,
			"price": "$15.000"
		},
		{
			"product": "HAMBURGER",
			"quantity": 1,
			"price": "$12.300"
		}
	]
}
  1. Create a function that adds an order (a new table below the existing Order 1 table).

  2. Create a function that removes an order table with a given id: removeOrderById(int id) Use the following method to start: https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById

  3. Try your add order function iterating the list created on 2. and make sure the data is loaded into the table from the JavaScript code.

  4. Create a function that loads the orders (creates the HTML tables) from a mocked list of orders in your JavaScript file. Once this function is working call it from the body tag in order to invoke this function everytime the page is loaded:

	<body onload="loadOrders();">

Part 3: Consume the REST API and connect it with the FrontEnd

  1. Create a function that calls the API Endpoint that retrieves the orders list using the Axios API library
  2. Implement the callback when the orders list is return succesfully that uses the OrderController.js functions.
  3. Modify the loadOrders function so it actually makes a call to the Orders API and loads the orders from the server.
  4. Implement the callback when the request fails that shows a dialog to user saying that "There is a problem with our servers. We apologize for the inconvince, please try again later"
  5. In order to test your application do the following:
    • Add your JavaScript file to the SpringBoot project under the resources/static/js folder (create the folder if it does not exist)
    • Add your html page (index.html) to the resources/static folder
  6. Create a Heroku project and deploy your SpringBoot then test that it works as expected.

04labarsw-i's People

Contributors

sancarbar avatar john11d-payu-gpo avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.