Skip to content

Commit 21d1360

Browse files
committed
v1.1.0 changes, see CHANGELOG for details.
1 parent 3b9d485 commit 21d1360

27 files changed

Lines changed: 1729 additions & 10165 deletions

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
## 1.1.0 (Sept 16, 2016)
2+
3+
Migration:
4+
5+
- Migrated AngularFire from 1.x.x to 2.x.x
6+
- Migrated Firebase from 2.x.x to 3.x.x
7+
- Migrated Firebase database from Firebase.com to new Firebase console
8+
9+
Upgrades:
10+
11+
- Upgraded AngularFire to 2.0.2
12+
- Upgraded Firebase to 3.4.0
13+
- Upgraded AngularJS to 1.5.8
14+
- Upgraded Bootstrap to 3.3.7
15+
- Upgraded jQuery to 3.1.0
16+
117
## 1.0.1 (Nov 12, 2015)
218

319
Features:

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2013-2016 Cheng Deng
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,34 @@
1212

1313
## Dependencies
1414

15-
* [AngularFire 1.1.1](http://angularfire.com)
16-
* [AngularJS 1.3.15](http://angularjs.org/)
17-
* [Bootstrap 3.3.4] (http://getbootstrap.com/)
18-
* [Firebase 2.2.4](http://firebase.com)
15+
* [AngularFire 2.0.2](https://github.com/firebase/angularfire)
16+
* [Google AngularJS 1.5.8](https://angularjs.org/)
17+
* [Google Firebase 3.4.0](https://firebase.google.com)
18+
* [Bootstrap 3.3.7](http://getbootstrap.com/)
19+
* [JQuery 3.1.0](https://jquery.com/)
1920

2021
## Configuration
2122

2223
* Please configure Firebase URL in app/js/config.js before running.
2324

2425
```javascript
2526
// your Firebase URL goes here
26-
app.constant("FBURL", "https://angularfire-survey.firebaseio.com/surveys");
27+
var config = {
28+
apiKey: "AIzaSyAVCmE0CaAntEeB7p3Up9L990FGHnO11_E",
29+
authDomain: "angularfire-survey.firebaseapp.com",
30+
databaseURL: "https://angularfire-survey.firebaseio.com",
31+
storageBucket: "angularfire-survey.appspot.com",
32+
messagingSenderId: "204946184892"
33+
};
2734
```
2835

2936
* Set up Email/Password authentication in Firebase.
3037

31-
- Log in to Firebase and go to **Manage App**
32-
- Click on **Login & Auth** in the left panel
33-
- Select **Email & Password** tab and **"Enable Email & Password Authentication"**
34-
- Add email and password to **Registered Users** list on the bottom of this page
38+
- Log in to [Firebase console](https://firebase.google.com/console/), open the **Auth** section
39+
- On the **Sign in method** tab, enable the **Email/password** sign-in method and click **Save**.
40+
- Add email and password to **Users** tab
3541

36-
* Replace line 78 & 79 in app/js/controller.js with your own credentials you just set up.
42+
* Replace line 80 & 81 in app/js/controller.js with your own credentials you just set up.
3743

3844
```javascript
3945
$scope.email = "admin@mydomain.com";

app/index.html

Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,73 @@
11
<!doctype html>
22
<html lang="en" ng-app="myApp">
3-
<head>
4-
<meta charset="utf-8">
5-
<title>AngularFire Survey</title>
6-
<link rel="stylesheet" type="text/css" href="css/main.css"/>
7-
<!-- bootstrap 3.3.4 -->
8-
<link rel="stylesheet" type="text/css" href="lib/bootstrap/css/bootstrap.min.css"/>
9-
<!-- angularJS 1.3.15 -->
10-
<!-- loading angular in the head section is used to work with ngCloak
11-
and prevent the Angular html template from being briefly displayed by
12-
the browser in its raw (uncompiled) from while the application is loading -->
13-
<script type="text/javascript" src="lib/angular/angular.min.js"></script>
14-
<script type="text/javascript" src="lib/angular/angular-route.min.js"></script>
15-
</head>
16-
<body class="ng-cloak">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>AngularFire Survey</title>
6+
<link rel="stylesheet" type="text/css" href="css/main.css"/>
7+
<!-- bootstrap 3.3.4 -->
8+
<link rel="stylesheet" type="text/css" href="lib/bootstrap/css/bootstrap.min.css"/>
9+
<!-- angularJS 1.3.15 -->
10+
<!-- loading angular in the head section is used to work with ngCloak
11+
and prevent the Angular html template from being briefly displayed by
12+
the browser in its raw (uncompiled) from while the application is loading -->
13+
<script type="text/javascript" src="lib/angular/angular.min.js"></script>
14+
<script type="text/javascript" src="lib/angular/angular-route.min.js"></script>
15+
</head>
16+
<body class="ng-cloak">
1717

18-
<!-- Navigation -->
19-
<nav class="navbar navbar-default" role="navigation">
20-
<div class="container">
21-
<div class="navbar-header">
22-
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
23-
<span class="sr-only">Toggle navigation</span>
24-
<span class="icon-bar"></span>
25-
<span class="icon-bar"></span>
26-
<span class="icon-bar"></span>
27-
</button>
28-
<a class="navbar-brand" href="#/">AngularFire Survey</a>
29-
</div>
18+
<!-- Navigation -->
19+
<nav class="navbar navbar-default" role="navigation">
20+
<div class="container">
21+
<div class="navbar-header">
22+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
23+
<span class="sr-only">Toggle navigation</span>
24+
<span class="icon-bar"></span>
25+
<span class="icon-bar"></span>
26+
<span class="icon-bar"></span>
27+
</button>
28+
<a class="navbar-brand" href="#/">AngularFire Survey</a>
29+
</div>
3030

31-
<div class="collapse navbar-collapse navbar-ex1-collapse">
32-
<ul class="nav navbar-nav">
33-
<li ng-class="{active: isActive('/survey')}"><a href="#/survey">Take the Survey</a></li>
34-
<li ng-class="{active: isActive('/result')}" ng-show="authData"><a href="#/result">Survey Result</a></li>
35-
</ul>
36-
<ul class="nav navbar-nav navbar-right">
37-
<li ng-hide="authData" class="active"><a href="#/login">Login</a></li>
38-
<li ng-show="authData"><a href ng-click="logout()">Logout</a></li>
39-
</ul>
40-
</div><!-- /.navbar-collapse -->
41-
</div><!-- /.container -->
42-
</nav>
31+
<div class="collapse navbar-collapse navbar-ex1-collapse">
32+
<ul class="nav navbar-nav">
33+
<li ng-class="{
34+
active: isActive('/survey')
35+
}"><a href="#/survey">Take the Survey</a></li>
36+
<li ng-class="{
37+
active: isActive('/result')
38+
}" ng-show="authData"><a href="#/result">Survey Result</a></li>
39+
</ul>
40+
<ul class="nav navbar-nav navbar-right">
41+
<li ng-hide="authData" class="active"><a href="#/login">Login</a></li>
42+
<li ng-show="authData"><a href ng-click="logout()">Logout</a></li>
43+
</ul>
44+
</div><!-- /.navbar-collapse -->
45+
</div><!-- /.container -->
46+
</nav>
4347

44-
<div class="container">
45-
<!-- Main content -->
46-
<div ng-view></div>
47-
</div>
48-
49-
<div class="navbar navbar-default navbar-fixed-bottom">
5048
<div class="container">
51-
<p class="text-muted credit">This is a <a href="http://github.com/cdeng/angularFire-survey" title="Github project" target="_blank">
52-
Github</a> Project. {{ 'Current version is v%VERSION%.' | interpolate }}</p>
49+
<!-- Main content -->
50+
<div ng-view></div>
5351
</div>
54-
</div>
5552

56-
<!-- firebase 2.2.4 -->
57-
<script type="text/javascript" src="lib/firebase/firebase.js"></script>
58-
<!-- jQuery 2.1.4 -->
59-
<script type="text/javascript" src="lib/jquery/jquery.min.js"></script>
60-
<!-- bootstrap 3.3.4 -->
61-
<script type="text/javascript" src="lib/bootstrap/js/bootstrap.min.js"></script>
62-
<!-- angularFire 1.1.1 -->
63-
<script type="text/javascript" src="lib/angularFire/angularfire.min.js"></script>
64-
<!-- custom modules -->
65-
<script type="text/javascript" src="js/app.js"></script>
66-
<script type="text/javascript" src="js/config.js"></script>
67-
<script type="text/javascript" src="js/services.js"></script>
68-
<script type="text/javascript" src="js/controllers.js"></script>
69-
<script type="text/javascript" src="js/filters.js"></script>
70-
<script type="text/javascript" src="js/directives.js"></script>
53+
<div class="navbar navbar-default navbar-fixed-bottom">
54+
<div class="container">
55+
<p class="text-muted credit">This is a <a href="http://github.com/cdeng/angularFire-survey" title="Github project" target="_blank">
56+
Github</a> Project. {{ 'Current version is v%VERSION%.' | interpolate }}</p>
57+
</div>
58+
</div>
59+
60+
<script type="text/javascript" src="lib/jquery/jquery.min.js"></script>
61+
<script type="text/javascript" src="lib/firebase/firebase.js"></script>
62+
<script type="text/javascript" src="lib/bootstrap/js/bootstrap.min.js"></script>
63+
<script type="text/javascript" src="lib/angularFire/angularfire.min.js"></script>
64+
65+
<!-- custom modules -->
66+
<script type="text/javascript" src="js/app.js"></script>
67+
<script type="text/javascript" src="js/config.js"></script>
68+
<script type="text/javascript" src="js/services.js"></script>
69+
<script type="text/javascript" src="js/controllers.js"></script>
70+
<script type="text/javascript" src="js/filters.js"></script>
71+
<script type="text/javascript" src="js/directives.js"></script>
7172
</body>
7273
</html>

app/js/app.js

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
* @module myApp
66
*/
77
var app = angular.module("myApp", [
8-
"ngRoute", "myApp.config", "myApp.filters", "myApp.services",
8+
"firebase", "myApp.config", "myApp.filters", "myApp.services",
99
"myApp.directives", "myApp.controllers"
1010
]);
1111

1212
// configure views
1313
app.config(["$routeProvider",
14-
function($routeProvider) {
14+
function ($routeProvider) {
1515

1616
$routeProvider.when("/survey", {
1717
templateUrl: "partials/survey.html",
@@ -28,10 +28,10 @@ app.config(["$routeProvider",
2828
controller: "resultCtrl",
2929
resolve: {
3030
// controller will not be loaded until $requireAuth resolves
31-
"currentAuth": ["Auth", function(Auth) {
32-
// $requireAuth returns a promise so the resolve waits for it to complete
33-
return Auth.$requireAuth();
34-
}]
31+
"currentAuth": ["Auth", function (Auth) {
32+
// $requireAuth returns a promise so the resolve waits for it to complete
33+
return Auth.$requireSignIn();
34+
}]
3535
}
3636
});
3737

@@ -40,33 +40,26 @@ app.config(["$routeProvider",
4040
}
4141
]);
4242

43-
// double-check whether the app has been configured
44-
app.run(["FBURL", function(FBURL) {
45-
if( FBURL === "https://angularfire-survey.firebaseio.com/surveys" ) {
46-
angular.element(document.body).html("<h1>Please configure app/js/config.js before running!</h1>");
47-
}
48-
}]);
49-
5043
// redirect the user back to the survey page if auth error is catched
5144
app.run(["$rootScope", "$location", "Auth",
52-
function($rootScope, $location, Auth) {
45+
function ($rootScope, $location, Auth) {
5346

5447
// any time auth status updates, add auth data to rootScope
55-
Auth.$onAuth(function(authData) {
56-
$rootScope.authData = authData;
48+
Auth.$onAuthStateChanged(function (authData) {
49+
$rootScope.authData = authData;
5750
});
58-
59-
$rootScope.logout = function() {
60-
Auth.$unauth();
51+
52+
$rootScope.logout = function () {
53+
Auth.$signOut();
6154
$location.path("/survey");
6255
};
63-
56+
6457
// show nav menu in highlight when it's active
6558
$rootScope.isActive = function (viewLocation) {
6659
return viewLocation === $location.path();
6760
};
6861

69-
$rootScope.$on("$routeChangeError", function(event, next, previous, error) {
62+
$rootScope.$on("$routeChangeError", function (event, next, previous, error) {
7063
if (error === "AUTH_REQUIRED") {
7164
$location.path("/survey");
7265
}

app/js/config.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44
* Config module which defines Firebase URL.
55
* @module myApp/config
66
*/
7-
var app = angular.module("myApp.config", ["ngRoute"]);
7+
var app = angular.module("myApp.config", []);
88

99
// your Firebase URL goes here
10-
app.constant("FBURL", "https://angularfire-survey.firebaseio.com/surveys");
10+
var config = {
11+
apiKey: "AIzaSyAVCmE0CaAntEeB7p3Up9L990FGHnO11_E",
12+
authDomain: "angularfire-survey.firebaseapp.com",
13+
databaseURL: "https://angularfire-survey.firebaseio.com",
14+
storageBucket: "angularfire-survey.appspot.com",
15+
messagingSenderId: "204946184892"
16+
};
17+
firebase.initializeApp(config);
18+
19+
// double-check whether the app has been configured
20+
if (config.authDomain === "angularfire-survey.firebaseapp.com") {
21+
angular.element(document.body).html("<h1>Please configure app/js/config.js before running!</h1>");
22+
}

app/js/controllers.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
* Controllers module which defines controllers.
55
* @module myApp/controllers
66
*/
7-
var app = angular.module("myApp.controllers", ["ngRoute"]);
7+
var app = angular.module("myApp.controllers", []);
88

99
// Survey controller
10-
app.controller("surveyCtrl", ["$scope", "FBURL", "$firebaseArray",
11-
function($scope, FBURL, $firebaseArray) {
10+
app.controller("surveyCtrl", function($scope, $firebaseArray) {
1211

13-
var ref = new Firebase(FBURL);
12+
var ref = firebase.database().ref();
1413
// create a synchronized array
1514
$scope.surveys = $firebaseArray(ref);
1615
// timestamp
@@ -72,11 +71,10 @@ app.controller("surveyCtrl", ["$scope", "FBURL", "$firebaseArray",
7271
};
7372

7473
}
75-
]);
74+
);
7675

7776
// Login controller
78-
app.controller("loginCtrl", ["$scope", "$location", "Auth",
79-
function($scope, $location, Auth) {
77+
app.controller("loginCtrl", function($scope, $location, Auth) {
8078

8179
// temporary email and password placeholder
8280
$scope.email = "admin@mydomain.com";
@@ -94,10 +92,10 @@ app.controller("loginCtrl", ["$scope", "$location", "Auth",
9492
var $btn = $("#loginButton").button("loading");
9593

9694
// authentication using an email / password combination
97-
Auth.$authWithPassword({
98-
email: $scope.email,
99-
password: $scope.password
100-
}).then(function(authData) {
95+
Auth.$signInWithEmailAndPassword(
96+
$scope.email,
97+
$scope.password
98+
).then(function(authData) {
10199
// the data contains all auth info
102100
$scope.authData = authData;
103101
// redirect to result page after successful login
@@ -113,15 +111,14 @@ app.controller("loginCtrl", ["$scope", "$location", "Auth",
113111

114112
};
115113
}
116-
]);
114+
);
117115

118116
// Result controller
119-
app.controller("resultCtrl", ["$scope", "FBURL", "$firebaseArray",
120-
function($scope, FBURL, $firebaseArray) {
117+
app.controller("resultCtrl", function($scope, $firebaseArray) {
121118

122-
var ref = new Firebase(FBURL);
119+
var ref = firebase.database().ref();
123120
// download the data into local object
124121
$scope.results = $firebaseArray(ref);
125122

126123
}
127-
]);
124+
);

0 commit comments

Comments
 (0)