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

Commit efb3c00

Browse files
authored
Merge pull request #48 from turnervink/feature/new-logo
Added the new logo and fixed the login page's CSS
2 parents fb6909a + 4a954df commit efb3c00

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1141
-0
lines changed

app/app.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
var greenlistApp = angular.module("greenlistApp", ["ngRoute", "firebase", "ui.bootstrap"]);
2+
3+
greenlistApp.run(["$rootScope", "$location", function($rootScope, $location) {
4+
$rootScope.$on("$routeChangeError", function(event, next, previous, error) {
5+
// We can catch the error thrown when the $requireSignIn promise is rejected
6+
// and redirect the user back to the home page
7+
if (error === "AUTH_REQUIRED") {
8+
$location.path("/login");
9+
}
10+
});
11+
}]);
12+
13+
greenlistApp.config(["$routeProvider", function($routeProvider) {
14+
$routeProvider
15+
.when("/login", {
16+
templateUrl: "views/html/login.html"
17+
})
18+
.when("/list", {
19+
templateUrl: "views/html/shopping.html",
20+
controller: "ShoppingListCtrl",
21+
resolve: {
22+
"CurrentAuth": ["Auth", function(Auth) {
23+
return Auth.$requireSignIn();
24+
}]
25+
}
26+
})
27+
.when("/history", {
28+
templateUrl: "views/html/history.html",
29+
controller: "HistoryListCtrl",
30+
resolve: {
31+
"CurrentAuth": ["Auth", function(Auth) {
32+
return Auth.$requireSignIn();
33+
}]
34+
}
35+
})
36+
37+
.when('/ctrl', {
38+
templateUrl: "views/partials/modal.html",
39+
controller: 'ModalCtrl'
40+
41+
})
42+
43+
.when("/reports", {
44+
templateUrl: "views/html/report.html",
45+
controller: "ReportCtrl",
46+
resolve: {
47+
"CurrentAuth": ["Auth", function(Auth) {
48+
return Auth.$requireSignIn();
49+
}]
50+
}
51+
})
52+
53+
.when("/affiliates", {
54+
templateUrl: "views/html/affiliates.html",
55+
controller: "AffiliatesCtrl"
56+
})
57+
58+
.otherwise({
59+
redirectTo: "/login"
60+
});
61+
62+
}]);
63+
64+
/*
65+
This controller listens for route changes and assigns a class to the body in order to
66+
have a different background colour for each view. A value of "undefined-page" is used for
67+
the login view as there is not controller associated with it.
68+
*/
69+
greenlistApp.controller("GlobalCtrl", ["$scope", "$rootScope", function($scope, $rootScope) {
70+
$rootScope.$on("$routeChangeStart", function(event, toState, toParams) {
71+
$scope.bodyClass = toState.$$route.controller + "-page";
72+
});
73+
}]);
74+
75+
greenlistApp.factory("Auth", ["$firebaseAuth",
76+
function($firebaseAuth) {
77+
return $firebaseAuth();
78+
}]);
79+

app/controllers/AffiliatesCtrl.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
greenlistApp.controller("AffiliatesCtrl", ["$scope", "UserInfo", function($scope, UserInfo) {
2+
3+
}]);

app/controllers/AuthCtrl.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
greenlistApp.controller("AuthCtrl", ["$scope", "$route", "UserInfo", "$firebaseAuth", function($scope, $route, UserInfo, $firebaseAuth) {
2+
var auth = $firebaseAuth();
3+
4+
$scope.signIn = function() {
5+
auth.$signInWithRedirect("google").then(function(firebaseUser) {
6+
console.log("Signed in as " + firebaseUser.user.displayName);
7+
UserInfo.initUser(firebaseUser.user.displayName, firebaseUser.user.uid, firebaseUser.user.photoURL);
8+
}).catch(function(error) {
9+
console.error("Auth failed:", error);
10+
});
11+
}
12+
13+
$scope.signOut = function() {
14+
auth.$signOut().then(function() {
15+
console.log("Goodbye!");
16+
UserInfo.clearUser();
17+
}).catch(function(error) {
18+
console.error("Error signing out: " + error);
19+
});
20+
}
21+
22+
auth.$onAuthStateChanged(
23+
function(firebaseUser) {
24+
if (firebaseUser) {
25+
console.log("User is auth'd as " + firebaseUser.displayName);
26+
UserInfo.initUser(firebaseUser.displayName, firebaseUser.uid, firebaseUser.photoURL);
27+
} else {
28+
console.error("Could not auth user");
29+
}
30+
});
31+
}]);

app/controllers/HistoryListCtrl.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
greenlistApp.controller("HistoryListCtrl",
2+
["CurrentAuth", "$scope", "UserInfo", "DatabaseRef", "$firebaseObject", "DatabaseQuery",
3+
function(CurrentAuth, $scope, UserInfo, DatabaseRef, $firebaseObject, DatabaseQuery) {
4+
5+
UserInfo.initUser(CurrentAuth.displayName, CurrentAuth.uid, CurrentAuth.photoURL);
6+
7+
8+
$scope.heading = 'History';
9+
10+
$scope.listBtnColor = 'white';
11+
12+
$scope.histBtnColor = 'green';
13+
14+
$scope.reptBtnColor = 'white';
15+
16+
$scope.listColor = 'black';
17+
18+
$scope.histColor = 'white';
19+
20+
$scope.reptColor = 'black';
21+
22+
23+
var historyFood = $firebaseObject(DatabaseRef.getRefToSpecificList('history'));
24+
25+
$scope.historyItem = historyFood;
26+
27+
$scope.logWaste = function(food) {
28+
29+
if (!food.dataUpdated) {
30+
DatabaseQuery.updateWasteScore(food);
31+
}
32+
33+
}
34+
35+
$scope.addToList = function(food) {
36+
37+
if (!food.dataUpdated) {
38+
DatabaseQuery.updateWasteScore(food);
39+
}
40+
41+
DatabaseQuery.setItemList(food, "shopping");
42+
}
43+
44+
45+
}]);

app/controllers/ModalCtrl.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
greenlistApp.controller('ModalCtrl', function($scope, $modalInstance) {
2+
3+
$scope.test = {};
4+
$scope.back = function() {
5+
$modalInstance.close($scope.test.input);
6+
};
7+
});

app/controllers/PanelCtrl.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
greenlistApp.controller("PanelCtrl", ["$scope", function($scope) {
2+
3+
$scope.heading = 'Shopping List';
4+
5+
}]);

app/controllers/ReportCtrl.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
greenlistApp.controller("ReportCtrl",
2+
["CurrentAuth", "$scope", "UserInfo", "DatabaseRef", "$firebaseObject",
3+
function(CurrentAuth, $scope, UserInfo, DatabaseRef, $firebaseObject) {
4+
5+
UserInfo.initUser(CurrentAuth.displayName, CurrentAuth.uid, CurrentAuth.photoURL);
6+
7+
$scope.heading = 'Report';
8+
9+
$scope.listBtnColor = 'white';
10+
11+
$scope.histBtnColor = 'white';
12+
13+
$scope.reptBtnColor = 'green';
14+
15+
$scope.listColor = 'black';
16+
17+
$scope.histColor = 'black';
18+
19+
$scope.reptColor = 'white';
20+
21+
}]);
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
greenlistApp.controller("ShoppingListCtrl",
2+
["CurrentAuth", "$scope", "UserInfo", "DatabaseRef", "$firebaseObject", "$modal", "$window","DatabaseQuery",
3+
function(CurrentAuth, $scope, UserInfo, DatabaseRef, $firebaseObject, $modal, $window,DatabaseQuery) {
4+
5+
UserInfo.initUser(CurrentAuth.displayName, CurrentAuth.uid, CurrentAuth.photoURL);
6+
7+
$scope.heading = 'Shopping List';
8+
9+
$scope.listBtnColor = 'green';
10+
11+
$scope.histBtnColor = 'white';
12+
13+
$scope.reptBtnColor = 'white';
14+
15+
$scope.listColor = 'white';
16+
17+
$scope.histColor = 'black';
18+
19+
$scope.reptColor = 'black';
20+
21+
var uncheckedItems = $firebaseObject(DatabaseRef.getUncheckedItems());
22+
uncheckedItems.$bindTo($scope, "uncheckedItems");
23+
24+
var checkedItems = $firebaseObject(DatabaseRef.getCheckedItems());
25+
checkedItems.$bindTo($scope, "checkedItems");
26+
27+
$scope.toggleCheck = function(item, status) {
28+
DatabaseQuery.updateCheckedStatus(item, status);
29+
}
30+
31+
$scope.addItem = function(item) {
32+
DatabaseQuery.addItem(item);
33+
$scope.newItemName = "";
34+
}
35+
36+
$scope.deleteItem = function(item) {
37+
if (item.dataUpdated == undefined) {
38+
DatabaseQuery.deleteItem(item);
39+
} else {
40+
DatabaseQuery.setItemList(item, "history");
41+
}
42+
}
43+
44+
$scope.archive = function() {
45+
DatabaseRef.getCheckedItems()
46+
.once("value")
47+
.then(function(data) {
48+
49+
data.forEach(function(item) {
50+
DatabaseQuery.updateWasteDataStatus(item.val(), false);
51+
DatabaseQuery.setItemList(item.val(), "history");
52+
});
53+
54+
});
55+
56+
DatabaseRef.getUncheckedItems()
57+
.once("value")
58+
.then(function(data) {
59+
60+
data.forEach(function(item) {
61+
62+
if (item.val().dataUpdated == undefined) {
63+
DatabaseQuery.deleteItem(item.val());
64+
} else {
65+
DatabaseQuery.setItemList(item.val(), "history");
66+
}
67+
68+
});
69+
70+
});
71+
}
72+
73+
}]);

app/firebaseinfo.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var config = {
2+
apiKey: "AIzaSyAnOvIFGZ9IiYbcEdJvA8AZtIf4_FZa8yk",
3+
authDomain: "greenlist-bb6f7.firebaseapp.com",
4+
databaseURL: "https://greenlist-bb6f7.firebaseio.com",
5+
projectId: "greenlist-bb6f7",
6+
storageBucket: "greenlist-bb6f7.appspot.com",
7+
messagingSenderId: "647042734711"
8+
};
9+
firebase.initializeApp(config);

0 commit comments

Comments
 (0)