Hooking up Angular to Profile.jade
This commit is contained in:
1
app.js
1
app.js
@ -250,6 +250,7 @@ app.get(
|
|||||||
);
|
);
|
||||||
app.all('/account', passportConf.isAuthenticated);
|
app.all('/account', passportConf.isAuthenticated);
|
||||||
app.get('/account', userController.getAccount);
|
app.get('/account', userController.getAccount);
|
||||||
|
app.get('/account/api', userController.getAccountAngular);
|
||||||
app.post('/account/profile', userController.postUpdateProfile);
|
app.post('/account/profile', userController.postUpdateProfile);
|
||||||
app.post('/account/password', userController.postUpdatePassword);
|
app.post('/account/password', userController.postUpdatePassword);
|
||||||
app.post('/account/delete', userController.postDeleteAccount);
|
app.post('/account/delete', userController.postDeleteAccount);
|
||||||
|
@ -145,12 +145,28 @@ exports.getAccount = function(req, res) {
|
|||||||
title: 'Manage your Free Code Camp Account',
|
title: 'Manage your Free Code Camp Account',
|
||||||
challenges: c,
|
challenges: c,
|
||||||
ch: req.user.challengesHash,
|
ch: req.user.challengesHash,
|
||||||
moment: moment,
|
moment: moment
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Angular API Call
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.getAccountAngular = function(req, res) {
|
||||||
|
Challenge.find({}, null, { sort: { challengeNumber: 1 } }, function(err, c) {
|
||||||
|
if (err) {
|
||||||
|
console.error('Challenge err: ', err);
|
||||||
|
next(err);
|
||||||
|
}
|
||||||
|
res.json({
|
||||||
user: req.user
|
user: req.user
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /users/:username
|
* GET /users/:username
|
||||||
* Public Profile page.
|
* Public Profile page.
|
||||||
|
@ -45,12 +45,9 @@ $(document).ready(function() {
|
|||||||
var profileValidation = angular.module('profileValidation',[]);
|
var profileValidation = angular.module('profileValidation',[]);
|
||||||
profileValidation.controller('profileValidationController', ['$scope', '$http',
|
profileValidation.controller('profileValidationController', ['$scope', '$http',
|
||||||
function($scope, $http) {
|
function($scope, $http) {
|
||||||
$http.get('/account').success(function(data) {
|
$http.get('/account/api').success(function(data) {
|
||||||
console.log('============');
|
|
||||||
console.log(data);
|
|
||||||
console.log('============');
|
|
||||||
$scope.user = data.user;
|
$scope.user = data.user;
|
||||||
|
console.log($scope.user);
|
||||||
});
|
});
|
||||||
//$scope.user = user;
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
@ -8,19 +8,15 @@ block content
|
|||||||
.form-group
|
.form-group
|
||||||
label.col-sm-3.col-sm-offset-2.control-label(for='name') Name
|
label.col-sm-3.col-sm-offset-2.control-label(for='name') Name
|
||||||
.col-sm-4
|
.col-sm-4
|
||||||
input.form-control(type='text', name='name', id='name', value='#{user.profile.name}')
|
input.form-control(type='text', placeholder='Name', name='name', ng-model='user.profile.name', ng-minlength='3', ng-maxlength='20', required='required', ng-focus='ng-focus', id='name', value='{{user.profile.name}}')
|
||||||
.form-group
|
|
||||||
label.col-sm-3.col-sm-offset-2.control-label(for='name') Name
|
|
||||||
.col-sm-4
|
|
||||||
input.form-control(type='text', placeholder='Name', name='name', ng-model='user.name', ng-minlength='3', ng-maxlength='20', required='required', ng-focus='ng-focus', id='name', value='{{user.name}}')
|
|
||||||
.form-group
|
.form-group
|
||||||
label.col-sm-3.col-sm-offset-2.control-label(for='username') Username (use letters, numbers, underscore) *
|
label.col-sm-3.col-sm-offset-2.control-label(for='username') Username (use letters, numbers, underscore) *
|
||||||
.col-sm-4
|
.col-sm-4
|
||||||
input.form-control(type='text', name='username', id='username', value='#{user.profile.username}')
|
input.form-control(type='text', name='username', id='username', ng-model='user.profile.username', value='{{user.profile.username}}')
|
||||||
.form-group
|
.form-group
|
||||||
label.col-sm-3.col-sm-offset-2.control-label(for='email') Email *
|
label.col-sm-3.col-sm-offset-2.control-label(for='email') Email *
|
||||||
.col-sm-4
|
.col-sm-4
|
||||||
input.form-control(type='email', name='email', id='email', value='#{user.email}')
|
input.form-control(type='email', name='email', id='email', ng-model='user.email', value= '{{user.email}}')
|
||||||
.form-group
|
.form-group
|
||||||
label.col-sm-3.col-sm-offset-2.control-label(for='location') Location
|
label.col-sm-3.col-sm-offset-2.control-label(for='location') Location
|
||||||
.col-sm-4
|
.col-sm-4
|
||||||
@ -28,9 +24,9 @@ block content
|
|||||||
.form-group
|
.form-group
|
||||||
label.col-sm-3.col-sm-offset-2.control-label(for='email') Twitter Handle
|
label.col-sm-3.col-sm-offset-2.control-label(for='email') Twitter Handle
|
||||||
.col-sm-4
|
.col-sm-4
|
||||||
input.form-control(type='text', name='twitterHandle', id='twitterHandle', ng-model="user.twitterHandle" value='#{user.profile.twitterHandle}')
|
input.form-control(type='text', name='twitterHandle', id='twitterHandle', ng-model="user.profile.twitterHandle" value='#{user.profile.twitterHandle}')
|
||||||
span
|
span
|
||||||
{{user.twitterHandle}}
|
{{user.profile.twitterHandle}}
|
||||||
.form-group
|
.form-group
|
||||||
label.col-sm-3.col-sm-offset-2.control-label(for='email') Github Profile Link
|
label.col-sm-3.col-sm-offset-2.control-label(for='email') Github Profile Link
|
||||||
.col-sm-4
|
.col-sm-4
|
||||||
|
Reference in New Issue
Block a user