frontend improvments

This commit is contained in:
s452111 2020-01-20 17:12:59 +01:00
parent ea45ccbfab
commit 153f70a463
3 changed files with 36 additions and 29 deletions

View File

@ -69,13 +69,39 @@ function sendGetRequest() {
// }
// };
$.getJSON(url+buff, function( data ) {
var cars_data = '';
$('#table ').empty();
var cars_data = ' ' +
' <thead> ' +
' <tr>\n' +
' <th>#</th>\n' +
' <th>Marka</th>\n' +
' <th>Model</th>\n' +
' <th>Wersja</th>\n' +
'<!-- <th>Rok produkcji</th>-->\n' +
' <th>Moc silnika [KM]</th>\n' +
' <th>Pojemność silnika</th>\n' +
' <th>Skrzynia biegów</th>\n' +
' <th>Napęd</th>\n' +
' <th>Typ auta</th>\n' +
' <th>Liczba drzwi</th>\n' +
' <th>Liczba miejsc</th>\n' +
' <th>Ceny od</th>\n' +
' <th>Ceny do</th>\n' +
' <th>Srednio</th>\n' +
' <th>Srednia ocena</th>\n' +
' <th>Rodzaj paliwa</th>\n' +
' <th>Srednie spalanie</th>\n' +
' <th>Zalety</th>\n' +
' <th>Wady</th>\n' +
' </tr></thead>';
$.each(data, function (key, value) {
var i = 1;
cars_data += '<tr>';
cars_data += '<td>' + i + '</td>';
cars_data += '<td>' + value.brand + '</td>';
cars_data += '<td>' + value.model + '</td>';
cars_data += '<td>' + value.version + '</td>';
cars_data += '<td>' + value.year + '</td>';
// cars_data += '<td>' + value.year + '</td>';
cars_data += '<td>' + value.engine_power + '</td>';
cars_data += '<td>' + value.engine_capacity + '</td>';
cars_data += '<td>' + value.transmission + '</td>';
@ -88,12 +114,11 @@ function sendGetRequest() {
cars_data += '<td>' + value.average + '</td>';
cars_data += '<td>' + value.rating + '</td>';
cars_data += '<td>' + value.fuel + '</td>';
cars_data += '<td>' + value.fuelEconomy + '</td>';
cars_data += '<td>' + value.fuelEconomy.toFixed(1) + '</td>';
cars_data += '<td>' + value.car_pros + '</td>';
cars_data += '<td>' + value.car_cons + '</td>';
cars_data += '</tr>';
i = i + 1;
});
$('#table').append(cars_data);
});

View File

@ -118,31 +118,13 @@
</select>
</div>
</div>
<button type="button" class="btn btn-warning" onclick="sendGetRequest()">Rekomenduj auta!</button>
<button type="button" class="btn btn-warning" style="margin-bottom: 10px" onclick="sendGetRequest()">Rekomenduj
auta!
</button>
</form>
<div class="container-fluid">
<table class="table table-bordered table-striped col" id="table">
<tr>
<th>Marka</th>
<th>Model</th>
<th>Wersja</th>
<th>Rok produkcji</th>
<th>Moc silnika [KM]</th>
<th>Pojemność silnika</th>
<th>Skrzynia biegów</th>
<th>Napęd</th>
<th>Typ auta</th>
<th>Liczba drzwi</th>
<th>Liczba miejsc</th>
<th>Ceny od</th>
<th>Ceny do</th>
<th>Srednio</th>
<th>Rodzaj paliwa</th>
<th>Srednie spalanie</th>
<th>Zalety</th>
<th>Wady</th>
</tr>
</table>
</div>
</div>

View File

@ -63,13 +63,13 @@ public class CarService {
private List<CarDto> processList(List<CarDto> 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<Car> tmp = new ArrayList<>();
for(int i = 0; i < 15; i++){
tmp.add(rawCars.get(i));