Skip to content

Commit

Permalink
Move DannyLuu:dev (#577) to evancohen:dl/fitbitSquash
Browse files Browse the repository at this point in the history
* 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
justbill2020 authored and evancohen committed Mar 4, 2017
1 parent a5bed17 commit e4b035f
Show file tree
Hide file tree
Showing 16 changed files with 555 additions and 136 deletions.
19 changes: 18 additions & 1 deletion app/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ ul.calendar {

.fitbit-title {
margin-right: 10px;
font-size: 24px;
font-size: 28px;
}

.fitbit-subtitle {
Expand All @@ -258,6 +258,23 @@ ul.calendar {
width: 450px;
}

.fitbit-goals {
float: right;
width: 60%;
}

.fitbit-progress-bar {
position: relative;
width: 50%;
height: 5px;
background-color: grey;
}

.fitbit-progress {
position: absolute;
height: 100%;
}

.playing-track img {
float: left;
margin-right: 5px;
Expand Down
26 changes: 26 additions & 0 deletions app/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,31 @@
"voice": "(Schalte) (das) (die) Licht(er) *action",
"description": "Steuert Farbe und Helligkeit von Lichtern."
}
},
"fitbit": {
"user": "DE_User: ",
"averageSteps": "DE_Average Steps: ",
"batteryStatus": "DE_Battery Status: ",
"today": "DE_Today",
"steps": "DE_steps",
"averageSteps": "DE_steps a day",
"caloriesBurned": "DE_calories burned",
"lastSync": "DE_Last Sync",
"average": "DE_Average",
"activeMinutes": "DE_active minutes",
"distance": "DE_km",
"floors": "DE_floors",
"topBadges": "DE_Top Badges",
"sleep": "DE_Sleep",
"lastNight": "DE_Last Night",
"awake": "DE_Awake",
"restless": "DE_Restless",
"hours": "DE_hrs",
"km": "DE_km",
"miles": "DE_mi",
"minutes": "DE_min",
"times": "DE_x",
"restingHR": "DE_resting heart rate",
"bpm": "DE_bpm"
}
}
26 changes: 26 additions & 0 deletions app/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,31 @@
"voice": "Show remote (QR code) (QR) (link)",
"description": "Show the local IP of the Remote App URL"
}
},
"fitbit": {
"user": "User: ",
"averageSteps": "Average Steps: ",
"batteryStatus": "Battery Status: ",
"today": "Today",
"steps": "steps",
"averageSteps": "steps a day",
"caloriesBurned": "calories burned",
"lastSync": "Last Sync",
"average": "Average",
"activeMinutes": "active minutes",
"distance": "km",
"floors": "floors",
"topBadges": "Top Badges",
"sleep": "Sleep",
"lastNight": "Last Night",
"awake": "Awake",
"restless": "Restless",
"hours": "hrs",
"km": "km",
"miles": "mi",
"minutes": "min",
"times": "x",
"restingHR": "resting heart rate",
"bpm": "bpm"
}
}
26 changes: 26 additions & 0 deletions app/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,31 @@
"voice": ":state las luces a *action",
"description": "Cambia el estado de las luces."
}
},
"fitbit": {
"user": "ES_User: ",
"averageSteps": "ES_Average Steps: ",
"batteryStatus": "ES_Battery Status: ",
"today": "ES_Today",
"steps": "ES_steps",
"averageSteps": "ES_steps a day",
"caloriesBurned": "ES_calories burned",
"lastSync": "ES_Last Sync",
"average": "ES_Average",
"activeMinutes": "ES_active minutes",
"distance": "ES_km",
"floors": "ES_floors",
"topBadges": "ES_Top Badges",
"sleep": "ES_Sleep",
"lastNight": "ES_Last Night",
"awake": "ES_Awake",
"restless": "ES_Restless",
"hours": "ES_hrs",
"km": "ES_km",
"miles": "ES_mi",
"minutes": "ES_min",
"times": "ES_x",
"restingHR": "ES_resting heart rate",
"bpm": "ES_bpm"
}
}
26 changes: 26 additions & 0 deletions app/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,31 @@
"voice": "(Montre(-moi)|Affiche) le lien du serveur",
"description": "Affiche le lien de l'application"
}
},
"fitbit": {
"user": "FR_User: ",
"averageSteps": "FR_Average Steps: ",
"batteryStatus": "FR_Battery Status: ",
"today": "FR_Today",
"steps": "FR_steps",
"averageSteps": "FR_steps a day",
"caloriesBurned": "FR_calories burned",
"lastSync": "FR_Last Sync",
"average": "FR_Average",
"activeMinutes": "FR_active minutes",
"distance": "FR_km",
"floors": "FR_floors",
"topBadges": "FR_Top Badges",
"sleep": "FR_Sleep",
"lastNight": "FR_Last Night",
"awake": "FR_Awake",
"restless": "FR_Restless",
"hours": "FR_hrs",
"km": "FR_km",
"miles": "FR_mi",
"minutes": "FR_min",
"times": "FR_x",
"restingHR": "FR_resting heart rate",
"bpm": "FR_bpm"
}
}
26 changes: 26 additions & 0 deletions app/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,31 @@
"voice": "불 :state *action (해)줘",
"description": "불 :state *action (해)줘."
}
},
"fitbit": {
"user": "KO_User: ",
"averageSteps": "KO_Average Steps: ",
"batteryStatus": "KO_Battery Status: ",
"today": "KO_Today",
"steps": "KO_steps",
"averageSteps": "KO_steps a day",
"caloriesBurned": "KO_calories burned",
"lastSync": "KO_Last Sync",
"average": "KO_Average",
"activeMinutes": "KO_active minutes",
"distance": "KO_km",
"floors": "KO_floors",
"topBadges": "KO_Top Badges",
"sleep": "KO_Sleep",
"lastNight": "KO_Last Night",
"awake": "KO_Awake",
"restless": "KO_Restless",
"hours": "KO_hrs",
"km": "KO_km",
"miles": "KO_mi",
"minutes": "KO_min",
"times": "KO_x",
"restingHR": "KO_resting heart rate",
"bpm": "KO_bpm"
}
}
26 changes: 26 additions & 0 deletions app/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,31 @@
"voice": "(alterar) :state (a) (as) luz(es) *action",
"description": "Controlar cor e brilho das luzes Hue."
}
},
"fitbit": {
"user": "PT_User: ",
"averageSteps": "PT_Average Steps: ",
"batteryStatus": "PT_Battery Status: ",
"today": "PT_Today",
"steps": "PT_steps",
"averageSteps": "PT_steps a day",
"caloriesBurned": "PT_calories burned",
"lastSync": "PT_Last Sync",
"average": "PT_Average",
"activeMinutes": "PT_active minutes",
"distance": "PT_km",
"floors": "PT_floors",
"topBadges": "PT_Top Badges",
"sleep": "PT_Sleep",
"lastNight": "PT_Last Night",
"awake": "PT_Awake",
"restless": "PT_Restless",
"hours": "PT_hrs",
"km": "PT_km",
"miles": "PT_mi",
"minutes": "PT_min",
"times": "PT_x",
"restingHR": "PT_resting heart rate",
"bpm": "PT_bpm"
}
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h1 ng-controller="Greeting" ng-bind="greeting" ng-cloak></h1>
<div class="partial-result" ng-bind="partialResult" ng-hide="speechError"></div>
</div>
<div class="bottom-left">
<div ng-include="'plugins/fitbit/index.html'" ng-if="fitbit"></div>
<div ng-include="'plugins/fitbit/index.html'"></div>
<div ng-include="'plugins/scrobbler/index.html'"></div>
</div>
<div class="bottom-right">
Expand Down
2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const powerSaveBlocker = electron.powerSaveBlocker
powerSaveBlocker.start('prevent-display-sleep')

// Launching the mirror in dev mode
const DevelopmentMode = (process.argv.indexOf("dev") > -1)
const DevelopmentMode = process.argv[2] === "dev"

// Load the smart mirror config
let config
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@
"wiredep-cli": "^0.1.0"
},
"dependencies": {
"angular-moment": "^1.0.1",
"annyang": "^2.6.0",
"electron-json-storage": "2.0.0",
"express": "^4.14.0",
"fitbit-oauth2": "0.0.1",
"hyperion-client": "1.0.3",
"moment": "^2.17.1",
"socket.io": "^1.6.0",
"sonus": "^0.1.7"
},
Expand All @@ -60,11 +62,11 @@
"no-console": 0
},
"globals": {
"angular": false,
"annyang": false,
"moment": false,
"config": false,
"RRule": false
"angular": false,
"annyang": false,
"moment": false,
"config": false,
"RRule": false
}
}
}
98 changes: 87 additions & 11 deletions plugins/fitbit/controller.js
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);
Loading

0 comments on commit e4b035f

Please sign in to comment.