Skip to content

Fix client reset on start #470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 0 additions & 96 deletions www/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -677,56 +677,7 @@ background-image: none !important; }
margin: 1rem;
position: relative;
}
/* Dark theme */
/*
.tab-nav{
background-color: #212121 !important; background-size: 0 !important;
}
ion-header-bar {
background-color: #212121 !important;
}
.ion-view-background{
background-color: #303030 !important;
}
.tabs-custom-dark > .tabs,
.tabs.tabs-custom-dark {
border-color: #5D3A23;
background-color: #5D3A23;
background-image: linear-gradient(0deg, #0c60ee, #0c60ee 50%, transparent 30%);
color: #33e0bb; }
.tabs-custom-dark > .tabs .tab-item .badge,
.tabs.tabs-custom-dark .tab-item .badge {
background-color: #33e0bb;
color: #387ef5; }

.tabs-striped.tabs-custom-dark .tabs {
background-color: #5D3A23; }

.tabs-striped.tabs-custom-dark .tab-item {
color: rgba(255, 255, 255, 0.3);
opacity: 1; }
.tabs-striped.tabs-custom-dark .tab-item .badge {
opacity: 0.3; }
.tabs-striped.tabs-custom-dark .tab-item.tab-item-active, .tabs-striped.tabs-custom-dark .tab-item.active, .tabs-striped.tabs-positive .tab-item.activated {
margin-top: -2px;
color: #fff;
border-style: solid;
border-width: 2px 0 0 0;
border-color: #fff; }

.title.title-center.header-item {
color: white;
}
.date-picker-button-dark {
color: #33e0bb !important; padding: 0 15px; border-color: transparent; margin-top: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.16), 0 2px 2px rgba(0,0,0,0.23);
border-style: solid; border-color: white; border-width: 0px; border-radius: 5px;
}
.date-picker-arrow-dark {
color: rgba(51,224,187, 0.7) !important; margin-top: 4px; background-color: transparent !important;
}

*/
/* Dark theme ends */
/* Light theme */
.control-icon-button{
text-align: center;
Expand Down Expand Up @@ -776,9 +727,6 @@ ion-header-bar {
.ion-view-background{
background-color: #ededed !important;
}
.ion-view-background-dark {
background-color: #303030 !important;
}
.tabs-custom > .tabs,
.tabs.tabs-custom {
border-color: #5D3A23;
Expand Down Expand Up @@ -817,12 +765,6 @@ ion-header-bar {
/* Light theme ends */


.earlier-later-expand-dark {
color: white;
margin: 16px 16px 0 6px;
font-size: 0.8em;
opacity: 0.7;
}
.earlier-later-expand {
color: #303030;
margin: 16px 16px 0 6px;
Expand All @@ -839,35 +781,9 @@ ion-header-bar {
margin-top: 0 !important;
margin-bottom: 0!important;
}
.list-location-dark {
color: white;
background-color: transparent;
font-size: 0.8em;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 30px;
margin-top: 0 !important;
margin-bottom: 0 !important;
}
.list-location-dark {
color: white;
background-color: transparent;
font-size: 0.8em;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 30px;
margin-top: 0;
margin-bottom: 0;
}
p.list-text-dark {
color: white;
}
p.list-text {
color: #303030;
}
a.list-text-dark {
color: white;
}
a.list-text {
color: #303030;
}
Expand Down Expand Up @@ -940,9 +856,6 @@ button.button.back-button.buttons.button-clear.header-item {
.list-card {
margin: 16px 0; box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
}
.bg-dark {
background-color: #424242;
}
.bg-light {
background-color: #ffffff;
}
Expand All @@ -961,21 +874,12 @@ button.button.back-button.buttons.button-clear.header-item {
.list-col-left-margin {
text-align: center; padding: 0.7em 0.8em 0.4em 0.8em; border-right-width: 0.5px; border-right-color: #ccc; border-right-style: solid; border-bottom-color: #ccc; border-bottom-width: 0.5px; border-bottom-style: solid;
}
.list-col-left-dark-margin {
text-align: center; padding: 0.7em 0.8em 0.4em 0.8em; border-right-width: 0.5px; border-right-color: white; border-right-style: solid; border-bottom-color: white; border-bottom-width: 0.5px; border-bottom-style: solid;
}
.list-col-left {
text-align: center; padding: 1.1em 0.8em 0.6em 0.8em; border-right-width: 0.5px; border-right-color: #ccc; border-right-style: solid; border-bottom-color: #ccc; border-bottom-width: 0.5px; border-bottom-style: solid;
}
.list-col-left-dark {
text-align: center; padding: 1.1em 0.8em 0.6em 0.8em; border-right-width: 0.5px; border-right-color: white; border-right-style: solid; border-bottom-color: white; border-bottom-width: 0.5px; border-bottom-style: solid;
}
.list-col-right {
text-align: center; padding: 0.25em 0.8em; border-bottom-color: #ccc; border-bottom-width: 0.5px; border-bottom-style: solid;
}
.list-col-right-dark {
text-align: center; padding: 0.25em 0.8em; border-bottom-color: white; border-bottom-width: 0.5px; border-bottom-style: solid;
}
.start-time-tag {
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
text-align: center;
Expand Down
1 change: 1 addition & 0 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
<!--script src="js/goals/party.js"></script-->
<script src="js/goals/signup.js"></script>
<script src="js/plugin/logger.js"></script>
<script src="js/plugin/storage.js"></script>


<script src="lib/d3/d3.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion www/js/common/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ angular.module('emission.main.common.services', [])
commonGraph.data = {};
commonGraph.UPDATE_DONE = "COMMON_GRAPH_UPDATE_DONE";

var db = window.cordova.plugins.BEMUserCache;
var selKey = "common-trips";

commonGraph.createEmpty = function() {
Expand All @@ -18,6 +17,7 @@ angular.module('emission.main.common.services', [])
};

commonGraph.updateCurrent = function() {
var db = window.cordova.plugins.BEMUserCache;
db.getDocument(selKey, false).then(function(entryList) {
try{
var cmGraph = entryList;
Expand Down
108 changes: 52 additions & 56 deletions www/js/control/general-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ angular.module('emission.main.control',['emission.services',
'emission.splash.updatecheck',
'emission.main.metrics.factory',
'emission.stats.clientstats',
'angularLocalStorage',
'emission.plugin.kvstore',
'emission.plugin.logger'])

.controller('ControlCtrl', function($scope, $window, $ionicScrollDelegate,
$ionicPlatform,
$state, $ionicPopup, $ionicActionSheet, $ionicPopover,
$rootScope, storage, ionicDatePicker,
$rootScope, KVStore, ionicDatePicker,
StartPrefs, ControlHelper,
ControlCollectionHelper, ControlSyncHelper,
ControlTransitionNotifyHelper,
Expand Down Expand Up @@ -48,30 +49,37 @@ angular.module('emission.main.control',['emission.services',
};

$scope.emailLog = ControlHelper.emailLog;
$scope.dark_theme = $rootScope.dark_theme;
$scope.userData = []
$scope.getUserData = function() {
var userDataFromStorage = CalorieCal.get();
$scope.userData = []
var height = userDataFromStorage.height.toString();
var weight = userDataFromStorage.weight.toString();
var temp = {
age: userDataFromStorage.age,
height: height + (userDataFromStorage.heightUnit == 1? ' cm' : ' ft'),
weight: weight + (userDataFromStorage.weightUnit == 1? ' kg' : ' lb'),
gender: userDataFromStorage.gender == 1? 'Male' : 'Female'
}
for (var i in temp) {
$scope.userData.push({key: i, value: temp[i]});
return CalorieCal.get().then(function(userDataFromStorage) {
$scope.rawUserData = userDataFromStorage;
if ($scope.userDataSaved()) {
$scope.userData = []
var height = userDataFromStorage.height.toString();
var weight = userDataFromStorage.weight.toString();
var temp = {
age: userDataFromStorage.age,
height: height + (userDataFromStorage.heightUnit == 1? ' cm' : ' ft'),
weight: weight + (userDataFromStorage.weightUnit == 1? ' kg' : ' lb'),
gender: userDataFromStorage.gender == 1? 'Male' : 'Female'
}
for (var i in temp) {
$scope.userData.push({key: i, value: temp[i]});
}
}
});
}

$scope.userDataSaved = function() {
return CalorieCal.get().userDataSaved == true;
}
if ($scope.userDataSaved()) {
$scope.getUserData();
if (angular.isDefined($scope.rawUserData) && $scope.rawUserData != null) {
return $scope.rawUserData.userDataSaved;
} else {
return false;
}
}
$ionicPlatform.ready().then(function() {
$scope.refreshScreen();
});
$scope.getLowAccuracy = function() {
// return true: toggle on; return false: toggle off.
var isMediumAccuracy = ControlCollectionHelper.isMediumAccuracy();
Expand All @@ -86,25 +94,6 @@ angular.module('emission.main.control',['emission.services',
}
}
$scope.toggleLowAccuracy = ControlCollectionHelper.toggleLowAccuracy;
$scope.ionViewBackgroundClass = function() {
return ($scope.dark_theme)? "ion-view-background-dark" : "ion-view-background";
}
$scope.getDarkTheme = function() {
return $scope.dark_theme;
}
$scope.toggleDarkTheme = function() {
if ($scope.dark_theme) {
$rootScope.dark_theme = false;
$scope.dark_theme = false;
StartPrefs.setDefaultTheme(null);
$state.reload();
} else {
$rootScope.dark_theme = true;
$scope.dark_theme = true;
StartPrefs.setDefaultTheme('dark_theme');
$state.reload();
}
}

$scope.getConnectURL = function() {
ControlHelper.getSettings().then(function(response) {
Expand Down Expand Up @@ -165,12 +154,12 @@ angular.module('emission.main.control',['emission.services',
$state.go("root.main.map");
}
$scope.getState = function() {
ControlCollectionHelper.getState().then(function(response) {
return ControlCollectionHelper.getState().then(function(response) {
$scope.$apply(function() {
$scope.settings.collect.state = response;
});
}, function(error) {
$ionicPopup.alert("while getting email, "+error);
$ionicPopup.alert("while reading FSM state, "+error);
});
};

Expand All @@ -192,18 +181,13 @@ angular.module('emission.main.control',['emission.services',
});
}

var clearBoth = function() {
storage.clearAll();
clearUsercache();
}

$scope.nukeUserCache = function() {
var nukeChoiceActions = [{text: "UI state only",
action: storage.clearAll},
action: KVStore.clearOnlyLocal},
{text: 'Native cache only',
action: clearUsercache},
action: KVStore.clearOnlyNative},
{text: 'Everything',
action: clearBoth}];
action: KVStore.clearAll}];

$ionicActionSheet.show({
titleText: "Clear data",
Expand All @@ -229,7 +213,9 @@ angular.module('emission.main.control',['emission.services',
}

$scope.$on('$ionicView.afterEnter', function() {
$ionicPlatform.ready().then(function() {
$scope.refreshScreen();
});
})

// Execute action on hidden popover
Expand All @@ -249,15 +235,24 @@ angular.module('emission.main.control',['emission.services',
$scope.settings.auth = {};
$scope.settings.connect = {};
$scope.settings.channel = function(newName) {
return arguments.length ? (UpdateCheck.setChannel(newName)) : UpdateCheck.getChannel();
return arguments.length ? (UpdateCheck.setChannel(newName)) : $scope.settings.storedChannel;
};

UpdateCheck.getChannel().then(function(retVal) {
$scope.$apply(function() {
$scope.settings.storedChannel = retVal;
});
});
$scope.getConnectURL();
$scope.getCollectionSettings();
$scope.getSyncSettings();
$scope.getTNotifySettings();
$scope.getEmail();
$scope.getState();
$scope.getState().then($scope.isTrackingOn).then(function(isTracking) {
$scope.$apply(function() {
$scope.settings.collect.trackingOn = isTracking;
});
});
$scope.getUserData();
};

$scope.returnToIntro = function() {
Expand Down Expand Up @@ -336,18 +331,19 @@ angular.module('emission.main.control',['emission.services',
return ionic.Platform.isIOS();
}

$scope.refreshScreen();
$ionicPopover.fromTemplateUrl('templates/control/main-sync-settings.html', {
scope: $scope
}).then(function(popover) {
$scope.syncSettingsPopup = popover;
});
$scope.trackingOn = function() {
$scope.isTrackingOn = function() {
return $ionicPlatform.ready().then(function() {
if($scope.isAndroid()){
return $scope.settings.collect.state != "local.state.tracking_stopped";
} else if ($scope.isIOS()) {
return $scope.settings.collect.state != "STATE_TRACKING_STOPPED";
}
});
};
$scope.userStartStopTracking = function() {
if ($scope.startStopBtnToggle){
Expand All @@ -358,17 +354,17 @@ angular.module('emission.main.control',['emission.services',
$scope.startStopBtnToggle = true;
}
}
$scope.startStopBtnToggle = $scope.trackingOn();
$scope.startStopBtnToggle = $scope.trackingOn;
$scope.getExpandButtonClass = function() {
return ($scope.expanded)? "icon ion-ios-arrow-up" : "icon ion-ios-arrow-down";
}
$scope.getUserDataExpandButtonClass = function() {
return ($scope.dataExpanded)? "icon ion-ios-arrow-up" : "icon ion-ios-arrow-down";
}
$scope.eraseUserData = function() {
CalorieCal.delete();
CalorieCal.delete().then(function() {
$ionicPopup.alert({template: 'User data erased.'});

});
}
$scope.parseState = function(state) {
if (state) {
Expand Down
Loading