Commit a9de7b595328c09e2a4d297bd1b7c5aba710cf52
Exists in
master
and in
8 other branches
Merge branch 'master' into feature-proposal-vote
Conflicts: src/app/components/auth/auth.service.js
Showing
8 changed files
with
137 additions
and
78 deletions
Show diff stats
src/app/components/article-service/article.service.js
| ... | ... | @@ -178,7 +178,7 @@ |
| 178 | 178 | }); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - function getEvents (community_id, params, cbSuccess, cbError) { | |
| 181 | + function getEvents (community_id, params) { | |
| 182 | 182 | // Ex.: /api/v1/communities/19195/articles?categories_ids[]=' + cat_id + '&content_type=Event'; |
| 183 | 183 | // Ex.: /api/v1/communities/' + community_id + '/articles?categories_ids[]=' + cat_id + '&content_type=Event'; |
| 184 | 184 | |
| ... | ... | @@ -188,11 +188,9 @@ |
| 188 | 188 | 'content_type':'Event' |
| 189 | 189 | }, params); |
| 190 | 190 | |
| 191 | - UtilService.get(url, {params: paramsExtended}).then(function(data){ | |
| 192 | - _pipeIsInThePast(data); | |
| 193 | - cbSuccess(data.articles); | |
| 194 | - }).catch(function(error){ | |
| 195 | - cbError(error); | |
| 191 | + return UtilService.get(url, {params: paramsExtended}).then(function(data){ | |
| 192 | + _pipeRemoveOldEvents(data); | |
| 193 | + return data; | |
| 196 | 194 | }); |
| 197 | 195 | } |
| 198 | 196 | |
| ... | ... | @@ -210,21 +208,11 @@ |
| 210 | 208 | // }); |
| 211 | 209 | // } |
| 212 | 210 | |
| 213 | - function subscribeToEvent (event_id, params, cbSuccess, cbError) { | |
| 211 | + function subscribeToEvent (event_id) { | |
| 212 | + var url = service.apiArticles + event_id + '/follow'; | |
| 213 | + var encodedParams = 'private_token=' + $rootScope.currentUser.private_token; | |
| 214 | 214 | |
| 215 | - if(!$rootScope.currentUser){ | |
| 216 | - cbError({message: 'Usuário não logado.'}); | |
| 217 | - | |
| 218 | - }else{ | |
| 219 | - var url = service.apiArticles + event_id + '/follow'; | |
| 220 | - var encodedParams = 'private_token=' + $rootScope.currentUser.private_token; | |
| 221 | - | |
| 222 | - UtilService.post(url, encodedParams).then(function(response){ | |
| 223 | - cbSuccess(response); | |
| 224 | - }).catch(function(error){ | |
| 225 | - cbError(error); | |
| 226 | - }); | |
| 227 | - } | |
| 215 | + return UtilService.post(url, encodedParams); | |
| 228 | 216 | } |
| 229 | 217 | |
| 230 | 218 | function searchTopics (params, cbSuccess, cbError) { |
| ... | ... | @@ -282,14 +270,17 @@ |
| 282 | 270 | }); |
| 283 | 271 | } |
| 284 | 272 | |
| 285 | - function _pipeIsInThePast(data){ | |
| 273 | + function _pipeRemoveOldEvents(data){ | |
| 286 | 274 | if(!data.articles && data.article){ |
| 287 | 275 | data.articles = [data.article]; |
| 276 | + data.article = null; | |
| 288 | 277 | } |
| 278 | + | |
| 289 | 279 | var now = (new Date()).getTime(); |
| 290 | 280 | var eventDate = null; |
| 291 | 281 | var events = data.articles; |
| 292 | 282 | |
| 283 | + var results = []; | |
| 293 | 284 | for (var i = events.length - 1; i >= 0; i--) { |
| 294 | 285 | var event = events[i]; |
| 295 | 286 | |
| ... | ... | @@ -297,10 +288,16 @@ |
| 297 | 288 | eventDate = new Date(event.end_date); |
| 298 | 289 | } |
| 299 | 290 | |
| 300 | - if(eventDate.getTime() < now){ | |
| 301 | - event.isOld = true; | |
| 291 | + // if(eventDate.getTime() < now){ | |
| 292 | + // event.isOld = true; | |
| 293 | + // } | |
| 294 | + if(eventDate.getTime() >= now){ | |
| 295 | + results.push(event); | |
| 302 | 296 | } |
| 303 | 297 | } |
| 298 | + | |
| 299 | + data.articles = results; | |
| 304 | 300 | } |
| 301 | + | |
| 305 | 302 | } |
| 306 | 303 | })(); | ... | ... |
src/app/components/dialoga-service/dialoga.service.js
| ... | ... | @@ -205,10 +205,10 @@ |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - function getEvents (params, cbSuccess, cbError) { | |
| 208 | + function getEvents (params) { | |
| 209 | 209 | var paramsExtended = angular.extend({}, params); |
| 210 | 210 | |
| 211 | - ArticleService.getEvents(API.communityId, paramsExtended, cbSuccess, cbError); | |
| 211 | + return ArticleService.getEvents(API.communityId, paramsExtended); | |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | // TODO: implement | ... | ... |
src/app/components/event-list/event-list.directive.js
| ... | ... | @@ -23,48 +23,62 @@ |
| 23 | 23 | // vm.attachListeners(); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - EventListController.prototype.init = function () { | |
| 26 | + EventListController.prototype.init = function() { | |
| 27 | 27 | var vm = this; |
| 28 | 28 | |
| 29 | - if(!vm.events){ | |
| 29 | + if (!vm.events) { | |
| 30 | 30 | throw { name: 'NotDefined', message: 'The attribute "events" is undefined.'}; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - if(!vm.isCollapsed){ | |
| 33 | + if (!vm.isCollapsed) { | |
| 34 | 34 | vm.isCollapsed = true; |
| 35 | 35 | } |
| 36 | 36 | }; |
| 37 | 37 | |
| 38 | - EventListController.prototype.toggleView = function () { | |
| 38 | + EventListController.prototype.toggleView = function() { | |
| 39 | 39 | var vm = this; |
| 40 | 40 | vm.isCollapsed = !vm.isCollapsed; |
| 41 | 41 | }; |
| 42 | 42 | |
| 43 | - EventListController.prototype.subscribe = function (event) { | |
| 43 | + EventListController.prototype.subscribe = function(event) { | |
| 44 | 44 | var vm = this; |
| 45 | 45 | |
| 46 | - if(event.isOld){ | |
| 47 | - vm.$log.debug('Event already happened. Abort.'); | |
| 48 | - return; | |
| 49 | - } | |
| 50 | - | |
| 51 | 46 | var event_id = event.id; |
| 52 | - vm.$log.debug('event_id', event_id); | |
| 53 | 47 | |
| 54 | - if(!vm.$rootScope.currentUser){ | |
| 48 | + // must be authenticated | |
| 49 | + if (!vm.$rootScope.currentUser) { | |
| 55 | 50 | vm.$log.info('User is not logged in. Redirect to Auth page.'); |
| 56 | - vm.$state.go('entrar',{ | |
| 51 | + vm.$state.go('entrar', { | |
| 57 | 52 | redirect_uri: 'state=inicio&task=subscribe&event_id=' + event_id |
| 58 | - },{ | |
| 53 | + }, { | |
| 59 | 54 | location: true |
| 60 | 55 | }); |
| 61 | - }else{ | |
| 62 | - vm.ArticleService.subscribeToEvent(event_id, {}, function(response){ | |
| 63 | - vm.$log.debug('response', response); | |
| 64 | - }, function(error){ | |
| 65 | - vm.$log.debug('error', error); | |
| 66 | - }); | |
| 56 | + | |
| 57 | + return; | |
| 67 | 58 | } |
| 59 | + | |
| 60 | + // do the subscription | |
| 61 | + event._loading = true; | |
| 62 | + vm.ArticleService.subscribeToEvent(event_id).then(function (data) { | |
| 63 | + vm.$log.debug('success', data); | |
| 64 | + | |
| 65 | + if(data.success === true){ | |
| 66 | + // subscribed with success | |
| 67 | + event.already_follow = true; | |
| 68 | + } | |
| 69 | + | |
| 70 | + if(data.success === false && data.already_follow === true){ | |
| 71 | + // already subscribed | |
| 72 | + event.already_follow = true; | |
| 73 | + } | |
| 74 | + }, function (data) { | |
| 75 | + vm.$log.debug('error', data); | |
| 76 | + }, function (data){ | |
| 77 | + vm.$log.debug('update', data); | |
| 78 | + }).finally(function(data){ | |
| 79 | + vm.$log.debug('finally', data); | |
| 80 | + event._loading = false; | |
| 81 | + }); | |
| 68 | 82 | }; |
| 69 | 83 | |
| 70 | 84 | var directive = { | ... | ... |
src/app/components/event-list/event-list.html
| ... | ... | @@ -40,11 +40,8 @@ |
| 40 | 40 | </span> |
| 41 | 41 | </div> |
| 42 | 42 | <div class="col-xs-12 col-sm-4 col-md-5 vcenter"> |
| 43 | - <span class="description">{{::event.title.split('-')[0]}}</span> | |
| 43 | + <span class="description">{{::event.setting.presenter}}</span> | |
| 44 | 44 | </div> |
| 45 | - <!-- <div class="col-xs-12 col-sm-4 col-md-3 text-center vcenter"> | |
| 46 | - <span class="theme">{{::event.categories[0].name}}</span> | |
| 47 | - </div> --> | |
| 48 | 45 | <div class="col-xs-12 col-sm-4 col-md-4 text-right vcenter" style="padding-right: 20px;"> |
| 49 | 46 | <div class="row"> |
| 50 | 47 | <div class="col-xs-6 text-right"> |
| ... | ... | @@ -55,10 +52,19 @@ |
| 55 | 52 | </div> |
| 56 | 53 | </div> |
| 57 | 54 | <div class="col-xs-6"> |
| 58 | - <button type="button" class="btn color-theme-common-bg btn-disabled" disabled ng-click="vm.subscribe(event)"> | |
| 59 | - Inscreva-se | |
| 60 | - <span class="sr-only">no bate-papo com (ministro) no dia {event.start_date | date : "dd/MM/yyyy"}} as {{event.start_date | date : "HH:mm"}} horas</span> | |
| 61 | - </button> | |
| 55 | + <div ng-show="!event.already_follow"> | |
| 56 | + <button type="button" class="btn btn-subscribe" ng-click="vm.subscribe(event)"> | |
| 57 | + Inscreva-se | |
| 58 | + <span class="sr-only">no bate-papo com (ministro) no dia {event.start_date | date : "dd/MM/yyyy"}} as {{event.start_date | date : "HH:mm"}} horas</span> | |
| 59 | + </button> | |
| 60 | + </div> | |
| 61 | + <div ng-show="event.already_follow"> | |
| 62 | + <button type="button" class="btn btn-subscribed disabled" disabled="disabled"> | |
| 63 | + <span class="glyphicon glyphicon-ok" aria-hidden="true"></span> | |
| 64 | + Inscrito | |
| 65 | + <span class="sr-only">Você já está inscrito neste evento.</span> | |
| 66 | + </button> | |
| 67 | + </div> | |
| 62 | 68 | </div> |
| 63 | 69 | </div> |
| 64 | 70 | </div> | ... | ... |
src/app/components/event-list/event-list.scss
| ... | ... | @@ -10,6 +10,7 @@ |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | .event-list--panel { |
| 13 | + color: #484848; | |
| 13 | 14 | width: 100%; |
| 14 | 15 | height: 240px; |
| 15 | 16 | margin: 8px 0; |
| ... | ... | @@ -24,9 +25,22 @@ |
| 24 | 25 | } |
| 25 | 26 | |
| 26 | 27 | .btn { |
| 27 | - color: #e1e1e1; | |
| 28 | 28 | text-transform: uppercase; |
| 29 | - font-weight: bold; | |
| 29 | + // font-weight: bold; | |
| 30 | + | |
| 31 | + &.btn-subscribe { | |
| 32 | + color: #fff; | |
| 33 | + background-color: $defaultblue; | |
| 34 | + } | |
| 35 | + | |
| 36 | + &.btn-subscribed { | |
| 37 | + color: $defaultblue; | |
| 38 | + border: 1px solid $defaultblue; | |
| 39 | + | |
| 40 | + .glyphicon { | |
| 41 | + color: #4eca74; | |
| 42 | + } | |
| 43 | + } | |
| 30 | 44 | } |
| 31 | 45 | |
| 32 | 46 | .row-level-1 { |
| ... | ... | @@ -45,6 +59,20 @@ |
| 45 | 59 | height: auto; |
| 46 | 60 | overflow: visible; |
| 47 | 61 | } |
| 62 | + | |
| 63 | + | |
| 64 | + .date-wrapper {margin-left: 16px; } | |
| 65 | + .time-wrapper {margin-left: 22px; } | |
| 66 | + // .description {margin-left: 22px; } | |
| 67 | + | |
| 68 | + .date-wrapper .glyphicon, | |
| 69 | + .time-wrapper .glyphicon { | |
| 70 | + color: $defaultblue; | |
| 71 | + font-size: 18px; | |
| 72 | + font-size: 1.8rem; | |
| 73 | + position: relative; | |
| 74 | + top: 3px; | |
| 75 | + } | |
| 48 | 76 | } |
| 49 | 77 | |
| 50 | 78 | &--table{ |
| ... | ... | @@ -110,12 +138,6 @@ |
| 110 | 138 | } |
| 111 | 139 | } |
| 112 | 140 | |
| 113 | - .event-list--panel { | |
| 114 | - .date-wrapper {margin-left: 16px; } | |
| 115 | - .time-wrapper {margin-left: 22px; } | |
| 116 | - // .description {margin-left: 22px; } | |
| 117 | - } | |
| 118 | - | |
| 119 | 141 | .event-tab--icon { |
| 120 | 142 | font-size: 25px; |
| 121 | 143 | } | ... | ... |
src/app/pages/inicio/inicio.controller.js
| ... | ... | @@ -76,13 +76,18 @@ |
| 76 | 76 | |
| 77 | 77 | // Load event list |
| 78 | 78 | vm.loadingEvents = true; |
| 79 | - vm.DialogaService.getEvents({}, function(events) { | |
| 80 | - vm.events = events; | |
| 81 | - vm.loadingEvents = false; | |
| 79 | + vm.DialogaService.getEvents().then(function(data) { | |
| 80 | + vm.$log.debug('getEvents.success', data); | |
| 81 | + vm.events = data.articles; | |
| 82 | + vm.featuredEvent = vm.events[0]; | |
| 82 | 83 | }, function(error) { |
| 83 | - vm.$log.error('Error on getEvents.', error); | |
| 84 | - vm.loadingEvents = false; | |
| 84 | + vm.$log.debug('Error on getEvents.', error); | |
| 85 | 85 | vm.eventsError = error; |
| 86 | + }, function(data) { | |
| 87 | + vm.$log.debug('{UPDATE}', data); | |
| 88 | + }).finally(function(data){ | |
| 89 | + vm.$log.debug('{FINALLY}', data); | |
| 90 | + vm.loadingEvents = false; | |
| 86 | 91 | }); |
| 87 | 92 | |
| 88 | 93 | function _loadAfterHome () { |
| ... | ... | @@ -160,6 +165,15 @@ |
| 160 | 165 | vm.article.videoIsLoaded = true; |
| 161 | 166 | }; |
| 162 | 167 | |
| 168 | + InicioPageController.prototype.showEventVideo = function() { | |
| 169 | + var vm = this; | |
| 170 | + | |
| 171 | + hideBackground(0); // force to hide | |
| 172 | + | |
| 173 | + vm.featuredEvent.canView = true; | |
| 174 | + vm.featuredEvent.bodyTrusted = vm.$sce.trustAsHtml(vm.featuredEvent.body); | |
| 175 | + }; | |
| 176 | + | |
| 163 | 177 | InicioPageController.prototype.submitSearch = function() { |
| 164 | 178 | var vm = this; |
| 165 | 179 | |
| ... | ... | @@ -167,10 +181,10 @@ |
| 167 | 181 | |
| 168 | 182 | // scroll to result grid |
| 169 | 183 | var $searchResult = angular.element('#search-result'); |
| 170 | - if($searchResult && $searchResult.length > 0){ | |
| 184 | + if ($searchResult && $searchResult.length > 0) { | |
| 171 | 185 | angular.element('body').animate({scrollTop: $searchResult.offset().top}, 'fast'); |
| 172 | 186 | vm.filtredPrograms = vm.getFiltredPrograms(); |
| 173 | - }else{ | |
| 187 | + }else { | |
| 174 | 188 | vm.$log.warn('#search-result element not found.'); |
| 175 | 189 | } |
| 176 | 190 | }; |
| ... | ... | @@ -251,7 +265,7 @@ |
| 251 | 265 | return output; |
| 252 | 266 | }; |
| 253 | 267 | |
| 254 | - InicioPageController.prototype._filterByCategory = function (input, category) { | |
| 268 | + InicioPageController.prototype._filterByCategory = function(input, category) { | |
| 255 | 269 | var vm = this; |
| 256 | 270 | |
| 257 | 271 | input = input || []; |
| ... | ... | @@ -265,7 +279,7 @@ |
| 265 | 279 | for (var i = 0; i < input.length; i++) { |
| 266 | 280 | var program = input[i]; |
| 267 | 281 | |
| 268 | - if(!program.categories || program.categories.length === 0){ | |
| 282 | + if (!program.categories || program.categories.length === 0) { | |
| 269 | 283 | vm.$log.warn('Program without theme (category)', program.slug); |
| 270 | 284 | continue; |
| 271 | 285 | } | ... | ... |
src/app/pages/inicio/inicio.html
| ... | ... | @@ -5,7 +5,12 @@ |
| 5 | 5 | <div class="col-md-8" ng-class="{'col-md-offset-2': !pageInicio.featuredEvent}"> |
| 6 | 6 | <div class="video-player js-youtube"> |
| 7 | 7 | <div class="embed-responsive embed-responsive-16by9"> |
| 8 | - <div class="js-iframe" ng-if="pageInicio.article.videoIsLoaded" ng-bind-html="pageInicio.article.abstractTrusted"></div> | |
| 8 | + <div ng-if="!pageInicio.featuredEvent || !pageInicio.featuredEvent.canView"> | |
| 9 | + <div class="js-iframe" ng-if="pageInicio.article.videoIsLoaded" ng-bind-html="pageInicio.article.abstractTrusted"></div> | |
| 10 | + </div> | |
| 11 | + <div ng-if="pageInicio.featuredEvent && pageInicio.featuredEvent.canView"> | |
| 12 | + <div class="js-iframe" ng-bind-html="pageInicio.featuredEvent.bodyTrusted"></div> | |
| 13 | + </div> | |
| 9 | 14 | <div class="video-background" ng-click="pageInicio.showVideo()"> |
| 10 | 15 | <div class="video-thumbnail" aria-hidden="true" style="background-image:url(/assets/images/youtube-background.png)"></div> |
| 11 | 16 | <button class="video-play-button" aria-live="assertive" aria-label="Assistir o vídeo tutorial Dialoga Brasil"> |
| ... | ... | @@ -22,15 +27,16 @@ |
| 22 | 27 | <h2 class="box-title">Bate papo com <b>MINISTROS/AS</b></h2> |
| 23 | 28 | </div> |
| 24 | 29 | <div class="box-middle col-xs-12 col-sm-4 col-md-12"> |
| 25 | - <div class="video" style="background-image: url(/assets/images/event-video-area.png)"> | |
| 30 | + <div class="video" | |
| 31 | + ng-style="{'background-image': 'url(' + pageInicio.featuredEvent.image.url + ')'}" | |
| 32 | + ng-click="pageInicio.showEventVideo()" | |
| 33 | + > | |
| 26 | 34 | </div> |
| 27 | 35 | </div> |
| 28 | 36 | <div class="box-bottom col-xs-12 col-sm-4 col-md-12"> |
| 29 | - <div class="date">DD/MM/YYYY</div> | |
| 37 | + <div class="date">{{pageInicio.featuredEvent.start_date | date : "dd/MM/yyyy"}}</div> | |
| 30 | 38 | <div class="live">AO VIVO</div> |
| 31 | - <p> | |
| 32 | - Lorem ipsum dolor sit amet, mei at facete constituto partiendo et. | |
| 33 | - </p> | |
| 39 | + <div class="description" ng-bind-html="pageInicio.featuredEvent.abstract"></div> | |
| 34 | 40 | </div> |
| 35 | 41 | <div class="clearfix"></div> |
| 36 | 42 | </div> | ... | ... |
src/app/pages/inicio/inicio.scss
| ... | ... | @@ -53,9 +53,9 @@ |
| 53 | 53 | padding: 0; |
| 54 | 54 | |
| 55 | 55 | .video { |
| 56 | + cursor: pointer; | |
| 56 | 57 | width: 100%; |
| 57 | 58 | min-height: 125px; |
| 58 | - background-color: #4A4A0E; | |
| 59 | 59 | background-size: cover; |
| 60 | 60 | background-position: center; |
| 61 | 61 | } |
| ... | ... | @@ -84,7 +84,7 @@ |
| 84 | 84 | border-radius: 20px; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - p { padding: 10px 0;} | |
| 87 | + .description { padding: 10px 0;} | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | @media screen and (min-width: $screen-lg) { | ... | ... |