WIP : kart dashboard
This commit is contained in:
@ -1,7 +1,16 @@
|
||||
timelapsStorage = localStorage;
|
||||
if(typeof timelapsStorage.current_kart_id === "undefined"){
|
||||
if (typeof timelapsStorage.current_kart_id === "undefined") {
|
||||
timelapsStorage.setItem('current_kart_id', null);
|
||||
}
|
||||
if (typeof timelapsStorage.params_max_relay_time === "undefined") {
|
||||
timelapsStorage.setItem('params_max_relay_time', null);
|
||||
}
|
||||
if (typeof timelapsStorage.params_min_stand_time === "undefined") {
|
||||
timelapsStorage.setItem('params_min_stand_time', null);
|
||||
}
|
||||
if (typeof timelapsStorage.params_max_fuel_autonomy === "undefined") {
|
||||
timelapsStorage.setItem('params_max_fuel_autonomy', null);
|
||||
}
|
||||
|
||||
function getKartsMenu() {
|
||||
$.ajax({
|
||||
@ -12,12 +21,12 @@ function getKartsMenu() {
|
||||
success: function (data, status) {
|
||||
actual_kart = timelapsStorage.current_kart_id;
|
||||
$.each(data.reverse(), function (index, value) {
|
||||
btn_class = 'btn-light';
|
||||
if(actual_kart == value.id ){
|
||||
btn_class = 'btn-primary';
|
||||
btn_class = 'btn-light';
|
||||
if (actual_kart == value.id) {
|
||||
btn_class = 'btn-primary';
|
||||
}
|
||||
$('#link_all').after("" +
|
||||
" <a id=\"link_" + value.id + "\" href=\"#\" onclick=\"showKartDashboard("+value.id+")\" class=\"btn "+btn_class+" btn-icon-split btn-sm\">\n \n" +
|
||||
" <a id=\"link_" + value.id + "\" href=\"#\" onclick=\"showKartDashboard(" + value.id + ")\" class=\"btn " + btn_class + " btn-icon-split btn-sm\">\n \n" +
|
||||
" <span class=\"icon text-gray-600\">\n" +
|
||||
" <i class=\"fas fa-car\"></i>\n" +
|
||||
"</span>\n" +
|
||||
@ -290,7 +299,7 @@ function getDriversByKart() {
|
||||
{
|
||||
data: "id",
|
||||
render: function (data, type, row, meta) {
|
||||
return '<a href="#" onclick=\'modalEditDriver(' + data + ')\' class="btn btn-primary btn-circle"><i class="fas fa-edit"></i></a> <a href="#" onclick=\'deleteDriver(' + data + ','+value.id + ',' + meta.row + ')\' class="btn btn-danger btn-circle"><i class="fas fa-trash"></i>';
|
||||
return '<a href="#" onclick=\'modalEditDriver(' + data + ')\' class="btn btn-primary btn-circle"><i class="fas fa-edit"></i></a> <a href="#" onclick=\'deleteDriver(' + data + ',' + value.id + ',' + meta.row + ')\' class="btn btn-danger btn-circle"><i class="fas fa-trash"></i>';
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -404,7 +413,76 @@ function startRace() {
|
||||
|
||||
}
|
||||
|
||||
function getDashboardKartInfo() {
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
crossDomain: true,
|
||||
url: api_url + 'relaysbykart/' + timelapsStorage.current_kart_id + '/',
|
||||
dataType: 'json',
|
||||
success: function (data, status) {
|
||||
console.log(data);
|
||||
$.each(data.reverse(), function (index, value) {
|
||||
console.log(value);
|
||||
if(value.relay_end == null){
|
||||
$('#current_driver_name').text(value.driver.first_name);
|
||||
$('#refTime_current_driver').val(value.driver.ref_time);
|
||||
}else{
|
||||
$('#next_driver_list').append("" +
|
||||
"<div class=\"col-xl-2 col-lg-4 col-md-6\">\n" +
|
||||
" <div class=\"card\" style=\"width: auto;\">\n" +
|
||||
" <a class=\"card-img-top\">\n" +
|
||||
" <img class=\"card-img-top \" src=\"img/"+value.driver.id+".png\" alt=\"Card image cap\">\n" +
|
||||
" </a>\n" +
|
||||
" <div class=\"card-body\">\n" +
|
||||
" <h5 class=\"card-title\">"+value.driver.first_name+"</h5>\n" +
|
||||
" <p class=\"card-text\">Total : 03:39:36<br>\n" +
|
||||
" Tps de repos : 14:05:26<br>\n" +
|
||||
" <label for=\"refTime\">Temps de ref. :</label>\n" +
|
||||
" </p>\n" +
|
||||
"\n" +
|
||||
" <div class=\"input-group\">\n" +
|
||||
" <span class=\"input-group-btn\">\n" +
|
||||
" <button type=\"button\" class=\"btn btn-danger btn-number\" onclick=\"\">\n" +
|
||||
" <i class=\"fas fa-plus\"></i>\n" +
|
||||
" </button>\n" +
|
||||
" </span>\n" +
|
||||
" <input type=\"text\" id=\"refTime\" class=\"form-control\" value=\""+value.driver.ref_time+"\">\n" +
|
||||
" <span class=\"input-group-btn\">\n" +
|
||||
" <button type=\"button\" class=\"btn btn-success btn-number\" onclick=\"\">\n" +
|
||||
" <i class=\"fas fa-minus\"></i>\n" +
|
||||
" </button>\n" +
|
||||
" </span>\n" +
|
||||
" </div>\n" +
|
||||
" </div>\n" +
|
||||
" </div>\n" +
|
||||
" </div>" +
|
||||
"");
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
error: function (xhr) {
|
||||
$.notify("APIs unreachable!", "error");
|
||||
console.log('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText);
|
||||
},
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function showKartDashboard(kart_id) {
|
||||
timelapsStorage.setItem('current_kart_id', kart_id);
|
||||
window.location.href='index_kart.html';
|
||||
}
|
||||
if (kart_id != null) {
|
||||
window.location.href = 'index_kart.html';
|
||||
} else {
|
||||
window.location.href = 'index.html';
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
if (timelapsStorage.current_kart_id == "null" || typeof timelapsStorage.current_kart_id === "undefined") {
|
||||
$('#link_all').removeClass('btn-light').addClass('btn-primary');
|
||||
}
|
||||
|
||||
});
|
Reference in New Issue
Block a user