├── .bowerrc ├── .gitignore ├── LICENSE ├── README.md ├── app ├── app.css ├── app.js ├── common │ ├── datepicker-directive.js │ ├── footer-directive.html │ ├── footer-directive.js │ ├── main-controller.js │ └── validate-english-directive.js ├── home │ ├── home-controller.js │ └── home.html ├── news-feed │ ├── feed.js │ ├── news-feed-controller.js │ └── news-feed.html └── users │ ├── authentication.js │ └── identity.js ├── bower.json ├── index.html └── package.json /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "app/bower_components" 3 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | logs/* 2 | !.gitkeep 3 | node_modules/ 4 | bower_components/ 5 | tmp 6 | .DS_Store 7 | .idea 8 | .vscode -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2010-2014 Google, Inc. http://angularjs.org 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Social Network - Angular JS demo project -------------------------------------------------------------------------------- /app/app.css: -------------------------------------------------------------------------------- 1 | /* app css stylesheet */ 2 | 3 | body { 4 | margin-top: 60px; 5 | } 6 | 7 | .border { 8 | border: 1px solid black; 9 | padding: 15px; 10 | } 11 | 12 | .margin-bottom-100 { 13 | margin-bottom: 100px; 14 | } 15 | 16 | .menu { 17 | list-style: none; 18 | border-bottom: 0.1em solid black; 19 | margin-bottom: 2em; 20 | padding: 0 0 0.5em; 21 | } 22 | 23 | .hidden-element { 24 | display: none; 25 | } 26 | 27 | .disabled-button { 28 | opacity: 0.5; 29 | } 30 | 31 | .small-image { 32 | width: 250px; 33 | } 34 | 35 | input.ng-invalid.ng-dirty { 36 | background-color: pink; 37 | } 38 | 39 | .menu:before { 40 | content: "["; 41 | } 42 | 43 | .menu:after { 44 | content: "]"; 45 | } 46 | 47 | .menu > li { 48 | display: inline; 49 | } 50 | 51 | .menu > li:before { 52 | content: "|"; 53 | padding-right: 0.3em; 54 | } 55 | 56 | .menu > li:nth-child(1):before { 57 | content: ""; 58 | padding: 0; 59 | } 60 | -------------------------------------------------------------------------------- /app/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('socialNetwork', [ 4 | 'ngRoute', 5 | 'ngCookies', 6 | 'socialNetwork.common', 7 | 'socialNetwork.common.footer', 8 | 'socialNetwork.common.validation', 9 | 'socialNetwork.common.datepicker', 10 | 'socialNetwork.home', 11 | 'socialNetwork.newsFeed', 12 | 'socialNetwork.users.identity' 13 | ]) 14 | .config(['$routeProvider', '$httpProvider', function($routeProvider, $httpProvider) { 15 | $routeProvider.otherwise({redirectTo: '/'}); 16 | 17 | $httpProvider.interceptors.push(['$q','toastr', function($q, toastr) { 18 | return { 19 | 'responseError': function(rejection) { 20 | if (rejection.data && rejection.data['error_description']) { 21 | toastr.error(rejection.data['error_description']); 22 | } 23 | else if (rejection.data && rejection.data.modelState && rejection.data.modelState['']){ 24 | var errors = rejection.data.modelState['']; 25 | if (errors.length > 0) { 26 | toastr.error(errors[0]); 27 | } 28 | } 29 | 30 | return $q.reject(rejection); 31 | } 32 | } 33 | }]); 34 | }]) 35 | .run(['$rootScope', '$location', 'authentication', function($rootScope, $location, authentication) { 36 | $rootScope.$on('$routeChangeError', function(ev, current, previous, rejection) { 37 | if (rejection == 'Unauthorized Access') { 38 | $location.path('/'); 39 | } 40 | }); 41 | 42 | authentication.refreshCookie(); 43 | }]) 44 | .constant('jQuery', $) 45 | .constant('toastr', toastr) 46 | .constant('BASE_URL', 'http://softuni-social-network.azurewebsites.net/api/'); 47 | -------------------------------------------------------------------------------- /app/common/datepicker-directive.js: -------------------------------------------------------------------------------- 1 | angular.module('socialNetwork.common.datepicker', []) 2 | .directive('datePicker', [function() { 3 | return { 4 | restrict: 'A', 5 | link: function(scope, element, attrs) { 6 | var minDate = attrs['minDate'] || '-20'; 7 | var maxDate = attrs['maxDate'] || '+1M +10D'; 8 | 9 | element.datepicker({ 10 | minDate: parseInt(minDate), 11 | maxDate: maxDate 12 | }); 13 | } 14 | } 15 | }]); -------------------------------------------------------------------------------- /app/common/footer-directive.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/common/footer-directive.js: -------------------------------------------------------------------------------- 1 | angular.module('socialNetwork.common.footer', []) 2 | .directive('footer', [function() { 3 | return { 4 | restrict: 'A', 5 | templateUrl: 'app/common/footer-directive.html', 6 | link: function (scope, element) { 7 | 8 | } 9 | }; 10 | }]); 11 | -------------------------------------------------------------------------------- /app/common/main-controller.js: -------------------------------------------------------------------------------- 1 | angular.module('socialNetwork.common', []) 2 | .controller('MainCtrl', [ 3 | '$scope', 4 | 'identity', 5 | function($scope, identity) { 6 | identity.getCurrentUser() 7 | .then(function(user) { 8 | $scope.currentUser = user; 9 | $scope.isAuthenticated = true; 10 | }); 11 | }]); -------------------------------------------------------------------------------- /app/common/validate-english-directive.js: -------------------------------------------------------------------------------- 1 | angular.module('socialNetwork.common.validation', []) 2 | .directive('validateEnglish', [function() { 3 | return { 4 | restrict: 'A', 5 | link: function(scope, element) { 6 | 7 | } 8 | } 9 | }]); -------------------------------------------------------------------------------- /app/home/home-controller.js: -------------------------------------------------------------------------------- 1 | angular.module('socialNetwork.home', [ 2 | 'socialNetwork.users.authentication' 3 | ]) 4 | .config(['$routeProvider', function($routeProvider) { 5 | $routeProvider.when('/', { 6 | templateUrl: 'app/home/home.html', 7 | controller: 'HomeCtrl' 8 | }); 9 | }]) 10 | .controller('HomeCtrl', [ 11 | '$scope', 12 | '$location', 13 | 'authentication', 14 | function($scope, $location, authentication) { 15 | if (authentication.isAuthenticated()) { 16 | $location.path('/newsFeed'); 17 | } 18 | 19 | $scope.login = function (user) { 20 | authentication.loginUser(user) 21 | .then(function(loggedInUser){ 22 | $location.path('/newsFeed'); 23 | }); 24 | }; 25 | 26 | $scope.register = function (user) { 27 | authentication.registerUser(user) 28 | .then(function(registeredUser) { 29 | $location.path('/newsFeed'); 30 | }); 31 | }; 32 | }]); -------------------------------------------------------------------------------- /app/home/home.html: -------------------------------------------------------------------------------- 1 |