Browse Source

events by day implemented, todo: calendar view to select a day

master
arnaucode 7 years ago
parent
commit
2dc2105948
6 changed files with 93 additions and 4 deletions
  1. +3
    -0
      www/index.html
  2. +12
    -2
      www/js/app.js
  3. +68
    -0
      www/js/byDay.js
  4. +3
    -1
      www/js/calendar.js
  5. +7
    -0
      www/templates/byDay.html
  6. +0
    -1
      www/templates/calendar.html

+ 3
- 0
www/index.html

@ -20,6 +20,8 @@
<link href="css/style.css" rel="stylesheet"> <link href="css/style.css" rel="stylesheet">
<link href="css/colors.css" rel="stylesheet"> <link href="css/colors.css" rel="stylesheet">
<link rel="stylesheet" href="lib/angular-material/angular-material.css">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet"> <link href="css/ionic.app.css" rel="stylesheet">
--> -->
@ -56,6 +58,7 @@
<script src="js/place.js"></script> <script src="js/place.js"></script>
<script src="js/byPlace.js"></script> <script src="js/byPlace.js"></script>
<script src="js/calendar.js"></script> <script src="js/calendar.js"></script>
<script src="js/byDay.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>

+ 12
- 2
www/js/app.js

@ -1,5 +1,5 @@
var urlapi = "http://localhost:3000/api/";
//var urlapi = "http://192.168.1.33:3000/api/";
//var urlapi = "http://localhost:3000/api/";
var urlapi = "http://192.168.1.33:3000/api/";
@ -19,6 +19,7 @@ angular.module('app', [
'app.place', 'app.place',
'app.byPlace', 'app.byPlace',
'app.calendar', 'app.calendar',
'app.byDay',
'app.users', 'app.users',
'app.user', 'app.user',
'app.login', 'app.login',
@ -152,6 +153,15 @@ angular.module('app', [
} }
} }
}) })
.state('app.byDay', {
url: '/byDay/:day',
views: {
'menuContent': {
templateUrl: 'templates/byDay.html',
controller: 'ByDayCtrl'
}
}
})
.state('app.users', { .state('app.users', {
url: '/users', url: '/users',
views: { views: {

+ 68
- 0
www/js/byDay.js

@ -0,0 +1,68 @@
angular.module('app.byDay', ['pascalprecht.translate'])
.controller('ByDayCtrl', function($scope, $http, $ionicModal,
$timeout, $ionicLoading, $filter, $stateParams) {
$scope.day=$stateParams.day;
$scope.events=[];
$scope.page=0;
$scope.doRefresh = function() {
/* events refresh: */
//$http.get(urlapi + 'events?page=' + $scope.page)
$http.get(urlapi + 'events/day/'+ $stateParams.day)
.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;
};
});

+ 3
- 1
www/js/calendar.js

@ -3,5 +3,7 @@ angular.module('app.calendar', ['pascalprecht.translate'])
.controller('CalendarCtrl', function($scope, $http, $ionicModal, $timeout, .controller('CalendarCtrl', function($scope, $http, $ionicModal, $timeout,
$ionicLoading, $filter) { $ionicLoading, $filter) {
$scope.dayClick = function(date) {
window.location="#/app/byDay/" + date;
};
}); });

+ 7
- 0
www/templates/byDay.html

@ -0,0 +1,7 @@
<ion-view view-title="day: {{day}}">
<ion-content class="c_blueGrey100">
<ion-refresher pulling-text="{{'Pull_to_refresh' | translate}}..." on-refresh="doRefresh()">
</ion-refresher>
<div ng-include="'templates/templateEvents.html'"></div>
</ion-content>
</ion-view>

+ 0
- 1
www/templates/calendar.html

@ -1,5 +1,4 @@
<ion-view view-title="Calendar"> <ion-view view-title="Calendar">
<ion-content> <ion-content>
</ion-content> </ion-content>
</ion-view> </ion-view>

Loading…
Cancel
Save