implemented upload file image for new event

This commit is contained in:
arnaucode
2017-06-23 16:45:13 +02:00
parent baa74e1921
commit 82cceaff53
247 changed files with 51054 additions and 49 deletions

View File

@@ -1,5 +1,5 @@
//var urlapi = "http://localhost:3000/api/";
var urlapi = "http://192.168.1.33:3000/api/";
var urlapi = "http://192.168.1.35:3001/api/";

View File

@@ -1,59 +1,62 @@
angular.module('app.mapEvents', ['pascalprecht.translate', 'ui-leaflet'])
.controller('MapEventsCtrl', function($scope, $http, $ionicModal,
$timeout, $ionicLoading, $filter,
leafletBoundsHelpers, $cordovaSocialSharing) {
.controller('MapEventsCtrl', function($scope, $http, $ionicModal,
$timeout, $ionicLoading, $filter,
leafletBoundsHelpers, $cordovaSocialSharing) {
//map
$scope.center= {
lat: 0,
lng: 0,
zoom: 1
$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.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;
$scope.events = [];
$scope.page = 0;
$http.get(urlapi + 'events')
.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.$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.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
};
}
$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){
}, function(data) {
console.log('data error');
$scope.$broadcast('scroll.refreshComplete');//refresher stop
$ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 });
$scope.$broadcast('scroll.refreshComplete'); //refresher stop
$ionicLoading.show({
template: 'Error connecting server',
noBackdrop: true,
duration: 2000
});
});
});
});
});

View File

@@ -1,7 +1,8 @@
angular.module('app.newEvent', ['pascalprecht.translate', 'ui-leaflet'])
.controller('NewEventCtrl', function($scope, $http, $ionicModal, $timeout,
$ionicLoading, $filter, leafletData, leafletBoundsHelpers) {
$ionicLoading, $filter, leafletData, leafletBoundsHelpers,
$cordovaCamera) {
//initialization
@@ -16,6 +17,30 @@ angular.module('app.newEvent', ['pascalprecht.translate', 'ui-leaflet'])
}
};
//imgfile
$scope.selectImgFile = function() {
console.log("img");
var options = {
quality: 100,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
allowEdit: true,
encodingType: Camera.EncodingType.PNG,
targetWidth: 500,
targetHeight: 500,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false,
correctOrientation: true
};
$cordovaCamera.getPicture(options).then(function(imageData) {
$scope.event.imgpreview = "data:image/jpeg;base64," + imageData;
$scope.event.img = imageData;
}, function(err) {
console.log(err);
});
};
//get list of categories
$scope.categories;
$http.get(urlapi + 'categoriesList')

View File

@@ -43,6 +43,7 @@
</a>
</div>
</div>-->
<div ng-hide="followingUsers[0]">No following users, select users to follow to see the events</div>
<div ng-include="'templates/templateEvents.html'"></div>
</ion-content>
</ion-view>

View File

@@ -48,7 +48,7 @@
<a class="item item-icon-left" menu-close href="#/app/settings">
<i class="icon ion-ios-gear"></i> Settings
</a>
<a class="item item-icon-left" menu-close href="#/app/userZone">
<a ng-show="storageuser" class="item item-icon-left" menu-close href="#/app/userZone">
<i class="icon ion-compose"></i> User zone
</a>
<a class="item item-icon-left" menu-close href="#/app/login"

View File

@@ -15,9 +15,11 @@
<span class="input-label">{{'Hour' | translate}}</span>
<input ng-model="event.date" type="time" placeholder="">
</label>
<label class="item item-input">
<!--<label class="item item-input">
<input type="text" ng-model="event.img" placeholder="img">
</label>
</label>-->
<div ng-hide="event.imgpreview" class="button" ng-click="selectImgFile()">Select image</div>
<img ng-src="{{event.imgpreview}}" ng-click="selectImgFile()"/>
<ion-list>
Categories:
<ion-checkbox ng-model="category.selected" ng-repeat="category in categories"