Compare commits

...

14 commits

Author SHA1 Message Date
Korina Cordero
9502fbe9cf Merge branch '457-cmb-add-telephone-number-to-search' into '424-cmb-release'
Merge branch '458-cmb-service-type-transaction-names' of...

See merge request jankstudio/resq!548
2020-08-14 09:28:32 +00:00
Korina Cordero
b1d397c127 Merge branch '458-cmb-service-type-transaction-names' of gitlab.com:jankstudio/resq into 457-cmb-add-telephone-number-to-search 2020-08-14 09:26:37 +00:00
Korina Cordero
5de7410cb4 Merge branch '466-cmb-rider-name-label' into '424-cmb-release'
Uncomment SSL. #466

See merge request jankstudio/resq!547
2020-08-14 09:17:36 +00:00
Korina Cordero
3c470177ea Uncomment SSL. #466 2020-08-14 09:16:36 +00:00
Korina Cordero
abc11e6913 Merge branch '466-cmb-rider-name-label' into '424-cmb-release'
Resolve "CMB - rider name label"

See merge request jankstudio/resq!545
2020-08-14 09:14:04 +00:00
Korina Cordero
bf5a5c602f Fix issues with rider names. #466 2020-08-14 09:01:27 +00:00
Korina Cordero
9a444051e4 Create rider cache for rider names. #466 2020-08-14 07:01:09 +00:00
Korina Cordero
6ff3ae8dbe Merge branch '424-cmb-release' of gitlab.com:jankstudio/resq into 466-cmb-rider-name-label 2020-08-14 04:27:42 +00:00
Korina Cordero
66e46c4bad Merge branch '457-cmb-add-telephone-number-to-search' into '424-cmb-release'
Remove rider name from labels in Dashboard. #457

See merge request jankstudio/resq!539
2020-08-06 08:39:04 +00:00
Korina Cordero
b20c61a830 Remove rider name from labels in Dashboard. #457 2020-08-06 08:38:02 +00:00
Korina Cordero
b9706ede89 Merge branch '457-cmb-add-telephone-number-to-search' into '424-cmb-release'
Remove log messages. #457

See merge request jankstudio/resq!538
2020-08-05 10:32:25 +00:00
Korina Cordero
90918c49ef Merge branch '458-cmb-service-type-transaction-names' into '424-cmb-release'
Resolve "CMB - service type transaction names"

See merge request jankstudio/resq!533
2020-08-05 09:47:01 +00:00
Korina Cordero
8006545242 Merge branch '457-cmb-add-telephone-number-to-search' into '424-cmb-release'
Resolve "CMB - add telephone number to search"

See merge request jankstudio/resq!535
2020-08-05 09:46:31 +00:00
Korina Cordero
74039a8011 Set service types to battery sales, warranty replacement, jumpstart, and warranty claim. #458 2020-08-05 06:48:17 +00:00
7 changed files with 208 additions and 20 deletions

View file

@ -56,3 +56,14 @@ rider_priority_down_jo:
path: /riders/{id}/priority_down/{jo_id}
controller: App\Controller\RiderController::priorityDownJO
methods: [GET]
rider_ajax_avialable:
path: /riders/{id}/available
controller: App\Controller\RiderController::ajaxAvailable
methods: [GET]
rider_ajax_rider_name:
path: /riders/{id}/name
controller: App\Controller\RiderController::ajaxRiderName
methods: [GET]

View file

@ -3,6 +3,8 @@ class DashboardMap {
this.options = options;
this.rider_markers = rider_markers;
this.cust_markers = cust_markers;
this.rider_availability = {};
this.rider_names = {};
// layer groups
this.layer_groups = {
@ -146,6 +148,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) {
this.putMarker(
id,
@ -170,6 +215,8 @@ class DashboardMap {
this.layer_groups.customer.removeLayer(markers[id]);
this.layer_groups.mobile_customer.removeLayer(markers[id]);
delete markers[id];
}
putMobileCustomerMarker(id, lat, lng) {
@ -184,27 +231,29 @@ class DashboardMap {
);
}
putRiderAvailableMarker(id, lat, lng) {
this.putMarker(
putRiderAvailableMarker(id, lat, lng, name) {
this.putMarkerWithLabel(
id,
lat,
lng,
this.rider_markers,
this.options.icons.rider_available,
this.layer_groups.rider_available,
this.options.rider_popup_url
this.options.rider_popup_url,
name
);
}
putRiderActiveJOMarker(id, lat, lng) {
this.putMarker(
putRiderActiveJOMarker(id, lat, lng, name) {
this.putMarkerWithLabel(
id,
lat,
lng,
this.rider_markers,
this.options.icons.rider_active_jo,
this.layer_groups.rider_active_jo,
this.options.rider_popup_url
this.options.rider_popup_url,
name
);
}
@ -219,6 +268,8 @@ class DashboardMap {
this.layer_groups.rider_active_jo.removeLayer(markers[id]);
this.layer_groups.rider_available.removeLayer(markers[id]);
delete markers[id];
}
loadLocations(location_url) {
@ -252,14 +303,43 @@ class DashboardMap {
$.each(riders, function(id, data) {
var lat = data.latitude;
var lng = data.longitude;
var name = '';
if (data.has_jo)
my.putRiderActiveJOMarker(id, lat, lng);
else
my.putRiderAvailableMarker(id, lat, lng);
if (my.rider_names.hasOwnProperty(id)) {
name = my.rider_names[id];
if (data.has_jo)
my.putRiderActiveJOMarker(id, lat, lng, name);
else
my.putRiderAvailableMarker(id, lat, lng, name)
} else {
getRiderName(id, my.options.rider_name_url, function(name) {
my.rider_names[id] = name;
if (data.has_jo)
my.putRiderActiveJOMarker(id, lat, lng, name);
else
my.putRiderAvailableMarker(id, lat, lng, name)
});
}
});
// console.log(rider_markers);
});
}
}
function getRiderName(id, url, callback) {
var name = '';
var rider_url = url.replace('[id]', id);
$.ajax({
method: "GET",
url: rider_url
}).done(function(response) {
name = response.rider_name;
callback(name);
});
}

View file

@ -1,7 +1,8 @@
class MapEventHandler {
constructor(options, dashmap) {
constructor(options, dashmap, ssl) {
this.options = options;
this.dashmap = dashmap;
this.ssl = ssl;
}
connect(user_id, host, port) {
@ -11,7 +12,7 @@ class MapEventHandler {
this.mqtt = new Paho.MQTT.Client(host, port, client_id);
var options = {
// useSSL: true,
useSSL: this.ssl,
timeout: 3,
invocationContext: this,
onSuccess: this.onConnect.bind(this),
@ -35,6 +36,10 @@ class MapEventHandler {
// subscribe to rider status
console.log('subscribing to ' + 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) {
@ -55,7 +60,7 @@ class MapEventHandler {
onMessage(msg) {
// console.log(msg);
console.log('received message');
// console.log('received message');
var channel = msg.destinationName;
var chan_split = channel.split('/');
@ -73,12 +78,50 @@ class MapEventHandler {
}
handleRider(chan_split, payload) {
console.log("rider message");
// console.log("rider message");
var rider_id = chan_split[1];
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":
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(':');
console.log(pl_split);
// console.log(pl_split);
// check for correct format
if (pl_split.length != 2)
@ -87,8 +130,21 @@ class MapEventHandler {
var lat = parseFloat(pl_split[0]);
var lng = parseFloat(pl_split[1]);
// TODO: check if available or not
this.dashmap.putRiderAvailableMarker(chan_split[1], lat, lng);
var display_marker = true;
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;
case "status":
console.log("got status for rider " + chan_split[1] + " - " + payload);

View file

@ -596,4 +596,38 @@ class RiderController extends Controller
return $this->redirecttoRoute('rider_update', ['id' => $rider->getID()]);
}
/**
* @ParamConverter("rider", class="App\Entity\Rider")
*/
public function ajaxAvailable(EntityManagerInterface $em, Rider $rider)
{
$jo = $rider->getRiderActiveJobOrder();
if ($jo == null || $jo->isClosed())
$avail = 'available';
else
$avail = 'unavailable';
$response = new Response(
$avail,
Response::HTTP_OK,
['content-type' => 'text/plain']
);
return $response;
}
/**
* @ParamConverter("rider", class="App\Entity\Rider")
*/
public function ajaxRiderName(EntityManagerInterface $em, Rider $rider)
{
$rider_name = '';
if ($rider != null)
$rider_name = $rider->getFullName();
return $this->json([
'rider_name' => $rider_name,
]);
}
}

View file

@ -6,11 +6,13 @@ class CMBServiceType extends NameValue
{
const BATTERY_REPLACEMENT_NEW = 'battery_new';
const BATTERY_REPLACEMENT_WARRANTY = 'battery_warranty';
const WARRANTY_CLAIM = 'warranty_claim';
const JUMPSTART = 'jumpstart';
const COLLECTION = [
'battery_new' => 'Battery Sales',
'battery_warranty' => 'Under Warranty',
'battery_warranty' => 'Warranty Replacement',
'warranty_claim' => 'Warranty Claim',
'jumpstart' => 'Jumpstart',
];
}

View file

@ -86,6 +86,10 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface
case CMBServiceType::BATTERY_REPLACEMENT_WARRANTY:
$this->processWarranty($total, $criteria, $invoice);
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:
// $this->processRecharge($total, $invoice);
// break;

View file

@ -35,7 +35,8 @@ function initMap(r_markers, c_markers, icons) {
'zoom': 13,
'rider_popup_url': '/riders/[id]/popup',
'cust_popup_url': '/job-order/[id]/popup',
'icons': icons
'icons': icons,
'rider_name_url': '/riders/[id]/name'
};
var dashmap = new DashboardMap(options, r_markers, c_markers);