Skip to content

Commit

Permalink
Merge pull request #1022 from QuantiModo/feature/location_info
Browse files Browse the repository at this point in the history
Location tracking info
  • Loading branch information
mikepsinn committed Feb 8, 2017
2 parents dfd4809 + dc065cb commit 6916efb
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 116 deletions.
42 changes: 21 additions & 21 deletions www/js/controllers/appCtrl.js
Expand Up @@ -176,15 +176,15 @@ angular.module('starter')

$scope.goToVariableSettingsForCauseVariable = function(correlationObject) {
if(correlationObject.causeVariable){
$rootScope.goToVariableSettingsForVariableObject(correlationObject.causeVariable);
$state.go('app.variableSettings', {variableObject: correlationObject.causeVariable});
} else {
$state.go('app.variableSettings', {variableName: correlationObject.causeVariableName});
}
};

$scope.goToVariableSettingsForEffectVariable = function(correlationObject) {
if(correlationObject.effectVariable){
$rootScope.goToVariableSettingsForVariableObject(correlationObject.effectVariable);
$state.go('app.variableSettings', {variableObject: correlationObject.effectVariable});
} else {
$state.go('app.variableSettings', {variableName: correlationObject.effectVariableName});
}
Expand Down Expand Up @@ -363,15 +363,6 @@ angular.module('starter')
quantimodoService.setLocalStorageItem(flagName, true);
};

$rootScope.hideHelpCard = function () {
var card = $rootScope.defaultHelpCards[0];
card.hide = true;
$rootScope.defaultHelpCards = $rootScope.defaultHelpCards.filter(function( obj ) {
return obj.id !== card.id;
});
quantimodoService.deleteElementOfLocalStorageItemById('defaultHelpCards', card.id);
};

// open datepicker for "from" date
$scope.openFromDatePicker = function () {
ionicDatePicker.openDatePicker($scope.fromDatePickerObj);
Expand Down Expand Up @@ -418,7 +409,6 @@ angular.module('starter')
});
};

var helpPopupMessages = config.appSettings.helpPopupMessages || false;

$scope.showHelpInfoPopup = function (ev, id) {
// Appending dialog to document.body to cover sidenav in docs app
Expand Down Expand Up @@ -1228,10 +1218,6 @@ angular.module('starter')
});
};

$rootScope.goToVariableSettingsForVariableObject = function (variableObject) {
$state.go('app.variableSettings', {variableObject: variableObject, variableName: variableObject.name});
};

// Triggered on a button click, or some other target
$scope.showFavoriteActionSheet = function(favorite, $index, bloodPressure) {

Expand Down Expand Up @@ -1443,14 +1429,14 @@ angular.module('starter')
quantimodoService.deleteItemFromLocalStorage('lastStudy');
console.debug("quantimodoService.postUserVariableDeferred: success: " + JSON.stringify(params));
$ionicLoading.hide();
$rootScope.goBack();
$scope.goBack();
}, function(error) {
$ionicLoading.hide();
console.error(error);
});
};

$rootScope.goBack = function () {
$scope.goBack = function () {
if($ionicHistory.viewHistory().backView){
$ionicHistory.goBack();
} else {
Expand Down Expand Up @@ -2077,9 +2063,7 @@ angular.module('starter')
if($rootScope.trackLocation && !skipPopup){
$ionicPopup.alert({
title: 'Location Tracking Enabled',
template: 'By automatically recording your location we can try to gain insights into the effects ' +
' of time spent at the gym, certain restaurants, or work. Another benefit is that it keeps the ' +
' app running the background so it opens instantly instead of taking a few seconds to load.'
template: $rootScope.variableCategories.Location.moreInfo
});
quantimodoService.updateLocationVariablesAndPostMeasurementIfChanged();
}
Expand All @@ -2102,6 +2086,22 @@ angular.module('starter')
quantimodoService.showAlert(title, template, subTitle);
};

$scope.showMaterialAlert = function(ev, title, textContent) {
// Appending dialog to document.body to cover sidenav in docs app
// Modal dialogs should fully cover application
// to prevent interaction outside of dialog
$mdDialog.show(
$mdDialog.alert()
.parent(angular.element(document.querySelector('#popupContainer')))
.clickOutsideToClose(true)
.title(title)
.textContent(textContent)
.ariaLabel(title)
.ok('Got it!')
.targetEvent(ev)
);
};

if(!$scope.subscriptionPlanId){
$scope.subscriptionPlanId = 'monthly7';
}
Expand Down
5 changes: 2 additions & 3 deletions www/js/controllers/chartsPageCtrl.js
Expand Up @@ -43,8 +43,7 @@ angular.module('starter')
};

$scope.editSettingsButtonClick = function() {
$rootScope.goToVariableSettingsForVariableObject($rootScope.variableObject);

$state.go('app.variableSettings', {variableObject: $rootScope.variableObject});
};


Expand Down Expand Up @@ -296,7 +295,7 @@ angular.module('starter')
$scope.goToHistoryForVariableObject($rootScope.variableObject);
}
if (index === 4) {
$rootScope.goToVariableSettingsForVariableObject($rootScope.variableObject);
$state.go('app.variableSettings', {variableObject: $rootScope.variableObject});
}
if (index === 5) {
$scope.addTag($rootScope.variableObject);
Expand Down
49 changes: 16 additions & 33 deletions www/js/controllers/importCtrl.js
@@ -1,25 +1,26 @@
angular.module('starter')

// controls the Import Data page of the app
.controller('ImportCtrl', function($scope, $ionicLoading, $state, $rootScope, quantimodoService,
$cordovaOauth, $ionicPopup, $stateParams) {

$scope.controller_name = "ImportCtrl";

$rootScope.showFilterBarSearchIcon = false;

/*// redirect if not logged in
if(!$rootScope.user){

$state.go(config.appSettings.welcomeState);
// app wide signal to sibling controllers that the state has changed
$rootScope.$broadcast('transition');
}*/
$scope.$on('$ionicView.beforeEnter', function(e) {
console.debug("ImportCtrl beforeEnter");
if (typeof Bugsnag !== "undefined") { Bugsnag.context = $state.current.name; }
if (typeof analytics !== 'undefined') { analytics.trackView($state.current.name); }
$ionicLoading.show();
if(true || $rootScope.isMobile || $stateParams.native){
loadNativeConnectorPage();
} else {
goToWebImportDataPage();
}
});

// close the loader
window.closeLoading = function(){
$ionicLoading.hide();
};
$scope.hideImportHelpCard = function () {
$scope.showImportHelpCard = false;
window.localStorage.showImportHelpCard = false;
};

var goToWebImportDataPage = function() {
console.debug('importCtrl.init: Going to quantimodoService.getAccessTokenFromAnySource');
Expand Down Expand Up @@ -63,6 +64,7 @@ angular.module('starter')
};

var loadNativeConnectorPage = function(){
$scope.showImportHelpCard = (window.localStorage.hideImportHelpCard !== true);
console.debug('importCtrl: $rootScope.isMobile so using native connector page');
quantimodoService.getConnectorsDeferred()
.then(function(connectors){
Expand All @@ -78,23 +80,4 @@ angular.module('starter')
});
};

// constructor
var init = function(){
console.debug($state.current.name + ' initializing...');
$rootScope.stateParams = $stateParams;
if (typeof Bugsnag !== "undefined") { Bugsnag.context = $state.current.name; }
if (typeof analytics !== 'undefined') { analytics.trackView($state.current.name); }
$ionicLoading.show({ template: '<ion-spinner></ion-spinner>' });

if(true || $rootScope.isMobile || $stateParams.native){
loadNativeConnectorPage();
} else {
goToWebImportDataPage();
}
};

$scope.$on('$ionicView.beforeEnter', function(e) { console.debug("Entering state " + $state.current.name);
init();
});

});
14 changes: 6 additions & 8 deletions www/js/controllers/onboardingCtrl.js
Expand Up @@ -27,7 +27,6 @@ angular.module('starter')

$scope.$on('$ionicView.afterEnter', function(){
console.debug("OnboardingCtrl afterEnter");
quantimodoService.setupHelpCards(true);
quantimodoService.getConnectorsDeferred(); // Make sure they're ready in advance
});

Expand All @@ -53,15 +52,15 @@ angular.module('starter')
quantimodoService.setLocalStorageItem('onboardingPages', JSON.stringify(onboardingPages));
};

$rootScope.onboardingGoToImportPage = function () {
$scope.onboardingGoToImportPage = function () {
$rootScope.hideHomeButton = true;
$rootScope.hideMenuButton = true;
removeImportPage();
$rootScope.onboardingPages[0].nextPageButtonText = "Done connecting data sources";
$state.go('app.import');
};

$rootScope.skipOnboarding = function () {
$scope.skipOnboarding = function () {
$rootScope.hideMenuButton = false;
window.localStorage.onboarded = true;
$state.go(config.appSettings.defaultState);
Expand All @@ -71,7 +70,7 @@ angular.module('starter')
$scope.onHelpButtonPress($rootScope.onboardingPages[0].title, $rootScope.onboardingPages[0].moreInfo);
};

$rootScope.goToReminderSearchCategoryFromOnboarding = function() {
$scope.goToReminderSearchCategoryFromOnboarding = function() {
$rootScope.hideHomeButton = true;
$rootScope.hideMenuButton = true;
if(!$rootScope.user){
Expand All @@ -84,20 +83,19 @@ angular.module('starter')
$scope.goToReminderSearchCategory($rootScope.onboardingPages[0].variableCategoryName);
};

$rootScope.enableLocationTracking = function () {
$scope.enableLocationTracking = function () {
$rootScope.trackLocationChange(true, true);
$rootScope.hideOnboardingPage();
};

$rootScope.doneOnboarding = function () {
$scope.doneOnboarding = function () {
$state.go('app.remindersInbox');
$rootScope.hideMenuButton = false;
window.localStorage.onboarded = true;
quantimodoService.deleteItemFromLocalStorage('onboardingPages');
//$rootScope.onboardingPages = null;
};

$rootScope.hideOnboardingPage = function () {
$scope.hideOnboardingPage = function () {

$rootScope.onboardingPages = $rootScope.onboardingPages.filter(function( obj ) {
return obj.id !== $rootScope.onboardingPages[0].id;
Expand Down
11 changes: 10 additions & 1 deletion www/js/controllers/remindersInboxCtrl.js
Expand Up @@ -39,6 +39,7 @@ angular.module('starter')
$scope.$on('$ionicView.beforeEnter', function(e) {

console.debug("RemindersInboxCtrl beforeEnter ");
$scope.defaultHelpCards = quantimodoService.setupHelpCards();

$scope.loading = true;
if(!$rootScope.accessTokenInUrl && !$rootScope.user){
Expand Down Expand Up @@ -159,7 +160,6 @@ angular.module('starter')
$scope.state.showAddVitalSignButton = config.appSettings.remindersInbox.showAddVitalSignButton;
}


var setPageTitle = function(){
if(typeof(config.appSettings.remindersInbox.title) !== 'undefined'){
//$scope.state.title = config.appSettings.remindersInbox.title;
Expand Down Expand Up @@ -610,4 +610,13 @@ angular.module('starter')
}, 20000);

};

$scope.hideHelpCard = function () {
var card = $scope.defaultHelpCards[0];
card.hide = true;
$scope.defaultHelpCards = $scope.defaultHelpCards.filter(function( obj ) {
return obj.id !== card.id;
});
quantimodoService.deleteElementOfLocalStorageItemById('defaultHelpCards', card.id);
};
});
4 changes: 2 additions & 2 deletions www/js/controllers/upgradeCtrl.js
Expand Up @@ -17,11 +17,11 @@ angular.module('starter')
});

$scope.$on('$ionicView.leave', function(){
$rootScope.hideNavigationMenu = false; console.debug('$rootScope.hideNavigationMenu = false');

});

$scope.$on('$ionicView.beforeLeave', function(){

$rootScope.hideNavigationMenu = false; console.debug('$rootScope.hideNavigationMenu = false');
});

$scope.$on('$ionicView.afterLeave', function(){
Expand Down

0 comments on commit 6916efb

Please sign in to comment.