From 5332f6d0db0f7cf1c98e7f34532eb4610c0068fb Mon Sep 17 00:00:00 2001 From: arnaucode Date: Thu, 26 Jan 2017 17:42:49 +0100 Subject: [PATCH] mdl css added, remaking everything --- www/index.html | 3 + www/js/app.js | 2 +- www/js/travel.js | 37 +++--- www/js/travels.js | 223 +----------------------------------- www/js/user.js | 14 +-- www/js/users.js | 22 +--- www/templates/menu.html | 3 +- www/templates/offerCar.html | 2 +- www/templates/signup.html | 10 +- www/templates/travel.html | 111 +++++++++--------- 10 files changed, 95 insertions(+), 332 deletions(-) diff --git a/www/index.html b/www/index.html index 9df15be..3b54eac 100644 --- a/www/index.html +++ b/www/index.html @@ -11,6 +11,9 @@ + + + diff --git a/www/js/app.js b/www/js/app.js index d930588..6804747 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -94,7 +94,7 @@ angular.module('starter', [ }) .state('app.travel', { - url: '/travels/:travelId', + url: '/travels/:travelid', views: { 'menuContent': { templateUrl: 'templates/travel.html', diff --git a/www/js/travel.js b/www/js/travel.js index 856fe8f..478c28b 100644 --- a/www/js/travel.js +++ b/www/js/travel.js @@ -1,25 +1,25 @@ angular.module('app.travel', ['pascalprecht.translate']) .controller('TravelCtrl', function($scope, $stateParams, $http, $ionicModal, $ionicPopup, $filter) { - if(localStorage.getItem('c_token')){// adding token to the headers - $http.defaults.headers.common['X-Access-Token'] = localStorage.getItem('c_token'); - } - $scope.storageusername=localStorage.getItem("c_username"); - console.log($stateParams.travelId); - $scope.travels= JSON.parse(localStorage.getItem('c_travels')); - $scope.travel = $filter('filter')($scope.travels, $stateParams.travelId, true)[0]; - - /*$http.get(urlapi + 'travels/comment/'+$stateParams.travelId) - .success(function(data, status, headers,config){ + + $scope.travel={}; + $scope.doRefresh = function() { + /* travels refresh: */ + $http.get(urlapi + 'travels/id/' + $stateParams.travelid) + .then(function(data){ + console.log('data success travels'); console.log(data); // for browser console - $scope.comments = data; // for UI - }) - .error(function(data, status, headers,config){ + $scope.travel = data.data; // for UI + $scope.$broadcast('scroll.refreshComplete');//refresher stop + + }, function(data){ console.log('data error'); - }) - .then(function(result){ - comments = result.data; - });*/ + $scope.$broadcast('scroll.refreshComplete');//refresher stop + $ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 }); + + }); + }; + $scope.doRefresh(); $scope.deleteTravel = function(){ @@ -147,9 +147,6 @@ console.log($scope.newComment); }); $scope.closeNewComment(); }; - console.log("a"); - console.log($scope.storageusername); - console.log($scope.travel.owner); $scope.arrayObjectIndexOf = function(myArray, searchTerm, property) { diff --git a/www/js/travels.js b/www/js/travels.js index 512c90a..afe70d9 100644 --- a/www/js/travels.js +++ b/www/js/travels.js @@ -3,236 +3,23 @@ angular.module('app.travels', ['pascalprecht.translate']) .controller('TravelsCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter) { - + $scope.travels=[]; $scope.doRefresh = function() { /* travels refresh: */ $http.get(urlapi + 'travels') - .success(function(data, status, headers,config){ + .then(function(data){ console.log('data success travels'); console.log(data); // for browser console - $scope.travels = data; // for UI - localStorage.setItem('c_travels', JSON.stringify($scope.travels)); - localStorage.setItem('c_travelsLastDate', JSON.stringify(new Date())); + $scope.travels = data.data; // for UI $scope.$broadcast('scroll.refreshComplete');//refresher stop - }) - .error(function(data, status, headers,config){ + }, function(data){ console.log('data error'); $scope.$broadcast('scroll.refreshComplete');//refresher stop $ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 }); - }) - .then(function(result){ - travels = result.data; - $ionicLoading.show({ template: 'Travels actualized from server!', noBackdrop: true, duration: 2000 }); - }); - - /* users refresh: */ - $http.get(urlapi + 'users') - .success(function(data, status, headers, config){ - console.log('data success users'); - console.log(data); // for browser console - $scope.users = data; // for UI - localStorage.setItem('c_users', JSON.stringify($scope.users)); - $scope.$broadcast('scroll.refreshComplete');//refresher stop - - //set userdata - $scope.userdata = $filter('filter')($scope.users, {username: $scope.storageusername}, true)[0]; - console.log("userdata"); - console.log($scope.userdata); - localStorage.setItem("c_userdata", JSON.stringify($scope.userdata)); - }) - .error(function(data, status, headers,config){ - console.log('data error'); - $scope.$broadcast('scroll.refreshComplete');//refresher stop - }) - .then(function(result){ - users = result.data; }); }; - $scope.newtravel={}; - /*$scope.newtravel={ - title: "prova", - from: "prova", - to: "prova", - seats: 3, - package: true, - phone: 123, - telegram: "telusr", - description: "this is the description of prova" - };*/ - - // Create the login modal that we will use later - $ionicModal.fromTemplateUrl('templates/newofferingtravel.html', { - scope: $scope - }).then(function(modal) { - $scope.modalOffering = modal; - }); - - // Create the login modal that we will use later - $ionicModal.fromTemplateUrl('templates/newaskingtravel.html', { - scope: $scope - }).then(function(modal) { - $scope.modalAsking = modal; - }); - - $ionicModal.fromTemplateUrl('templates/newaskingpackage.html', { - scope: $scope - }).then(function(modal) { - $scope.modalPackage = modal; - }); - - // Triggered in the login modal to close it - $scope.closeNewOfferingTravel = function() { - $scope.modalOffering.hide(); - }; - // Triggered in the login modal to close it - $scope.closeNewAskingTravel = function() { - $scope.modalAsking.hide(); - }; - $scope.closeNewAskingPackage = function() { - $scope.modalPackage.hide(); - }; - - // Open the login modal - $scope.showNewOfferingTravel = function() { - $scope.modalOffering.show(); - }; - // Open the login modal - $scope.showNewAskingTravel = function() { - $scope.modalAsking.show(); - }; - $scope.showNewAskingPackage = function() { - $scope.modalPackage.show(); - }; - - // Perform the login action when the user submits the login form - $scope.doNewOfferingTravel = function() { - console.log('Doing new travel', $scope.newtravel); - $scope.newtravel.icon="lorry"; - $scope.newtravel.generateddate=$scope.newtravel.date; - /*$scope.newtravel.owner=localStorage.getItem("c_username"); - $scope.newtravel.telegram=JSON.parse(localStorage.getItem("c_userdata")).telegram; - $scope.newtravel.phone=JSON.parse(localStorage.getItem("c_userdata")).phone;*/ - $scope.newtravel.modality="offering"; - //$scope.newtravel.token=localStorage.getItem("c_token"); - console.log($scope.newtravel); - $http({ - url: urlapi + 'travels', - method: "POST", - data: $scope.newtravel - }) - .then(function(response) { - // success - console.log("response: "); - console.log(response); - //$scope.newtravel._id=response.data._id; - //$scope.travels.push($scope.newtravel); - $scope.travels=response.data; - localStorage.setItem('c_travels', JSON.stringify($scope.travels)); - localStorage.setItem('c_travelsLastDate', JSON.stringify(new Date())); - $scope.newtravel={}; - if(response.data.success==false){ - - $ionicLoading.show({ template: 'failed to generate new travel', noBackdrop: true, duration: 2000 }); - } - }, - function(response) { // optional - // failed - $ionicLoading.show({ template: 'failed to generate new publication, all input fields needed', noBackdrop: true, duration: 2000 }); - }); - - // Simulate a login delay. Remove this and replace with your login - // code if using a login system - $timeout(function() { - $scope.closeNewOfferingTravel(); - }, 1000); - }; - - $scope.doNewAskingTravel = function() { - console.log('Doing new travel', $scope.newtravel); - $scope.newtravel.icon="lorry"; - $scope.newtravel.generateddate=$scope.newtravel.date; - /*$scope.newtravel.owner=localStorage.getItem("c_username"); - $scope.newtravel.telegram=JSON.parse(localStorage.getItem("c_userdata")).telegram; - $scope.newtravel.phone=JSON.parse(localStorage.getItem("c_userdata")).phone;*/ - - $scope.newtravel.modality="asking"; - console.log($scope.newtravel); - $http({ - url: urlapi + 'travels', - method: "POST", - data: $scope.newtravel - }) - .then(function(response) { - // success - console.log("response: "); - console.log(response); - //$scope.newtravel._id=response.data._id; - //$scope.travels.push($scope.newtravel); - $scope.travels=response.data; - localStorage.setItem('c_travels', JSON.stringify($scope.travels)); - localStorage.setItem('c_travelsLastDate', JSON.stringify(new Date())); - $scope.newtravel={}; - if(response.data.success==false){ - - $ionicLoading.show({ template: 'failed to generate new asking travel', noBackdrop: true, duration: 2000 }); - } - }, - function(response) { // optional - // failed - $ionicLoading.show({ template: 'failed to generate new publication, all input fields needed', noBackdrop: true, duration: 2000 }); - }); - - // Simulate a login delay. Remove this and replace with your login - // code if using a login system - $timeout(function() { - $scope.closeNewAskingTravel(); - }, 1000); - }; - - $scope.doNewAskingPackage = function() { - console.log('Doing new package', $scope.newtravel); - $scope.newtravel.icon="lorry"; - $scope.newtravel.generateddate=$scope.newtravel.date; - /*$scope.newtravel.owner=localStorage.getItem("c_username"); - $scope.newtravel.telegram=JSON.parse(localStorage.getItem("c_userdata")).telegram; - $scope.newtravel.phone=JSON.parse(localStorage.getItem("c_userdata")).phone;*/ - - $scope.newtravel.package=true; - - $scope.newtravel.modality="package"; - console.log($scope.newtravel); - $http({ - url: urlapi + 'travels', - method: "POST", - data: $scope.newtravel - }) - .then(function(response) { - // success - console.log("response: "); - console.log(response); - //$scope.newtravel._id=response.data._id; - //$scope.travels.push($scope.newtravel); - $scope.travels=response.data; - localStorage.setItem('c_travels', JSON.stringify($scope.travels)); - localStorage.setItem('c_travelsLastDate', JSON.stringify(new Date())); - $scope.newtravel={}; - if(response.data.success==false){ - - $ionicLoading.show({ template: 'failed to generate new asking package', noBackdrop: true, duration: 2000 }); - } - }, - function(response) { // optional - // failed - $ionicLoading.show({ template: 'failed to generate new publication, all input fields needed', noBackdrop: true, duration: 2000 }); - }); - - // Simulate a login delay. Remove this and replace with your login - // code if using a login system - $timeout(function() { - $scope.closeNewAskingPackage(); - }, 1000); - }; + $scope.doRefresh(); }); diff --git a/www/js/user.js b/www/js/user.js index ca8b608..e91ea63 100644 --- a/www/js/user.js +++ b/www/js/user.js @@ -4,18 +4,14 @@ angular.module('app.user', ['pascalprecht.translate']) $scope.user={}; - $http.get(urlapi + 'users/getByUserId/'+$stateParams.userid) - .success(function(data, status, headers,config){ + $http.get(urlapi + 'users/id/'+$stateParams.userid) + .then(function(data, status, headers,config){ console.log('data success'); console.log(data); // for browser console - $scope.user = data; // for UI - }) - .error(function(data, status, headers,config){ + $scope.user = data.data; // for UI + },function(data, status, headers,config){ console.log('data error'); - }) - .then(function(result){ - travels = result.data; - }); + }); diff --git a/www/js/users.js b/www/js/users.js index a1e1022..4995260 100644 --- a/www/js/users.js +++ b/www/js/users.js @@ -6,27 +6,6 @@ angular.module('app.users', ['pascalprecht.translate']) $scope.users=JSON.parse(localStorage.getItem('c_users')); $scope.doRefresh = function() { - /* travels refresh: */ - $http.get(urlapi + 'travels') - .success(function(data, status, headers,config){ - console.log('data success'); - console.log(data); // for browser console - $scope.travels = data; // for UI - localStorage.setItem('c_travels', JSON.stringify($scope.travels)); - localStorage.setItem('c_travelsLastDate', JSON.stringify(new Date())); - $scope.$broadcast('scroll.refreshComplete');//refresher stop - - }) - .error(function(data, status, headers,config){ - console.log('data error'); - $scope.$broadcast('scroll.refreshComplete');//refresher stop - $ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 }); - - }) - .then(function(result){ - travels = result.data; - $ionicLoading.show({ template: 'Travels actualized from server!', noBackdrop: true, duration: 2000 }); - }); /* users refresh: */ $http.get(urlapi + 'users') @@ -51,4 +30,5 @@ angular.module('app.users', ['pascalprecht.translate']) users = result.data; }); }; + $scope.doRefresh(); }); diff --git a/www/templates/menu.html b/www/templates/menu.html index 92ee752..2b80197 100644 --- a/www/templates/menu.html +++ b/www/templates/menu.html @@ -44,7 +44,8 @@ {{'Users' | translate }} - {{'Notifications' | translate }} + + {{'Notifications' | translate }} {{userdata.notifications.length}} diff --git a/www/templates/offerCar.html b/www/templates/offerCar.html index 910421d..93cd9c8 100644 --- a/www/templates/offerCar.html +++ b/www/templates/offerCar.html @@ -50,7 +50,7 @@

-

diff --git a/www/templates/signup.html b/www/templates/signup.html index 8151bfd..59e6b5e 100644 --- a/www/templates/signup.html +++ b/www/templates/signup.html @@ -29,16 +29,12 @@ - -

{{'Avatar' | translate }}*: {{signupData.avatar}}

+ diff --git a/www/templates/travel.html b/www/templates/travel.html index 07971c8..5c71ea0 100644 --- a/www/templates/travel.html +++ b/www/templates/travel.html @@ -1,21 +1,24 @@
- - -

{{travel.title}}

-
{{travel.date | date:"dd/MM HH:mm a"}}
+ +
+

+ + + {{travel.user.username}} + +

+

+ +

+
+

{{travel.title}}

+
{{travel.date | date:"dd/MM HH:mm a"}}
-

{{travel.description}}

+

{{travel.description}}

{{travel.from}} --> {{travel.to}}

@@ -23,11 +26,11 @@

- {{travel.phone}} + {{travel.user.phone}}

- @{{travel.telegram}} + @{{travel.user.telegram}}

@@ -37,65 +40,65 @@

-
{{'Can_carry_package' | translate}}
-
{{'Need_to_carry_package' | translate}}
+
{{'Can_carry_package' | translate}}
+
{{'Need_to_carry_package' | translate}}

-

-

{{'n_Seats' | translate}}: {{travel.seats}}
-
{{'n_People' | translate}}: {{travel.seats}}
-

+

+

{{'n_Seats' | translate}}: {{travel.seats}}
+
{{'n_People' | translate}}: {{travel.seats}}
+

-
+
-
- {{'Joined_users' | translate}}:
- - {{join.joinedUsername}}
-
+ {{'Joined_users' | translate}}:
+ + {{join.joinedUsername}}
+
-
- {{'Comments' | translate}}:
- -

{{comment.commentUsername}}

-

{{comment.comment}}

-
-
-
- {{'New_comment' | translate}} -
-
-