Skip to content

Commit

Permalink
went through all of code, completed authorization, login, registering…
Browse files Browse the repository at this point in the history
… and creating and editing boards
  • Loading branch information
helanan committed Dec 2, 2016
1 parent 245001d commit 795ec4c
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 62 deletions.
10 changes: 5 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ <h1>Pin This!</h1>
</body>
<script src="https://www.gstatic.com/firebasejs/3.6.2/firebase.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="js/materialize.min.js"></script>
<!-- <script type="text/javascript" src="js/materialize.min.js"></script> -->
<script type="text/javascript" src="/lib/bower_components/angular/angular.min.js"></script>
<script src="/lib/bower_components/angular-route/angular-route.min.js"></script>
<script src="/javascripts/app.js"></script>
<script src="/javascripts/AppConstants.js"></script>
<script src="/javascripts/AppConfig.js"></script>
<script src="/javascripts/factories/AuthFactory.js"></script>
<script src="/javascripts/factories/BoardFactory.js"></script>
<!-- <script src="/javascripts/factories/BoardFactory.js"></script> -->
<script src="/javascripts/factories/UserFactory.js"></script>
<script src="/javascripts/controllers/AuthCtrl.js"></script>
<script src="/javascripts/controllers/NavCtrl.js"></script>
<script src="/javascripts/controllers/GeneralViewCtrl.js"></script>
<!-- <script src="/javascripts/controllers/NavCtrl.js"></script> -->
<!-- <script src="/javascripts/controllers/GeneralViewCtrl.js"></script>
<script src="/javascripts/controllers/CreateBoardCtrl.js"></script>
<script src="/javascripts/controllers/BoardViewCtrl.js"></script>
<script src="/javascripts/controllers/BoardEditCtrl.js"></script>
<script src="/javascripts/controllers/BoardEditCtrl.js"></script> -->
</html>
50 changes: 25 additions & 25 deletions javascripts/AppConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@ app.config(function($routeProvider){
templateUrl: 'partials/auth.html',
controller:'AuthCtrl'
})
.when('/boards/list', {
templateUrl: 'partials/general-view.html',
controller: 'GeneralViewCtrl',
resolve: {isAuth}
})
.when('/boards/new', {
templateUrl: 'partials/create-board.html',
controller: 'CreateBoardCtrl',
resolve: {isAuth}
})
.when('/boards/view/:id', {
templateUrl: 'partials/board-view.html',
controller: 'BoardViewCtrl',
resolve: {isAuth}
})
.when('/boards/edit/:id', {
templateUrl: 'partials/create-board.html',
controller:'BoardEditCtrl',
resolve: {isAuth}
})
.when('/logout', {
templateUrl: 'partials/auth.html',
controller: 'AuthCtrl',
resolve: {isAuth}
})
// .when('/boards/list', {
// templateUrl: 'partials/general-view.html',
// controller: 'GeneralViewCtrl',
// resolve: {isAuth}
// })
// .when('/boards/new', {
// templateUrl: 'partials/create-board.html',
// controller: 'CreateBoardCtrl',
// resolve: {isAuth}
// })
// .when('/boards/view/:id', {
// templateUrl: 'partials/board-view.html',
// controller: 'BoardViewCtrl',
// resolve: {isAuth}
// })
// .when('/boards/edit/:id', {
// templateUrl: 'partials/create-board.html',
// controller:'BoardEditCtrl',
// resolve: {isAuth}
// })
// .when('/logout', {
// templateUrl: 'partials/auth.html',
// controller: 'AuthCtrl',
// resolve: {isAuth}
// })
.otherwise('/auth');
});
2 changes: 1 addition & 1 deletion javascripts/controllers/AuthCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
app.controller("AuthCtrl", function($scope, $rootScope, AuthFactory, UserFactory, $location){
$scope.setLoginContainer = true;
$scope.setRegisterContainer = false;
});


if($location.path() == "/logout"){
AuthFactory.logout();
Expand Down
12 changes: 6 additions & 6 deletions javascripts/controllers/BoardEditCtrl.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"use strict";

app.controller("BoardEditCtrl", function($scope, $location, $routeParams, BoardFactory){
$scope.newBoard = {};
let BoardId = $routeParams.id;
$scope.newPin = {};
let boardId = $routeParams.id;

ItemFactory.getSingleBoard(BoardId).then(function(oneBoard){
oneBoard.id = BoardId;
$scope.newBoard = oneBoard;
BoardFactory.getSingleBoard(boardId).then(function(oneBoard){
oneBoard.id = boardId;
$scope.newPin = oneBoard;
});

$scope.addBoard = function(){
$scope.addNewBoard = function(){
BoardFactory.editBoard($scope.newBoard).then(function(response){
$scope.newBoard = {};
$location.url("/boards/list");
Expand Down
8 changes: 4 additions & 4 deletions javascripts/controllers/CreateBoardCtrl.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"use strict";

app.controller("CreateBoardCtrl", function($scope, $rootScope, $location, BoardFactory){
$scope.newBoard = {};
$scope.newPin = {};

$scope.addNewBoard = function(){
$scope.newBoard.isClicked = true;
$scope.newPin.isSelected = false;
$scope.newBoard.uid = $rootScope.user.uid;
BoardFactory.postNewBoard($scope.newBoard).then(function(BoardId){
BoardFactory.postNewBoard($scope.newPin).then(function(boardId){
$location.url("/boards/list");
$scope.newBoard = {};
$scope.newPin = {};
});
};
});
8 changes: 4 additions & 4 deletions javascripts/factories/BoardFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ app.factory("BoardFactory", function($q, $http, FIREBASE_CONFIG){
$http.post(`${FIREBASE_CONFIG.databaseURL}/boards.json`,
JSON.stringify({
assignedTo: newBoard.assignedTo,
isClicked: newBoard.isClicked,
board: newBoard.board,
isSelected: newBoard.isSelected,
board: newBoard.pin,
uid: newBoard.uid
})
)
Expand Down Expand Up @@ -67,8 +67,8 @@ var getSingleBoard = function(boardId){
$http.put(`${FIREBASE_CONFIG.databaseURL}/boards/${editBoard.id}.json`,
JSON.stringify({
assignedTo: editBoard.assignedTo,
isCompleted: editBoard.isClicked,
task: editBoard.board,
isSelected: editBoard.isSelected,
pins: editBoard.pin,
uid: editBoard.uid
})
)
Expand Down
Empty file.
37 changes: 37 additions & 0 deletions javascripts/factories/UserFactory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"use strict";
app.factory("UserFactory", function($q, $http, FIREBASE_CONFIG){
let addUser = (authData) => {
return $q((resolve, reject) => {
$http.post(`${FIREBASE_CONFIG.databaseURL}/users.json`, JSON.stringify({
uid: authData.uid,
username: authData.username
})
)
.success(function(storeUserSuccess){
resolve(storeUserSuccess);
})
.error(function(storeUserError){
reject(storeUserError);
});
});
};

let getUser = (userId) =>{
return $q((resolve, reject) => {
$http.get(`${FIREBASE_CONFIG.databaseURL}/users.json?orderBy="uid"&equalTo="${userId}"`)
.success(function(userObject){
let users = [];
Object.keys(userObject).forEach(function(key){
users.push(userObject[key]);
});
resolve(users[0]);
})
.error(function(error){
reject(error);
});
});

};

return {addUser:addUser, getUser:getUser};
});
55 changes: 55 additions & 0 deletions partials/auth.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<div class="container col-xs-4 col-xs-offset-3">
<div class="row">
<button class="btn btn-success col-xs-6" ng-click="setRegisterContainer()">Register</button>
<button class="btn btn-info col-xs-6" ng-click="setLoginContainer()">Login</button>

</div>
<div class="row">

<!-- start of register form -->
<form ng-show="loginContainer">

<div class="form-group">
<label>Email Address</label>
<input type="email" class="col-xs-offset-1 col-xs-10" placeholder="Email address" ng-model="login.email" required autofocus>
</div>

<div class="form-group">
<label>Password</label>
<input type="password" class="col-xs-offset-1 col-xs-10" placeholder="" ng-model="login.password" required>
</div>

<div class="form-group">
<a class="btn btn-lg btn-success col-xs-offset-1 col-xs-10" ng-click="loginUser(login)">Submit Login</a>
</div>

</form>
<!--end of register form -->

<!-- start of login form -->
<form ng-show="registerContainer">

<div class="form-group">
<label>Email Address</label>
<input type="email" class="col-xs-offset-1 col-xs-10" placeholder="Email address" ng-model="register.email" required autofocus>
</div>

<div class="form-group">
<label>Password</label>
<input type="password" class="col-xs-offset-1 col-xs-10" placeholder="" ng-model="register.password" required>
</div>

<div class="form-group">
<label>Username</label>
<input type="text" class="col-xs-offset-1 col-xs-10" placeholder="Username" ng-model="register.username" required>
</div>

<div class="form-group">
<a class="btn btn-lg btn-success col-xs-offset-1 col-xs-10" ng-click="registerUser(register)">Submit Registration</a>
</div>

</form>
<!-- end of login form -->

</div>
</div>
17 changes: 0 additions & 17 deletions partials/loginview.html

This file was deleted.

0 comments on commit 795ec4c

Please sign in to comment.