-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move DannyLuu:dev (#577) to evancohen:dl/fitbitSquash
* removed "npm" and "install" packages from dependencies * fix for conf-audio.sh removes the comment line from exported file contents * Update config.schema.json fixes #519 @DannyLuu i just updated the part that allows it to save... the UI still needs to be fixed... please keep working on it... * Add missing brace. (#542) * Adding eslint + travis (#548) * Adding eslint + travis * Remove Dependency CI and show build status * Fixing path problems and first run (#549) * use path.resolve() to get files fixing up sonus.js * updating speech config schema * remove umdl beacuse we aren't using it anymore * fix sonus error on first run * better error message on first run * oh no. 😰 * don't use kiosk mode when started with dev 🚀 * Remove error when Stock names are not filled. (#551) * Remove error when Stock names are not filled. * Add missing semi-colon * Set refresh to 30mins. * Fix browser console errors with null tv show lists. (#552) * Fix browser console errors with null tv show lists. * Fix build error. I am new to angular?! * Angular doesn't need double negations? * Fixed error with language parameter and weather (#550) * Fixed typo in language variable name * Fixed typo in language variable name * Fixed wrong moment.js lang parameter * Changed handling of the language variable handling for moment.js * v0.0.10 * Create alias for starting the smart mirror from anywhere. (#555) * Create alias for starting the smart mirror from anywhere. * Update smart mirror! * Update bashrc with subshell function. * Reload bash profile upon install. * Update install message to reflect new changes * fixing fitbit * Add english resource for Fitbit. * Cycle through Fitbit statistics. * Update controller documentation and optimized service calls. * Update fitibt css for progress bar. * Add floors to Today's stats and fixed other tags. * Update fitbit EN resource. * Shortened the progress bar. * Update init logic... my bad. * Show progress bar on daily stats. * Update progress bar ot turn green when 100% * Localizing units * Update ui to display green progress bar when over 100% * Adding comments for new enpoints that I would like to integrate. * Update english locale. * Update service and controller with new api requests. * Update fitbit index html to incorporate controller function calls. * Adding all changes. * Setting groups to cycle. * Finalizating changes. * Updated views on data displayed. * Add message resources Resources added for the languanges. WIll need translations * Replaced spaces with tabs * Found the culprit!
- Loading branch information
1 parent
a5bed17
commit e4b035f
Showing
16 changed files
with
555 additions
and
136 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
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
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,33 +1,109 @@ | ||
function Fitbit($scope, $interval, FitbitService, SpeechService) { | ||
var refreshFitbitData = function () { | ||
console.log('refreshing fitbit data'); | ||
var totalStatGroups = 4; | ||
$scope.currentStatGroup = 0; | ||
|
||
// Check if the fitbit configuration exists before initializing the service. | ||
if (typeof config.fitbit !== 'undefined') { | ||
FitbitService.init(function () { | ||
refreshFitbitData(); | ||
$interval(cycleFitbitStats, 10000); // 10 secs | ||
$interval(refreshTodaySummary, 1800000); // 30 mins | ||
$interval(refreshDeviceSummary, 3600000); // 1 hour | ||
$interval(refreshProfileSummary, 3600000 * 6); // 6 hours | ||
$interval(refreshSleepSummary, 3600000 * 6); // 6 hours | ||
$interval(refreshHeartRate, 3600000 * 6); // 6 hours | ||
$interval(refreshLifetimeSummary, 3600000 * 12); // 12 hours | ||
}); | ||
} | ||
|
||
// Profile | ||
var refreshProfileSummary = function () { | ||
FitbitService.profileSummary(function (response) { | ||
$scope.fbDailyAverage = response; | ||
$scope.profile = response; | ||
}); | ||
}; | ||
|
||
// Today | ||
var refreshTodaySummary = function () { | ||
FitbitService.todaySummary(function (response) { | ||
$scope.fbToday = response; | ||
$scope.todaySummary = response; | ||
}); | ||
}; | ||
|
||
// Sleep | ||
var refreshSleepSummary = function () { | ||
FitbitService.sleepSummary(function (response) { | ||
$scope.fbSleep = response; | ||
$scope.sleep = response; | ||
}); | ||
}; | ||
|
||
// Device | ||
var refreshDeviceSummary = function () { | ||
FitbitService.deviceSummary(function (response) { | ||
$scope.fbDevices = response; | ||
$scope.devices = response; | ||
}); | ||
}; | ||
|
||
if (typeof config.fitbit !== 'undefined') { | ||
refreshFitbitData() | ||
$interval(refreshFitbitData, config.fitbit.refreshInterval * 60000 || 3600000) | ||
} | ||
// Lifetime Statistics | ||
var refreshLifetimeSummary = function () { | ||
FitbitService.lifetimeSummary(function (response) { | ||
$scope.lifetimeSummary = response; | ||
}); | ||
}; | ||
|
||
// Heart Rate | ||
var refreshHeartRate = function () { | ||
FitbitService.heartRate(function (response) { | ||
$scope.heartRate = response; | ||
}); | ||
}; | ||
|
||
// All Data | ||
var refreshFitbitData = function () { | ||
refreshProfileSummary(); | ||
refreshTodaySummary(); | ||
refreshSleepSummary(); | ||
refreshDeviceSummary(); | ||
refreshHeartRate(); | ||
refreshLifetimeSummary(); | ||
}; | ||
|
||
// Cycle Through | ||
var cycleFitbitStats = function () { | ||
$scope.currentStatGroup = ($scope.currentStatGroup + 1) % totalStatGroups; | ||
}; | ||
|
||
// Refresh all stats | ||
// refresh some stats of specific topics? | ||
SpeechService.addCommand('show_my_walking', function () { | ||
refreshFitbitData(); | ||
}); | ||
|
||
var sleepEndDate = function(sleepStartDate, duration) { | ||
var date = new Date(sleepStartDate); | ||
date.setMilliseconds(date.getMilliseconds() + duration); | ||
return date; | ||
}; | ||
|
||
var barColour = function(current, goal) { | ||
if (current < goal) { | ||
return 'white'; | ||
} | ||
return 'lime'; | ||
}; | ||
|
||
var calculatePercent = function(current, goal) { | ||
if (current < goal) { | ||
return (100 * current/goal) + '%'; | ||
} | ||
return '100%'; | ||
}; | ||
|
||
$scope.calculatePercent = calculatePercent; | ||
$scope.barColour = barColour; | ||
$scope.sleepEndDate = sleepEndDate; | ||
|
||
} | ||
|
||
angular.module('SmartMirror') | ||
.controller('Fitbit', Fitbit); | ||
.controller('Fitbit', Fitbit); |
Oops, something went wrong.