Merge branch '424-cmb-release' of gitlab.com:jankstudio/resq into 466-cmb-rider-name-label
This commit is contained in:
commit
6ff3ae8dbe
5 changed files with 135 additions and 17 deletions
|
|
@ -56,3 +56,8 @@ rider_priority_down_jo:
|
||||||
path: /riders/{id}/priority_down/{jo_id}
|
path: /riders/{id}/priority_down/{jo_id}
|
||||||
controller: App\Controller\RiderController::priorityDownJO
|
controller: App\Controller\RiderController::priorityDownJO
|
||||||
methods: [GET]
|
methods: [GET]
|
||||||
|
|
||||||
|
rider_ajax_avialable:
|
||||||
|
path: /riders/{id}/available
|
||||||
|
controller: App\Controller\RiderController::ajaxAvailable
|
||||||
|
methods: [GET]
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ class DashboardMap {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.rider_markers = rider_markers;
|
this.rider_markers = rider_markers;
|
||||||
this.cust_markers = cust_markers;
|
this.cust_markers = cust_markers;
|
||||||
|
this.rider_availability = {};
|
||||||
|
|
||||||
// layer groups
|
// layer groups
|
||||||
this.layer_groups = {
|
this.layer_groups = {
|
||||||
|
|
@ -146,6 +147,49 @@ class DashboardMap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
putMarkerWithLabel(id, lat, lng, markers, icon, layer_group, popup_url, name) {
|
||||||
|
var my = this;
|
||||||
|
// existing marker
|
||||||
|
if (markers.hasOwnProperty(id)) {
|
||||||
|
markers[id].setLatLng(L.latLng(lat, lng));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// new marker
|
||||||
|
// add label
|
||||||
|
markers[id] = L.marker(
|
||||||
|
[lat, lng],
|
||||||
|
{ icon: icon }
|
||||||
|
);
|
||||||
|
|
||||||
|
var marker_label = id + ' - ' + name;
|
||||||
|
|
||||||
|
markers[id].bindTooltip(marker_label,
|
||||||
|
{
|
||||||
|
permanent: true,
|
||||||
|
direction: 'right'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
markers[id].addTo(layer_group);
|
||||||
|
|
||||||
|
if (my.options.enable_popup) {
|
||||||
|
markers[id].bindPopup('Loading...');
|
||||||
|
|
||||||
|
// bind ajax for popup
|
||||||
|
markers[id].on('click', function(e) {
|
||||||
|
var popup = e.target.getPopup();
|
||||||
|
var url = popup_url.replace('[id]', id);
|
||||||
|
console.log(url);
|
||||||
|
$.get(url).done(function(data) {
|
||||||
|
popup.setContent(data);
|
||||||
|
popup.update();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
putCustomerMarker(id, lat, lng) {
|
putCustomerMarker(id, lat, lng) {
|
||||||
this.putMarker(
|
this.putMarker(
|
||||||
id,
|
id,
|
||||||
|
|
@ -170,6 +214,8 @@ class DashboardMap {
|
||||||
|
|
||||||
this.layer_groups.customer.removeLayer(markers[id]);
|
this.layer_groups.customer.removeLayer(markers[id]);
|
||||||
this.layer_groups.mobile_customer.removeLayer(markers[id]);
|
this.layer_groups.mobile_customer.removeLayer(markers[id]);
|
||||||
|
|
||||||
|
delete markers[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
putMobileCustomerMarker(id, lat, lng) {
|
putMobileCustomerMarker(id, lat, lng) {
|
||||||
|
|
@ -184,27 +230,29 @@ class DashboardMap {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
putRiderAvailableMarker(id, lat, lng) {
|
putRiderAvailableMarker(id, lat, lng, name) {
|
||||||
this.putMarker(
|
this.putMarkerWithLabel(
|
||||||
id,
|
id,
|
||||||
lat,
|
lat,
|
||||||
lng,
|
lng,
|
||||||
this.rider_markers,
|
this.rider_markers,
|
||||||
this.options.icons.rider_available,
|
this.options.icons.rider_available,
|
||||||
this.layer_groups.rider_available,
|
this.layer_groups.rider_available,
|
||||||
this.options.rider_popup_url
|
this.options.rider_popup_url,
|
||||||
|
name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
putRiderActiveJOMarker(id, lat, lng) {
|
putRiderActiveJOMarker(id, lat, lng, name) {
|
||||||
this.putMarker(
|
this.putMarkerWithLabel(
|
||||||
id,
|
id,
|
||||||
lat,
|
lat,
|
||||||
lng,
|
lng,
|
||||||
this.rider_markers,
|
this.rider_markers,
|
||||||
this.options.icons.rider_active_jo,
|
this.options.icons.rider_active_jo,
|
||||||
this.layer_groups.rider_active_jo,
|
this.layer_groups.rider_active_jo,
|
||||||
this.options.rider_popup_url
|
this.options.rider_popup_url,
|
||||||
|
name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -219,6 +267,8 @@ class DashboardMap {
|
||||||
|
|
||||||
this.layer_groups.rider_active_jo.removeLayer(markers[id]);
|
this.layer_groups.rider_active_jo.removeLayer(markers[id]);
|
||||||
this.layer_groups.rider_available.removeLayer(markers[id]);
|
this.layer_groups.rider_available.removeLayer(markers[id]);
|
||||||
|
|
||||||
|
delete markers[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
loadLocations(location_url) {
|
loadLocations(location_url) {
|
||||||
|
|
@ -252,11 +302,12 @@ class DashboardMap {
|
||||||
$.each(riders, function(id, data) {
|
$.each(riders, function(id, data) {
|
||||||
var lat = data.latitude;
|
var lat = data.latitude;
|
||||||
var lng = data.longitude;
|
var lng = data.longitude;
|
||||||
|
var name = '';
|
||||||
|
|
||||||
if (data.has_jo)
|
if (data.has_jo)
|
||||||
my.putRiderActiveJOMarker(id, lat, lng);
|
my.putRiderActiveJOMarker(id, lat, lng, name);
|
||||||
else
|
else
|
||||||
my.putRiderAvailableMarker(id, lat, lng);
|
my.putRiderAvailableMarker(id, lat, lng, name);
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log(rider_markers);
|
// console.log(rider_markers);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
class MapEventHandler {
|
class MapEventHandler {
|
||||||
constructor(options, dashmap) {
|
constructor(options, dashmap, ssl) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.dashmap = dashmap;
|
this.dashmap = dashmap;
|
||||||
|
this.ssl = ssl;
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(user_id, host, port) {
|
connect(user_id, host, port) {
|
||||||
|
|
@ -11,7 +12,7 @@ class MapEventHandler {
|
||||||
|
|
||||||
this.mqtt = new Paho.MQTT.Client(host, port, client_id);
|
this.mqtt = new Paho.MQTT.Client(host, port, client_id);
|
||||||
var options = {
|
var options = {
|
||||||
// useSSL: true,
|
useSSL: this.ssl,
|
||||||
timeout: 3,
|
timeout: 3,
|
||||||
invocationContext: this,
|
invocationContext: this,
|
||||||
onSuccess: this.onConnect.bind(this),
|
onSuccess: this.onConnect.bind(this),
|
||||||
|
|
@ -35,6 +36,10 @@ class MapEventHandler {
|
||||||
// subscribe to rider status
|
// subscribe to rider status
|
||||||
console.log('subscribing to ' + my.options.channels.rider_status);
|
console.log('subscribing to ' + my.options.channels.rider_status);
|
||||||
my.mqtt.subscribe(my.options.channels.rider_status);
|
my.mqtt.subscribe(my.options.channels.rider_status);
|
||||||
|
|
||||||
|
// subscribe to rider availability
|
||||||
|
console.log('subscribing to ' + my.options.channels.rider_availability);
|
||||||
|
my.mqtt.subscribe(my.options.channels.rider_availability);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (my.options.track_jo) {
|
if (my.options.track_jo) {
|
||||||
|
|
@ -55,7 +60,7 @@ class MapEventHandler {
|
||||||
|
|
||||||
onMessage(msg) {
|
onMessage(msg) {
|
||||||
// console.log(msg);
|
// console.log(msg);
|
||||||
console.log('received message');
|
// console.log('received message');
|
||||||
|
|
||||||
var channel = msg.destinationName;
|
var channel = msg.destinationName;
|
||||||
var chan_split = channel.split('/');
|
var chan_split = channel.split('/');
|
||||||
|
|
@ -73,12 +78,50 @@ class MapEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleRider(chan_split, payload) {
|
handleRider(chan_split, payload) {
|
||||||
console.log("rider message");
|
// console.log("rider message");
|
||||||
|
var rider_id = chan_split[1];
|
||||||
switch (chan_split[2]) {
|
switch (chan_split[2]) {
|
||||||
|
case "availability":
|
||||||
|
console.log("got availability for rider " + chan_split[1] + " - " + payload);
|
||||||
|
var obj = JSON.parse(payload);
|
||||||
|
|
||||||
|
var status = obj.status;
|
||||||
|
console.log("status " + status);
|
||||||
|
switch (status) {
|
||||||
|
case 'rider_offline':
|
||||||
|
this.dashmap.rider_availability[chan_split[1]] = false;
|
||||||
|
this.dashmap.removeRiderMarker(chan_split[1]);
|
||||||
|
break;
|
||||||
|
case 'rider_online':
|
||||||
|
this.dashmap.rider_availability[chan_split[1]] = true;
|
||||||
|
var lat = parseFloat(obj.latitude);
|
||||||
|
var lng = parseFloat(obj.longitude);
|
||||||
|
|
||||||
|
// cheeck if rider is available / unavailable
|
||||||
|
// TODO: make url not hardcoded
|
||||||
|
var dashmap = this.dashmap;
|
||||||
|
$.get('https://cmbdev.wildcard.cc/riders/' + chan_split[1] + '/available').done(function(data) {
|
||||||
|
console.log('rider availability - ' + data);
|
||||||
|
switch (data) {
|
||||||
|
case 'available':
|
||||||
|
console.log('putting available marker ' + chan_split[1] + ' ' + lat + ':' + lng);
|
||||||
|
dashmap.switchRiderStatus(chan_split[1], 'available');
|
||||||
|
dashmap.putRiderAvailableMarker(chan_split[1], lat, lng);
|
||||||
|
break;
|
||||||
|
case 'unavailable':
|
||||||
|
console.log('putting active jo marker ' + chan_split[1] + ' ' + lat + ':' + lng);
|
||||||
|
dashmap.switchRiderStatus(chan_split[1], 'jo');
|
||||||
|
dashmap.putRiderActiveJOMarker(chan_split[1], lat, lng);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "location":
|
case "location":
|
||||||
console.log("got location for rider " + chan_split[1] + " - " + payload);
|
// console.log("got location for rider " + chan_split[1] + " - " + payload
|
||||||
var pl_split = payload.split(':');
|
var pl_split = payload.split(':');
|
||||||
console.log(pl_split);
|
// console.log(pl_split);
|
||||||
|
|
||||||
// check for correct format
|
// check for correct format
|
||||||
if (pl_split.length != 2)
|
if (pl_split.length != 2)
|
||||||
|
|
@ -87,8 +130,21 @@ class MapEventHandler {
|
||||||
var lat = parseFloat(pl_split[0]);
|
var lat = parseFloat(pl_split[0]);
|
||||||
var lng = parseFloat(pl_split[1]);
|
var lng = parseFloat(pl_split[1]);
|
||||||
|
|
||||||
// TODO: check if available or not
|
var display_marker = true;
|
||||||
this.dashmap.putRiderAvailableMarker(chan_split[1], lat, lng);
|
if (this.dashmap.rider_availability.hasOwnProperty(chan_split[1])) {
|
||||||
|
if (!this.dashmap.rider_availability[chan_split[1]]) {
|
||||||
|
console.log('NOT displaying marker for inactive rider');
|
||||||
|
display_marker = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('rider not in availability check');
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: cache rider availability (available vs active jo) status and check before displaying icon
|
||||||
|
// NOTE: we really should fix our terms since available can mean many things
|
||||||
|
if (display_marker) {
|
||||||
|
this.dashmap.putRiderAvailableMarker(chan_split[1], lat, lng);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "status":
|
case "status":
|
||||||
console.log("got status for rider " + chan_split[1] + " - " + payload);
|
console.log("got status for rider " + chan_split[1] + " - " + payload);
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,13 @@ class CMBServiceType extends NameValue
|
||||||
{
|
{
|
||||||
const BATTERY_REPLACEMENT_NEW = 'battery_new';
|
const BATTERY_REPLACEMENT_NEW = 'battery_new';
|
||||||
const BATTERY_REPLACEMENT_WARRANTY = 'battery_warranty';
|
const BATTERY_REPLACEMENT_WARRANTY = 'battery_warranty';
|
||||||
|
const WARRANTY_CLAIM = 'warranty_claim';
|
||||||
const JUMPSTART = 'jumpstart';
|
const JUMPSTART = 'jumpstart';
|
||||||
|
|
||||||
const COLLECTION = [
|
const COLLECTION = [
|
||||||
'battery_new' => 'Battery Sales',
|
'battery_new' => 'Battery Sales',
|
||||||
'battery_warranty' => 'Under Warranty',
|
'battery_warranty' => 'Warranty Replacement',
|
||||||
|
'warranty_claim' => 'Warranty Claim',
|
||||||
'jumpstart' => 'Jumpstart',
|
'jumpstart' => 'Jumpstart',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,10 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface
|
||||||
case CMBServiceType::BATTERY_REPLACEMENT_WARRANTY:
|
case CMBServiceType::BATTERY_REPLACEMENT_WARRANTY:
|
||||||
$this->processWarranty($total, $criteria, $invoice);
|
$this->processWarranty($total, $criteria, $invoice);
|
||||||
break;
|
break;
|
||||||
|
case CMBServiceType::WARRANTY_CLAIM:
|
||||||
|
// TODO: this will change once we confirm what needs to be computed
|
||||||
|
$this->processOtherServices($total, $invoice, $stype);
|
||||||
|
break;
|
||||||
//case ServiceType::POST_RECHARGED:
|
//case ServiceType::POST_RECHARGED:
|
||||||
// $this->processRecharge($total, $invoice);
|
// $this->processRecharge($total, $invoice);
|
||||||
// break;
|
// break;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue