Commit 2870b0549f7deb02b093200a0e543b5b2f999571

Authored by Leonardo Merlin
2 parents c31c2869 bfe0e42e

Merge branch 'refact-auth' into merlin

@@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
15 "bootstrap-sass-official": "~3.3.4", 15 "bootstrap-sass-official": "~3.3.4",
16 "jquery": "~2.1.4", 16 "jquery": "~2.1.4",
17 "modernizr": "~2.8.3", 17 "modernizr": "~2.8.3",
  18 + "ngstorage": "~0.3.9",
18 "open-sans-fontface": "~1.4.2" 19 "open-sans-fontface": "~1.4.2"
19 }, 20 },
20 "devDependencies": { 21 "devDependencies": {
src/app/components/a11y-bar/a11y-bar.html
@@ -4,27 +4,27 @@ @@ -4,27 +4,27 @@
4 <div class="col-sm-6"> 4 <div class="col-sm-6">
5 <ul class="skip-links list-inline list-unstyled"> 5 <ul class="skip-links list-inline list-unstyled">
6 <li> 6 <li>
7 - <a accesskey="1" href="#content" id="skip-to-content" ng-click="focusOn('#content', $event)"> 7 + <a class="color-theme-common-fg" accesskey="1" href="#content" id="skip-to-content" ng-click="focusOn('#content', $event)">
8 Ir para o conteúdo 8 Ir para o conteúdo
9 - <span>1</span> 9 + <span class="color-theme-common-bg">1</span>
10 </a> 10 </a>
11 </li> 11 </li>
12 <li> 12 <li>
13 - <a accesskey="2" href="#navigation" id="skip-to-navigation" ng-click="focusOn('#navigation', $event)"> 13 + <a class="color-theme-common-fg" accesskey="2" href="#navigation" id="skip-to-navigation" ng-click="focusOn('#navigation', $event)">
14 Ir para o menu 14 Ir para o menu
15 - <span>2</span> 15 + <span class="color-theme-common-bg">2</span>
16 </a> 16 </a>
17 </li> 17 </li>
18 <li> 18 <li>
19 - <a accesskey="3" href="#search" id="skip-to-search" ng-click="focusOn('#search', $event)"> 19 + <a class="color-theme-common-fg" accesskey="3" href="#search" id="skip-to-search" ng-click="focusOn('#search', $event)">
20 Ir para a busca 20 Ir para a busca
21 - <span>3</span> 21 + <span class="color-theme-common-bg">3</span>
22 </a> 22 </a>
23 </li> 23 </li>
24 <li> 24 <li>
25 - <a accesskey="4" href="#footer" id="skip-to-footer" ng-click="focusOn('#footer', $event)"> 25 + <a class="color-theme-common-fg" accesskey="4" href="#footer" id="skip-to-footer" ng-click="focusOn('#footer', $event)">
26 Ir para o rodapé 26 Ir para o rodapé
27 - <span>4</span> 27 + <span class="color-theme-common-bg">4</span>
28 </a> 28 </a>
29 </li> 29 </li>
30 </ul> 30 </ul>
@@ -33,13 +33,13 @@ @@ -33,13 +33,13 @@
33 <div class="col-sm-6"> 33 <div class="col-sm-6">
34 <ul class="action-links list-inline list-unstyled pull-right"> 34 <ul class="action-links list-inline list-unstyled pull-right">
35 <li> 35 <li>
36 - <a id="siteaction-accessibility" href="#" title="Acessibilidade" accesskey="5" ng-click="actionAccessibility()">Acessibilidade</a> 36 + <a id="siteaction-accessibility" class="color-theme-common-fg" href="#" title="Acessibilidade" accesskey="5" ng-click="actionAccessibility()">Acessibilidade</a>
37 </li> 37 </li>
38 <li> 38 <li>
39 - <a id="siteaction-contrast" href="#" title="Alto Contraste" accesskey="6" ng-click="actionContrast()">Alto Contraste</a> 39 + <a id="siteaction-contrast" class="color-theme-common-fg" href="#" title="Alto Contraste" accesskey="6" ng-click="actionContrast()">Alto Contraste</a>
40 </li> 40 </li>
41 <li> 41 <li>
42 - <a id="siteaction-sitemap" ui-sref="mapa-do-site" title="Mapa do Site" accesskey="7" ng-click="actionSitemap()">Mapa do Site</a> 42 + <a id="siteaction-sitemap" class="color-theme-common-fg" ui-sref="mapa-do-site" title="Mapa do Site" accesskey="7" ng-click="actionSitemap()">Mapa do Site</a>
43 </li> 43 </li>
44 </ul> 44 </ul>
45 </div> 45 </div>
src/app/components/a11y-bar/a11y-bar.scss
@@ -2,7 +2,12 @@ @@ -2,7 +2,12 @@
2 font-size: 12px; 2 font-size: 12px;
3 padding: 5px 0; 3 padding: 5px 0;
4 span { 4 span {
5 - background-color: #eee;  
6 - padding: 0 3px; 5 + color: #fff;
  6 + padding: 0 5px;
  7 + }
  8 +
  9 + .action-links {
  10 + text-transform: uppercase;
  11 + border-bottom: 1px dotted #262626;
7 } 12 }
8 } 13 }
src/app/components/article-box/article-box.directive.js
@@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
33 vm.category = vm.article.categories[0]; 33 vm.category = vm.article.categories[0];
34 } 34 }
35 35
36 - if(!vm.banner){ 36 + if(!vm.banner && vm.article.image){
37 vm.banner = { 37 vm.banner = {
38 src: $rootScope.basePath + vm.article.image.url, 38 src: $rootScope.basePath + vm.article.image.url,
39 alt: 'Imagem de destaque do conteúdo' 39 alt: 'Imagem de destaque do conteúdo'
src/app/components/article-grid/article-grid.directive.js
@@ -32,13 +32,9 @@ @@ -32,13 +32,9 @@
32 ArticleGridController.prototype.init = function() { 32 ArticleGridController.prototype.init = function() {
33 var vm = this; 33 var vm = this;
34 34
35 - vm.ArticleService.getPrograms(function(programs){  
36 - vm.articles = programs;  
37 - });  
38 -  
39 - vm.ArticleService.getCategories(function(categories){  
40 - vm.categories = categories;  
41 - }); 35 + vm.articles = null;
  36 + vm.filtredArticleList = null;
  37 + vm.categories = null;
42 38
43 vm.orderCriteries = [ 39 vm.orderCriteries = [
44 { label: 'Título', name: 'titulo' }, 40 { label: 'Título', name: 'titulo' },
@@ -46,7 +42,6 @@ @@ -46,7 +42,6 @@
46 { label: 'Aleatório', name: 'aleatorio' } 42 { label: 'Aleatório', name: 'aleatorio' }
47 ]; 43 ];
48 44
49 - vm.filtredArticleList = vm.getFiltredArticles();  
50 vm.search = vm.$location.search(); 45 vm.search = vm.$location.search();
51 46
52 // Add initial values for the filter 47 // Add initial values for the filter
@@ -70,6 +65,16 @@ @@ -70,6 +65,16 @@
70 angular.element('body').animate({scrollTop: $el.offset().top}, 'slow'); 65 angular.element('body').animate({scrollTop: $el.offset().top}, 'slow');
71 } 66 }
72 67
  68 + vm.loadData(function(){
  69 + vm.filtredArticleList = vm.getFiltredArticles();
  70 + });
  71 +
  72 + vm.attachListeners();
  73 + };
  74 +
  75 + ArticleGridController.prototype.attachListeners = function() {
  76 + var vm = this;
  77 +
73 // update window location params 78 // update window location params
74 vm.$scope.$on('change-selectedCategory', function(event, selectedCategory){ 79 vm.$scope.$on('change-selectedCategory', function(event, selectedCategory){
75 vm.selectedCategory = selectedCategory; 80 vm.selectedCategory = selectedCategory;
@@ -116,6 +121,30 @@ @@ -116,6 +121,30 @@
116 }); 121 });
117 122
118 }; 123 };
  124 + ArticleGridController.prototype.loadData = function(cb) {
  125 + var vm = this;
  126 +
  127 + var articlesLoaded = false;
  128 + var categoriesLoaded = false;
  129 +
  130 + vm.ArticleService.getPrograms(function(programs){
  131 + vm.articles = programs;
  132 + articlesLoaded = true;
  133 + endLoad();
  134 + });
  135 +
  136 + vm.ArticleService.getCategories(function(categories){
  137 + vm.categories = categories;
  138 + categoriesLoaded = true;
  139 + endLoad();
  140 + });
  141 +
  142 + function endLoad () {
  143 + if(articlesLoaded && categoriesLoaded){
  144 + cb();
  145 + }
  146 + }
  147 + };
119 148
120 ArticleGridController.prototype.resetFilterValues = function() { 149 ArticleGridController.prototype.resetFilterValues = function() {
121 var vm = this; 150 var vm = this;
src/app/components/auth-user/auth-user.directive.js 0 → 100644
@@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
  1 +(function() {
  2 + 'use strict';
  3 +
  4 + angular
  5 + .module('dialoga')
  6 + .directive('authUser', authUser);
  7 +
  8 + /** @ngInject */
  9 + function authUser() {
  10 +
  11 + /** @ngInject */
  12 + function AuthUserController($scope, AuthService, Session, AUTH_EVENTS, $log) {
  13 + $log.debug('AuthUserController');
  14 +
  15 + var vm = this;
  16 +
  17 + vm.$scope = $scope;
  18 + vm.AuthService = AuthService;
  19 + vm.Session = Session;
  20 + vm.AUTH_EVENTS = AUTH_EVENTS;
  21 + vm.$log = $log;
  22 +
  23 + vm.init();
  24 + }
  25 +
  26 + AuthUserController.prototype.init = function (){
  27 + var vm = this;
  28 +
  29 + vm.currentUser = vm.Session.getCurrentUser();
  30 +
  31 + // handle login
  32 + vm.$scope.$on(vm.AUTH_EVENTS.loginSuccess, function () {
  33 + vm.currentUser = vm.Session.getCurrentUser();
  34 + });
  35 +
  36 + // handle logout
  37 + vm.$scope.$on(vm.AUTH_EVENTS.logoutSuccess, function () {
  38 + vm.currentUser = vm.Session.getCurrentUser();
  39 + });
  40 + };
  41 +
  42 + AuthUserController.prototype.onClickLogout = function (){
  43 + var vm = this;
  44 +
  45 + vm.AuthService.logout();
  46 + };
  47 +
  48 + var directive = {
  49 + restrict: 'E',
  50 + templateUrl: 'app/components/auth-user/auth-user.html',
  51 + controller: AuthUserController,
  52 + controllerAs: 'vm',
  53 + bindToController: true
  54 + };
  55 +
  56 + return directive;
  57 +
  58 + }
  59 +
  60 +})();
src/app/components/auth-user/auth-user.html 0 → 100644
@@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
  1 +<div class="auth-user">
  2 + <div ng-if="vm.currentUser" class="pull-right">
  3 + <span>{{::vm.currentUser.login}}</span>
  4 + <span>|</span>
  5 + <button type="button" class="btn btn-link" ng-click="vm.onClickLogout()">Sair</button>
  6 + </div>
  7 +
  8 + <div ng-if="!vm.currentUser">
  9 + <button type="button" class="btn btn-link pull-right" ui-sref="entrar">
  10 + <!-- <span class="icon icon-user" aria-hidden="true"></span> -->
  11 + <!-- <span class="glyphicon glyphicon-user"></span> -->
  12 + Entrar
  13 + </button>
  14 + </div>
  15 +</div>
src/app/components/auth-user/auth-user.scss 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +.auth-user {
  2 + button {
  3 + font-weight: bold;
  4 + }
  5 +}
src/app/components/auth/auth.service.js
@@ -10,18 +10,9 @@ @@ -10,18 +10,9 @@
10 /** @ngInject */ 10 /** @ngInject */
11 function AuthService($http, $rootScope, Session, AUTH_EVENTS, API, $log) { 11 function AuthService($http, $rootScope, Session, AUTH_EVENTS, API, $log) {
12 12
13 - var service = {  
14 - login: login,  
15 - logout: logout,  
16 - isAuthenticated: isAuthenticated,  
17 - isAuthorized: isAuthorized  
18 - };  
19 -  
20 - $log.debug('AuthService', service);  
21 - return service;  
22 -  
23 function login (credentials) { 13 function login (credentials) {
24 - var url = API.host + '/api/v1/login'; 14 + var hostProd = 'http://login.dialoga.gov.br';
  15 + var url = hostProd + '/api/v1/login';
25 var encodedData = 'login=' + credentials.username + '&password=' + credentials.password; 16 var encodedData = 'login=' + credentials.username + '&password=' + credentials.password;
26 17
27 return $http 18 return $http
@@ -40,7 +31,10 @@ @@ -40,7 +31,10 @@
40 } 31 }
41 32
42 function logout () { 33 function logout () {
  34 +
43 Session.destroy(); 35 Session.destroy();
  36 +
  37 + $rootScope.$broadcast(AUTH_EVENTS.logoutSuccess);
44 } 38 }
45 39
46 function isAuthenticated () { 40 function isAuthenticated () {
@@ -54,42 +48,42 @@ @@ -54,42 +48,42 @@
54 48
55 return (service.isAuthenticated() && authorizedRoles.indexOf(Session.userRole) !== -1); 49 return (service.isAuthenticated() && authorizedRoles.indexOf(Session.userRole) !== -1);
56 } 50 }
  51 +
  52 + var service = {
  53 + login: login,
  54 + logout: logout,
  55 + isAuthenticated: isAuthenticated,
  56 + isAuthorized: isAuthorized
  57 + };
  58 +
  59 + $log.debug('AuthService', service);
  60 + return service;
57 } 61 }
58 62
59 /** @ngInject */ 63 /** @ngInject */
60 - function Session($cookies, $log) { 64 + function Session($localStorage, $log) {
61 65
62 var service = {}; 66 var service = {};
63 67
64 - var currentUser = $cookies.getObject('currentUser') || {}; 68 + // $localStorage.currentUser = $localStorage.currentUser || null;
65 69
66 service.create = function(data) { 70 service.create = function(data) {
67 71
68 - currentUser.id = data.id;  
69 - currentUser.email = data.email;  
70 - currentUser.login = data.login;  
71 - currentUser.permissions = data.permissions;  
72 - currentUser.person = data.person;  
73 - currentUser.private_token = data.private_token;  
74 - currentUser.activated = data.activated;  
75 -  
76 - $cookies.putObject('currentUser', currentUser); 72 + $localStorage.currentUser = data;
  73 + $log.debug('User session created.', $localStorage.currentUser);
77 74
78 - $log.debug('User session created.', currentUser);  
79 - return currentUser; 75 + return $localStorage.currentUser;
80 }; 76 };
81 77
82 service.destroy = function() { 78 service.destroy = function() {
83 79
84 - currentUser = {};  
85 -  
86 - $cookies.remove('currentUser'); 80 + delete $localStorage.currentUser;
87 81
88 $log.debug('User session destroyed.'); 82 $log.debug('User session destroyed.');
89 }; 83 };
90 84
91 service.getCurrentUser = function () { 85 service.getCurrentUser = function () {
92 - return currentUser; 86 + return $localStorage.currentUser;
93 }; 87 };
94 88
95 return service; 89 return service;
src/app/components/navbar/navbar.html
1 <nav id="navigation" class="header-navbar navbar navbar-static-top" role="navigation"> 1 <nav id="navigation" class="header-navbar navbar navbar-static-top" role="navigation">
2 - <div class="container-fluid">  
3 - <div class="navbar-header">  
4 - <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse" aria-expanded="false">  
5 - <span class="sr-only">Alternar menu de navegação</span>  
6 - <span class="icon-bar" aria-hidden="true"></span>  
7 - <span class="icon-bar" aria-hidden="true"></span>  
8 - <span class="icon-bar" aria-hidden="true"></span>  
9 - </button>  
10 - <a class="navbar-brand" ui-sref="inicio">  
11 - <img src="/assets/images/logo.png" alt="Dialoga Brasil | O país fica melhor quando você participa" />  
12 - <!-- <span class="glyphicon glyphicon-home"></span> Início -->  
13 - </a>  
14 - </div> 2 + <div class="navbar-header">
  3 + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse" aria-expanded="false">
  4 + <span class="sr-only">Alternar menu de navegação</span>
  5 + <span class="icon-bar" aria-hidden="true"></span>
  6 + <span class="icon-bar" aria-hidden="true"></span>
  7 + <span class="icon-bar" aria-hidden="true"></span>
  8 + </button>
  9 + <a class="navbar-brand" ui-sref="inicio">
  10 + <img src="/assets/images/logo.png" alt="Dialoga Brasil | O país fica melhor quando você participa" />
  11 + <!-- <span class="glyphicon glyphicon-home"></span> Início -->
  12 + </a>
  13 + </div>
15 14
16 - <div id="navbar-collapse" class="collapse navbar-collapse">  
17 - <ul class="nav navbar-nav">  
18 - <li><a ui-sref="sobre">Sobre</a></li>  
19 - <li><a ui-sref="programas">Programas</a></li>  
20 - <li><a ui-sref="propostas">Propostas</a></li>  
21 - <!-- <li><a ui-sref="ranking">Ranking</a></li> -->  
22 - <li><a ui-sref="duvidas">Dúvidas</a></li>  
23 - <!-- <li><a ui-sref="respostas">Respostas</a></li> -->  
24 - </ul>  
25 - </div> 15 + <div id="navbar-collapse" class="collapse navbar-collapse">
  16 + <ul class="nav navbar-nav">
  17 + <li><a ui-sref="sobre">Sobre</a></li>
  18 + <li><a ui-sref="programas">Programas</a></li>
  19 + <li><a ui-sref="propostas">Propostas</a></li>
  20 + <!-- <li><a ui-sref="ranking">Ranking</a></li> -->
  21 + <li><a ui-sref="duvidas">Dúvidas</a></li>
  22 + <!-- <li><a ui-sref="respostas">Respostas</a></li> -->
  23 + </ul>
26 </div> 24 </div>
27 </nav> 25 </nav>
src/app/components/navbar/navbar.scss
@@ -2,6 +2,16 @@ @@ -2,6 +2,16 @@
2 2
3 .navbar-brand { 3 .navbar-brand {
4 height: auto; 4 height: auto;
  5 + padding-bottom: 0;
  6 + padding-left: 0;
  7 + }
  8 +
  9 + .navbar-toggle {
  10 + margin-top: 20px;
  11 +
  12 + .icon-bar {
  13 + height: 3px;
  14 + }
5 } 15 }
6 16
7 .navbar-nav a { 17 .navbar-nav a {
src/app/components/proposal-ranking/proposal-ranking-carousel.scss
@@ -4,26 +4,29 @@ @@ -4,26 +4,29 @@
4 4
5 .proposal-ranking--carousel { 5 .proposal-ranking--carousel {
6 background-color: #f1f1f1; 6 background-color: #f1f1f1;
  7 + border-radius: 5px;
  8 + overflow: hidden;
7 9
8 &-top { 10 &-top {
9 position: relative; 11 position: relative;
10 color: #fff; 12 color: #fff;
11 font-weight: bold; 13 font-weight: bold;
12 - font-size: 18px;  
13 - padding: 5px 10px; 14 + font-size: 25px;
  15 + padding: 20px 15px;
14 16
15 17
16 &-triggers { 18 &-triggers {
17 position: absolute; 19 position: absolute;
18 - right: 5px;  
19 - top: 5px; 20 + right: 15px;
  21 + top: 20px;
20 22
21 - li { 23 + button {
22 border: 1px solid #fff; 24 border: 1px solid #fff;
23 border-radius: 100%; 25 border-radius: 100%;
24 width: 15px; 26 width: 15px;
25 height: 15px; 27 height: 15px;
26 margin-right: 5px; 28 margin-right: 5px;
  29 + background-color: transparent;
27 30
28 cursor: pointer; 31 cursor: pointer;
29 32
@@ -37,6 +40,12 @@ @@ -37,6 +40,12 @@
37 &-middle { 40 &-middle {
38 position: relative; 41 position: relative;
39 padding: 25px 30px; 42 padding: 25px 30px;
  43 + cursor: pointer;
  44 + -webkit-user-select: none;
  45 + -khtml-user-select: none;
  46 + -moz-user-select: none;
  47 + -ms-user-select: none;
  48 + user-select: none;
40 49
41 .content { 50 .content {
42 position: relative; 51 position: relative;
@@ -65,6 +74,10 @@ @@ -65,6 +74,10 @@
65 z-index: 10; 74 z-index: 10;
66 75
67 &-icon { 76 &-icon {
  77 + position: absolute;
  78 + top: 10px;
  79 + right: 15px;
  80 +
68 .glyphicon { 81 .glyphicon {
69 position: relative; 82 position: relative;
70 top: -2px; 83 top: -2px;
src/app/components/proposal-ranking/proposal-ranking.directive.js
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 // initial values 26 // initial values
27 var vm = this; 27 var vm = this;
28 28
29 - vm.activeIndex = 1; 29 + vm.activeIndex = 0;
30 vm.loading = false; 30 vm.loading = false;
31 31
32 if(angular.isDefined(vm.limit) && angular.isString(vm.limit)){ 32 if(angular.isDefined(vm.limit) && angular.isString(vm.limit)){
@@ -59,14 +59,14 @@ @@ -59,14 +59,14 @@
59 votes_for: 1780 59 votes_for: 1780
60 },{ 60 },{
61 id: 935, 61 id: 935,
62 - abstract: 'Magni sunt ut molestiae. A porro et quod saepe placeat amet nihil. Aut ut id voluptatem doloribus quia.', 62 + abstract: 'Aut fuga magni adipisci. Recusandae ipsum distinctio omnis ut illum. Magni sunt ut molestiae.',
63 effective_support: 0.1572052401746725, 63 effective_support: 0.1572052401746725,
64 hits: 8602, 64 hits: 8602,
65 votes_against: 7005, 65 votes_against: 7005,
66 votes_for: 8728 66 votes_for: 8728
67 },{ 67 },{
68 id: 1008, 68 id: 1008,
69 - abstract: 'Cum quas assumenda nihil delectus eos. Minus fugit velit voluptatem nisi nam esse ut id.', 69 + abstract: 'Recusandae ipsum distinctio omnis ut illum. Magni sunt ut molestiae. Aut fuga magni adipisci.',
70 effective_support: 0.1572052401746725, 70 effective_support: 0.1572052401746725,
71 hits: 9181, 71 hits: 9181,
72 votes_against: 612, 72 votes_against: 612,
@@ -82,10 +82,22 @@ @@ -82,10 +82,22 @@
82 }, 2000); 82 }, 2000);
83 }; 83 };
84 84
  85 + ProposalRankingController.prototype.swipeLeft = function () {
  86 + var vm = this;
  87 +
  88 + vm.activeIndex = (vm.activeIndex < vm.limit - 1) ? ++vm.activeIndex : 0;
  89 + };
  90 +
  91 + ProposalRankingController.prototype.swipeRight = function () {
  92 + var vm = this;
  93 +
  94 + vm.activeIndex = (vm.activeIndex > 0) ? --vm.activeIndex : vm.limit - 1;
  95 + };
  96 +
85 ProposalRankingController.prototype.switchProposal = function (index) { 97 ProposalRankingController.prototype.switchProposal = function (index) {
86 var vm = this; 98 var vm = this;
87 99
88 - if(index > 0 && index <= vm.limit) { 100 + if(index >= 0 && index < vm.limit) {
89 vm.activeIndex = index; 101 vm.activeIndex = index;
90 }else{ 102 }else{
91 vm.$log.warn('[switchProposal] "index" not handled:', index); 103 vm.$log.warn('[switchProposal] "index" not handled:', index);
src/app/components/proposal-ranking/proposal-ranking.html
1 <div class="proposal-ranking contraste-box"> 1 <div class="proposal-ranking contraste-box">
2 - <div class="proposal-ranking--carousel" ng-if="vm.display==='carousel'">  
3 - <div class="proposal-ranking--carousel-top color-theme-bg">  
4 - <div class="proposal-ranking--carousel-position">  
5 - <span>1º</span>  
6 - <span>Lugar</span>  
7 - </div>  
8 - <div class="proposal-ranking--carousel-top-triggers">  
9 - <ul class="list-inline">  
10 - <li ng-class="{'active': vm.activeIndex === 1}" ng-click="vm.switchProposal(1)"></li>  
11 - <li ng-class="{'active': vm.activeIndex === 2}" ng-click="vm.switchProposal(2)"></li>  
12 - <li ng-class="{'active': vm.activeIndex === 3}" ng-click="vm.switchProposal(3)"></li>  
13 - </ul>  
14 - </div> 2 + <div class="proposal-ranking--carousel" ng-if="vm.display === 'carousel'">
  3 + <div ng-if="!vm.proposals">
  4 + Carregando...
15 </div> 5 </div>
16 - <div class="proposal-ranking--carousel-middle">  
17 - <div class="content">  
18 - <p>Lorem ipsum dolor sit amet, an qui alia constituam. Forensibus scripserit pri at, sit et dolorum ancillae. Ad sea quas utamur salutandi, illud veritus propriae mea ut. Ius no timeam intellegat liberavisse, eum suscipit pertinax ad. Illum graeci postulant et pro, at clita facete quo, cibo liber ad pri.</p> 6 + <div ng-if="vm.proposals">
  7 + <div class="proposal-ranking--carousel-top color-theme-bg">
  8 + <div class="proposal-ranking--carousel-position" ng-repeat="proposal in vm.proposals">
  9 + <span ng-show="vm.activeIndex === $index">{{::($index+1)}}º</span>
  10 + <span ng-show="vm.activeIndex === $index">Lugar</span>
  11 + </div>
  12 + <div class="proposal-ranking--carousel-top-triggers" ng-if="vm.proposals">
  13 + <ul class="list-inline">
  14 + <li class="item-dot" ng-repeat="proposal in vm.proposals">
  15 + <button type="button" ng-class="{'active': vm.activeIndex === $index}" ng-click="vm.switchProposal($index)" title="Apersentar proposta na posição {{$index}}"></button>
  16 + </li>
  17 + </ul>
  18 + </div>
19 </div> 19 </div>
20 - <div class="proposal-ranking--carousel-middle-watermark"><span>1º</span></div>  
21 - </div>  
22 - <div class="proposal-ranking--carousel-bottom color-theme-common-bg" ng-click="vm.showProposals()">  
23 - <div class="proposal-ranking--carousel-bottom-icon">  
24 - <span>Veja as propostas mais vortadas</span>  
25 - <span class="glyphicon glyphicon-chevron-down pull-right color-theme-common-fg"></span> 20 + <div class="proposal-ranking--carousel-middle" ng-swipe-left="vm.swipeLeft()" ng-swipe-right="vm.swipeRight()">
  21 + <div ng-repeat="proposal in vm.proposals" class="animation-swipe">
  22 + <div class="content">
  23 + <div ng-show="vm.activeIndex === $index">{{::proposal.abstract}}</div>
  24 + </div>
  25 + <div class="proposal-ranking--carousel-middle-watermark" ng-show="vm.activeIndex === $index">
  26 + <span>{{::($index+1)}}º</span>
  27 + </div>
  28 + </div>
  29 + </div>
  30 + <div class="proposal-ranking--carousel-bottom color-theme-common-bg" ng-click="vm.showProposals()">
  31 + <div>Veja as propostas mais vortadas</div>
  32 + <div class="proposal-ranking--carousel-bottom-icon">
  33 + <span class="glyphicon glyphicon-chevron-down pull-right color-theme-common-fg"></span>
  34 + </div>
26 </div> 35 </div>
27 </div> 36 </div>
28 </div> 37 </div>
src/app/components/proposal-related/proposal-related.directive.js
@@ -0,0 +1,100 @@ @@ -0,0 +1,100 @@
  1 +(function() {
  2 + 'use strict';
  3 +
  4 + angular
  5 + .module('dialoga')
  6 + .directive('proposalRelated', proposalRelated);
  7 +
  8 + /** @ngInject */
  9 + function proposalRelated() {
  10 +
  11 + /** @ngInject */
  12 + function ProposalRelatedController(ArticleService, $scope, $element, $timeout, $log) {
  13 + $log.debug('ProposalRelatedController');
  14 +
  15 + var vm = this;
  16 + vm.ArticleService = ArticleService;
  17 + vm.$scope = $scope;
  18 + vm.$element = $element;
  19 + vm.$timeout = $timeout;
  20 + vm.$log = $log;
  21 +
  22 + vm.init();
  23 + }
  24 +
  25 + ProposalRelatedController.prototype.init = function () {
  26 + // initial values
  27 + var vm = this;
  28 +
  29 + vm.activeIndex = 1;
  30 + vm.loading = false;
  31 +
  32 + if(angular.isDefined(vm.limit) && angular.isString(vm.limit)){
  33 + vm.limit = parseInt(vm.limit);
  34 + }else{
  35 + vm.limit = 3;
  36 + }
  37 +
  38 + vm.loadData();
  39 + };
  40 +
  41 + ProposalRelatedController.prototype.loadData = function () {
  42 + // async values
  43 + var vm = this;
  44 +
  45 + vm.loading = true;
  46 +
  47 + // simulate delay
  48 + vm.$timeout(function(){
  49 + vm.loading = false;
  50 +
  51 + // Fake Data
  52 + // vm.proposals = vm.ArticleService.getProposals();
  53 + vm.proposals = [{
  54 + id: 4159,
  55 + abstract: 'Ut odio unde porro in. Aut fuga magni adipisci. Recusandae ipsum distinctio omnis ut illum.',
  56 + effective_support: 0.1572052401746725,
  57 + hits: 4159,
  58 + votes_against: 3779,
  59 + votes_for: 1780
  60 + },{
  61 + id: 935,
  62 + abstract: 'Magni sunt ut molestiae. A porro et quod saepe placeat amet nihil. Aut ut id voluptatem doloribus quia.',
  63 + effective_support: 0.1572052401746725,
  64 + hits: 8602,
  65 + votes_against: 7005,
  66 + votes_for: 8728
  67 + },{
  68 + id: 1008,
  69 + abstract: 'Cum quas assumenda nihil delectus eos. Minus fugit velit voluptatem nisi nam esse ut id.',
  70 + effective_support: 0.1572052401746725,
  71 + hits: 9181,
  72 + votes_against: 612,
  73 + votes_for: 1786
  74 + }];
  75 +
  76 + if(vm.display === 'list'){
  77 + // wait until DOM be created
  78 + vm.$timeout(function(){
  79 + attachPopover.call(vm);
  80 + }, 20);
  81 + }
  82 + }, 2000);
  83 + };
  84 +
  85 + var directive = {
  86 + restrict: 'E',
  87 + templateUrl: 'app/components/proposal-related/proposal-related.html',
  88 + scope: {
  89 + article: '='
  90 + },
  91 + controller: ProposalRelatedController,
  92 + controllerAs: 'vm',
  93 + bindToController: true
  94 + };
  95 +
  96 +
  97 + return directive;
  98 + }
  99 +
  100 +})();
src/app/components/proposal-related/proposal-related.html
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +<div class="proposal-related">
  2 + Proposta
  3 +</div>
src/app/index.config.js
@@ -3,13 +3,13 @@ @@ -3,13 +3,13 @@
3 3
4 angular 4 angular
5 .module('dialoga') 5 .module('dialoga')
6 - .config(configAuthInterceptor) 6 + .config(configHeadersInterceptor)
7 .config(configLocationProvider) 7 .config(configLocationProvider)
8 .config(configBreadcrumbProvider) 8 .config(configBreadcrumbProvider)
9 .config(config); 9 .config(config);
10 10
11 /** @ngInject */ 11 /** @ngInject */
12 - function configAuthInterceptor ($httpProvider){ 12 + function configHeadersInterceptor ($httpProvider){
13 13
14 //Reset headers to avoid OPTIONS request (aka preflight) 14 //Reset headers to avoid OPTIONS request (aka preflight)
15 $httpProvider.defaults.headers.common = {}; 15 $httpProvider.defaults.headers.common = {};
src/app/index.module.js
@@ -2,6 +2,6 @@ @@ -2,6 +2,6 @@
2 'use strict'; 2 'use strict';
3 3
4 angular 4 angular
5 - .module('dialoga', ['ngAnimate', 'ngCookies', 'ngTouch', 'ngSanitize', 'ui.router', 'socialLinks', 'slugifier', 'ncy-angular-breadcrumb']); 5 + .module('dialoga', ['ngAnimate', 'ngCookies', 'ngTouch', 'ngSanitize', 'ui.router', 'ngStorage', 'socialLinks', 'slugifier', 'ncy-angular-breadcrumb']);
6 6
7 })(); 7 })();
src/app/index.route.js
@@ -56,7 +56,7 @@ @@ -56,7 +56,7 @@
56 'main': { 56 'main': {
57 templateUrl: 'app/pages/programas/programas.html', 57 templateUrl: 'app/pages/programas/programas.html',
58 controller: 'ProgramasPageController', 58 controller: 'ProgramasPageController',
59 - controllerAs: 'pagePrograma' 59 + controllerAs: 'pageProgramas'
60 }, 60 },
61 'footer': { templateUrl: 'app/pages/footer/footer.html' } 61 'footer': { templateUrl: 'app/pages/footer/footer.html' }
62 } 62 }
src/app/index.run.js
@@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
13 .run(runBlock); 13 .run(runBlock);
14 14
15 /** @ngInject */ 15 /** @ngInject */
16 - function runAuth($rootScope, $cookies, USER_ROLES, AUTH_EVENTS, AuthService, $log) { 16 + function runAuth($rootScope, $localStorage, USER_ROLES, AUTH_EVENTS, AuthService, $log) {
17 17
18 // Listner url/state changes, and check permission 18 // Listner url/state changes, and check permission
19 $rootScope.$on('$stateChangeStart', function(event, next) { 19 $rootScope.$on('$stateChangeStart', function(event, next) {
@@ -38,6 +38,8 @@ @@ -38,6 +38,8 @@
38 } 38 }
39 }); 39 });
40 40
  41 + $rootScope.currentUser = $localStorage.currentUser;
  42 +
41 $log.debug('[RUN] Auth end.'); 43 $log.debug('[RUN] Auth end.');
42 } 44 }
43 45
src/app/pages/auth/auth.controller.js
@@ -6,12 +6,13 @@ @@ -6,12 +6,13 @@
6 .controller('AuthPageController', AuthPageController); 6 .controller('AuthPageController', AuthPageController);
7 7
8 /** @ngInject */ 8 /** @ngInject */
9 - function AuthPageController($rootScope, AUTH_EVENTS, AuthService, Session, $log) { 9 + function AuthPageController($scope, $rootScope, AUTH_EVENTS, AuthService, Session, $log) {
10 $log.debug('AuthPageController'); 10 $log.debug('AuthPageController');
11 11
12 var vm = this; 12 var vm = this;
13 13
14 vm.$rootScope = $rootScope; 14 vm.$rootScope = $rootScope;
  15 + vm.$scope = $scope;
15 vm.AUTH_EVENTS = AUTH_EVENTS; 16 vm.AUTH_EVENTS = AUTH_EVENTS;
16 vm.AuthService = AuthService; 17 vm.AuthService = AuthService;
17 vm.Session = Session; 18 vm.Session = Session;
@@ -27,15 +28,33 @@ @@ -27,15 +28,33 @@
27 vm.credentials = {}; 28 vm.credentials = {};
28 29
29 // attach events 30 // attach events
  31 + vm.currentUser = vm.Session.getCurrentUser();
30 32
  33 + // handle login
  34 + vm.$scope.$on(vm.AUTH_EVENTS.loginSuccess, function () {
  35 + vm.currentUser = vm.Session.getCurrentUser();
  36 + });
  37 +
  38 + // handle logout
  39 + vm.$scope.$on(vm.AUTH_EVENTS.logoutSuccess, function () {
  40 + vm.currentUser = vm.Session.getCurrentUser();
  41 + });
31 // ... 42 // ...
32 }; 43 };
33 44
  45 +
  46 + AuthPageController.prototype.onClickLogout = function (){
  47 + var vm = this;
  48 +
  49 + vm.AuthService.logout();
  50 + };
  51 +
34 AuthPageController.prototype.login = function(credentials) { 52 AuthPageController.prototype.login = function(credentials) {
35 var vm = this; 53 var vm = this;
36 54
37 - vm.AuthService.login(credentials).then(function(/*user*/) { 55 + vm.AuthService.login(credentials).then(function(user) {
38 // handle view 56 // handle view
  57 + vm.$log.debug('user', user);
39 }, function() { 58 }, function() {
40 // handle view 59 // handle view
41 }); 60 });
src/app/pages/auth/signin.html
1 <section role="main" class="section-gray auth-content"> 1 <section role="main" class="section-gray auth-content">
2 <div class="container"> 2 <div class="container">
3 - <div class="row">  
4 - <div class="col-sm-8 col-sm-offset-2">  
5 - <h2>Identifique-se</h2>  
6 - <form name="loginForm" ng-submit="pageSignin.login(pageSignin.credentials)">  
7 - <div class="form-group">  
8 - <label for="inputUsername" class="sr-only">E-mail:</label>  
9 - <div class="input-group">  
10 - <div class="input-group-addon"><span class="glyphicon glyphicon-user"></span></div>  
11 - <input type="text" id="inputUsername" class="form-control" placeholder="E-mail" required="" autofocus="" ng-model="pageSignin.credentials.username"> 3 +
  4 + <div ng-if="pageSignin.currentUser">
  5 + <div class="row">
  6 + <div class="col-sm-8 col-sm-offset-2">
  7 + <h3>Você está logado!</h3>
  8 + <button type="button" ng-click="pageSignin.onClickLogout()" class="btn btn-primary">Sair</button>
  9 + </div>
  10 + </div>
  11 + </div>
  12 +
  13 + <div ng-if="!pageSignin.currentUser">
  14 + <div class="row">
  15 + <div class="col-sm-8 col-sm-offset-2">
  16 + <h2>Identifique-se</h2>
  17 + <form name="loginForm" ng-submit="pageSignin.login(pageSignin.credentials)">
  18 + <div class="form-group">
  19 + <label for="inputUsername" class="sr-only">E-mail:</label>
  20 + <div class="input-group">
  21 + <div class="input-group-addon"><span class="glyphicon glyphicon-user"></span></div>
  22 + <input type="text" id="inputUsername" class="form-control" placeholder="E-mail" required="" autofocus="" ng-model="pageSignin.credentials.username">
  23 + </div>
  24 + </div>
  25 + <div class="form-group">
  26 + <label for="inputPassword" class="sr-only">Senha:</label>
  27 + <div class="input-group">
  28 + <div class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></div>
  29 + <input type="password" id="inputPassword" class="form-control" placeholder="Senha" required="" ng-model="pageSignin.credentials.password">
  30 + </div>
12 </div> 31 </div>
13 - </div>  
14 - <div class="form-group">  
15 - <label for="inputPassword" class="sr-only">Senha:</label>  
16 - <div class="input-group">  
17 - <div class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></div>  
18 - <input type="password" id="inputPassword" class="form-control" placeholder="Senha" required="" ng-model="pageSignin.credentials.password"> 32 + <div class="form-group">
  33 + <button class="btn btn-lg btn-primary btn-block" type="submit">Entrar</button>
19 </div> 34 </div>
20 - </div>  
21 - <div class="form-group">  
22 - <button class="btn btn-lg btn-primary btn-block" type="submit">Entrar</button>  
23 - </div>  
24 - </form> 35 + </form>
  36 + </div>
25 </div> 37 </div>
26 - </div>  
27 - <div class="row">  
28 - <div class="col-sm-8 col-sm-offset-2">  
29 - <hr class="separator-or"></hr> 38 + <div class="row">
  39 + <div class="col-sm-8 col-sm-offset-2">
  40 + <hr class="separator-or"></hr>
  41 + </div>
30 </div> 42 </div>
31 - </div>  
32 - <div class="row">  
33 - <div class="col-sm-8 col-sm-offset-2">  
34 - <button class="btn btn-lg btn-link btn-block" type="button" ui-sref="cadastrar">Cadastre-se</button> 43 + <div class="row">
  44 + <div class="col-sm-8 col-sm-offset-2">
  45 + <button class="btn btn-lg btn-link btn-block" type="button" ui-sref="cadastrar">Cadastre-se</button>
  46 + </div>
35 </div> 47 </div>
36 </div> 48 </div>
37 </div> 49 </div>
src/app/pages/header/header.html
@@ -2,25 +2,19 @@ @@ -2,25 +2,19 @@
2 2
3 <div class="row"> 3 <div class="row">
4 <div class="col-sm-12"> 4 <div class="col-sm-12">
5 -  
6 - <div class="accessibility-wrapper">  
7 -  
8 - <button type="button" class="btn btn-link pull-right" ui-sref="entrar">  
9 - <span class="icon icon-user" aria-hidden="true"></span>  
10 - Entrar  
11 - </button>  
12 - </div> 5 + <auth-user></auth-user>
13 </div> 6 </div>
14 </div> 7 </div>
15 8
16 <div class="row"> 9 <div class="row">
17 - <app-navbar></app-navbar> 10 + <div class="col-sm-12">
  11 + <app-navbar></app-navbar>
  12 + </div>
18 </div> 13 </div>
19 14
20 - <!-- TODO: breadcrumb -->  
21 - <!-- <ol class="breadcrumb">  
22 - <li><a href="#">Home</a></li>  
23 - <li><a href="#">Library</a></li>  
24 - <li class="active">Data</li>  
25 - </ol> --> 15 + <div class="row">
  16 + <div class="col-sm-12">
  17 + <div ncy-breadcrumb></div>
  18 + </div>
  19 + </div>
26 </header> 20 </header>
src/app/pages/programas/programa.html
1 <div class="page--conheca-o-programa"> 1 <div class="page--conheca-o-programa">
2 <section> 2 <section>
3 <div class="container"> 3 <div class="container">
4 - <div ng-if="pageProgramaContent.article && pageProgramaContent.article.title">  
5 - <div ncy-breadcrumb></div>  
6 - </div>  
7 - </div>  
8 - </section>  
9 -  
10 - <section>  
11 - <div class="container">  
12 <div ng-if="!pageProgramaContent.article.body"> 4 <div ng-if="!pageProgramaContent.article.body">
13 <div ng-if="!pageProgramaContent.error" class="alert alert-info" role="alert">Carregando detalhes sobre o progama...</div> 5 <div ng-if="!pageProgramaContent.error" class="alert alert-info" role="alert">Carregando detalhes sobre o progama...</div>
14 <div ng-if="pageProgramaContent.error" class="alert alert-warning" role="alert">{{pageProgramaContent}}</div> 6 <div ng-if="pageProgramaContent.error" class="alert alert-warning" role="alert">{{pageProgramaContent}}</div>
src/app/pages/programas/programas.html
1 -<div class="container page--programas">  
2 - <h1>TODO: Home > Programas</h1> 1 +<div class="page--programas">
  2 + <section class="section-gray section-space-up">
  3 + <div class="container">
  4 + <div id="lista-de-programas" class="row">
  5 + <div class="col-sm-4 col-md-3">
  6 + <category-list ng-if="pageProgramas.categories"></category-list>
  7 + </div>
  8 + <div class="col-sm-8 col-md-9">
  9 + <article-grid></article-grid>
  10 + </div>
  11 + </div>
  12 + </div>
  13 + </section>
3 </div> 14 </div>
src/index.html
@@ -40,6 +40,7 @@ @@ -40,6 +40,7 @@
40 <div ui-view="header"></div> 40 <div ui-view="header"></div>
41 <div id="content" ui-view="main"></div> 41 <div id="content" ui-view="main"></div>
42 <div ui-view="footer"></div> 42 <div ui-view="footer"></div>
  43 +
43 <div id="footer-brasil"></div> 44 <div id="footer-brasil"></div>
44 45
45 <!-- build:js(src) scripts/vendor.js --> 46 <!-- build:js(src) scripts/vendor.js -->