|
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 |
| - |
0 commit comments