This commit is contained in:
2018-05-12 04:47:40 +05:30
parent 5a4285bbe7
commit 639ada1c9d
25 changed files with 136 additions and 135 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
._LICENSE

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,3 +0,0 @@
{
"directory": "app/bower_components"
}

View File

@@ -1,13 +0,0 @@
{
"globalstrict": true,
"globals": {
"angular": false,
"describe": false,
"it": false,
"expect": false,
"beforeEach": false,
"afterEach": false,
"module": false,
"inject": false
}
}

View File

@@ -1,14 +0,0 @@
language: node_js
node_js:
- "0.10"
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- npm start > /dev/null &
- npm run update-webdriver
- sleep 1 # give server time to start
script:
- node_modules/.bin/karma start karma.conf.js --no-auto-watch --single-run --reporters=dots --browsers=Firefox
- node_modules/.bin/protractor e2e-tests/protractor.conf.js --browser=firefox

View File

@@ -6,5 +6,5 @@ angular.module('ngSocial', [
'ngSocial.facebook'
]).
config(['$routeProvider', function($routeProvider) {
$routeProvider.otherwise({redirectTo: '/facebook'});
$routeProvider.otherwise({redirectTo: '/login'});
}]);

View File

@@ -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>

View File

@@ -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
View File

BIN
app/images/image1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

BIN
app/images/image2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
app/images/image3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
app/images/image4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 B

BIN
app/images/image5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
app/images/image6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
app/images/image7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
app/images/image8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1,19 +1,15 @@
<!DOCTYPE html>
<!--[if lt IE 7]> <html lang="en" ng-app="ngSocial" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html lang="en" ng-app="ngSocial" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html lang="en" ng-app="ngSocial" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" ng-app="ngSocial" class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>ngSocial App</title>
<title>Facebook</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="app.css">
</head>
<body ng-controller="FacebookCtrl">
<nav class="navbar navbar-inverse">
<body ng-app="ngSocial">
<nav class="navbar navbar-inverse" ng-controller="LoginCtrl">
<div class="col-sm-6 col-md-6 container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
@@ -25,26 +21,24 @@
<a class="navbar-brand" href="#">Facebook</a>
</div>
</div>
<div class="col-sm-6 col-md-6 pull-right">
<div class="col-sm-6 col-md-6 pull-right" ng-show="isLoggedIn == false">
<form class="navbar-form pull-right">
<input type="text" class="form-control" placeholder="Username" ng-model="username" id="username">
<input type="password" class="form-control" placeholder="Password" ng-model="password" id="password">
<button class="btn btn-success" type="submit" ng-click="login()">Login</button>
<button class="btn btn-success" type="button" ng-click="login()">Login</button>
</form>
</div>
</div>
<div class="col-sm-6 col-md-6 pull-right" ng-show="isLoggedIn">
<form class="navbar-form pull-right">
<button type="button" class="btn btn-default btn-sm pull-right" ng-click="logout()">
<span class="glyphicon glyphicon-log-out"></span> Logout
</button>
</form>
</div>
</nav>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div class="container">
<div ng-view></div>
</div>
<!-- In production use:
<script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
-->
<div class="container">
<div ng-view></div>
</div>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="app.js"></script>