From c7fa6720ed1a3179896012fe6f3186423d19c13a Mon Sep 17 00:00:00 2001 From: Caio SBA Date: Fri, 22 May 2015 18:07:49 -0300 Subject: [PATCH] After successful login, load list of discussions. Right now, it loads all discussions if configuration noosferoCommunity is not set, or only discussions from that community, otherwise. --- ConfJuvApp/www/html/_discussions_list.html | 5 +++++ ConfJuvApp/www/html/_header.html | 2 +- ConfJuvApp/www/html/_proposal_list.html | 5 ----- ConfJuvApp/www/index.html | 2 +- ConfJuvApp/www/js/config.js.example | 6 +++--- ConfJuvApp/www/js/controllers.js | 37 +++++++++++++++++++++++++++---------- 6 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 ConfJuvApp/www/html/_discussions_list.html delete mode 100644 ConfJuvApp/www/html/_proposal_list.html diff --git a/ConfJuvApp/www/html/_discussions_list.html b/ConfJuvApp/www/html/_discussions_list.html new file mode 100644 index 0000000..47f9f3c --- /dev/null +++ b/ConfJuvApp/www/html/_discussions_list.html @@ -0,0 +1,5 @@ + + + {{discussion.title}} + + diff --git a/ConfJuvApp/www/html/_header.html b/ConfJuvApp/www/html/_header.html index 158e1f1..0172653 100644 --- a/ConfJuvApp/www/html/_header.html +++ b/ConfJuvApp/www/html/_header.html @@ -1,5 +1,5 @@ -

3ª Conferência Nacional de Juventude

+

ConfJuv

diff --git a/ConfJuvApp/www/html/_proposal_list.html b/ConfJuvApp/www/html/_proposal_list.html deleted file mode 100644 index 39ded16..0000000 --- a/ConfJuvApp/www/html/_proposal_list.html +++ /dev/null @@ -1,5 +0,0 @@ - - - {{proposal.title}} - - diff --git a/ConfJuvApp/www/index.html b/ConfJuvApp/www/index.html index 753e3ad..7bc951b 100644 --- a/ConfJuvApp/www/index.html +++ b/ConfJuvApp/www/index.html @@ -26,7 +26,7 @@ - + diff --git a/ConfJuvApp/www/js/config.js.example b/ConfJuvApp/www/js/config.js.example index e35e04b..35d65c4 100644 --- a/ConfJuvApp/www/js/config.js.example +++ b/ConfJuvApp/www/js/config.js.example @@ -1,5 +1,5 @@ var ConfJuvAppConfig = { - noosferoApiHost: '', - noosferoApiVersion: '', - noosferoApiPrivateToken: '' + noosferoApiHost: 'http://juventude.gov.br', + noosferoApiVersion: 'v1', + noosferoCommunity: 95425 }; diff --git a/ConfJuvApp/www/js/controllers.js b/ConfJuvApp/www/js/controllers.js index 70c547f..6420dad 100644 --- a/ConfJuvApp/www/js/controllers.js +++ b/ConfJuvApp/www/js/controllers.js @@ -4,14 +4,7 @@ angular.module('confjuvapp.controllers', []) $scope.loading = false; // FIXME: This list should come from the server - $scope.proposalList = [ - { - title: 'Diminuir os juros do FIES' - }, - { - title: 'Desmilitarizar a polícia' - } - ]; + $scope.discussionsList = []; // Login modal @@ -56,9 +49,11 @@ angular.module('confjuvapp.controllers', []) $http.post(ConfJuvAppUtils.pathTo('login'), jQuery.param(data), config) .then(function(resp) { $scope.closeModal(); - $ionicPopup.alert({ title: 'Login', template: 'Login efetuado com sucesso!' }); + var popup = $ionicPopup.alert({ title: 'Login', template: 'Login efetuado com sucesso!' }); ConfJuvAppUtils.loggedIn = true; - $scope.loading = false; + popup.then(function() { + $scope.loadDiscussions(resp.data.private_token); + }); }, function(err) { $scope.closeModal(); 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', []) }); }; + $scope.loadDiscussions = function(token) { + $scope.discussionsList = []; + + var path = '?private_token=' + token + '&fields=title&content_type=ProposalsDiscussionPlugin::Discussion'; + + if (ConfJuvAppConfig.noosferoCommunity == '') { + path = 'articles' + path; + } + else { + path = 'communities/' + ConfJuvAppConfig.noosferoCommunity + '/articles' + path; + } + + $http.get(ConfJuvAppUtils.pathTo(path)) + .then(function(resp) { + $scope.loading = false; + $scope.discussionsList = resp.data.articles; + }, function(err) { + var popup = $ionicPopup.alert({ title: 'Discussões', template: 'Não foi possível carregar as discussões' }); + $scope.loading = false; + }); + }; + }); // Ends controller -- libgit2 0.21.2