@ -0,0 +1,68 @@ |
|||
angular.module('app.byPlace', ['pascalprecht.translate']) |
|||
|
|||
.controller('ByPlaceCtrl', function($scope, $http, $ionicModal, |
|||
$timeout, $ionicLoading, $filter, $stateParams) { |
|||
|
|||
$scope.category=$stateParams.categoryname; |
|||
$scope.events=[]; |
|||
$scope.page=0; |
|||
$scope.doRefresh = function() { |
|||
/* events refresh: */ |
|||
//$http.get(urlapi + 'events?page=' + $scope.page)
|
|||
$http.get(urlapi + 'events/category/'+ $stateParams.categoryname) |
|||
.then(function(data){ |
|||
$scope.events=data.data; |
|||
console.log($scope.events); |
|||
$scope.$broadcast('scroll.refreshComplete');//refresher stop
|
|||
|
|||
}, function(data){ |
|||
console.log('data error'); |
|||
$scope.$broadcast('scroll.refreshComplete');//refresher stop
|
|||
$ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 }); |
|||
|
|||
}); |
|||
}; |
|||
$scope.doRefresh(); |
|||
|
|||
$scope.share = function(event){ |
|||
var message = "[" + event.title + "]" + event.description; |
|||
/*var subject = event.title; |
|||
var file= ['',''];*/ |
|||
var link = "http://duckduckgo.com"; |
|||
$cordovaSocialSharing |
|||
.share(message, link) // Share via native share sheet
|
|||
.then(function(result) { |
|||
// Success!
|
|||
}, function(err) { |
|||
// An error occured. Show a message to the user
|
|||
}); |
|||
}; |
|||
$scope.savedEvents=[]; |
|||
$scope.$on('$ionicView.enter', function(){//per executar-ho cada cop que es carrega el view
|
|||
if (localStorage.getItem("events_app_savedEvents")) { |
|||
$scope.savedEvents = JSON.parse(localStorage.getItem("events_app_savedEvents")); |
|||
} |
|||
}); |
|||
$scope.saveEvent = function(event){ |
|||
$scope.savedEvents.push(event); |
|||
localStorage.setItem("events_app_savedEvents", JSON.stringify($scope.savedEvents)); |
|||
$ionicLoading.show({ template: 'Event saved', noBackdrop: true, duration: 1000 }); |
|||
}; |
|||
$scope.unsaveEvent = function(event){ |
|||
for(var i=0; i<$scope.savedEvents.length; i++) { |
|||
if ($scope.savedEvents[i]._id === event._id){ |
|||
$scope.savedEvents.splice(i, 1); |
|||
} |
|||
} |
|||
localStorage.setItem("events_app_savedEvents", JSON.stringify($scope.savedEvents)); |
|||
$ionicLoading.show({ template: 'Event unsaved', noBackdrop: true, duration: 1000 }); |
|||
}; |
|||
$scope.isEventSaved = function(event) { |
|||
for(var i=0; i<$scope.savedEvents.length; i++) { |
|||
if ($scope.savedEvents[i]._id === event._id){ |
|||
return true; |
|||
} |
|||
} |
|||
return false; |
|||
}; |
|||
}); |
@ -0,0 +1,59 @@ |
|||
angular.module('app.mapEvents', ['pascalprecht.translate', 'ui-leaflet']) |
|||
|
|||
.controller('MapEventsCtrl', function($scope, $http, $ionicModal, |
|||
$timeout, $ionicLoading, $filter, |
|||
leafletBoundsHelpers, $cordovaSocialSharing) { |
|||
|
|||
//map
|
|||
$scope.center= { |
|||
lat: 0, |
|||
lng: 0, |
|||
zoom: 1 |
|||
}; |
|||
$scope.markers=[]; |
|||
$scope.tiles= { |
|||
url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", |
|||
options: { |
|||
attribution: '<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' |
|||
} |
|||
}; |
|||
|
|||
$scope.events=[]; |
|||
$scope.page=0; |
|||
$http.get(urlapi + 'events') |
|||
.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.$broadcast('scroll.refreshComplete');//refresher stop
|
|||
for(var i=0; i<$scope.events.length; i++) |
|||
{ |
|||
if($scope.events[i].location) |
|||
{ |
|||
var msg="<a href='#/app/events/"+$scope.events[i]._id+"'>" |
|||
+"<h4>"+$scope.events[i].title + "</h4>" |
|||
+"<img src='"+$scope.events[i].img+"' style='width:100%;'>" |
|||
+$scope.events[i].description+"</a>"; |
|||
|
|||
$scope.markers.push({ |
|||
lat: Number($scope.events[i].location.geo.lat), |
|||
lng: Number($scope.events[i].location.geo.long), |
|||
message: msg |
|||
}); |
|||
$scope.center= { |
|||
lat: Number($scope.events[i].location.geo.lat), |
|||
lng: Number($scope.events[i].location.geo.long), |
|||
zoom: 12 |
|||
}; |
|||
} |
|||
} |
|||
}, function(data){ |
|||
console.log('data error'); |
|||
$scope.$broadcast('scroll.refreshComplete');//refresher stop
|
|||
$ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 }); |
|||
|
|||
}); |
|||
|
|||
|
|||
}); |
@ -0,0 +1,51 @@ |
|||
angular.module('app.place', ['pascalprecht.translate', 'ui-leaflet']) |
|||
|
|||
.controller('PlaceCtrl', function($scope, $http, $ionicModal, $timeout, |
|||
$ionicLoading, $filter, leafletData, leafletBoundsHelpers) { |
|||
|
|||
$scope.center= { |
|||
lat: 0, |
|||
lng: 0, |
|||
zoom: 1 |
|||
}; |
|||
$scope.markers=new Array(); |
|||
$scope.tiles= { |
|||
url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", |
|||
options: { |
|||
attribution: '<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' |
|||
} |
|||
}; |
|||
$scope.place={ |
|||
location:{ |
|||
direction:"", |
|||
geo:{ |
|||
lat:"", |
|||
long:"" |
|||
} |
|||
} |
|||
}; |
|||
$scope.getGeo = function(){ |
|||
$scope.markers=[]; |
|||
console.log($scope.place.location.direction); |
|||
$http.get('http://nominatim.openstreetmap.org/search?q=' + $scope.place.location.direction + '&format=json&limit=1') |
|||
.then(function(data) { |
|||
console.log(data); |
|||
if(data.data[0]) |
|||
{ |
|||
$scope.place.location.geo.lat=data.data[0].lat; |
|||
$scope.place.location.geo.long=data.data[0].lon; |
|||
//$scope.newtravel.from.name=data.data[0].display_name;
|
|||
$scope.markers.push({ |
|||
lat: Number(data.data[0].lat), |
|||
lng: Number(data.data[0].lon), |
|||
message: $scope.place.location.direction |
|||
}); |
|||
$scope.center= { |
|||
lat: Number(data.data[0].lat), |
|||
lng: Number(data.data[0].lon), |
|||
zoom: 16 |
|||
}; |
|||
} |
|||
}); |
|||
}; |
|||
}); |
@ -0,0 +1,43 @@ |
|||
<ion-view view-title="category: {{category}}"> |
|||
<ion-content class="c_blueGrey100"> |
|||
<ion-refresher pulling-text="{{'Pull_to_refresh' | translate}}..." on-refresh="doRefresh()"> |
|||
</ion-refresher> |
|||
<div class="card" ng-repeat="event in events"> |
|||
<a class="item item-avatar" ng-href="#/app/users/{{event.user._id}}"> |
|||
<img ng-src="{{event.user.img}}"> |
|||
<h2>{{event.user.username}}</h2> |
|||
<p>{{event.user.shortDescription}}</p> |
|||
</a> |
|||
<a ng-href="#/app/events/{{event._id}}" class="item item-image" |
|||
ng-show="event.img"> |
|||
<img ng-src="{{event.img}}"> |
|||
</a> |
|||
<a ng-href="#/app/events/{{event._id}}" class="item item-text-wrap"> |
|||
<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> |
|||
<div class="item tabs tabs-icon-only"> |
|||
<a class="tab-item" ng-click="share(event)"> |
|||
<i class="icon ion-android-share-alt"></i> |
|||
</a> |
|||
<a class="tab-item"> |
|||
|
|||
</a> |
|||
<a class="tab-item" ng-click="unsaveEvent(event)" |
|||
ng-show="isEventSaved(event)"> |
|||
<i class="icon ion-heart ctext_red600"></i> |
|||
</a> |
|||
<a class="tab-item" ng-click="saveEvent(event)" |
|||
ng-hide="isEventSaved(event)"> |
|||
<i class="icon ion-heart"></i> |
|||
</a> |
|||
</div> |
|||
</div> |
|||
</ion-content> |
|||
</ion-view> |
@ -0,0 +1,7 @@ |
|||
<ion-view view-title="Map of Events"> |
|||
<ion-content class="c_blueGrey100"> |
|||
<leaflet |
|||
width="100%" height="100%" markers="markers" |
|||
center="center" tiles="tiles" id="map-simple-map"></leaflet> |
|||
</ion-content> |
|||
</ion-view> |
@ -0,0 +1,25 @@ |
|||
<ion-view view-title="Define a place"> |
|||
<ion-content> |
|||
<label class="item item-input"> |
|||
<input type="text" ng-model="place.location.direction" placeholder="Direction"> |
|||
</label> |
|||
<div ng-click="getGeo()" class="button button-small c_indigo400 item-note" |
|||
ng-show="place.location.direction"> |
|||
Get geolocation |
|||
</div> |
|||
<leaflet ng-show="markers[0]" |
|||
width="100%" height="40%" markers="markers" center="center" |
|||
tiles="tiles" id="map-simple-map"></leaflet> |
|||
|
|||
<label class="item item-input"> |
|||
<span class="input-label">Radius</span> |
|||
<input type="number"> |
|||
</label> |
|||
|
|||
<div class="item"> |
|||
<div ng-click="postEvent()" class="button c_indigo400 item-note" ng-show="place.location.geo.lat"> |
|||
Post new event! |
|||
</div> |
|||
</div> |
|||
</ion-content> |
|||
</ion-view> |