Setting new global JS conf file.
This commit is contained in:
parent
0d8f112c9e
commit
2bbb8c17f8
@ -469,6 +469,7 @@
|
|||||||
<!-- Custom scripts for all pages-->
|
<!-- Custom scripts for all pages-->
|
||||||
<script src="js/sb-admin-2.min.js"></script>
|
<script src="js/sb-admin-2.min.js"></script>
|
||||||
<script src="vendor/notify/notify.min.js"></script>
|
<script src="vendor/notify/notify.min.js"></script>
|
||||||
|
<script src="js/var_conf.js"></script>
|
||||||
<script src="js/timelaps.js"></script>
|
<script src="js/timelaps.js"></script>
|
||||||
|
|
||||||
<!-- Page level plugins -->
|
<!-- Page level plugins -->
|
||||||
|
231
js/timelaps.js
231
js/timelaps.js
@ -1,42 +1,3 @@
|
|||||||
var api_url = 'http://timelaps.local:8000/api/v1/';
|
|
||||||
|
|
||||||
function getParams() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function showKarts() {
|
|
||||||
$.ajax({
|
|
||||||
type: 'GET',
|
|
||||||
crossDomain: true,
|
|
||||||
url: api_url + 'karts/',
|
|
||||||
dataType: 'json',
|
|
||||||
success: function (data, status) {
|
|
||||||
console.log(data);
|
|
||||||
$('#dataTable_kart_list').DataTable({
|
|
||||||
data: data,
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
data: "id",
|
|
||||||
render: function (data, type, row, meta) {
|
|
||||||
return '<a href="#" class="btn btn-primary btn-circle"><i class="fas fa-edit"></i></a> <a href="#" class="btn btn-danger btn-circle"><i class="fas fa-trash"></i>';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: "name"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: "autonomy"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
},
|
|
||||||
error: function (xhr) {
|
|
||||||
$.notify("APIs unreachable!", "error");
|
|
||||||
console.log('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getKartsMenu() {
|
function getKartsMenu() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
@ -136,3 +97,195 @@ function getPilotsByKart() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getParams() {
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
crossDomain: true,
|
||||||
|
url: api_url + 'params/1/',
|
||||||
|
dataType: 'json',
|
||||||
|
success: function (data, status) {
|
||||||
|
$('#id').val(data.id);
|
||||||
|
$('#autonomy').val(data.autonomy);
|
||||||
|
$('#stand_minimum_time').val(data.stand_minimum_time);
|
||||||
|
$('#default_relay').val(data.default_relay);
|
||||||
|
$('#comment').val(data.comment);
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
$.notify("APIs unreachable!", "error");
|
||||||
|
console.log('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function editParams(data) {
|
||||||
|
$.ajax({
|
||||||
|
type: 'PUT',
|
||||||
|
crossDomain: true,
|
||||||
|
url: api_url + 'params/1/',
|
||||||
|
dataType: 'json',
|
||||||
|
data: data,
|
||||||
|
success: function (data, status) {
|
||||||
|
$.notify("Update done!", "success");
|
||||||
|
getParams();
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
$.notify("APIs unreachable!", "error");
|
||||||
|
console.log('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getKarts(id) {
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
crossDomain: true,
|
||||||
|
url: api_url + 'karts/'+id+'/',
|
||||||
|
dataType: 'json',
|
||||||
|
success: function (data, status) {
|
||||||
|
$('#id').val(data.id);
|
||||||
|
$('#autonomy').val(data.autonomy);
|
||||||
|
$('#stand_minimum_time').val(data.stand_minimum_time);
|
||||||
|
$('#default_relay').val(data.default_relay);
|
||||||
|
$('#comment').val(data.comment);
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
$.notify("APIs unreachable!", "error");
|
||||||
|
console.log('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function listKarts() {
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
crossDomain: true,
|
||||||
|
url: api_url + 'karts/',
|
||||||
|
dataType: 'json',
|
||||||
|
success: function (data, status) {
|
||||||
|
console.log(data);
|
||||||
|
$('#dataTable_kart_list').DataTable({
|
||||||
|
data: data,
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
data: "id",
|
||||||
|
render: function (data, type, row, meta) {
|
||||||
|
return '<a href="#" onclick="" class="btn btn-primary btn-circle">' +
|
||||||
|
'<i class="fas fa-edit"></i>' +
|
||||||
|
'</a>' +
|
||||||
|
' ' +
|
||||||
|
'<a href="#" onclick="if ( confirm( \'Do you want to delete the kart\' ) ) {deleteKarts('+data+')}" class="btn btn-danger btn-circle">' +
|
||||||
|
'<i class="fas fa-trash"></i>' +
|
||||||
|
'</a>';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: "name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: "autonomy"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
$.notify("APIs unreachable!", "error");
|
||||||
|
console.log('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteKarts(id) {
|
||||||
|
$.ajax({
|
||||||
|
type: 'DELETE',
|
||||||
|
crossDomain: true,
|
||||||
|
url: api_url + 'karts/'+id+'/',
|
||||||
|
dataType: 'json',
|
||||||
|
data: data,
|
||||||
|
success: function (data, status) {
|
||||||
|
$.notify("Delete done!", "success");
|
||||||
|
showKarts();
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
$.notify("APIs unreachable!", "error");
|
||||||
|
console.log('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function addKarts(data) {
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
crossDomain: true,
|
||||||
|
url: api_url + 'karts/',
|
||||||
|
dataType: 'json',
|
||||||
|
data: data,
|
||||||
|
success: function (data, status) {
|
||||||
|
$.notify("Update done!", "success");
|
||||||
|
//showKarts();
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
$.notify("APIs unreachable!", "error");
|
||||||
|
console.log('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function editKarts(data) {
|
||||||
|
$.ajax({
|
||||||
|
type: 'PUT',
|
||||||
|
crossDomain: true,
|
||||||
|
url: api_url + 'karts/1/',
|
||||||
|
dataType: 'json',
|
||||||
|
data: data,
|
||||||
|
success: function (data, status) {
|
||||||
|
$.notify("Update done!", "success");
|
||||||
|
showKarts();
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
$.notify("APIs unreachable!", "error");
|
||||||
|
console.log('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDriver(id) {
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
crossDomain: true,
|
||||||
|
url: api_url + 'drivers/'+id+'/',
|
||||||
|
dataType: 'json',
|
||||||
|
success: function (data, status) {
|
||||||
|
$('#id').val(data.id);
|
||||||
|
$('#autonomy').val(data.autonomy);
|
||||||
|
$('#stand_minimum_time').val(data.stand_minimum_time);
|
||||||
|
$('#default_relay').val(data.default_relay);
|
||||||
|
$('#comment').val(data.comment);
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
$.notify("APIs unreachable!", "error");
|
||||||
|
console.log('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function editDriver(data) {
|
||||||
|
$.ajax({
|
||||||
|
type: 'PUT',
|
||||||
|
crossDomain: true,
|
||||||
|
url: api_url + 'drivers/1/',
|
||||||
|
dataType: 'json',
|
||||||
|
data: data,
|
||||||
|
success: function (data, status) {
|
||||||
|
$.notify("Update done!", "success");
|
||||||
|
getPilotsByKart();
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
$.notify("APIs unreachable!", "error");
|
||||||
|
console.log('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
1
js/var_conf.js
Normal file
1
js/var_conf.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
var api_url = 'http://timelaps.local:8000/api/v1/';
|
68
karts.html
68
karts.html
@ -195,7 +195,8 @@
|
|||||||
<div class="card-header py-3">
|
<div class="card-header py-3">
|
||||||
<h6 class="m-0 font-weight-bold text-primary">
|
<h6 class="m-0 font-weight-bold text-primary">
|
||||||
Karting list -
|
Karting list -
|
||||||
<a href="#" class="btn btn-primary btn-circle" data-toggle="modal" data-target="#modal_newkart">
|
<a href="#" class="btn btn-primary btn-circle" data-toggle="modal"
|
||||||
|
data-target="#modal_newkart">
|
||||||
<i class="fas fa-plus"></i>
|
<i class="fas fa-plus"></i>
|
||||||
</a>
|
</a>
|
||||||
</h6>
|
</h6>
|
||||||
@ -215,42 +216,6 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<!---
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<a href="#" class="btn btn-primary btn-circle">
|
|
||||||
<i class="fas fa-edit"></i>
|
|
||||||
</a>
|
|
||||||
<a href="#" class="btn btn-danger btn-circle">
|
|
||||||
<i class="fas fa-trash"></i>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td>OCK 1</td>
|
|
||||||
<td>150</td>
|
|
||||||
<td>45</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<a href="#" class="btn btn-primary btn-circle">
|
|
||||||
<i class="fas fa-edit"></i>
|
|
||||||
</a>
|
|
||||||
<a href="#" class="btn btn-danger btn-circle">
|
|
||||||
<i class="fas fa-trash"></i>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td>OCK 2</td>
|
|
||||||
<td>150</td>
|
|
||||||
<td>45</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<a href="#" class="btn btn-primary btn-circle"><i class="fas fa-edit"></i></a><a href="#" class="btn btn-danger btn-circle"><i class="fas fa-trash"></i></a>
|
|
||||||
</td>
|
|
||||||
<td>OCK 3</td>
|
|
||||||
<td>150</td>
|
|
||||||
<td>45</td>
|
|
||||||
</tr>
|
|
||||||
-->
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -264,7 +229,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- End of Main Content -->
|
<!-- End of Main Content -->
|
||||||
|
|
||||||
<div class="modal fade" id="modal_newkart" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
<div class="modal fade" id="modal_newkart" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
|
||||||
|
aria-hidden="true">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
@ -273,15 +239,20 @@
|
|||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<form>
|
<form id="kartForm">
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
<input type="hidden" class="form-control" id="id" value="">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="inputKartName">Name</label>
|
<label for="name">Name</label>
|
||||||
<input type="email" class="form-control" id="inputKartName" placeholder="Enter kart name">
|
<input type="text" class="form-control" id="name" placeholder="Enter kart name">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="inputAutonomy">Autonomy</label>
|
<label for="autonomy">Autonomy</label>
|
||||||
<input type="password" class="form-control" id="inputAutonomy" placeholder="Autonomy">
|
<input type="number" step="1" class="form-control" id="autonomy" placeholder="Autonomy">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="comment">Comment</label>
|
||||||
|
<textarea class="form-control" id="comment" rows="3"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
@ -326,13 +297,22 @@
|
|||||||
<script src="vendor/datatables/jquery.dataTables.min.js"></script>
|
<script src="vendor/datatables/jquery.dataTables.min.js"></script>
|
||||||
<script src="vendor/datatables/dataTables.bootstrap4.min.js"></script>
|
<script src="vendor/datatables/dataTables.bootstrap4.min.js"></script>
|
||||||
<script src="vendor/notify/notify.min.js"></script>
|
<script src="vendor/notify/notify.min.js"></script>
|
||||||
|
<script src="js/var_conf.js"></script>
|
||||||
<script src="js/timelaps.js"></script>
|
<script src="js/timelaps.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
getKartsMenu();
|
getKartsMenu();
|
||||||
showKarts();
|
listKarts();
|
||||||
|
|
||||||
|
$("#kartForm").submit(function (event) {
|
||||||
|
console.log('prevent submit');
|
||||||
|
event.preventDefault();
|
||||||
|
console.log($(this).serialize());
|
||||||
|
addKarts($( this ).serialize())
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
32
params.html
32
params.html
@ -193,26 +193,26 @@
|
|||||||
<h6 class="m-0 font-weight-bold text-primary">Race params</h6>
|
<h6 class="m-0 font-weight-bold text-primary">Race params</h6>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form method="GET" action="paramRace.php">
|
<form id="edit_params" method="GET">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="hidden" class="form-control" name="name" value="startRace">
|
<input type="hidden" class="form-control" name="id" id="id" value="1">
|
||||||
<label for="autonomie">Autonomie du karting (Minutes)</label>
|
<label for="autonomy">Autonomie du karting (Minutes)</label>
|
||||||
<input type="number" step="1" name="autonomie" class="form-control" id="autonomie"
|
<input type="number" step="1" name="autonomy" class="form-control" id="autonomy"
|
||||||
placeholder="140" value="" required="">
|
value="" required="">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="dureeRelai">Durée des relais par défaut (Minutes)</label>
|
<label for="default_relay">Durée des relais par défaut (Minutes)</label>
|
||||||
<input type="number" step="1" name="dureeRelai" class="form-control" id="dureeRelai"
|
<input type="number" step="1" name="default_relay" class="form-control" id="default_relay"
|
||||||
placeholder="45" value="" required="">
|
value="" required="">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="dureeStand">Duree dans les stands minimum (Minutes)</label>
|
<label for="stand_minimum_time">Duree dans les stands minimum (Minutes)</label>
|
||||||
<input type="number" step="1" name="dureeStand" class="form-control" id="dureeStand"
|
<input type="number" step="1" name="stand_minimum_time" class="form-control" id="stand_minimum_time"
|
||||||
placeholder="1.5" value="" required="">
|
value="" required="">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="commentaire">Commentaire</label>
|
<label for="comment">Commentaire</label>
|
||||||
<textarea class="form-control" name="commentaire" id="commentaire" rows="3"></textarea>
|
<textarea class="form-control" name="comment" id="comment" rows="3"></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary">Enregistrer</button>
|
<button type="submit" class="btn btn-primary">Enregistrer</button>
|
||||||
@ -257,12 +257,18 @@
|
|||||||
<!-- Custom scripts for all pages-->
|
<!-- Custom scripts for all pages-->
|
||||||
<script src="js/sb-admin-2.min.js"></script>
|
<script src="js/sb-admin-2.min.js"></script>
|
||||||
<script src="vendor/notify/notify.min.js"></script>
|
<script src="vendor/notify/notify.min.js"></script>
|
||||||
|
<script src="js/var_conf.js"></script>
|
||||||
<script src="js/timelaps.js"></script>
|
<script src="js/timelaps.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
getKartsMenu();
|
getKartsMenu();
|
||||||
|
getParams();
|
||||||
|
$( "#edit_params" ).submit(function( event ) {
|
||||||
|
event.preventDefault();
|
||||||
|
editParams($( this ).serialize())
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -230,6 +230,7 @@
|
|||||||
<script src="vendor/datatables/jquery.dataTables.min.js"></script>
|
<script src="vendor/datatables/jquery.dataTables.min.js"></script>
|
||||||
<script src="vendor/datatables/dataTables.bootstrap4.min.js"></script>
|
<script src="vendor/datatables/dataTables.bootstrap4.min.js"></script>
|
||||||
<script src="vendor/notify/notify.min.js"></script>
|
<script src="vendor/notify/notify.min.js"></script>
|
||||||
|
<script src="js/var_conf.js"></script>
|
||||||
<script src="js/timelaps.js"></script>
|
<script src="js/timelaps.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user