Browse Source

implemented get events by categories

master
arnaucode 7 years ago
parent
commit
e102427098
11 changed files with 82 additions and 39 deletions
  1. +5
    -0
      www/css/style.css
  2. +2
    -1
      www/index.html
  3. +15
    -5
      www/js/app.js
  4. +6
    -16
      www/js/byCategory.js
  5. +17
    -0
      www/js/categories.js
  6. +9
    -8
      www/templates/byCategory.html
  7. +9
    -0
      www/templates/categories.html
  8. +9
    -4
      www/templates/event.html
  9. +8
    -3
      www/templates/events.html
  10. +1
    -1
      www/templates/main.html
  11. +1
    -1
      www/templates/menu.html

+ 5
- 0
www/css/style.css

@ -65,3 +65,8 @@
text-decoration: none; text-decoration: none;
color: #000000; color: #000000;
} }
.o_badge{
border-radius: 8px;
margin: 5px;
padding: 2px 5px;
}

+ 2
- 1
www/index.html

@ -50,7 +50,8 @@
<script src="js/event.js"></script> <script src="js/event.js"></script>
<script src="js/alerts.js"></script> <script src="js/alerts.js"></script>
<script src="js/savedEvents.js"></script> <script src="js/savedEvents.js"></script>
<script src="js/byCategories.js"></script>
<script src="js/categories.js"></script>
<script src="js/byCategory.js"></script>
<script src="js/users.js"></script> <script src="js/users.js"></script>
<script src="js/user.js"></script> <script src="js/user.js"></script>
<script src="js/login.js"></script> <script src="js/login.js"></script>

+ 15
- 5
www/js/app.js

@ -13,7 +13,8 @@ angular.module('app', [
'app.event', 'app.event',
'app.alerts', 'app.alerts',
'app.savedEvents', 'app.savedEvents',
'app.byCategories',
'app.categories',
'app.byCategory',
'app.users', 'app.users',
'app.user', 'app.user',
'app.login', 'app.login',
@ -93,12 +94,21 @@ angular.module('app', [
} }
} }
}) })
.state('app.byCategories', {
url: '/byCategories',
.state('app.categories', {
url: '/categories',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'templates/byCategories.html',
controller: 'ByCategoriesCtrl'
templateUrl: 'templates/categories.html',
controller: 'CategoriesCtrl'
}
}
})
.state('app.byCategory', {
url: '/byCategory/:categoryname',
views: {
'menuContent': {
templateUrl: 'templates/byCategory.html',
controller: 'ByCategoryCtrl'
} }
} }
}) })

www/js/byCategories.js → www/js/byCategory.js

@ -1,21 +1,18 @@
angular.module('app.byCategories', ['pascalprecht.translate'])
.controller('ByCategoriesCtrl', function($scope, $http, $ionicModal,
$timeout, $ionicLoading, $filter) {
angular.module('app.byCategory', ['pascalprecht.translate'])
.controller('ByCategoryCtrl', function($scope, $http, $ionicModal,
$timeout, $ionicLoading, $filter, $stateParams) {
$scope.category=$stateParams.categoryname;
$scope.events=[]; $scope.events=[];
$scope.alerts=[];
$scope.page=0; $scope.page=0;
$scope.doRefresh = function() { $scope.doRefresh = function() {
/* events refresh: */ /* events refresh: */
//$http.get(urlapi + 'events?page=' + $scope.page) //$http.get(urlapi + 'events?page=' + $scope.page)
$http.get(urlapi + 'events')
$http.get(urlapi + 'events/category/'+ $stateParams.categoryname)
.then(function(data){ .then(function(data){
console.log('data success events');
console.log(data); // for browser console
//$scope.events = data.data; // for UI
$scope.events=data.data; $scope.events=data.data;
console.log($scope.events);
$scope.$broadcast('scroll.refreshComplete');//refresher stop $scope.$broadcast('scroll.refreshComplete');//refresher stop
}, function(data){ }, function(data){
@ -24,11 +21,6 @@ angular.module('app.byCategories', ['pascalprecht.translate'])
$ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 }); $ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 });
}); });
$http.get(urlapi + 'alerts')
.then(function(data){
$scope.alerts=data.data;
}, function(data){
});
}; };
$scope.doRefresh(); $scope.doRefresh();
@ -49,8 +41,6 @@ angular.module('app.byCategories', ['pascalprecht.translate'])
$scope.$on('$ionicView.enter', function(){//per executar-ho cada cop que es carrega el view $scope.$on('$ionicView.enter', function(){//per executar-ho cada cop que es carrega el view
if (localStorage.getItem("events_app_savedEvents")) { if (localStorage.getItem("events_app_savedEvents")) {
$scope.savedEvents = JSON.parse(localStorage.getItem("events_app_savedEvents")); $scope.savedEvents = JSON.parse(localStorage.getItem("events_app_savedEvents"));
console.log("savedEvents");
console.log($scope.savedEvents);
} }
}); });
$scope.saveEvent = function(event){ $scope.saveEvent = function(event){

+ 17
- 0
www/js/categories.js

@ -0,0 +1,17 @@
angular.module('app.categories', ['pascalprecht.translate'])
.controller('CategoriesCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter) {
$scope.categories;
$http.get(urlapi + 'categoriesList')
.then(function(data){
$scope.categories=data.data;
console.log($scope.categories);
}, function(data){
console.log('data error');
console.log(data);
$ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 });
});
});

www/templates/byCategories.html → www/templates/byCategory.html

@ -1,11 +1,7 @@
<ion-view view-title="Events By Categories">
<ion-view view-title="category: {{category}}">
<ion-content class="c_blueGrey100"> <ion-content class="c_blueGrey100">
<ion-refresher pulling-text="{{'Pull_to_refresh' | translate}}..." on-refresh="doRefresh()"> <ion-refresher pulling-text="{{'Pull_to_refresh' | translate}}..." on-refresh="doRefresh()">
</ion-refresher> </ion-refresher>
<a href="#/app/alerts" class="item item-icon-left c_red400"
ng-show="alerts">
<i class="icon ion-android-alert"></i> <b>{{alerts.length}}</b> Emergency alerts!
</a>
<div class="card" ng-repeat="event in events"> <div class="card" ng-repeat="event in events">
<a class="item item-avatar" ng-href="#/app/users/{{event.user._id}}"> <a class="item item-avatar" ng-href="#/app/users/{{event.user._id}}">
<img ng-src="{{event.user.img}}"> <img ng-src="{{event.user.img}}">
@ -17,9 +13,14 @@
<img ng-src="{{event.img}}"> <img ng-src="{{event.img}}">
</a> </a>
<a ng-href="#/app/events/{{event._id}}" class="item item-text-wrap"> <a ng-href="#/app/events/{{event._id}}" class="item item-text-wrap">
<h2>{{event.title}}</h2>
<p>{{event.description}}</p>
<p>{{event.date | date: 'HH:mm, dd/MM/yyyy'}}</p>
<div class="item-note">{{event.date | date: 'HH:mm, dd/MM/yyyy'}}</div>
<h2>{{event.title}}</h2>
<p>{{event.description}}</p>
<p>
<span class="o_badge c_blueGrey300" ng-repeat="category in event.categories">
{{category.name}}
</span>
</p>
</a> </a>
<div class="item tabs tabs-icon-only"> <div class="item tabs tabs-icon-only">
<a class="tab-item" ng-click="share(event)"> <a class="tab-item" ng-click="share(event)">

+ 9
- 0
www/templates/categories.html

@ -0,0 +1,9 @@
<ion-view view-title="Categories">
<ion-content>
<ion-list>
<a class="item" ng-href="#/app/byCategory/{{category.name}}" ng-repeat="category in categories">
{{category.name}}
</a>
</ion-list>
</ion-content>
</ion-view>

+ 9
- 4
www/templates/event.html

@ -9,13 +9,18 @@
<img ng-src="{{event.img}}"> <img ng-src="{{event.img}}">
</div> </div>
<div class="item"> <div class="item">
<h2>{{event.title}}</h2>
<p>{{event.description}}</p>
<p>{{event.date | date: 'HH:mm, dd/MM/yyyy'}}</p>
<div class="item-note">{{event.date | date: 'HH:mm, dd/MM/yyyy'}}</div>
<h2>{{event.title}}</h2>
<p>{{event.description}}</p>
<p>
<span class="o_badge c_blueGrey300" ng-repeat="category in event.categories">
{{category.name}}
</span>
</p>
</div> </div>
<div class="item" ng-show="markers[0]"> <div class="item" ng-show="markers[0]">
<h2>Map</h2>
<h2>Place: {{event.location.direction}}</h2>
</div> </div>
<leaflet ng-show="markers[0]" <leaflet ng-show="markers[0]"
width="100%" height="40%" markers="markers" center="center" tiles="tiles" id="map-simple-map"></leaflet> width="100%" height="40%" markers="markers" center="center" tiles="tiles" id="map-simple-map"></leaflet>

+ 8
- 3
www/templates/events.html

@ -17,9 +17,14 @@
<img ng-src="{{event.img}}"> <img ng-src="{{event.img}}">
</a> </a>
<a ng-href="#/app/events/{{event._id}}" class="item item-text-wrap"> <a ng-href="#/app/events/{{event._id}}" class="item item-text-wrap">
<h2>{{event.title}}</h2>
<p>{{event.description}}</p>
<p>{{event.date | date: 'HH:mm, dd/MM/yyyy'}}</p>
<div class="item-note">{{event.date | date: 'HH:mm, dd/MM/yyyy'}}</div>
<h2>{{event.title}}</h2>
<p>{{event.description}}</p>
<p>
<span class="o_badge c_blueGrey300" ng-repeat="category in event.categories">
{{category.name}}
</span>
</p>
</a> </a>
<div class="item tabs tabs-icon-only"> <div class="item tabs tabs-icon-only">
<a class="tab-item" ng-click="share(event)"> <a class="tab-item" ng-click="share(event)">

+ 1
- 1
www/templates/main.html

@ -20,7 +20,7 @@
<a class="col c_deepPurple400" ng-href="#/app/search"> <a class="col c_deepPurple400" ng-href="#/app/search">
<i class="icon ion-search"></i> <i class="icon ion-search"></i>
</a> </a>
<a class="col c_cyan400" ng-href="#/app/byCategories">
<a class="col c_cyan400" ng-href="#/app/categories">
<i class="icon ion-pound"></i><!--by categories--> <i class="icon ion-pound"></i><!--by categories-->
</a> </a>
</div> </div>

+ 1
- 1
www/templates/menu.html

@ -30,7 +30,7 @@
<a class="item item-icon-left" menu-close href="#/app/savedEvents"> <a class="item item-icon-left" menu-close href="#/app/savedEvents">
<i class="icon ion-heart"></i> Saved Events <i class="icon ion-heart"></i> Saved Events
</a> </a>
<a class="item item-icon-left" menu-close href="#/app/byCategories">
<a class="item item-icon-left" menu-close href="#/app/categories">
<i class="icon ion-pound"></i> By Categories <i class="icon ion-pound"></i> By Categories
</a> </a>
<a class="item item-icon-left" menu-close href="#/app/events"> <a class="item item-icon-left" menu-close href="#/app/events">

Loading…
Cancel
Save