Commit 85963eadbf4a92916da1d3a20de661fb18046e02

Authored by Caio Almeida
1 parent 5c81c623

Adding configuration management and login modal

1 *~ 1 *~
2 *.sw* 2 *.sw*
  3 +ConfJuvApp/www/js/config.js
ConfJuvApp/www/index.html
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
18 <!-- your app's js --> 18 <!-- your app's js -->
19 <script src="js/app.js"></script> 19 <script src="js/app.js"></script>
20 <script src="js/controllers.js"></script> 20 <script src="js/controllers.js"></script>
  21 + <script src="js/config.js"></script>
21 </head> 22 </head>
22 <body ng-app="confjuvapp"> 23 <body ng-app="confjuvapp">
23 24
@@ -26,7 +27,7 @@ @@ -26,7 +27,7 @@
26 <h1 class="title">3ª Conferência Nacional de Juventude</h1> 27 <h1 class="title">3ª Conferência Nacional de Juventude</h1>
27 28
28 <div class="buttons"> 29 <div class="buttons">
29 - <button class="button" ng-click="openModal()">Adicionar proposta</button> 30 + <button class="button" ng-click="openModal()">Entrar</button>
30 </div> 31 </div>
31 </ion-header-bar> 32 </ion-header-bar>
32 <ion-content> 33 <ion-content>
@@ -37,5 +38,25 @@ @@ -37,5 +38,25 @@
37 </ion-list> 38 </ion-list>
38 </ion-content> 39 </ion-content>
39 </ion-pane> 40 </ion-pane>
  41 +
  42 + <script id="modal.html" type="text/ng-template">
  43 + <div class="modal">
  44 + <div class="bar bar-header bar-calm">
  45 + <button class="button" ng-click="closeModal()">Voltar</button>
  46 + <h1 class="title">Entrar</h1>
  47 + </div>
  48 + <form ng-submit="Login(data)">
  49 + <div class="list">
  50 + <div class="list list-inset">
  51 + <label class="item item-input">
  52 + <input type="text" placeholder="Nome de usuário" ng-model="data.login">
  53 + </label>
  54 + </div>
  55 + <button class="button button-block button-positive" type="submit">Entrar</button>
  56 + </div>
  57 + </form>
  58 + </div>
  59 + </script>
  60 +
40 </body> 61 </body>
41 </html> 62 </html>
ConfJuvApp/www/js/config.js.example 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +var ConfJuvAppConfig = {
  2 + noosferoApiHost: '',
  3 + noosferoApiVersion: '',
  4 + noosferoApiPrivateToken: ''
  5 +};
ConfJuvApp/www/js/controllers.js
1 angular.module('confjuvapp.controllers', []) 1 angular.module('confjuvapp.controllers', [])
2 - .controller('ProposalCtrl', function($scope) { 2 + .controller('ProposalCtrl', function($scope, $ionicModal) {
  3 +
3 // FIXME: This list should come from the server 4 // FIXME: This list should come from the server
4 $scope.proposalList = [ 5 $scope.proposalList = [
5 { 6 {
@@ -9,4 +10,35 @@ angular.module(&#39;confjuvapp.controllers&#39;, []) @@ -9,4 +10,35 @@ angular.module(&#39;confjuvapp.controllers&#39;, [])
9 title: 'Desmilitarizar a polícia' 10 title: 'Desmilitarizar a polícia'
10 } 11 }
11 ]; 12 ];
12 - }); 13 +
  14 + // Login modal
  15 +
  16 + // Initiate the modal
  17 + $ionicModal.fromTemplateUrl('modal.html', {
  18 + scope: $scope,
  19 + animation: 'slide-in-up'
  20 + }).then(function(modal) {
  21 + $scope.modal = modal;
  22 + });
  23 +
  24 + // Function to open the modal
  25 + $scope.openModal = function() {
  26 + $scope.modal.show();
  27 + };
  28 +
  29 + // Function to close the modal
  30 + $scope.closeModal = function() {
  31 + $scope.modal.hide();
  32 + };
  33 +
  34 + // Cleanup the modal when we're done with it!
  35 + $scope.$on('$destroy', function() {
  36 + $scope.modal.remove();
  37 + });
  38 +
  39 + // Function to login
  40 + $scope.Login = function(data) {
  41 + $scope.closeModal();
  42 + };
  43 +
  44 + }); // Ends controller
@@ -14,3 +14,5 @@ This application is built on top of Ionic, so you need this framework. @@ -14,3 +14,5 @@ This application is built on top of Ionic, so you need this framework.
14 # `ionic emulate (android|ios)` 14 # `ionic emulate (android|ios)`
15 15
16 In order to compile the theme, you need to run: `gulp sass` 16 In order to compile the theme, you need to run: `gulp sass`
  17 +
  18 +You need to configure the application by creating a file `www/js/config.js` based on `www/js/config.js.example`.