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
ConfJuvApp/www/html/_proposal_list.html
ConfJuvApp/www/index.html
ConfJuvApp/www/js/config.js.example
ConfJuvApp/www/js/controllers.js
... | ... | @@ -4,14 +4,7 @@ angular.module('confjuvapp.controllers', []) |
4 | 4 | $scope.loading = false; |
5 | 5 | |
6 | 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 | 9 | // Login modal |
17 | 10 | |
... | ... | @@ -56,9 +49,11 @@ angular.module('confjuvapp.controllers', []) |
56 | 49 | $http.post(ConfJuvAppUtils.pathTo('login'), jQuery.param(data), config) |
57 | 50 | .then(function(resp) { |
58 | 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 | 53 | ConfJuvAppUtils.loggedIn = true; |
61 | - $scope.loading = false; | |
54 | + popup.then(function() { | |
55 | + $scope.loadDiscussions(resp.data.private_token); | |
56 | + }); | |
62 | 57 | }, function(err) { |
63 | 58 | $scope.closeModal(); |
64 | 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 | 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 | 90 | }); // Ends controller | ... | ... |