From 153f70a46356ef3168711ac25a76a967d530df7c Mon Sep 17 00:00:00 2001 From: s452111 Date: Mon, 20 Jan 2020 17:12:59 +0100 Subject: [PATCH] frontend improvments --- .../src/main/client/html/js/sendingRequest.js | 35 ++++++++++++++++--- cars4you/src/main/client/html/search.html | 24 ++----------- .../com/cars/car4you/service/CarService.java | 6 ++-- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/cars4you/src/main/client/html/js/sendingRequest.js b/cars4you/src/main/client/html/js/sendingRequest.js index 784d5bf..57c65e9 100644 --- a/cars4you/src/main/client/html/js/sendingRequest.js +++ b/cars4you/src/main/client/html/js/sendingRequest.js @@ -69,13 +69,39 @@ function sendGetRequest() { // } // }; $.getJSON(url+buff, function( data ) { - var cars_data = ''; + $('#table ').empty(); + var cars_data = ' ' + + ' ' + + ' \n' + + ' #\n' + + ' Marka\n' + + ' Model\n' + + ' Wersja\n' + + '\n' + + ' Moc silnika [KM]\n' + + ' Pojemność silnika\n' + + ' Skrzynia biegów\n' + + ' Napęd\n' + + ' Typ auta\n' + + ' Liczba drzwi\n' + + ' Liczba miejsc\n' + + ' Ceny od\n' + + ' Ceny do\n' + + ' Srednio\n' + + ' Srednia ocena\n' + + ' Rodzaj paliwa\n' + + ' Srednie spalanie\n' + + ' Zalety\n' + + ' Wady\n' + + ' '; $.each(data, function (key, value) { + var i = 1; cars_data += ''; + cars_data += '' + i + ''; cars_data += '' + value.brand + ''; cars_data += '' + value.model + ''; cars_data += '' + value.version + ''; - cars_data += '' + value.year + ''; + // cars_data += '' + value.year + ''; cars_data += '' + value.engine_power + ''; cars_data += '' + value.engine_capacity + ''; cars_data += '' + value.transmission + ''; @@ -88,12 +114,11 @@ function sendGetRequest() { cars_data += '' + value.average + ''; cars_data += '' + value.rating + ''; cars_data += '' + value.fuel + ''; - cars_data += '' + value.fuelEconomy + ''; + cars_data += '' + value.fuelEconomy.toFixed(1) + ''; cars_data += '' + value.car_pros + ''; cars_data += '' + value.car_cons + ''; - cars_data += ''; - + i = i + 1; }); $('#table').append(cars_data); }); diff --git a/cars4you/src/main/client/html/search.html b/cars4you/src/main/client/html/search.html index 7d50d95..637a4e0 100644 --- a/cars4you/src/main/client/html/search.html +++ b/cars4you/src/main/client/html/search.html @@ -118,31 +118,13 @@ - +
- - - - - - - - - - - - - - - - - - - -
MarkaModelWersjaRok produkcjiMoc silnika [KM]Pojemność silnikaSkrzynia biegówNapędTyp autaLiczba drzwiLiczba miejscCeny odCeny doSrednioRodzaj paliwaSrednie spalanieZaletyWady
diff --git a/cars4you/src/main/java/com/cars/car4you/service/CarService.java b/cars4you/src/main/java/com/cars/car4you/service/CarService.java index 495b444..b9fec23 100644 --- a/cars4you/src/main/java/com/cars/car4you/service/CarService.java +++ b/cars4you/src/main/java/com/cars/car4you/service/CarService.java @@ -63,13 +63,13 @@ public class CarService { private List processList(List dtoList){ for(CarDto c : dtoList){ - Double fuelEconomy = 0D; + Double fuelEconomy; if(c.getFuel() == "Diesel"){ fuelEconomy = c.getEngine_power()*0.052174; //typowe spalanie L/KM dla diesla if(fuelEconomy < 5) fuelEconomy = 5.1; if(fuelEconomy > 15 ) fuelEconomy = 14.9; }else{ - fuelEconomy = c.getEngine_power()*0.1; //typowe spalanie L/KM dla benzyny //todo ustalic te parametru dokładniej + fuelEconomy = c.getEngine_power()*0.1; //typowe spalanie L/KM dla benzyny if(fuelEconomy < 5) fuelEconomy = 5.1; if(fuelEconomy > 15) fuelEconomy = 14.9; } @@ -128,7 +128,7 @@ public class CarService { } //jeżeli wyników jest wiecej niz 50 (to i tak jest już dużo) - if(rawCars.size() > 50){ + if(rawCars.size() > 10){ List tmp = new ArrayList<>(); for(int i = 0; i < 15; i++){ tmp.add(rawCars.get(i));