Skip to content

Commit

Permalink
Complete set before Viva
Browse files Browse the repository at this point in the history
  • Loading branch information
malithjkmt committed Jun 18, 2016
1 parent 16c2cf7 commit 20ed25d
Show file tree
Hide file tree
Showing 25 changed files with 1,015 additions and 88 deletions.
10 changes: 9 additions & 1 deletion client/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ $font-stack: Helvetica, sans-serif;
.map-container {
height: 500px;
}
.map-containerHome{
height: 600px;
}

.map-container-subscribe {
height: 400px;
Expand Down Expand Up @@ -110,7 +113,12 @@ $font-stack: Helvetica, sans-serif;

#addRoute{
float: right;
margin-top: 15%;
margin-right: 5%;
}

#addRouteBack{
margin-left: 5%;
float: left;
}

#routeForm{
Expand Down
15 changes: 10 additions & 5 deletions imports/startup/client/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,27 @@ Router.configure({
});


Router.route('/map', function () {
Router.route('/map/:_id', function () {
this.layout('myLayout', {
data: function () {
return "GT2 Map";
return "GT2 Live";
}
});
this.render('mapView', {
data: {
route_id: this.params._id
}
});
this.render('mapView');
this.render('nav', {to: 'nav'});

});




Router.route('/', function () {
this.layout('myLayout', {
data: function () {
return "GT2 Home";
return "GT2";
}
});
this.render('home');
Expand Down
119 changes: 87 additions & 32 deletions imports/ui/pages/addRoute/addRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@ var startPointSelected = false;
var endPointSelected = false



Template.addRouteTruckDriver.onCreated(function () {
// Subscribe to DB
Meteor.subscribe('trucks');
Meteor.subscribe('drivers');
});

/*
Template.addRouteMap.onRendered(function () {
startTime = document.getElementById('startTime').value;
});
*/

Template.addRouteMap.helpers({
geolocationError: function () {
Expand Down Expand Up @@ -78,13 +73,15 @@ Template.addRouteMap.helpers({

Template.addRouteMap.events({
'click #startingPoint'(event) {
// Starting point
if (startingPointMarker) {
startingPointMarker.setMap(null);
}
startSelectingState = true;
disableEnable(true);
},
'click #endingPoint'(event) {
// Ending point
if (endingPointMarker) {
endingPointMarker.setMap(null);
}
Expand All @@ -94,10 +91,12 @@ Template.addRouteMap.events({


},
// Add Marker
'click #addMarker'(event) {
addMarkerState = true;
document.getElementById('addMarker').disabled = true;
},
// Undo marker
'click #undo'(event) {
// remove the current route from the history
drawingHistory.pop();
Expand All @@ -114,9 +113,9 @@ Template.addRouteMap.events({

Template.addRouteDateTime.events({
'click #next'(event){
// get values from inputs
var startTime = document.getElementById('startTime').value;

var startDay = document.getElementById('startDay').value;
var startDay = document.getElementById('startDay').value;
Session.set('startTime', startTime);
Session.set('startDay', startDay);

Expand Down Expand Up @@ -150,29 +149,98 @@ Template.addRouteTruckDriver.events({
if (driverNIC && truckNO) {
Meteor.call('occupyTime', Session.get('startTime'), Session.get('startDay'), driverNIC, truckNO);
}


},
'click #addRouteBack'(event){
Router.go('/addRouteDateTime');
}
});

Template.addRouteTruckDriver.helpers({
// return available driver names
driversNames() {
var startTime = Session.get('startTime');
var startDay = Session.get('startDay');
var startTimeEnd = '2011-04-11T'+startTime;

var yu = new Date(startTimeEnd);
yu.setHours( yu.getHours() + 3 ); // this 3 is the time to travel the route + rest time
startTimeEnd = moment(yu).format('HH:mm');
console.log('startTime= '+ startTime +", startTimeEnd= "+startTimeEnd);

var drivers = Drivers.find().fetch();

var options = [];
var busyHours;

drivers.forEach(function (driver) {
options.push({label: driver.name, value: driver.nic});
});
var busy = false;
if(driver.busyHours){ busyHours = JSON.parse(driver.busyHours);
busyHours.forEach(function (item) {
if(item.day == startDay ){
// console.log(item.startTime);
var time = '2011-04-11T'+item.startTime;
var tt = moment(time).format('HH:mm');

if(tt > startTime && tt < startTimeEnd){
busy = true;
console.log('busy');
}
}
});}

if(!busy){
options.push({label: driver.name, value: driver.nic});
}

});
if(options.length == 0){
options.push({label: "no available drivers for that date time", value: 4456});
}
return options;
},
// return available trucks
truckNo() {
console.log(Session.get('startTime'));
console.log(Session.get('startDay'));

var startTime = Session.get('startTime');
var startDay = Session.get('startDay');
var startTimeEnd = '2011-04-11T'+startTime;

var yu = new Date(startTimeEnd);
yu.setHours( yu.getHours() + 3 ); // this 3 is the time to travel the route + rest time
startTimeEnd = moment(yu).format('HH:mm');
console.log('startTime= '+ startTime +", startTimeEnd= "+startTimeEnd);

var trucks = Trucks.find().fetch();

var options = [];
var busyHours;

trucks.forEach(function (truck) {
options.push({label: truck.license, value: truck.license});
var busy = false;
if(truck.busyHours){
busyHours = JSON.parse(truck.busyHours);
busyHours.forEach(function (item) {
if(item.day == startDay ){
// console.log(item.startTime);
var time = '2011-04-11T'+item.startTime;
var tt = moment(time).format('HH:mm');

if(tt > startTime && tt < startTimeEnd){
busy = true;
console.log('busy');
}
}
});
}

if(!busy){
options.push({label: truck.license, value: truck.license});
}

});
if(options.length == 0){
options.push({label: "no available trucks for that date time", value: 4456});
}
return options;
},
get_completeRoute(){
Expand All @@ -188,7 +256,7 @@ Template.addRouteTruckDriver.helpers({

Template.addRouteMap.onCreated(function () {


// Run only after Google API loaded
GoogleMaps.ready('addRouteMap', function (addRouteMap) {
console.log("I'm ready!");

Expand Down Expand Up @@ -253,6 +321,7 @@ Template.addRouteMap.onCreated(function () {
});
});

// ge the route path from Google API
function displayRoute(origin, destination, service, display) {
service.route({
origin: origin,
Expand Down Expand Up @@ -292,6 +361,7 @@ function disableEnable(value) {

}

// add route direction arrows
function fx(o) {
if (o && o.legs) {
for (l = 0; l < o.legs.length; ++l) {
Expand Down Expand Up @@ -320,20 +390,7 @@ function fx(o) {
}
}

Template.addRouteMap.rendered = function () {
// $('.clockpicker').clockpicker();
/* Meteor.typeahead.inject();
$('.tooltipped').tooltip({delay: 50});
*/
};

/* <div class="input-group clockpicker" data-placement="right" data-align="top" data-autoclose="true">
{{> afQuickField name='startTime' icon = "query_builder" type="text" }}
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
*/
// genereate route according to the selected start and end points
function generateRoute() {

if (startingPointMarker) {
Expand Down Expand Up @@ -417,8 +474,6 @@ function generateRoute() {
var child = document.getElementById("addRouteButtons1");
parent.removeChild(child);

/*document.getElementById('addRouteButtons1').style.visibility = 'hidden';
document.getElementById('addRouteButtons1').style.height = '0';*/

document.getElementById('addRouteButtons2').style.visibility = 'visible';
document.getElementById('addRouteButtons2').style.height = 'auto';
Expand Down
25 changes: 25 additions & 0 deletions imports/ui/pages/addRoute/addRouteDateTime.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<template name="addRouteDateTime">

<div class="container" id="routeForm">

{{#autoForm collection="Routes" id="addNewRouteForm2" type="insert"}}

<div class="card checkBoxCard">
<!-- input start time-->
{{> afQuickField name='startTime' id='startTime' icon = "query_builder" type="time" placeholder = "9:00 AM"}}
</div>

<div class="card checkBoxCard">
<!-- select days-->
{{> afQuickField name="day" id='startDay' icon = "date_range" firstOption="Select day" type="select" options=dayOptions}}

</div>

{{/autoForm}}


<button id="next" type="click" class="btn waves-effect">Next</button>

</div>

</template>
41 changes: 41 additions & 0 deletions imports/ui/pages/addRoute/addRouteTruckDriver.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<template name="addRouteTruckDriver">


{{#autoForm collection="Routes" id="addNewRouteForm" type="insert"}}

{{> afFieldInput name="mapRoute" id='routeMap' value= get_completeRoute}}
{{> afFieldInput name="active" value=false}}


<div id="hiddenInputs">
{{> afQuickField name='startTime' type="hidden" value= get_startTime}}
{{> afFieldInput name="day" type="hidden" value= get_startDay}}


</div>
<div class="card checkBoxCard" >
<!-- select garbage types-->

{{> afQuickField name='biodegradable' id='biodegradable' type="boolean-checkbox" }}
{{> afQuickField name='nonBiodegradable' id='nonBiodegradable' type="boolean-checkbox" }}
</div>

<div class="card checkBoxCard" id="pop">
<div class="row">
<div class="col s6">
{{> afFieldInput name="driverNIC" id='driverNIC' options=driversNames type="select" firstOption="Select a driver"}}

</div>
<div class="col s6">
{{> afFieldInput name="TruckNO" id='truckNO' options=truckNo type="select" firstOption="Select a truck" }}
</div>

</div>
</div>

<button id="addRouteBack" type="submit" class="btn waves-effect">Back</button>
<button id="addRoute" type="submit" class="btn waves-effect">Save</button>


{{/autoForm}}
</template>
Loading

0 comments on commit 20ed25d

Please sign in to comment.