Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed html buttons and login #24

Merged
merged 5 commits into from
Dec 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*.DS_Store
.DS_Store
lib/node_modules/
lib/bower_components/
*javascripts/AppConstants.js
javascripts/AppConstants.js
npm-debug.log
3 changes: 2 additions & 1 deletion css/main.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
body {
/*body {
background-image: url("img/cork.jpg");
font-family: 'Yanone Kaffeesatz', sans-serif;
font-size: 2em;
Expand All @@ -8,3 +8,4 @@ h1 {
font-family: 'Anton', sans-serif;
font-size: 1.5em;
}
*/
32 changes: 16 additions & 16 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@

<body>
<body ng-app="PinThisApp">
<div ng-include='./partials/navbar.html'></div>
<div ng-include="'./partials/navbar.html'"></div>

<div class="row">
<h1>Pin This!</h1>
<div class="col-xs-offset-2 col-xs-8" ng-view></div>
</div>

<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="/lib/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/lib/bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="/lib/bower_components/bootstrap/dist/js/bootstrap.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 type="text/javascript" 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 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/CreateBoardCtrl.js">
<script src="/javascripts/controllers/BoardViewCtrl.js"></script>
<script src="/javascripts/controllers/BoardEditCtrl.js"></script>
<script type="text/javascript" src="/javascripts/app.js"></script>
<script type="text/javascript" src="/javascripts/AppConstants.js"></script>
<script type="text/javascript" src="/javascripts/factories/AuthFactory.js"></script>
<script type="text/javascript" src="/javascripts/AppConfig.js"></script>
<script type="text/javascript" src="/javascripts/factories/BoardFactory.js"></script>
<script type="text/javascript" src="/javascripts/factories/UserFactory.js"></script>
<script type="text/javascript" src="/javascripts/controllers/AuthCtrl.js"></script>
<script type="text/javascript" src="/javascripts/controllers/NavCtrl.js"></script>
<script type="text/javascript" src="/javascripts/controllers/GeneralViewCtrl.js"></script>
<script type="text/javascript" src="/javascripts/controllers/BoardNewCtrl.js"></script>
<script type="text/javascript" src="/javascripts/controllers/BoardViewCtrl.js"></script>
<script type="text/javascript" src="/javascripts/controllers/BoardEditCtrl.js"></script>
</body>
</html>
12 changes: 7 additions & 5 deletions javascripts/AppConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ let isAuth = (AuthFactory) => new Promise((resolve, reject) => {
} else {
reject();
}
});
})

app.run(function($rootScope, $location, FIREBASE_CONFIG, AuthFactory){
firebase.initializeApp(FIREBASE_CONFIG);

$rootScope.$on('$routeChangeStart', function(event, currRoute, prevRoute){

let logged = AuthFactory.isAuthenticated();

let appTo;

if(currRoute.originalPath){
Expand All @@ -33,7 +33,7 @@ app.config(function($routeProvider){
$routeProvider
.when('/auth', {
templateUrl: 'partials/auth.html',
controller:'AuthCtrl'
controller:'AuthCtrl',
})
.when('/boards/list', {
templateUrl: 'partials/general-view.html',
Expand All @@ -42,7 +42,7 @@ app.config(function($routeProvider){
})
.when('/boards/new', {
templateUrl: 'partials/board-new.html',
controller: 'CreateBoardCtrl',
controller: 'BoardNewCtrl',
resolve: {isAuth}
})
.when('/boards/view/:id', {
Expand All @@ -61,4 +61,6 @@ app.config(function($routeProvider){
resolve: {isAuth}
})
.otherwise('/auth');
});
});

console.log("AppConfig loaded");
4 changes: 3 additions & 1 deletion javascripts/AppConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ app.constant("FIREBASE_CONFIG", {
databaseURL: "https://pinthis-fe275.firebaseio.com",
storageBucket: "pinthis-fe275.appspot.com",
messagingSenderId: "918121387819"
});
});

console.log("AppConstantsCompleted");
1 change: 1 addition & 0 deletions javascripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

var app = angular.module("PinThisApp", ["ngRoute"]);


19 changes: 9 additions & 10 deletions javascripts/controllers/AuthCtrl.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
"use strict";

app.controller("AuthCtrl", function($scope, $rootScope, AuthFactory, UserFactory, $location){
$scope.setLoginContainer = true;
$scope.setRegisterContainer = false;
app.controller("AuthCtrl", function($scope, $rootScope, $location, AuthFactory, UserFactory){
$scope.loginContainer = true;
$scope.registerContainer = false;


if($location.path() == "/logout"){
if($location.path() === "/logout"){
AuthFactory.logout();
$rootScope.user ={};
$location.url("/auth");
}

let logMeIn = function(loginParams){
AuthFactory.authenticate(loginParams).then(function(didLogin){
let logMeIn = function(loginStuff){
AuthFactory.authenticate(loginStuff).then(function(didLogin){
console.log("didLogin", didLogin);
return UserFactory.getUser(didLogin.uid);
}).then(function(userCreds){
$rootScope.user = userCreds;
$scope.login = {};
$scope.register = {};
$location.url("/boards/list");
$location.url('/boards/list');
console.log("userCreds", userCreds);
});
};


$scope.setLoginContainer = function(){
$scope.loginContainer = true;
$scope.registerContainer = false;

};

$scope.setRegisterContainer = function(){
$scope.loginContainer = false;
$scope.registerContainer = true;

};

$scope.registerUser = function(registerNewUser){
AuthFactory.registerWithEmail(registerNewUser).then(function(didRegister){
registerNewUser.uid = didRegister.uid;
console.log("didRegister", didRegister);
return UserFactory.addUser(registerNewUser);
}).then(function(registerComplete){
logMeIn(registerNewUser);
Expand Down
4 changes: 2 additions & 2 deletions javascripts/controllers/BoardEditCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ app.controller("BoardEditCtrl", function($scope, $location, $routeParams, BoardF
});

$scope.addNewBoard = function(){
BoardFactory.editBoard($scope.newBoard).then(function(response){
$scope.newPins = {};
BoardFactory.editBoard($scope.newPin).then(function(response){
$scope.newPin = {};
$location.url("/boards/list");
});
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"use strict";

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

$scope.addNewBoard = function(){
$scope.newPin.isSelected = false;
$scope.newBoard.uid = $rootScope.user.uid;
$scope.newPin.uid = $rootScope.user.uid;
BoardFactory.postNewBoard($scope.newPin).then(function(boardId){
$location.url("/boards/list");
$scope.newPin = {};
});
};
});

console.log("BoardNewCtrl")
1 change: 0 additions & 1 deletion javascripts/controllers/BoardViewCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
app.controller("BoardViewCtrl", function($scope, $routeParams, BoardFactory){
$scope.selectedBoard = {};
let boardId = $routeParams.id;
//console.log("$routeParams", BoardId);

BoardFactory.getSingleBoard(boardId).then(function(oneBoard){
oneBoard.id=boardId;
Expand Down
12 changes: 7 additions & 5 deletions javascripts/controllers/GeneralViewCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ app.controller("GeneralViewCtrl", function($scope, $rootScope, BoardFactory){
$scope.boards = [];

let getBoards = function(){
BoardFactory.getBoardList($rootScope.user.uid).then(function(fbItems){
$scope.boards = fbItems;
BoardFactory.getBoardList($rootScope.user.uid).then(function(fbBoards){
$scope.boards = fbBoards;
});
};

Expand All @@ -17,9 +17,11 @@ $scope.deleteBoard = function(boardId){
});
};

$scope.inputChange = function(change){
BoardFactory.editBoard(change).then(function(response){
$scope.inputChange = function(thingy){
BoardFactory.editBoard(thingy).then(function(response){
getBoards();
});
};
});
});

console.log("GeneralViewCtrl Loaded");
4 changes: 2 additions & 2 deletions javascripts/controllers/NavCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ app.controller("NavCtrl", function($scope) {
url:"#/logout"
},
{
name:"All Items",
name:"My Boards",
url:"#/boards/list"
},
{
name:"New Item",
name:"All Boards",
url:"#/boards/new"
}
];
Expand Down
4 changes: 3 additions & 1 deletion javascripts/factories/AuthFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ app.factory("AuthFactory", function($q, $http, $rootScope, FIREBASE_CONFIG) {
};

return {isAuthenticated:isAuthenticated, getUser:getUser, logout:logout, registerWithEmail:registerWithEmail, authenticate:authenticate, authenticateGoogle: authenticateGoogle};
});
});

console.log("AuthFactory loaded");
8 changes: 4 additions & 4 deletions javascripts/factories/BoardFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
app.factory("BoardFactory", function($q, $http, FIREBASE_CONFIG){

var getBoardList = function(userId){
return $q((resolve, reject) =>{
return $q((resolve, reject) => {
$http.get(`${FIREBASE_CONFIG.databaseURL}/boards.json?orderBy="uid"&equalTo="${userId}"`)
.success(function(response){
let boards = [];
Expand All @@ -24,7 +24,7 @@ app.factory("BoardFactory", function($q, $http, FIREBASE_CONFIG){
JSON.stringify({
assignedTo: newBoard.assignedTo,
isSelected: newBoard.isSelected,
board: newBoard.pin,
pin: newBoard.pin,
uid: newBoard.uid
})
)
Expand Down Expand Up @@ -52,8 +52,8 @@ var deleteBoard = function(boardId){
var getSingleBoard = function(boardId){
return $q((resolve, reject) => {
$http.get(`${FIREBASE_CONFIG.databaseURL}/boards/${boardId}.json`)
.success(function(getSingleRespose){
resolve(getSingleRespose);
.success(function(getSingleResponse){
resolve(getSingleResponse);
})
.error(function(getSingleError){
reject(getSingleError);
Expand Down
86 changes: 86 additions & 0 deletions javascripts/factories/PinFactory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"use strict";

app.factory("PinFactory", function($q, $http, FIREBASE_CONFIG){

var getPinList = function(userId){
return $q((resolve, reject) => {
$http.get(`${FIREBASE_CONFIG.databaseURL}/pins.json?orderBy="uid"&equalTo="${userId}"`)
.success(function(response){
let pins = [];
Object.keys(response).forEach(function(key){
response[key].id = key;
boards.push(response[key]);
});
resolve(pins);
})
.error(function(errorResponse){
reject(errorResponse);
});
});
};
var postNewPin = function(newPin){
return $q((resolve, reject)=>{
$http.post(`${FIREBASE_CONFIG.databaseURL}/boards.json`,
JSON.stringify({
assignedTo: newPin.assignedTo,
isSelected: newPin.isSelected,
pin: newPin.board,
uid: newPin.uid
})
)
.success(function(postResponse){
resolve(postResponse);
})
.error(function(postError){
reject(postError);
});
});
};

var deletePin = function(boardId){
return $q((resolve, reject) => {
$http.delete(`${FIREBASE_CONFIG.databaseURL}/pins/${PinId}.json`)
.success(function(deleteResponse){
resolve(deleteResponse);
})
.error(function(deleteError){
reject(deleteError);
});
});
};

var getSingleBoard = function(pinId){
return $q((resolve, reject) => {
$http.get(`${FIREBASE_CONFIG.databaseURL}/pins/${pinId}.json`)
.success(function(getSingleResponse){
resolve(getSingleResponse);
})
.error(function(getSingleError){
reject(getSingleError);
});
});
};

var editPin = function(editPin){
return $q((resolve, reject)=>{
$http.put(`${FIREBASE_CONFIG.databaseURL}/pins/${editPin.id}.json`,
JSON.stringify({
assignedTo: editPin.assignedTo,
isSelected: editPin.isSelected,
pins: editPin.pin,
uid: editPin.uid
})
)
.success(function(editResponse){
resolve(editResponse);
})
.error(function(editError){
reject(editError);
});
});
};


return {getPinList:getPinList, postNewPin:postNewPin, deletePin:deletePin, getSinglePin:getSinglePin, editPin:editPin};
});

1 change: 1 addition & 0 deletions javascripts/factories/UserFactory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"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({
Expand Down
Loading