Commit c7fa6720ed1a3179896012fe6f3186423d19c13a
1 parent
73af9b92
Exists in
master
and in
2 other branches
After successful login, load list of discussions. Right now, it loads all discus…
…sions if configuration noosferoCommunity is not set, or only discussions from that community, otherwise.
Showing
6 changed files
with
37 additions
and
20 deletions
Show diff stats
ConfJuvApp/www/html/_header.html
1 | <ion-header-bar class="bar-assertive" align-title="left" id="header"> | 1 | <ion-header-bar class="bar-assertive" align-title="left" id="header"> |
2 | - <h1 class="title">3ª Conferência Nacional de Juventude</h1> | 2 | + <h1 class="title">ConfJuv</h1> |
3 | 3 | ||
4 | <div class="buttons"> | 4 | <div class="buttons"> |
5 | <button class="button" ng-click="openModal()">Entrar</button> | 5 | <button class="button" ng-click="openModal()">Entrar</button> |
ConfJuvApp/www/html/_proposal_list.html
ConfJuvApp/www/index.html
@@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
26 | 26 | ||
27 | <!-- Main content --> | 27 | <!-- Main content --> |
28 | <ion-content> | 28 | <ion-content> |
29 | - <ng-include src="'html/_proposal_list.html'"></ng-include> | 29 | + <ng-include src="'html/_discussions_list.html'"></ng-include> |
30 | </ion-content> | 30 | </ion-content> |
31 | </ion-pane> | 31 | </ion-pane> |
32 | </body> | 32 | </body> |
ConfJuvApp/www/js/config.js.example
ConfJuvApp/www/js/controllers.js
@@ -4,14 +4,7 @@ angular.module('confjuvapp.controllers', []) | @@ -4,14 +4,7 @@ angular.module('confjuvapp.controllers', []) | ||
4 | $scope.loading = false; | 4 | $scope.loading = false; |
5 | 5 | ||
6 | // FIXME: This list should come from the server | 6 | // FIXME: This list should come from the server |
7 | - $scope.proposalList = [ | ||
8 | - { | ||
9 | - title: 'Diminuir os juros do FIES' | ||
10 | - }, | ||
11 | - { | ||
12 | - title: 'Desmilitarizar a polícia' | ||
13 | - } | ||
14 | - ]; | 7 | + $scope.discussionsList = []; |
15 | 8 | ||
16 | // Login modal | 9 | // Login modal |
17 | 10 | ||
@@ -56,9 +49,11 @@ angular.module('confjuvapp.controllers', []) | @@ -56,9 +49,11 @@ angular.module('confjuvapp.controllers', []) | ||
56 | $http.post(ConfJuvAppUtils.pathTo('login'), jQuery.param(data), config) | 49 | $http.post(ConfJuvAppUtils.pathTo('login'), jQuery.param(data), config) |
57 | .then(function(resp) { | 50 | .then(function(resp) { |
58 | $scope.closeModal(); | 51 | $scope.closeModal(); |
59 | - $ionicPopup.alert({ title: 'Login', template: 'Login efetuado com sucesso!' }); | 52 | + var popup = $ionicPopup.alert({ title: 'Login', template: 'Login efetuado com sucesso!' }); |
60 | ConfJuvAppUtils.loggedIn = true; | 53 | ConfJuvAppUtils.loggedIn = true; |
61 | - $scope.loading = false; | 54 | + popup.then(function() { |
55 | + $scope.loadDiscussions(resp.data.private_token); | ||
56 | + }); | ||
62 | }, function(err) { | 57 | }, function(err) { |
63 | $scope.closeModal(); | 58 | $scope.closeModal(); |
64 | var popup = $ionicPopup.alert({ title: 'Login', template: 'Erro ao efetuar login. Verifique usuário e senha e conexão com a internet.' }); | 59 | var popup = $ionicPopup.alert({ title: 'Login', template: 'Erro ao efetuar login. Verifique usuário e senha e conexão com a internet.' }); |
@@ -70,4 +65,26 @@ angular.module('confjuvapp.controllers', []) | @@ -70,4 +65,26 @@ angular.module('confjuvapp.controllers', []) | ||
70 | }); | 65 | }); |
71 | }; | 66 | }; |
72 | 67 | ||
68 | + $scope.loadDiscussions = function(token) { | ||
69 | + $scope.discussionsList = []; | ||
70 | + | ||
71 | + var path = '?private_token=' + token + '&fields=title&content_type=ProposalsDiscussionPlugin::Discussion'; | ||
72 | + | ||
73 | + if (ConfJuvAppConfig.noosferoCommunity == '') { | ||
74 | + path = 'articles' + path; | ||
75 | + } | ||
76 | + else { | ||
77 | + path = 'communities/' + ConfJuvAppConfig.noosferoCommunity + '/articles' + path; | ||
78 | + } | ||
79 | + | ||
80 | + $http.get(ConfJuvAppUtils.pathTo(path)) | ||
81 | + .then(function(resp) { | ||
82 | + $scope.loading = false; | ||
83 | + $scope.discussionsList = resp.data.articles; | ||
84 | + }, function(err) { | ||
85 | + var popup = $ionicPopup.alert({ title: 'Discussões', template: 'Não foi possível carregar as discussões' }); | ||
86 | + $scope.loading = false; | ||
87 | + }); | ||
88 | + }; | ||
89 | + | ||
73 | }); // Ends controller | 90 | }); // Ends controller |