Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Additional IndexedDB work
  • Loading branch information
audaciouscode committed Aug 7, 2017
1 parent 42f3997 commit 7cfa2c9
Show file tree
Hide file tree
Showing 6 changed files with 610 additions and 435 deletions.
2 changes: 1 addition & 1 deletion www/scripts/controllers/daily_check_in.js
Expand Up @@ -503,7 +503,7 @@ angular.module('livewellApp').controller('DailyCheckInCtrl', function($scope, $l
}, function() {
Database.updateClinicalStatus(function() {
Database.updateDailyReachout(function() {
Database.filter('clinial_reachout', 'updated', IDBKeyRange.lowerBound(0), "prev", function(cursor) {
Database.filter('clinical_reachout', 'updated', IDBKeyRange.lowerBound(0), "prev", function(cursor) {
$scope.emergency = false;
$scope.reachoutMessage = null;

Expand Down
24 changes: 22 additions & 2 deletions www/scripts/controllers/fetch_content.js
Expand Up @@ -8,7 +8,7 @@
* Controller of the livewellApp
*/

angular.module('livewellApp').controller('FetchContentCtrl', function ($scope,$http) {
angular.module('livewellApp').controller('FetchContentCtrl', function ($scope, $http, Database) {
// var SERVER_LOCATION = 'https://livewell2.firebaseio.com/';
var SERVER_LOCATION = 'https://livewellcss.northwestern.edu/firebase-proxy/';
var SECURE_CONTENT = 'https://mohrlab.northwestern.edu/livewell-dash/content/';
Expand Down Expand Up @@ -75,6 +75,17 @@ angular.module('livewellApp').controller('FetchContentCtrl', function ($scope,$h
if (oldStatus == undefined || oldStatus == null) {
console.log('SAVE 1: ' + JSON.stringify(response));
localStorage[el.route] = JSON.stringify(response);

var dbObject = {
updated: Date.now(),
status_code: response['currentCode'],
version: response['version'],
source: 'server'
};

Database.insertWithCallback('clinical_status', dbObject, function() {
console.log('STATUS CODE INITED: ' + JSON.stringify(dbObject))
});
} else {
oldStatus = JSON.parse(oldStatus);

Expand All @@ -90,7 +101,16 @@ angular.module('livewellApp').controller('FetchContentCtrl', function ($scope,$h

localStorage[el.route] = JSON.stringify(newStatus);

// TODO
var dbObject = {
updated: Date.now(),
status_code: response['currentCode'],
version: response['version'],
source: 'server'
};

Database.insertWithCallback('clinical_status', dbObject, function() {
console.log('STATUS CODE UPDATED: ' + JSON.stringify(dbObject))
});
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions www/scripts/controllers/home.js
Expand Up @@ -15,6 +15,8 @@ angular.module('livewellApp').controller('HomeCtrl', function ($scope, Pound, Da
{name:"Toolbox", href:"skills", class: "btn-info"},
{name:"Wellness Plan", href:"wellness/resources", class: "btn-info"},
];

console.log('LIVEWELL');

var now = Date.now()
var studyStart = parseFloat(localStorage['startDate']);
Expand Down
34 changes: 31 additions & 3 deletions www/scripts/controllers/weekly_check_in.js
Expand Up @@ -147,8 +147,36 @@ angular.module('livewellApp').controller('WeeklyCheckInCtrl', function($scope, $
dbObject[response['name']] = parseInt(response['value']);
}

Database.insert('weekly_check_in', dbObject);

$location.path("/ews");
Database.insertWithCallback('weekly_check_in', dbObject, function() {
console.log('000001');

Database.updateWeeklyReachout(function() {
console.log('000002');

Database.filter('clinical_weekly_reachout', 'updated', IDBKeyRange.lowerBound(0), "prev", function(cursor) {
console.log("GOT MESSAGE");

$scope.reachoutMessage = null;

if (cursor != null) {
$scope.reachoutMessage = cursor.value.message
}

console.log("NEW WEEKLY REVIEW MESSAGE: " + $scope.reachoutMessage);

$scope.$apply();

$("#continue").modal();

$('#continue').on('hide.bs.modal', function (e) {
console.log('HIDE');
console.log($location);

$location.path("/ews");
$scope.$apply();
});
});
});
});
}
});

0 comments on commit 7cfa2c9

Please sign in to comment.