Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table with the current positions of vehicles and status added to the map #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions RouteWebApplication/WebContent/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,49 @@ ul.navbar-nav > li > a {
}

div#map {
position: fixed;
height: 100%;
position: absolute;
height: 100vh;
width: 75%;
bottom: 0px;
top: 0px;
left: 0px;
right: 0px;
z-index: -1000;
z-index: 1;
}

div#infoBar {
margin-left: 85%;
width: 40vh;
height: 85vh;
overflow:auto;

}

div#infoBarEmbedded {
margin-left: 85%;
top: 5px;
width:40vh;
height: 100vh;
overflow:auto;

}

html, body {

width:100%;
height: 100%;
overflow-y: hidden;
overflow-x:auto;
}


div#caption {
position: absolute;
z-index: 2;
}



.h1, h1 {
padding-bottom: 1em;
}
Expand Down
39 changes: 30 additions & 9 deletions RouteWebApplication/WebContent/index-embedded.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,40 @@
</head>
<body>
<div class="my-tab-pane" id="section-1">

<div class="container">
<div class="row">
<div class="col-sm-12">
<h1>London Traffic Control</h1>
</div>

<div class="col-sm-9" id="caption">
<h1>London Traffic Control</h1>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-12">
</div>


<div class="col-sm-9" id="map"></div>
</div>

<div class="col-sm-3" id="infoBarEmbedded">

<table class="table table-bordered text-center"
id="infoTable">
<thead>

<tr>
<th id="vehicleID">Vehicle ID</th>
<th id="info">Info</th>


</tr>

</thead>

<tbody>


</tbody>
</table>
</div>
<div id="map" ></div>

</div>
</div>
</body>
Expand Down
38 changes: 23 additions & 15 deletions RouteWebApplication/WebContent/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,38 @@
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed"
data-toggle="collapse" data-target="#fhue" aria-expanded="false">
<span class="sr-only">Toggle navigation</span> <span
class="icon-bar"></span> <span class="icon-bar"></span> <span
class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img
src="images/capgeminiLogo.png"></a>
</div>
</div>
</nav>
<div class="my-tab-pane" id="section-1">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="col-sm-9" id="caption">
<h1>London Traffic Control</h1>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-12"></div>
</div>
<div id="map"></div>
<div class="col-sm-9" id="map"></div>
<div class="col-sm-2" id="infoBar">

<table class="table table-bordered text-center"
id="infoTable">
<thead>

<tr>
<th id="vehicleID">Vehicle ID</th>
<th id="info">Info</th>


</tr>

</thead>

<tbody>


</tbody>
</table>
</div>
</div>
</div>
</body>
Expand Down
57 changes: 56 additions & 1 deletion RouteWebApplication/WebContent/js/TrafficMonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,32 @@ var TrafficMonitor = (function(conf) {
c.ts = new Date();
c.addTo(map);
ambulances[car.vin] = c;

if (car.isFree == 'true') {

addRow(car.vin, 'GPS : (' + car.latitude + ', ' + car.longitude
+ ') </br> Status : free');

} else {

addRow(car.vin, 'GPS : (' + car.latitude + ', ' + car.longitude
+ ') </br> Status : busy');

}
} else {
var content;
if (car.isFree == 'true') {
content = 'GPS : (' + car.latitude + ', ' + car.longitude
+ ') </br> Status : free';

} else {
content = '(' + car.latitude + ', ' + car.longitude
+ ') </br> Status : busy';
}

$('#infoTable').find('tr#' + car.vin).find('td:eq(1)').html(
content);

}

c.moveTo([ car.latitude, car.longitude ], (new Date() - c.ts));
Expand All @@ -208,12 +234,41 @@ var TrafficMonitor = (function(conf) {

c.ts = new Date();
c.addTo(map);
cars[car.vin] = c;
cars[car.vin] = c;

addRow(car.vin, 'GPS : (' + car.latitude + ', ' + car.longitude
+ ')');
}
else {
var content = 'GPS : (' + car.latitude + ', ' + car.longitude + ')';
$('#infoTable').find('tr#' + car.vin).find('td:eq(1)').html(
content);

}
c.moveTo([ car.latitude, car.longitude ], (new Date() - c.ts));
c.ts = new Date();

}

function addRow(vehicleID, info) {
var table = document.getElementById('infoTable')
.getElementsByTagName('tbody')[0];
var row = table.insertRow(0);
row.id = vehicleID;
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
cell1.innerHTML = vehicleID;
cell2.innerHTML = info;

var tbody = $('#infoTable').find('tbody');
var newRows = tbody.find('tr').sort(
function(a, b) {
return $('td:first', a).text().localeCompare(
$('td:first', b).text());
});
tbody.append(newRows);

}

function update(car) {
if (car.vin.indexOf("ambulance") > -1) {
Expand Down