Browse Source

user historyon user profile added

pull/1/head
nau 8 years ago
parent
commit
f761f64b6c
9 changed files with 70 additions and 31 deletions
  1. +32
    -12
      app/www/js/controllers.js
  2. +1
    -1
      app/www/templates/newaskingtravel.html
  3. +1
    -1
      app/www/templates/newofferingtravel.html
  4. +5
    -1
      app/www/templates/travel.html
  5. +5
    -4
      app/www/templates/travels.html
  6. +24
    -4
      app/www/templates/user.html
  7. +0
    -6
      app/www/templates/users.html
  8. +1
    -1
      server/controllers/travelController.js
  9. +1
    -1
      server/server.js

+ 32
- 12
app/www/js/controllers.js

@ -1,7 +1,13 @@
//var urlapi="http://localhost:3000/api/";
var urlapi="http://192.168.1.40:3000/api/";
localStorage.setItem("c_username", "user2");
localStorage.setItem("c_token", "");
angular.module('starter.controllers', []) angular.module('starter.controllers', [])
.controller('AppCtrl', function($scope, $ionicModal, $timeout) { .controller('AppCtrl', function($scope, $ionicModal, $timeout) {
// With the new view caching in Ionic, Controllers are only called // With the new view caching in Ionic, Controllers are only called
// when they are recreated or on app start, instead of every page change. // when they are recreated or on app start, instead of every page change.
// To listen for when this page is active (for example, to refresh data), // To listen for when this page is active (for example, to refresh data),
@ -48,7 +54,7 @@ angular.module('starter.controllers', [])
$scope.travels=JSON.parse(localStorage.getItem('c_travels')); $scope.travels=JSON.parse(localStorage.getItem('c_travels'));
$scope.doRefresh = function() { $scope.doRefresh = function() {
$http.get('http://localhost:3000/api/travels')
$http.get(urlapi + 'travels')
.success(function(data, status, headers,config){ .success(function(data, status, headers,config){
console.log('data success'); console.log('data success');
console.log(data); // for browser console console.log(data); // for browser console
@ -116,12 +122,12 @@ angular.module('starter.controllers', [])
console.log('Doing new travel', $scope.newtravel); console.log('Doing new travel', $scope.newtravel);
$scope.newtravel.icon="lorry"; $scope.newtravel.icon="lorry";
$scope.newtravel.generateddate=$scope.newtravel.date; $scope.newtravel.generateddate=$scope.newtravel.date;
$scope.newtravel.owner="user";
$scope.newtravel.owner=localStorage.getItem("c_username");
$scope.newtravel.modality="offering"; $scope.newtravel.modality="offering";
console.log($scope.newtravel); console.log($scope.newtravel);
$http({ $http({
url: 'http://localhost:3000/api/travels',
url: urlapi + 'travels',
method: "POST", method: "POST",
data: $scope.newtravel data: $scope.newtravel
}) })
@ -148,12 +154,12 @@ angular.module('starter.controllers', [])
console.log('Doing new travel', $scope.newtravel); console.log('Doing new travel', $scope.newtravel);
$scope.newtravel.icon="lorry"; $scope.newtravel.icon="lorry";
$scope.newtravel.generateddate=$scope.newtravel.date; $scope.newtravel.generateddate=$scope.newtravel.date;
$scope.newtravel.owner="user";
$scope.newtravel.owner=localStorage.getItem("c_username");
$scope.newtravel.modality="asking"; $scope.newtravel.modality="asking";
console.log($scope.newtravel); console.log($scope.newtravel);
$http({ $http({
url: 'http://localhost:3000/api/travels',
url: urlapi + 'travels',
method: "POST", method: "POST",
data: $scope.newtravel data: $scope.newtravel
}) })
@ -179,13 +185,13 @@ angular.module('starter.controllers', [])
console.log('Doing new package', $scope.newtravel); console.log('Doing new package', $scope.newtravel);
$scope.newtravel.icon="lorry"; $scope.newtravel.icon="lorry";
$scope.newtravel.generateddate=$scope.newtravel.date; $scope.newtravel.generateddate=$scope.newtravel.date;
$scope.newtravel.owner="user";
$scope.newtravel.owner=localStorage.getItem("c_username");
$scope.newtravel.package=true; $scope.newtravel.package=true;
$scope.newtravel.modality="package"; $scope.newtravel.modality="package";
console.log($scope.newtravel); console.log($scope.newtravel);
$http({ $http({
url: 'http://localhost:3000/api/travels',
url: urlapi + 'travels',
method: "POST", method: "POST",
data: $scope.newtravel data: $scope.newtravel
}) })
@ -209,9 +215,10 @@ angular.module('starter.controllers', [])
}) })
.controller('TravelCtrl', function($scope, $stateParams, $http) { .controller('TravelCtrl', function($scope, $stateParams, $http) {
$scope.storageusername=localStorage.getItem("c_username");
$scope.travel=""; $scope.travel="";
console.log($stateParams.travelId); console.log($stateParams.travelId);
$http.get('http://localhost:3000/api/travels/'+$stateParams.travelId)
$http.get(urlapi + 'travels/'+$stateParams.travelId)
.success(function(data, status, headers,config){ .success(function(data, status, headers,config){
console.log('data success'); console.log('data success');
console.log(data); // for browser console console.log(data); // for browser console
@ -231,7 +238,7 @@ angular.module('starter.controllers', [])
$scope.users=JSON.parse(localStorage.getItem('c_users')); $scope.users=JSON.parse(localStorage.getItem('c_users'));
$scope.doRefresh = function() { $scope.doRefresh = function() {
$http.get('http://localhost:3000/api/users')
$http.get(urlapi + 'users')
.success(function(data, status, headers, config){ .success(function(data, status, headers, config){
console.log('data success'); console.log('data success');
console.log(data); // for browser console console.log(data); // for browser console
@ -250,9 +257,9 @@ angular.module('starter.controllers', [])
}) })
.controller('UserCtrl', function($scope, $stateParams, $http) { .controller('UserCtrl', function($scope, $stateParams, $http) {
$scope.travel="";
//$scope.user="";
console.log($stateParams.username); console.log($stateParams.username);
$http.get('http://localhost:3000/api/users/byusername/'+$stateParams.username)
$http.get(urlapi + 'users/byusername/'+$stateParams.username)
.success(function(data, status, headers,config){ .success(function(data, status, headers,config){
console.log('data success'); console.log('data success');
console.log(data); // for browser console console.log(data); // for browser console
@ -261,6 +268,19 @@ angular.module('starter.controllers', [])
.error(function(data, status, headers,config){ .error(function(data, status, headers,config){
console.log('data error'); console.log('data error');
}) })
.then(function(result){
user = result.data;
});
$http.get(urlapi + 'travels/user/'+$stateParams.username)
.success(function(data, status, headers,config){
console.log('data success');
console.log(data); // for browser console
$scope.travels = data; // for UI
})
.error(function(data, status, headers,config){
console.log('data error');
})
.then(function(result){ .then(function(result){
travels = result.data; travels = result.data;
}); });

+ 1
- 1
app/www/templates/newaskingtravel.html

@ -2,7 +2,7 @@
<ion-content> <ion-content>
<h4> <h4>
<img class='o-imgTitle' src="img/road.png" />
<img class='o-imgTitle' src="img/asking.png" />
New Asking Travel {{newtravel.title}} New Asking Travel {{newtravel.title}}
</h4> </h4>
<form class="list"> <form class="list">

+ 1
- 1
app/www/templates/newofferingtravel.html

@ -2,7 +2,7 @@
<ion-content> <ion-content>
<h4> <h4>
<img class='o-imgTitle' src="img/road.png" />
<img class='o-imgTitle' src="img/offering.png" />
New Travel {{newtravel.title}} New Travel {{newtravel.title}}
</h4> </h4>
<form class="list"> <form class="list">

+ 5
- 1
app/www/templates/travel.html

@ -32,9 +32,13 @@
<img class='o-imgMenu' src="img/telegram.png" /> {{travel.telegram}} <img class='o-imgMenu' src="img/telegram.png" /> {{travel.telegram}}
</p> </p>
<p class='text-right'>
<p class='text-right' ng-show="storageusername!==travel.owner">
<a ng-show="travel.modality=='offering'" href="#" class="button button-calm o-pull-right">Ask to join</a> <a ng-show="travel.modality=='offering'" href="#" class="button button-calm o-pull-right">Ask to join</a>
<a ng-show="travel.modality=='asking'" href="#" class="button button-calm o-pull-right">Offer car</a> <a ng-show="travel.modality=='asking'" href="#" class="button button-calm o-pull-right">Offer car</a>
<a ng-show="travel.modality=='package'" href="#" class="button button-calm o-pull-right">Offer car</a>
</p>
<p ng-show="storageusername==travel.owner" class="text-right">
<a href="#" class="button button-assertive o-pull-right">Delete</a>
</p> </p>
</div> </div>
</ion-content> </ion-content>

+ 5
- 4
app/www/templates/travels.html

@ -14,15 +14,16 @@
<a ng-repeat="travel in travels | orderBy: 'date'" class="item item-avatar" href="#/app/travels/{{travel._id}}"> <a ng-repeat="travel in travels | orderBy: 'date'" class="item item-avatar" href="#/app/travels/{{travel._id}}">
<img ng-src="img/{{travel.modality}}.png"> <img ng-src="img/{{travel.modality}}.png">
<h2>{{travel.title}}</h2> <h2>{{travel.title}}</h2>
<div class="item-note">
<div class="positive">{{travel.date | date:"dd/MM HH:mm a"}}</div>
<div class="badge badge-calm">{{travel.owner}}</div>
</div>
<p> <p>
{{travel.description}} {{travel.description}}
</p> </p>
<p class="" ng-show="travel.modality=='offering'">nºseats: {{travel.seats}}</p> <p class="" ng-show="travel.modality=='offering'">nºseats: {{travel.seats}}</p>
<p class="" ng-show="travel.modality=='asking'">nºpeople: {{travel.seats}}</p> <p class="" ng-show="travel.modality=='asking'">nºpeople: {{travel.seats}}</p>
<div class="item-note">
<div class="positive">{{travel.date | date:"dd/MM HH:mm a"}}</div>
<div class="badge badge-calm">{{travel.owner}}</div>
</div>
</a> </a>
</div> </div>
</ion-content> </ion-content>

+ 24
- 4
app/www/templates/user.html

@ -1,10 +1,7 @@
<ion-view view-title="User">
<ion-view view-title="User {{user.username}}">
<ion-content> <ion-content>
<div class="item item-avatar"> <div class="item item-avatar">
<img ng-src="img/avatars/{{user.avatar}}.png" /> <img ng-src="img/avatars/{{user.avatar}}.png" />
<div class="item-note o-text-right">
<a class="badge badge-calm" href="#/app/users/{{travel.owner}}">{{user.owner}}</a>
</div>
<h2>{{user.username}}</h2> <h2>{{user.username}}</h2>
</div> </div>
<div class="item item-body"> <div class="item item-body">
@ -14,5 +11,28 @@
<img class='o-imgMenu' src="img/telegram.png" /> {{user.telegram}} <img class='o-imgMenu' src="img/telegram.png" /> {{user.telegram}}
</p> </p>
</div> </div>
<div class="item item-body">
history of {{user.username}}:
<div class="positive">{{travels.length}} publications</div>
<a ng-repeat="travel in travels | orderBy: 'date'" class="item item-avatar" href="#/app/travels/{{travel._id}}">
<img ng-src="img/{{travel.modality}}.png">
<h2>{{travel.title}}
<div class="item-note">
<div class="positive">{{travel.date | date:"dd/MM HH:mm a"}}</div>
</div>
</h2>
<div class="item-note">
<p class="" ng-show="travel.modality=='offering'">nºseats: {{travel.seats}}</p>
<p class="" ng-show="travel.modality=='asking'">nºpeople: {{travel.seats}}</p>
</div>
<p>
{{travel.description}}
</p>
</a>
</div>
</ion-content> </ion-content>
</ion-view> </ion-view>

+ 0
- 6
app/www/templates/users.html

@ -5,12 +5,6 @@
on-refresh="doRefresh()"> on-refresh="doRefresh()">
</ion-refresher> </ion-refresher>
<div class="list"> <div class="list">
<div class="o-float-right">
<a ng-click="showNewAskingTravel()" class="button icon ion-email"></a>
<a ng-click="showNewAskingTravel()" class="button icon ion-help"></a>
<a ng-click="showNewOfferingTravel()" class="button icon ion-plus"></a>
</div>
<a ng-repeat="user in users | orderBy: 'date'" class="item item-avatar" href="#/app/users/{{user.username}}"> <a ng-repeat="user in users | orderBy: 'date'" class="item item-avatar" href="#/app/users/{{user.username}}">
<img ng-src="img/avatars/{{user.avatar}}.png"> <img ng-src="img/avatars/{{user.avatar}}.png">
<h2>{{user.username}}</h2> <h2>{{user.username}}</h2>

+ 1
- 1
server/controllers/travelController.js

@ -28,7 +28,7 @@ exports.findById = function(req, res) {
exports.findAllTravelsFromUsername = function(req, res) { exports.findAllTravelsFromUsername = function(req, res) {
travelModel.find({ travelModel.find({
_id: req.params.userid
owner: req.params.username
}, function(err, travels) { }, function(err, travels) {
if (err) throw err; if (err) throw err;

+ 1
- 1
server/server.js

@ -59,7 +59,7 @@ apiRoutes.route('/users/:id')
.get(userCtrl.findById); .get(userCtrl.findById);
apiRoutes.route('/users/byusername/:username') apiRoutes.route('/users/byusername/:username')
.get(userCtrl.findUserByUsername); .get(userCtrl.findUserByUsername);
apiRoutes.route('/travels/user/:userid')
apiRoutes.route('/travels/user/:username')
.get(travelCtrl.findAllTravelsFromUsername); .get(travelCtrl.findAllTravelsFromUsername);
apiRoutes.route('/auth') apiRoutes.route('/auth')

Loading…
Cancel
Save