Browse Source

added travel edit, added link to web view of travels, fixed travel delete button

master
arnaucode 6 years ago
parent
commit
82351d42da
11 changed files with 206 additions and 15 deletions
  1. +8
    -0
      README.md
  2. +4
    -0
      comandesUtils.txt
  3. +9
    -9
      package-lock.json
  4. +4
    -4
      package.json
  5. BIN
      releases/commonroutes.apk
  6. +1
    -0
      www/index.html
  7. +10
    -1
      www/js/app.js
  8. +103
    -0
      www/js/editTravel.js
  9. +4
    -0
      www/js/travel.js
  10. +58
    -0
      www/templates/editTravel.html
  11. +5
    -1
      www/templates/travel.html

+ 8
- 0
README.md

@ -8,6 +8,14 @@
![commonroutes](https://raw.githubusercontent.com/arnaucode/commonroutesApp/master/commonroutes.png "commonroutes") ![commonroutes](https://raw.githubusercontent.com/arnaucode/commonroutesApp/master/commonroutes.png "commonroutes")
To check the hash of the current version:
```
> sha1sum commonroutes.apk
9e20ffa064b304a756badde207e347f8aa5117d7
```
## Build ## Build
Add cordova camera plugin Add cordova camera plugin

+ 4
- 0
comandesUtils.txt

@ -9,6 +9,10 @@ export ANDROID_HOME=/home/asus/Android/Sdk/
export PATH=$PATH:$ANDROID_HOME:/home/asus/Android/Sdk/tools export PATH=$PATH:$ANDROID_HOME:/home/asus/Android/Sdk/tools
export PATH=$PATH:$ANDROID_HOME/home/asus/Android/Sdk/platform-tools export PATH=$PATH:$ANDROID_HOME/home/asus/Android/Sdk/platform-tools
export ANDROID_HOME=/home/xiaomi/Android/Sdk/
export PATH=$PATH:$ANDROID_HOME:/home/xiaomi/Android/Sdk/tools
export PATH=$PATH:$ANDROID_HOME/home/xiaomi/Android/Sdk/platform-tools
#run android sdk manager tools: #run android sdk manager tools:
cd /home/nau/Android/Sdk/tools cd /home/nau/Android/Sdk/tools

+ 9
- 9
package-lock.json

@ -736,14 +736,14 @@
} }
}, },
"cordova-plugin-camera": { "cordova-plugin-camera": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/cordova-plugin-camera/-/cordova-plugin-camera-4.0.2.tgz",
"integrity": "sha1-MJQQkn70Ctxr69Sw6R3yyMZE84o="
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/cordova-plugin-camera/-/cordova-plugin-camera-4.0.3.tgz",
"integrity": "sha1-c3Olk4MYyGzP2E43E+I4LRD+B2s="
}, },
"cordova-plugin-console": { "cordova-plugin-console": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/cordova-plugin-console/-/cordova-plugin-console-1.0.7.tgz",
"integrity": "sha1-ibepLtHDNYiN/ADZAtxBcgHPOws="
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/cordova-plugin-console/-/cordova-plugin-console-1.1.0.tgz",
"integrity": "sha1-4vusECkBeeRMtyxf28QQpTHBzW0="
}, },
"cordova-plugin-device": { "cordova-plugin-device": {
"version": "1.1.7", "version": "1.1.7",
@ -756,9 +756,9 @@
"integrity": "sha1-pEj8vpdMprQpiL00VRCdkj1sl2k=" "integrity": "sha1-pEj8vpdMprQpiL00VRCdkj1sl2k="
}, },
"cordova-plugin-splashscreen": { "cordova-plugin-splashscreen": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/cordova-plugin-splashscreen/-/cordova-plugin-splashscreen-4.0.3.tgz",
"integrity": "sha1-dzzRNjwfO6y5kBZj6eN5PdPgoZ0="
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/cordova-plugin-splashscreen/-/cordova-plugin-splashscreen-4.1.0.tgz",
"integrity": "sha1-gQKKt2Q+YVWT0n8q0CRFYR8ZRrY="
}, },
"cordova-plugin-whitelist": { "cordova-plugin-whitelist": {
"version": "1.3.3", "version": "1.3.3",

+ 4
- 4
package.json

@ -4,11 +4,11 @@
"description": "app: commonroutes", "description": "app: commonroutes",
"dependencies": { "dependencies": {
"cordova-android": "7.0.0", "cordova-android": "7.0.0",
"cordova-plugin-camera": "^4.0.2",
"cordova-plugin-console": "^1.0.7",
"cordova-plugin-camera": "^4.0.3",
"cordova-plugin-console": "^1.1.0",
"cordova-plugin-device": "^1.1.7", "cordova-plugin-device": "^1.1.7",
"cordova-plugin-inappbrowser": "^2.0.2", "cordova-plugin-inappbrowser": "^2.0.2",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-splashscreen": "^4.1.0",
"cordova-plugin-whitelist": "^1.3.3", "cordova-plugin-whitelist": "^1.3.3",
"gulp": "^3.5.6", "gulp": "^3.5.6",
"gulp-concat": "^2.2.0", "gulp-concat": "^2.2.0",
@ -45,4 +45,4 @@
"android" "android"
] ]
} }
}
}

BIN
releases/commonroutes.apk


+ 1
- 0
www/index.html

@ -42,6 +42,7 @@
<script src="js/search.js"></script> <script src="js/search.js"></script>
<script src="js/travels.js"></script> <script src="js/travels.js"></script>
<script src="js/travel.js"></script> <script src="js/travel.js"></script>
<script src="js/editTravel.js"></script>
<script src="js/newTravel.js"></script> <script src="js/newTravel.js"></script>
<script src="js/offerCar.js"></script> <script src="js/offerCar.js"></script>
<script src="js/askForCar.js"></script> <script src="js/askForCar.js"></script>

+ 10
- 1
www/js/app.js

@ -23,6 +23,7 @@ angular.module('starter', [
'app.search', 'app.search',
'app.travels', 'app.travels',
'app.travel', 'app.travel',
'app.editTravel',
'app.newTravel', 'app.newTravel',
'app.offerCar', 'app.offerCar',
'app.askForCar', 'app.askForCar',
@ -120,7 +121,15 @@ angular.module('starter', [
} }
} }
}) })
.state('app.editTravel', {
url: '/editTravel/:travelid',
views: {
'menuContent': {
templateUrl: 'templates/editTravel.html',
controller: 'EditTravelCtrl'
}
}
})
.state('app.newTravel', { .state('app.newTravel', {
url: '/newTravel', url: '/newTravel',
views: { views: {

+ 103
- 0
www/js/editTravel.js

@ -0,0 +1,103 @@
angular.module('app.editTravel', ['pascalprecht.translate', 'ui-leaflet'])
.controller('EditTravelCtrl', function($scope, $stateParams, $translate,
$http, $filter, $ionicLoading) {
$scope.center = {};
$scope.bounds = {};
$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.travel={};
// get the travel
$http.get(urlapi + 'travels/id/' + $stateParams.travelid)
.then(function(data) {
console.log('data success travels');
console.log(data); // for browser console
$scope.travel = data.data; // for UI
$scope.travel.date = new Date($scope.travel.date);
$scope.markers = [];
$scope.markers.push({
lat: Number($scope.travel.from.lat),
lng: Number($scope.travel.from.long),
message: $scope.travel.from.name
});
$scope.markers.push({
lat: Number($scope.travel.to.lat),
lng: Number($scope.travel.to.long),
message: $scope.travel.to.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
};
$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.updateTravel =function(){
$http({
url: urlapi + 'travels/id/modify/' + $scope.travel._id,
method: "PUT",
data: $scope.travel
})
.then(function(data) {
console.log(data);
window.location="#app/travels/" + $scope.travel._id;
},
function(data) { // optional
// failed
console.log(data);
$ionicLoading.show({ template: 'Error updating travel. ' + data.data, noBackdrop: true, duration: 2000 });
});
};
$scope.getGeo = function(){
$scope.markers=[];
console.log($scope.travel.from.name);
console.log($scope.travel.to.name);
$http.get('https://nominatim.openstreetmap.org/search?q=' + $scope.travel.from.name + '&format=json&limit=1')
.then(function(data) {
console.log(data);
if(data.data[0])
{
$scope.travel.from.lat=data.data[0].lat;
$scope.travel.from.long=data.data[0].lon;
$scope.travel.from.name=data.data[0].display_name;
$scope.markers.push({
lat: Number(data.data[0].lat),
lng: Number(data.data[0].lon),
message: data.data[0].display_name
});
}
$http.get('https://nominatim.openstreetmap.org/search?q=' + $scope.travel.to.name + '&format=json&limit=1')
.then(function(data) {
if(data.data[0])
{
$scope.travel.to.lat=data.data[0].lat;
$scope.travel.to.long=data.data[0].lon;
$scope.travel.to.name=data.data[0].display_name;
$scope.markers.push({
lat: Number(data.data[0].lat),
lng: Number(data.data[0].lon),
message: data.data[0].display_name
});
}
});
});
};
});

+ 4
- 0
www/js/travel.js

@ -285,6 +285,10 @@ angular.module('app.travel', ['pascalprecht.translate', 'ui-leaflet'])
//console.log("i: -1"); //console.log("i: -1");
return -1; return -1;
}; };
$scope.openTravelLink = function(travelid) {
window.open('http://routes.fair.coop/app/#!/travel/' + travelid, '_system', 'location=yes');
return false;
};
$scope.openTelegram = function(telegramuser) { $scope.openTelegram = function(telegramuser) {
window.open('http://telegram.me/' + telegramuser, '_system', 'location=yes'); window.open('http://telegram.me/' + telegramuser, '_system', 'location=yes');
return false; return false;

+ 58
- 0
www/templates/editTravel.html

@ -0,0 +1,58 @@
<ion-view view-title="{{'Edit Travel' | translate}}">
<ion-content>
<div class="padding">
<label class="item item-input">
<span class="input-label">{{'Title' | translate}}</span>
<input type="text" ng-model="travel.title">
</label>
<div layout="row">
<label class="item item-input">
<span class="input-label">{{'From' | translate}}</span>
<input type="text" ng-model="travel.from.name">
</label>
<label class="item item-input">
<span class="input-label">{{'To' | translate}}</span>
<input type="text" ng-model="travel.to.name">
</label>
</div>
</div><!-- end of padding -->
<a ng-click="getGeo()" ng-show="travel.from.name && travel.to.name"
class="button o_purple300">{{'Get_positions' | translate}}</a>
<leaflet ng-show="markers[0]"
width="100%" height="40%" markers="markers" center="center"
tiles="tiles" id="map-simple-map"></leaflet>
<div class="padding" ng-show="markers[0]">
<label class="item item-input" ng-show="travel.seats">
<span class="input-label">{{'n_Seats' | translate}}</span>
<input ng-model="travel.seats" type="number">
</label>
<label class="item-input">
<span class="input-label">{{'Date' | translate}}</span>
<input ng-model="travel.date" type="date" placeholder="">
</label>
<label class="item-input">
<span class="input-label">{{'Hour' | translate}}</span>
<input ng-model="travel.date" type="time" placeholder="">
</label>
<ion-toggle ng-show="travel.package" ng-model="travel.package" toggle-class="toggle-calm">
<i class="icon ion-ios-box"></i>
{{'Can_carry_package' | translate}}
</ion-toggle>
<ion-toggle ng-show="travel.collectivized" ng-model="travel.collectivized" toggle-class="toggle-calm">
{{'Collectivized_car' | translate}}
</ion-toggle>
<label class="item item-input">
<span class="input-label">{{'Description' | translate}}</span>
<input type="text" ng-model="travel.description">
</label>
<p class="padding">
<a ng-click="updateTravel()" class="button o_purple400 o_floatRight">
{{'Update Travel' | translate}}
</a>
</p>
</div><!-- end of padding -->
</ion-content>
</ion-view>

+ 5
- 1
www/templates/travel.html

@ -13,9 +13,13 @@
<i ng-show="travel.user.validated" class="ion-checkmark-circled ct_blue300"></i> <i ng-show="travel.user.validated" class="ion-checkmark-circled ct_blue300"></i>
</a> </a>
<p class="text-right"> <p class="text-right">
<a target="_blank" ng-href="http://routes.fair.coop/app/#!/travel/{{travel._id}}" class="button button-small o_grey300">
<a target="_blank" ng-click="openTravelLink(travel._id)" class="button button-small o_grey300">
<i class="icon ion-share" style="margin-left:-14px;"></i> <i class="icon ion-share" style="margin-left:-14px;"></i>
</a> </a>
<a ng-href="#/app/editTravel/{{travel._id}}" class="button button-small o_grey600"
ng-show="storageuser._id==travel.user._id">
<i class="icon ion-edit" style="margin-left:-14px;"></i>
</a>
<a ng-click="deleteTravel()" class="button button-small o_bRed" <a ng-click="deleteTravel()" class="button button-small o_bRed"
ng-show="storageuser._id==travel.user._id"> ng-show="storageuser._id==travel.user._id">
<i class="icon ion-trash-a" style="margin-left:-14px;"></i> <i class="icon ion-trash-a" style="margin-left:-14px;"></i>

Loading…
Cancel
Save