Merge pull request #662 from hargata/Hargata/gps.integration
further hardening
This commit is contained in:
@@ -164,6 +164,7 @@
|
||||
vehicleId: @Model.Id,
|
||||
odometerOptional: @Model.OdometerOptional.ToString().ToLower(),
|
||||
hasOdometerAdjustment: @Model.HasOdometerAdjustment.ToString().ToLower(),
|
||||
useEngineHours: @Model.UseHours.ToString().ToLower(),
|
||||
odometerDifference: decodeHTMLEntities('@Model.OdometerDifference'),
|
||||
odometerMultiplier: decodeHTMLEntities('@Model.OdometerMultiplier')
|
||||
};
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="alert alert-warning alert-dismissable" role="alert">
|
||||
@translator.Translate(userLanguage, "Experimental Feature - Your browser must be granted access to your precise location and support Geolocation and Wakelock API for this feature to function. Do not exit or minimize this app when recording. Verify all starting and ending odometers. Accuracy subject to hardware limitations.")
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
@translator.Translate(userLanguage, "Experimental Feature - Do not exit or minimize this app when recording. Verify all starting and ending odometers. Accuracy subject to hardware limitations.")
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -61,7 +60,7 @@
|
||||
<div class="input-group-text">
|
||||
<button type="button" class="btn btn-sm btn-primary zero-y-padding" onclick="getLastOdometerReadingAndIncrement('odometerRecordMileage')"><i class="bi bi-plus"></i></button>
|
||||
</div>
|
||||
<div class="input-group-text">
|
||||
<div class="input-group-text trip-show d-none">
|
||||
<button type="button" class="btn btn-sm btn-danger zero-y-padding" onclick="showTripModal()"><i class="bi bi-record-fill"></i></button>
|
||||
</div>
|
||||
}
|
||||
@@ -144,4 +143,5 @@
|
||||
function getOdometerRecordModelData() {
|
||||
return { id: @Model.Id}
|
||||
}
|
||||
checkTripRecorder();
|
||||
</script>
|
||||
File diff suppressed because one or more lines are too long
@@ -263,10 +263,10 @@ function startRecording() {
|
||||
});
|
||||
});
|
||||
} catch (err) {
|
||||
errorSwal('Location Services not Enabled');
|
||||
errorToast('Location Services not Enabled');
|
||||
}
|
||||
} else {
|
||||
errorSwal('Browser does not support GeoLocation and/or WakeLock API');
|
||||
errorToast('Browser does not support GeoLocation and/or WakeLock API');
|
||||
}
|
||||
}
|
||||
function recordPosition(position) {
|
||||
@@ -298,7 +298,17 @@ function recordPosition(position) {
|
||||
}
|
||||
}
|
||||
}
|
||||
function stopRecording() {
|
||||
function stopRecording(errMsg) {
|
||||
if (errMsg && errMsg.code) {
|
||||
switch (errMsg.code) {
|
||||
case 1:
|
||||
errorToast(errMsg.message);
|
||||
break;
|
||||
case 2:
|
||||
errorToast("Location Unavailable");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tripTimer != undefined) {
|
||||
clearInterval(tripTimer);
|
||||
tripTimer = undefined;
|
||||
@@ -364,4 +374,12 @@ function toggleSubOdometer() {
|
||||
} else {
|
||||
$(".trip-odometer-sub").addClass("d-none");
|
||||
}
|
||||
}
|
||||
function checkTripRecorder() {
|
||||
//check if connection is https, browser supports required API, and that vehicle does not use engine hours
|
||||
if (location.protocol != 'https:' || !navigator.geolocation || !navigator.wakeLock || GetVehicleId().useEngineHours) {
|
||||
$(".trip-show").remove();
|
||||
} else {
|
||||
$(".trip-show").removeClass('d-none');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user