Alpha
This commit is contained in:
@@ -1,56 +1,53 @@
|
||||
<div class="row" ng-controller="8">
|
||||
<div class="col-md-4">
|
||||
<h4>{{welcomeMsg}}</h4>
|
||||
<div ng-if="isLoggedIn == true">
|
||||
<a href="{{userInfo.link}}" target="_blank"><img ng-src="{{picture}}"></a>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<h4>{{userData.welcomeMsg}}</h4>
|
||||
<div ng-show="isLoggedIn">
|
||||
<a href="{{userData.userInfo.link}}" target="_blank"><img ng-src="{{userData.picture}}"></a>
|
||||
</div>
|
||||
<br>
|
||||
<br><br>
|
||||
<div ng-show="isLoggedIn" class="well">
|
||||
<h4>User Info</h4>
|
||||
<ul>
|
||||
<li>ID: {{userData.userInfo._id}}</li>
|
||||
<li>First Name: {{userData.userInfo.first_name}}</li>
|
||||
<li>Last Name: {{userData.userInfo.last_name}}</li>
|
||||
<li>Email: {{userData.userInfo.email}}</li>
|
||||
<li>Gender: {{userData.userInfo.gender}}</li>
|
||||
<li>Locale: {{userData.userInfo.locale}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
<br>
|
||||
<div class="well" ng-show="isLoggedIn">
|
||||
<h4>Permissions</h4>
|
||||
<ul>
|
||||
<li ng-repeat="permission in permissions">{{permission.permission}} - {{permission.status}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<h3>Welcome to Facebook!</h3>
|
||||
<div ng-show="isLoggedIn">
|
||||
<form ng-submit="postStatus()">
|
||||
<div class="form-group">
|
||||
<label>Status Update</label>
|
||||
<textarea ng-model="body" class="form-control"></textarea>
|
||||
</div>
|
||||
<br>
|
||||
<div ng-if="isLoggedIn == true">
|
||||
<button type="button" class="btn btn-default" ng-click="logout()">Logout</button>
|
||||
</div>
|
||||
<br><br>
|
||||
<div ng-if="isLoggedIn == true" class="well">
|
||||
<h4>User Info</h4>
|
||||
<ul>
|
||||
<li>ID: {{userInfo.id}}</li>
|
||||
<li>First Name: {{userInfo.first_name}}</li>
|
||||
<li>Last Name: {{userInfo.last_name}}</li>
|
||||
<li>Email: {{userInfo.email}}</li>
|
||||
<li>Gender: {{userInfo.gender}}</li>
|
||||
<li>Locale: {{userInfo.locale}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
<br>
|
||||
<div class="well" ng-if="isLoggedIn == true">
|
||||
<h4>Permissions</h4>
|
||||
<ul>
|
||||
<li ng-repeat="permission in permissions">{{permission.permission}} - {{permission.status}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<h3>Welcome to Facebook!</h3>
|
||||
<div ng-if="isLoggedIn == true">
|
||||
<form ng-submit="postStatus()">
|
||||
<div class="form-group">
|
||||
<label>Status Update</label>
|
||||
<textarea ng-model="body" class="form-control"></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-default">Submit</button>
|
||||
</form>
|
||||
<br><br>
|
||||
<div ng-repeat="post in posts" class="stbody">
|
||||
<div class="stimg">
|
||||
<img ng-src="{{picture}}">
|
||||
</div>
|
||||
<div class="sttext">
|
||||
{{post.message}}
|
||||
<div class="sttime">{{post.updated_time}}</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-default">Submit</button>
|
||||
</form>
|
||||
<br><br>
|
||||
<div ng-repeat="post in userData.posts" class="stbody">
|
||||
<div class="stimg" style="background-image: url({{userData.picture}});background-repeat: no-repeat;background-size: contain;">
|
||||
<!--<img ng-src="{{userData.picture}}">-->
|
||||
</div>
|
||||
<div class="sttext">
|
||||
{{post.post_content}}
|
||||
<div class="sttime">{{post.updated_time}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-if="isLoggedIn == false">
|
||||
<p>You need to login to post</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-show="isLoggedIn == false">
|
||||
<p>You need to login to post</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -6,12 +6,45 @@ angular.module('ngSocial.facebook', ['ngRoute'])
|
||||
$routeProvider.when('/facebook', {
|
||||
templateUrl: 'facebook/facebook.html',
|
||||
controller: 'FacebookCtrl'
|
||||
}).when('/login', {
|
||||
templateUrl: 'facebook/facebook.html',
|
||||
controller: 'LoginCtrl'
|
||||
});
|
||||
}])
|
||||
.controller('FacebookCtrl', ['$scope', '$http', function($scope, $http) {
|
||||
$scope.isLoggedIn = false;
|
||||
.service('refreshService', ['$http', function($http){
|
||||
self = this;
|
||||
var l2Response = {}
|
||||
|
||||
$scope.login = function(){
|
||||
this.refresh = function(_id, callback){
|
||||
if(this.isLoggedIn) {
|
||||
$http({
|
||||
url: 'http://127.0.0.1:5003/app/getUserInfo',
|
||||
method: "GET",
|
||||
params: {
|
||||
'_id': _id
|
||||
}
|
||||
}).then(function(response) {
|
||||
if(response) {
|
||||
var responseData = JSON.parse(response.data)
|
||||
l2Response.welcomeMsg = "Welcome "+ responseData.first_name;
|
||||
l2Response.userInfo = responseData;
|
||||
l2Response.picture = l2Response.userInfo ? (l2Response.userInfo.image_url ? l2Response.userInfo.image_url : '') : '';
|
||||
l2Response.posts = l2Response.userInfo ? (l2Response.userInfo.posts ? l2Response.userInfo.posts : []) : [];
|
||||
callback(l2Response);
|
||||
}
|
||||
}, function(response) {
|
||||
if(response && response.data) {
|
||||
l2Response.error = response.data.error;
|
||||
callback(l2Response);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}])
|
||||
.controller('LoginCtrl', ['$scope', '$http', '$window', 'refreshService', function($scope, $http, $window, refreshService) {
|
||||
$scope.connector = refreshService;
|
||||
$scope.isLoggedIn = refreshService.isLoggedIn ? refreshService.isLoggedIn : false;
|
||||
$scope.login = function(){
|
||||
var username = $scope.username
|
||||
var password = $scope.password
|
||||
$http({
|
||||
@@ -23,50 +56,57 @@ angular.module('ngSocial.facebook', ['ngRoute'])
|
||||
}
|
||||
}).then(function(response) {
|
||||
if(response) {
|
||||
$scope.isLoggedIn = true;
|
||||
var _id = JSON.parse(response.data)['_id']
|
||||
$scope.refresh(_id);
|
||||
$scope.connector.id = _id
|
||||
$scope.connector.isLoggedIn = true;
|
||||
$scope.isLoggedIn = true;
|
||||
// $scope.userData = refreshService.refresh(refreshService.id);
|
||||
$window.location.href = '/app/#/facebook';
|
||||
}
|
||||
}, function(response, status) {
|
||||
$scope.error = response.data.error
|
||||
}, function(response) {
|
||||
if(response && response.data)
|
||||
$scope.connector.error = response.data.error
|
||||
});
|
||||
}
|
||||
|
||||
$scope.logout = function(){
|
||||
//$facebook.logout().then(function(){
|
||||
$scope.isLoggedIn = false;
|
||||
$scope.refresh();
|
||||
$scope.connector.isLoggedIn = false;
|
||||
$scope.isLoggedIn = refreshService.isLoggedIn ? refreshService.isLoggedIn : false;
|
||||
$scope.userData = refreshService.refresh(refreshService.id);
|
||||
//});
|
||||
}
|
||||
|
||||
$scope.refresh = function(_id){
|
||||
if($scope.isLoggedIn) {
|
||||
}])
|
||||
.controller('FacebookCtrl', ['$scope', '$http', 'refreshService', function($scope, $http, refreshService) {
|
||||
self = this;
|
||||
$scope.connector = refreshService;
|
||||
$scope.isLoggedIn = $scope.connector.isLoggedIn;
|
||||
$scope.postStatus = function(){
|
||||
if($scope.isLoggedIn) {
|
||||
var post = $scope.body;
|
||||
var _id = $scope.connector.id;
|
||||
$http({
|
||||
url: 'http://127.0.0.1:5003/app/getUserInfo',
|
||||
method: "GET",
|
||||
params: {
|
||||
'_id': _id
|
||||
}
|
||||
url: 'http://127.0.0.1:5003/app/feed',
|
||||
method: "POST",
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' },
|
||||
data: "post="+ post+"&_id="+_id
|
||||
}).then(function(response) {
|
||||
if(response) {
|
||||
var responseData = JSON.parse(response.data)
|
||||
$scope.userInfo = responseData
|
||||
$scope.userData.msg = JSON.parse(response.data)['msg'];
|
||||
}
|
||||
self.refresh()
|
||||
}, function(response) {
|
||||
if(respnose && response.data)
|
||||
if(response && response.data)
|
||||
$scope.error = response.data.error
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$scope.postStatus = function(){
|
||||
var body = this.body;
|
||||
$facebook.api('/me/feed', 'post', {message: body}).then(function(response){
|
||||
$scope.msg = 'Thanks for Posting';
|
||||
$scope.refresh();
|
||||
});
|
||||
}
|
||||
self.refresh = function() {
|
||||
$scope.connector.refresh($scope.connector.id, function(data) {
|
||||
$scope.userData = data;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.refresh();
|
||||
self.refresh();
|
||||
}]);
|
||||
0
app/facebook/login.html
Normal file
0
app/facebook/login.html
Normal file
Reference in New Issue
Block a user