-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Export screen to show more accurate log data
This is a pretty update to how the Export screen works and how the log data is modified. The Export screen component was rewritten as a functional component in order to take advantage of hooks. The use for the hooks is to update the log data details when the Export component comes in to focus. The old version would only update the data once since the component would mount and never unmount leading to stale data. The new Export component will update the log details each time the view comes in to focus. The log details have now been broken up in to 3 sections: Total time the log covers, Number of points logged, and Time since last updated. The LocationService has been updated with a new class called LocationData. This take the old saveLocation method and makes it an instance method on the LocationData class. This also allows access to the location data that is in memory in order for the Export screen to show more accurate details. The LocationService has been updated to use this new class when saving the location data.
- Loading branch information
1 parent
df02c39
commit 476ac48
Showing
14 changed files
with
617 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,47 @@ | ||
export function convertPointsToString(count) { | ||
// For testing Manually override count | ||
// count = 3000 | ||
|
||
// Get minutes | ||
let tot_mins = count * 5; | ||
|
||
// Calculate days | ||
let days = tot_mins / 60 / 24; | ||
let rdays = Math.floor(days); | ||
|
||
// Calculate Hours | ||
let hours = (days - rdays) * 24; | ||
let rhours = Math.floor(hours); | ||
|
||
// Calculate Minutes | ||
let minutes = (hours - rhours) * 60; | ||
let rminutes = Math.round(minutes); | ||
|
||
if (rdays > 0) { | ||
if (rdays > 1) { | ||
if (rhours > 1) { | ||
return ( | ||
rdays + ' days, ' + rhours + ' hours and ' + rminutes + ' minutes.' | ||
); | ||
} else { | ||
return ( | ||
rdays + ' days, ' + rhours + ' hour and ' + rminutes + ' minutes.' | ||
); | ||
} | ||
} else { | ||
if (rhours > 1) { | ||
return ( | ||
rdays + ' day, ' + rhours + ' hours and ' + rminutes + ' minutes.' | ||
); | ||
} else { | ||
return ( | ||
rdays + ' day, ' + rhours + ' hour and ' + rminutes + ' minutes.' | ||
); | ||
} | ||
} | ||
} else if (rhours > 0) { | ||
if (rhours > 1) { | ||
return rhours + ' hours and ' + rminutes + ' minutes.'; | ||
} else { | ||
return rhours + ' hour and ' + rminutes + ' minutes.'; | ||
} | ||
} else { | ||
return rminutes + ' minutes.'; | ||
import pluralize from 'pluralize'; | ||
import languages from './../locales/languages'; | ||
|
||
export function timeSincePoint(point) { | ||
if (!point) { | ||
return languages.t('label.no_data'); | ||
} | ||
|
||
const pointDays = point ? daysDifferenceFromNow(point.time) : null; | ||
const pointHours = point ? hoursDifferenceFromNow(point.time) : null; | ||
const pointMinutes = point ? minutesDifferenceFromNow(point.time) : null; | ||
const pointTime = [ | ||
pointDays > 0 ? pluralize('day', pointDays, true) : null, | ||
pointHours > 0 ? pluralize('hour', pointHours, true) : null, | ||
pointMinutes > 0 | ||
? pluralize('minute', pointMinutes, true) | ||
: languages.t('label.less_than_one_minute'), | ||
] | ||
.filter(item => item) | ||
.join(' '); | ||
|
||
return pointTime; | ||
} | ||
|
||
function daysDifferenceFromNow(timestamp) { | ||
var difference = now() - timestamp; | ||
var daysDifference = Math.floor(difference / 1000 / 60 / 60 / 24); | ||
return daysDifference; | ||
} | ||
|
||
function hoursDifferenceFromNow(timestamp) { | ||
var difference = now() - timestamp; | ||
var hoursDifference = Math.floor(difference / 1000 / 60 / 60); | ||
return hoursDifference % 24; | ||
} | ||
|
||
function minutesDifferenceFromNow(timestamp) { | ||
var difference = now() - timestamp; | ||
var minutesDifference = Math.floor(difference / 1000 / 60); | ||
|
||
return minutesDifference % 60; | ||
} | ||
|
||
function now() { | ||
let nowUTC = new Date().toISOString(); | ||
return Date.parse(nowUTC); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.