mirror of
https://github.com/arnaucube/openEventsPlatformApp.git
synced 2026-02-07 03:36:44 +01:00
project started, some html and js files added, showing events and users work communicating with server api
This commit is contained in:
125
www/js/app.js
Normal file
125
www/js/app.js
Normal file
@@ -0,0 +1,125 @@
|
||||
var urlapi = "http://localhost:3000/api/";
|
||||
|
||||
|
||||
angular.module('app', [
|
||||
'ionic',
|
||||
'pascalprecht.translate',
|
||||
'app.menu',
|
||||
'app.events',
|
||||
'app.event',
|
||||
'app.users',
|
||||
'app.user'
|
||||
])
|
||||
|
||||
.run(function($ionicPlatform) {
|
||||
$ionicPlatform.ready(function() {
|
||||
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
|
||||
// for form inputs)
|
||||
if (window.cordova && window.cordova.plugins.Keyboard) {
|
||||
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
|
||||
cordova.plugins.Keyboard.disableScroll(true);
|
||||
|
||||
}
|
||||
if (window.StatusBar) {
|
||||
// org.apache.cordova.statusbar required
|
||||
StatusBar.styleDefault();
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
.config(function($stateProvider, $urlRouterProvider) {
|
||||
$stateProvider
|
||||
|
||||
// setup an abstract state for the tabs directive
|
||||
.state('app', {
|
||||
url: '/app',
|
||||
abstract: true,
|
||||
templateUrl: 'templates/menu.html',
|
||||
controller: 'MenuCtrl'
|
||||
})
|
||||
|
||||
// Each tab has its own nav history stack:
|
||||
|
||||
.state('app.events', {
|
||||
url: '/events',
|
||||
views: {
|
||||
'menuContent': {
|
||||
templateUrl: 'templates/events.html',
|
||||
controller: 'EventsCtrl'
|
||||
}
|
||||
}
|
||||
}).state('app.event', {
|
||||
url: '/events/:eventid',
|
||||
views: {
|
||||
'menuContent': {
|
||||
templateUrl: 'templates/event.html',
|
||||
controller: 'EventCtrl'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.users', {
|
||||
url: '/users',
|
||||
views: {
|
||||
'menuContent': {
|
||||
templateUrl: 'templates/users.html',
|
||||
controller: 'UsersCtrl'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.user', {
|
||||
url: '/users/:userid',
|
||||
views: {
|
||||
'menuContent': {
|
||||
templateUrl: 'templates/user.html',
|
||||
controller: 'UserCtrl'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// if none of the above states are matched, use this as the fallback
|
||||
$urlRouterProvider.otherwise('/app/events');
|
||||
})
|
||||
/* translator */
|
||||
.config(['$translateProvider', function($translateProvider) {
|
||||
|
||||
/* get lang from the file translations.js */
|
||||
for (lang in translations) {
|
||||
$translateProvider.translations(lang, translations[lang]);
|
||||
}
|
||||
|
||||
if (window.localStorage.getItem('lang')) {
|
||||
$translateProvider.preferredLanguage(window.localStorage.getItem('lang'));
|
||||
} else {
|
||||
$translateProvider.preferredLanguage('english');
|
||||
};
|
||||
|
||||
$translateProvider.useSanitizeValueStrategy('escape');
|
||||
|
||||
}])
|
||||
.factory('httpInterceptor', function httpInterceptor($q, $window, $location) {
|
||||
return {
|
||||
request: function(config) {
|
||||
return config;
|
||||
},
|
||||
requestError: function(config) {
|
||||
return config;
|
||||
},
|
||||
response: function(res) {
|
||||
return res;
|
||||
},
|
||||
responseError: function(res) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
})
|
||||
.factory('api', function($http) {
|
||||
return {
|
||||
init: function() {
|
||||
$http.defaults.headers.common['X-Access-Token'] = localStorage.getItem("cim_app_token");
|
||||
$http.defaults.headers.post['X-Access-Token'] = localStorage.getItem("cim_app_token");
|
||||
}
|
||||
};
|
||||
})
|
||||
.run(function(api) {
|
||||
api.init();
|
||||
});
|
||||
57
www/js/event.js
Normal file
57
www/js/event.js
Normal file
@@ -0,0 +1,57 @@
|
||||
angular.module('app.event', ['pascalprecht.translate', 'ui-leaflet'])
|
||||
|
||||
.controller('EventCtrl', function($scope, $http, $ionicModal,
|
||||
$stateParams, $timeout, $ionicLoading, $filter,
|
||||
leafletData, leafletBoundsHelpers) {
|
||||
|
||||
|
||||
$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.event={};
|
||||
$scope.doRefresh = function() {
|
||||
/* events refresh: */
|
||||
$http.get(urlapi + 'events/id/'+ $stateParams.eventid)
|
||||
.then(function(data){
|
||||
console.log('data success events');
|
||||
console.log(data); // for browser console
|
||||
//$scope.events = data.data; // for UI
|
||||
$scope.event=data.data;
|
||||
$scope.$broadcast('scroll.refreshComplete');//refresher stop
|
||||
|
||||
if($scope.event.location)
|
||||
{
|
||||
$scope.markers=[];
|
||||
$scope.markers.push({
|
||||
lat: Number($scope.event.location.geo.lat),
|
||||
lng: Number($scope.event.location.geo.long),
|
||||
message: $scope.event.location.name
|
||||
});
|
||||
$scope.center= {
|
||||
lat: (Number($scope.travel.from.lat)+Number($scope.travel.to.lat))/2,
|
||||
lng: (Number($scope.travel.from.long)+Number($scope.travel.to.long))/2,
|
||||
zoom: 4
|
||||
};
|
||||
}
|
||||
|
||||
}, function(data){
|
||||
console.log('data error');
|
||||
$scope.$broadcast('scroll.refreshComplete');//refresher stop
|
||||
$ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 });
|
||||
|
||||
});
|
||||
};
|
||||
$scope.doRefresh();
|
||||
|
||||
});
|
||||
27
www/js/events.js
Normal file
27
www/js/events.js
Normal file
@@ -0,0 +1,27 @@
|
||||
angular.module('app.events', ['pascalprecht.translate'])
|
||||
|
||||
.controller('EventsCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter) {
|
||||
|
||||
|
||||
$scope.events=[];
|
||||
$scope.page=0;
|
||||
$scope.doRefresh = function() {
|
||||
/* events refresh: */
|
||||
$http.get(urlapi + 'events?page=' + $scope.page)
|
||||
.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
|
||||
|
||||
}, function(data){
|
||||
console.log('data error');
|
||||
$scope.$broadcast('scroll.refreshComplete');//refresher stop
|
||||
$ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 });
|
||||
|
||||
});
|
||||
};
|
||||
$scope.doRefresh();
|
||||
|
||||
});
|
||||
15
www/js/menu.js
Normal file
15
www/js/menu.js
Normal file
@@ -0,0 +1,15 @@
|
||||
angular.module('app.menu', ['pascalprecht.translate'])
|
||||
|
||||
|
||||
.controller('MenuCtrl', function($scope, $window) {
|
||||
if (localStorage.getItem("events_app_userdata")) {
|
||||
$scope.storageuser = JSON.parse(localStorage.getItem("events_app_userdata"));
|
||||
console.log($scope.storageuser);
|
||||
}
|
||||
|
||||
$scope.logout = function() {
|
||||
localStorage.removeItem("events_app_token");
|
||||
localStorage.removeItem("events_app_userdata");
|
||||
$window.location.reload(true);
|
||||
};
|
||||
});
|
||||
7
www/js/translations.js
Normal file
7
www/js/translations.js
Normal file
@@ -0,0 +1,7 @@
|
||||
var translations = {
|
||||
"english": {
|
||||
"Actual_language": "Actual language: ",
|
||||
"Menu": "Menu",
|
||||
"Signup": "Signup"
|
||||
}
|
||||
};
|
||||
54
www/js/user.js
Normal file
54
www/js/user.js
Normal file
@@ -0,0 +1,54 @@
|
||||
angular.module('app.user', ['pascalprecht.translate', 'ui-leaflet'])
|
||||
|
||||
.controller('UserCtrl', function($scope, $http, $ionicModal,
|
||||
$stateParams, $timeout, $ionicLoading, $filter,
|
||||
leafletData, leafletBoundsHelpers) {
|
||||
|
||||
$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.user={};
|
||||
$scope.doRefresh = function() {
|
||||
/* events refresh: */
|
||||
$http.get(urlapi + 'users/id/'+ $stateParams.userid)
|
||||
.then(function(data){
|
||||
console.log('data success events');
|
||||
console.log(data); // for browser console
|
||||
//$scope.events = data.data; // for UI
|
||||
$scope.user=data.data;
|
||||
$scope.$broadcast('scroll.refreshComplete');//refresher stop
|
||||
if($scope.user.location)
|
||||
{
|
||||
$scope.markers=[];
|
||||
$scope.markers.push({
|
||||
lat: Number($scope.user.location.geo.lat),
|
||||
lng: Number($scope.user.location.geo.long),
|
||||
message: $scope.user.location.name
|
||||
});
|
||||
$scope.center= {
|
||||
lat: Number($scope.user.location.geo.lat),
|
||||
lng: Number($scope.user.location.geo.long),
|
||||
zoom: 16
|
||||
};
|
||||
}
|
||||
|
||||
}, function(data){
|
||||
console.log('data error');
|
||||
$scope.$broadcast('scroll.refreshComplete');//refresher stop
|
||||
$ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 });
|
||||
|
||||
});
|
||||
};
|
||||
$scope.doRefresh();
|
||||
|
||||
});
|
||||
27
www/js/users.js
Normal file
27
www/js/users.js
Normal file
@@ -0,0 +1,27 @@
|
||||
angular.module('app.users', ['pascalprecht.translate'])
|
||||
|
||||
.controller('UsersCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter) {
|
||||
|
||||
|
||||
$scope.users=[];
|
||||
$scope.page=0;
|
||||
$scope.doRefresh = function() {
|
||||
/* users refresh: */
|
||||
$http.get(urlapi + 'users?page=' + $scope.page)
|
||||
.then(function(data){
|
||||
console.log('data success users');
|
||||
console.log(data); // for browser console
|
||||
//$scope.users = data.data; // for UI
|
||||
$scope.users=data.data;
|
||||
$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();
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user