Commit 2870b0549f7deb02b093200a0e543b5b2f999571
Exists in
master
and in
8 other branches
Merge branch 'refact-auth' into merlin
Showing
26 changed files
with
449 additions
and
164 deletions
Show diff stats
bower.json
src/app/components/a11y-bar/a11y-bar.html
... | ... | @@ -4,27 +4,27 @@ |
4 | 4 | <div class="col-sm-6"> |
5 | 5 | <ul class="skip-links list-inline list-unstyled"> |
6 | 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 | 8 | Ir para o conteúdo |
9 | - <span>1</span> | |
9 | + <span class="color-theme-common-bg">1</span> | |
10 | 10 | </a> |
11 | 11 | </li> |
12 | 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 | 14 | Ir para o menu |
15 | - <span>2</span> | |
15 | + <span class="color-theme-common-bg">2</span> | |
16 | 16 | </a> |
17 | 17 | </li> |
18 | 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 | 20 | Ir para a busca |
21 | - <span>3</span> | |
21 | + <span class="color-theme-common-bg">3</span> | |
22 | 22 | </a> |
23 | 23 | </li> |
24 | 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 | 26 | Ir para o rodapé |
27 | - <span>4</span> | |
27 | + <span class="color-theme-common-bg">4</span> | |
28 | 28 | </a> |
29 | 29 | </li> |
30 | 30 | </ul> |
... | ... | @@ -33,13 +33,13 @@ |
33 | 33 | <div class="col-sm-6"> |
34 | 34 | <ul class="action-links list-inline list-unstyled pull-right"> |
35 | 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 | 37 | </li> |
38 | 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 | 40 | </li> |
41 | 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 | 43 | </li> |
44 | 44 | </ul> |
45 | 45 | </div> | ... | ... |
src/app/components/a11y-bar/a11y-bar.scss
src/app/components/article-box/article-box.directive.js
src/app/components/article-grid/article-grid.directive.js
... | ... | @@ -32,13 +32,9 @@ |
32 | 32 | ArticleGridController.prototype.init = function() { |
33 | 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 | 39 | vm.orderCriteries = [ |
44 | 40 | { label: 'Título', name: 'titulo' }, |
... | ... | @@ -46,7 +42,6 @@ |
46 | 42 | { label: 'Aleatório', name: 'aleatorio' } |
47 | 43 | ]; |
48 | 44 | |
49 | - vm.filtredArticleList = vm.getFiltredArticles(); | |
50 | 45 | vm.search = vm.$location.search(); |
51 | 46 | |
52 | 47 | // Add initial values for the filter |
... | ... | @@ -70,6 +65,16 @@ |
70 | 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 | 78 | // update window location params |
74 | 79 | vm.$scope.$on('change-selectedCategory', function(event, selectedCategory){ |
75 | 80 | vm.selectedCategory = selectedCategory; |
... | ... | @@ -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 | 149 | ArticleGridController.prototype.resetFilterValues = function() { |
121 | 150 | var vm = this; | ... | ... |
... | ... | @@ -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 | +})(); | ... | ... |
... | ... | @@ -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/auth.service.js
... | ... | @@ -10,18 +10,9 @@ |
10 | 10 | /** @ngInject */ |
11 | 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 | 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 | 16 | var encodedData = 'login=' + credentials.username + '&password=' + credentials.password; |
26 | 17 | |
27 | 18 | return $http |
... | ... | @@ -40,7 +31,10 @@ |
40 | 31 | } |
41 | 32 | |
42 | 33 | function logout () { |
34 | + | |
43 | 35 | Session.destroy(); |
36 | + | |
37 | + $rootScope.$broadcast(AUTH_EVENTS.logoutSuccess); | |
44 | 38 | } |
45 | 39 | |
46 | 40 | function isAuthenticated () { |
... | ... | @@ -54,42 +48,42 @@ |
54 | 48 | |
55 | 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 | 63 | /** @ngInject */ |
60 | - function Session($cookies, $log) { | |
64 | + function Session($localStorage, $log) { | |
61 | 65 | |
62 | 66 | var service = {}; |
63 | 67 | |
64 | - var currentUser = $cookies.getObject('currentUser') || {}; | |
68 | + // $localStorage.currentUser = $localStorage.currentUser || null; | |
65 | 69 | |
66 | 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 | 78 | service.destroy = function() { |
83 | 79 | |
84 | - currentUser = {}; | |
85 | - | |
86 | - $cookies.remove('currentUser'); | |
80 | + delete $localStorage.currentUser; | |
87 | 81 | |
88 | 82 | $log.debug('User session destroyed.'); |
89 | 83 | }; |
90 | 84 | |
91 | 85 | service.getCurrentUser = function () { |
92 | - return currentUser; | |
86 | + return $localStorage.currentUser; | |
93 | 87 | }; |
94 | 88 | |
95 | 89 | return service; | ... | ... |
src/app/components/navbar/navbar.html
1 | 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 | 24 | </div> |
27 | 25 | </nav> | ... | ... |
src/app/components/navbar/navbar.scss
src/app/components/proposal-ranking/proposal-ranking-carousel.scss
... | ... | @@ -4,26 +4,29 @@ |
4 | 4 | |
5 | 5 | .proposal-ranking--carousel { |
6 | 6 | background-color: #f1f1f1; |
7 | + border-radius: 5px; | |
8 | + overflow: hidden; | |
7 | 9 | |
8 | 10 | &-top { |
9 | 11 | position: relative; |
10 | 12 | color: #fff; |
11 | 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 | 18 | &-triggers { |
17 | 19 | position: absolute; |
18 | - right: 5px; | |
19 | - top: 5px; | |
20 | + right: 15px; | |
21 | + top: 20px; | |
20 | 22 | |
21 | - li { | |
23 | + button { | |
22 | 24 | border: 1px solid #fff; |
23 | 25 | border-radius: 100%; |
24 | 26 | width: 15px; |
25 | 27 | height: 15px; |
26 | 28 | margin-right: 5px; |
29 | + background-color: transparent; | |
27 | 30 | |
28 | 31 | cursor: pointer; |
29 | 32 | |
... | ... | @@ -37,6 +40,12 @@ |
37 | 40 | &-middle { |
38 | 41 | position: relative; |
39 | 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 | 50 | .content { |
42 | 51 | position: relative; |
... | ... | @@ -65,6 +74,10 @@ |
65 | 74 | z-index: 10; |
66 | 75 | |
67 | 76 | &-icon { |
77 | + position: absolute; | |
78 | + top: 10px; | |
79 | + right: 15px; | |
80 | + | |
68 | 81 | .glyphicon { |
69 | 82 | position: relative; |
70 | 83 | top: -2px; | ... | ... |
src/app/components/proposal-ranking/proposal-ranking.directive.js
... | ... | @@ -26,7 +26,7 @@ |
26 | 26 | // initial values |
27 | 27 | var vm = this; |
28 | 28 | |
29 | - vm.activeIndex = 1; | |
29 | + vm.activeIndex = 0; | |
30 | 30 | vm.loading = false; |
31 | 31 | |
32 | 32 | if(angular.isDefined(vm.limit) && angular.isString(vm.limit)){ |
... | ... | @@ -59,14 +59,14 @@ |
59 | 59 | votes_for: 1780 |
60 | 60 | },{ |
61 | 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 | 63 | effective_support: 0.1572052401746725, |
64 | 64 | hits: 8602, |
65 | 65 | votes_against: 7005, |
66 | 66 | votes_for: 8728 |
67 | 67 | },{ |
68 | 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 | 70 | effective_support: 0.1572052401746725, |
71 | 71 | hits: 9181, |
72 | 72 | votes_against: 612, |
... | ... | @@ -82,10 +82,22 @@ |
82 | 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 | 97 | ProposalRankingController.prototype.switchProposal = function (index) { |
86 | 98 | var vm = this; |
87 | 99 | |
88 | - if(index > 0 && index <= vm.limit) { | |
100 | + if(index >= 0 && index < vm.limit) { | |
89 | 101 | vm.activeIndex = index; |
90 | 102 | }else{ |
91 | 103 | vm.$log.warn('[switchProposal] "index" not handled:', index); | ... | ... |
src/app/components/proposal-ranking/proposal-ranking.html
1 | 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 | 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 | 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 | 35 | </div> |
27 | 36 | </div> |
28 | 37 | </div> | ... | ... |
src/app/components/proposal-related/proposal-related.directive.js
... | ... | @@ -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
src/app/index.config.js
... | ... | @@ -3,13 +3,13 @@ |
3 | 3 | |
4 | 4 | angular |
5 | 5 | .module('dialoga') |
6 | - .config(configAuthInterceptor) | |
6 | + .config(configHeadersInterceptor) | |
7 | 7 | .config(configLocationProvider) |
8 | 8 | .config(configBreadcrumbProvider) |
9 | 9 | .config(config); |
10 | 10 | |
11 | 11 | /** @ngInject */ |
12 | - function configAuthInterceptor ($httpProvider){ | |
12 | + function configHeadersInterceptor ($httpProvider){ | |
13 | 13 | |
14 | 14 | //Reset headers to avoid OPTIONS request (aka preflight) |
15 | 15 | $httpProvider.defaults.headers.common = {}; | ... | ... |
src/app/index.module.js
... | ... | @@ -2,6 +2,6 @@ |
2 | 2 | 'use strict'; |
3 | 3 | |
4 | 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 | 56 | 'main': { |
57 | 57 | templateUrl: 'app/pages/programas/programas.html', |
58 | 58 | controller: 'ProgramasPageController', |
59 | - controllerAs: 'pagePrograma' | |
59 | + controllerAs: 'pageProgramas' | |
60 | 60 | }, |
61 | 61 | 'footer': { templateUrl: 'app/pages/footer/footer.html' } |
62 | 62 | } | ... | ... |
src/app/index.run.js
... | ... | @@ -13,7 +13,7 @@ |
13 | 13 | .run(runBlock); |
14 | 14 | |
15 | 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 | 18 | // Listner url/state changes, and check permission |
19 | 19 | $rootScope.$on('$stateChangeStart', function(event, next) { |
... | ... | @@ -38,6 +38,8 @@ |
38 | 38 | } |
39 | 39 | }); |
40 | 40 | |
41 | + $rootScope.currentUser = $localStorage.currentUser; | |
42 | + | |
41 | 43 | $log.debug('[RUN] Auth end.'); |
42 | 44 | } |
43 | 45 | ... | ... |
src/app/pages/auth/auth.controller.js
... | ... | @@ -6,12 +6,13 @@ |
6 | 6 | .controller('AuthPageController', AuthPageController); |
7 | 7 | |
8 | 8 | /** @ngInject */ |
9 | - function AuthPageController($rootScope, AUTH_EVENTS, AuthService, Session, $log) { | |
9 | + function AuthPageController($scope, $rootScope, AUTH_EVENTS, AuthService, Session, $log) { | |
10 | 10 | $log.debug('AuthPageController'); |
11 | 11 | |
12 | 12 | var vm = this; |
13 | 13 | |
14 | 14 | vm.$rootScope = $rootScope; |
15 | + vm.$scope = $scope; | |
15 | 16 | vm.AUTH_EVENTS = AUTH_EVENTS; |
16 | 17 | vm.AuthService = AuthService; |
17 | 18 | vm.Session = Session; |
... | ... | @@ -27,15 +28,33 @@ |
27 | 28 | vm.credentials = {}; |
28 | 29 | |
29 | 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 | 52 | AuthPageController.prototype.login = function(credentials) { |
35 | 53 | var vm = this; |
36 | 54 | |
37 | - vm.AuthService.login(credentials).then(function(/*user*/) { | |
55 | + vm.AuthService.login(credentials).then(function(user) { | |
38 | 56 | // handle view |
57 | + vm.$log.debug('user', user); | |
39 | 58 | }, function() { |
40 | 59 | // handle view |
41 | 60 | }); | ... | ... |
src/app/pages/auth/signin.html
1 | 1 | <section role="main" class="section-gray auth-content"> |
2 | 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 | 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 | 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 | 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 | 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 | 47 | </div> |
36 | 48 | </div> |
37 | 49 | </div> | ... | ... |
src/app/pages/header/header.html
... | ... | @@ -2,25 +2,19 @@ |
2 | 2 | |
3 | 3 | <div class="row"> |
4 | 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 | 6 | </div> |
14 | 7 | </div> |
15 | 8 | |
16 | 9 | <div class="row"> |
17 | - <app-navbar></app-navbar> | |
10 | + <div class="col-sm-12"> | |
11 | + <app-navbar></app-navbar> | |
12 | + </div> | |
18 | 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 | 20 | </header> | ... | ... |
src/app/pages/programas/programa.html
1 | 1 | <div class="page--conheca-o-programa"> |
2 | 2 | <section> |
3 | 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 | 4 | <div ng-if="!pageProgramaContent.article.body"> |
13 | 5 | <div ng-if="!pageProgramaContent.error" class="alert alert-info" role="alert">Carregando detalhes sobre o progama...</div> |
14 | 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 | 14 | </div> | ... | ... |