Skip to content
This repository has been archived by the owner on Dec 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #246 from turnervink/develop
Browse files Browse the repository at this point in the history
Merge sprint 3 version into master
  • Loading branch information
AndyHaoT authored May 25, 2017
2 parents c099d55 + 4a3f309 commit 88f4c72
Show file tree
Hide file tree
Showing 60 changed files with 1,278 additions and 261 deletions.
19 changes: 14 additions & 5 deletions public/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ greenlistApp.config(["$routeProvider", function($routeProvider) {
}]
}
})

.when("/detailReports",{
templateUrl: "views/html/detailReport.html",
controller: "EfficiencyCtrl",
Expand All @@ -66,10 +65,20 @@ greenlistApp.config(["$routeProvider", function($routeProvider) {
return Auth.$requireSignIn();
}]
}


})

})
.when("/settings", {
templateUrl: "views/html/settings.html",
controller: "SettingsCtrl",
resolve: {
"CurrentAuth": ["Auth", function(Auth) {
return Auth.$requireSignIn();
}]
}
})
.when("/goodbye", {
templateUrl: "views/html/goodbye.html",
controller: "AuthCtrl",
})
.when("/affiliates", {
templateUrl: "views/html/affiliates.html",
controller: "AffiliatesCtrl"
Expand Down
1 change: 0 additions & 1 deletion public/app/controllers/BadBoyCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ greenlistApp.controller("BadBoyCtrl", ["$scope", "UserInfo", function($scope, Us
$scope.playAudio = function() {
var audio = new Audio('images/monty.wav')
audio.play();
console.log("play stuff");
};
}]);
14 changes: 13 additions & 1 deletion public/app/controllers/EfficiencyCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ greenlistApp.controller("EfficiencyCtrl",

// Get the needed data for graphing
DatabaseQuery.getChartData(item, function(dates, scores, recentDates, recentScores) {
console.log("Got dates and scores", dates, scores, recentDates, recentScores);

var modalInstance = $uibModal.open({
templateUrl: 'views/partials/detailReportModal.html',
windowClass: 'dataModal',

// Controller for the modal
controller: function($scope, $uibModalInstance) {
$scope.close = function() {
$uibModalInstance.close();
}

$scope.food = item;

// Chart variables
Expand Down Expand Up @@ -67,6 +70,15 @@ greenlistApp.controller("EfficiencyCtrl",
}
}
]
},
pan: {
enabled: true,
mode: "x"
},
zoom: {
enabled: true,
drag: false,
mode: "x"
}
};

Expand Down
16 changes: 13 additions & 3 deletions public/app/controllers/HistoryListCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
*/
greenlistApp.controller("HistoryListCtrl",
["CurrentAuth", "$scope", "UserInfo", "DatabaseRef", "CalculationService", "$firebaseObject", "DatabaseQuery",
function(CurrentAuth, $scope, UserInfo, DatabaseRef, CalculationService, $firebaseObject, DatabaseQuery) {
function(CurrentAuth, $scope, UserInfo, DatabaseRef, CalculationService, $firebaseObject, DatabaseQuery, $route) {

// Set up user info with the UserInfo service
UserInfo.initUser(CurrentAuth.displayName, CurrentAuth.uid, CurrentAuth.photoURL, CurrentAuth.email);



// Define style values for the header and nav bar
$scope.heading = 'History';
$scope.listBtnColor = 'white';
Expand All @@ -19,6 +21,8 @@ greenlistApp.controller("HistoryListCtrl",
$scope.listBgImg = 'images/icons/cart-off.png';
$scope.histBgImg = 'images/icons/hist-icon-on.png';
$scope.reptBgImg = 'images/icons/reports-off.png';
$scope.navDisplay = 'block';
$scope.inputHeight = '0';

// Create a database reference to items in the history list
var historyFood = $firebaseObject(DatabaseRef.getRefToSpecificList('history'));
Expand All @@ -36,7 +40,6 @@ greenlistApp.controller("HistoryListCtrl",
if (!food.dataUpdated) {
DatabaseQuery.updateWasteScore(food, status, function(gotData) {});
}

}

/**
Expand All @@ -47,9 +50,10 @@ greenlistApp.controller("HistoryListCtrl",
*
* @param food
* @status boolean for showing cancel or ask later button
* @status boolean for showing cancel or ask later button
*/
$scope.addToList = function(food, status) {
if (!food.dataUpdated) {
if (!food.dataUpdated && !food.NonFood) {
DatabaseQuery.updateWasteScore(food, status, function(gotData) {
if (gotData || gotData === null) {
DatabaseQuery.setItemList(food, "shopping");
Expand All @@ -60,6 +64,8 @@ greenlistApp.controller("HistoryListCtrl",
}
}



/**
* Get the color for the background of food efficiency bar based
* on the average of the food efficiency.
Expand Down Expand Up @@ -89,4 +95,8 @@ greenlistApp.controller("HistoryListCtrl",
}
}





}]);
46 changes: 43 additions & 3 deletions public/app/controllers/PanelCtrl.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/**
* Brings out side nav by injecting new view with modal.
*/
greenlistApp.controller('PanelCtrl', function($scope, $aside, UserInfo) {

greenlistApp.controller('PanelCtrl', function($scope, $aside, UserInfo, DatabaseRef, $firebaseObject, $uibModal, DatabaseQuery, $route) {
$scope.userPic = UserInfo.getCurrentUser().photoUrl;

$scope.asideState = {
Expand Down Expand Up @@ -40,15 +39,56 @@ greenlistApp.controller('PanelCtrl', function($scope, $aside, UserInfo) {
$scope.close = function() {
$uibModalInstance.close();
//e.stopPropagation();

};
/*$scope.cancel = function(e) {
$uibModalInstance.dismiss();
e.stopPropagation();
};*/

var allShareList = $firebaseObject(DatabaseRef.getAllShareList());
allShareList.$bindTo($scope, "allLists");

$scope.addNewList= function(list){
DatabaseQuery.createNewList(list);
$scope.newListName = "";
}

$scope.deleteList = function(listKey){
DatabaseQuery.deleteSharedList(listKey);
UserInfo.setCurrentList(UserInfo.getCurrentUser().uid, "My List");
$scope.currentList = UserInfo.getCurrentList().name;
$route.reload();
}

$scope.shareThisList = function(listKey, listName) {
DatabaseQuery.shareList(listKey, listName);
}

$scope.switchList = function(list) {
if (list === "main") {
UserInfo.setCurrentList(UserInfo.getCurrentUser().uid, "My List");
} else {
UserInfo.setCurrentList(list.listKey, list.name);
}

$scope.currentList = UserInfo.getCurrentList().name;
$route.reload();

}

}
}).result.then(postClose, postClose);
}

/**
* Run when the panel dropdown menu ng-inits
*/
$scope.getCurrentList = function() {

if (UserInfo.getCurrentList().name == null) {
UserInfo.setCurrentList(UserInfo.getCurrentUser().uid, "My List");
}

$scope.currentList = UserInfo.getCurrentList().name; // TODO make this work!
}
});
113 changes: 106 additions & 7 deletions public/app/controllers/ReportCtrl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
greenlistApp.controller("ReportCtrl",
["CurrentAuth", "$scope", "UserInfo", "DatabaseRef", "$firebaseObject", "$firebaseArray", "CalculationService", "DatabaseQuery",
function(CurrentAuth, $scope, UserInfo, DatabaseRef, $firebaseObject, $firebaseArray, CalculationService, DatabaseQuery) {
["CurrentAuth", "$scope", "UserInfo", "DatabaseRef", "$firebaseObject", "$firebaseArray", "CalculationService", "DatabaseQuery","$uibModal",
function(CurrentAuth, $scope, UserInfo, DatabaseRef, $firebaseObject, $firebaseArray, CalculationService, DatabaseQuery, $uibModal) {

UserInfo.initUser(CurrentAuth.displayName, CurrentAuth.uid, CurrentAuth.photoURL, CurrentAuth.email);

Expand All @@ -22,8 +22,8 @@ greenlistApp.controller("ReportCtrl",

var setOverallAvg = $firebaseObject(DatabaseRef.overallAverage());
setOverallAvg.$bindTo($scope, "calAverage").then(function() {
console.log("Bound", $scope.calAverage);
var scoreAnim = new CountUp("elo-rating", 0, $scope.calAverage.$value * 20, 0, 1.5);

var scoreAnim = new CountUp("elo-rating", 0, $scope.calAverage.$value, 0, 1.5);
scoreAnim.start(); // Animate the efficiency score counting up

/*
Expand All @@ -41,12 +41,39 @@ greenlistApp.controller("ReportCtrl",
$scope.motivationMsg = "Keep it up!";
} else if ($scope.calAverage.$value <= 100) {
$scope.motivationMsg = "You're doing awesome!";
} else if ($scope.calAverage.$value == 9001) {
} else if ($scope.calAverage.$value === 450) {
$scope.motivationMsg = "Dammit Nappa!";
} else {
$scope.motivationMsg = "Keep it up!";
$scope.motivationMsg = "Dammit Nappa!";
}

if ($scope.calAverage.$value < 40) {
$scope.grade = "D";
} else if ($scope.calAverage.$value <= 63) {
$scope.grade = "C";
} else if ($scope.calAverage.$value <= 73) {
$scope.grade = "B";
} else if ($scope.calAverage.$value <= 83) {
$scope.grade = "A";
} else if ($scope.calAverage.$value <= 86) {
$scope.grade = "A+";
} else if ($scope.calAverage.$value <= 100) {
$scope.grade = "A++";
} else if ($scope.calAverage.$value === 450.05) {
$scope.grade = "Over 9000";
}

if($scope.calAverage.$value > 86) {
$scope.confetti = true;
} else {
$scope.confetti = false;
}

if ($scope.calAverage.$value === null) {
$scope.tweetText = "I just started using greenlist to work on reducing my food waste! Try it today at greenl.ist -"
} else {
$scope.tweetText = "My food efficiency grade is " + $scope.grade + " on greenlist! Try it today at greenl.ist -";
}

});

Expand Down Expand Up @@ -107,12 +134,84 @@ greenlistApp.controller("ReportCtrl",
$scope.menuMargin = '0';
}

$scope.dataModal = function(item) {

// Get the needed data for graphing
DatabaseQuery.getChartData(item, function(dates, scores, recentDates, recentScores) {

var modalInstance = $uibModal.open({
templateUrl: 'views/partials/detailReportModal.html',
windowClass: 'dataModal',

// Controller for the modal
controller: function($scope, $uibModalInstance) {
$scope.close = function() {
$uibModalInstance.close();
}

$scope.food = item;

// Chart variables
$scope.labels = dates;
$scope.chartData = scores;
$scope.colors = ['#278518', '#278518', '#278518', '#278518'];
$scope.options = {
elements: {
point: {}
},
scales: {
yAxes: [
{
id: 'y-axis-1',
type: 'linear',
display: true,
position: 'left',
ticks: {
beginAtZero: true,
max: 100,
stepSize: 50,
fontSize: 16,
fontFamily: "Asap"
}
}
],
xAxes: [
{
display: true,
ticks: {
maxTicksLimit: 5,
fontSize: 16,
minRotation: 45,
fontFamily: "Asap"
}
}
]
},
pan: {
enabled: true,
mode: "x"
},
zoom: {
enabled: true,
drag: false,
mode: "x"
}
};

// Recent chart variables
$scope.recentLabels = recentDates;
$scope.recentChartData = recentScores;
}

});
});
}


// Chart test code
var item = {
"name": "bread"
};



}]);
7 changes: 7 additions & 0 deletions public/app/controllers/SettingsCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
greenlistApp.controller("SettingsCtrl", ["$scope", "UserInfo", "DatabaseQuery", function($scope, UserInfo, DatabaseQuery) {

$scope.eraseData = function() {
DatabaseQuery.eraseData();
}

}]);
Loading

0 comments on commit 88f4c72

Please sign in to comment.