From 6559dc163be94327e1fee6c825a0d588b44d0e54 Mon Sep 17 00:00:00 2001 From: idoctnef Date: Thu, 6 Oct 2016 21:42:37 +0200 Subject: [PATCH] telegram and phone on new travel, added from data storage, no input --- www/js/controllers.js | 56 +++++++++++++++++++++++++++- www/templates/help.html | 4 +- www/templates/newaskingpackage.html | 4 +- www/templates/newaskingtravel.html | 4 +- www/templates/newofferingtravel.html | 4 +- 5 files changed, 63 insertions(+), 9 deletions(-) diff --git a/www/js/controllers.js b/www/js/controllers.js index 972591a..f4572bf 100644 --- a/www/js/controllers.js +++ b/www/js/controllers.js @@ -71,6 +71,8 @@ angular.module('starter.controllers', ['pascalprecht.translate']) localStorage.setItem("c_token", response.data.token); localStorage.setItem("c_userid", response.data.userid); localStorage.setItem("c_avatar", response.data.avatar); + + localStorage.setItem("c_userdata", JSON.stringify(response.data.userdata)); }else{ console.log("login failed"); } @@ -172,6 +174,7 @@ angular.module('starter.controllers', ['pascalprecht.translate']) localStorage.removeItem("c_token"); localStorage.removeItem("c_avatar"); localStorage.removeItem("c_userid"); + localStorage.removeItem("c_userdata"); $window.location.reload(true); }; }) @@ -192,8 +195,11 @@ angular.module('starter.controllers', ['pascalprecht.translate']) $scope.travels=""; $scope.travels=JSON.parse(localStorage.getItem('c_travels')); + $scope.userdata=JSON.parse(localStorage.getItem('c_userdata')); + console.log($scope.userdata); $scope.doRefresh = function() { + /* travels refresh: */ $http.get(urlapi + 'travels') .success(function(data, status, headers,config){ console.log('data success'); @@ -214,6 +220,23 @@ angular.module('starter.controllers', ['pascalprecht.translate']) 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'); + 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 + }) + .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={ @@ -277,7 +300,8 @@ angular.module('starter.controllers', ['pascalprecht.translate']) $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); @@ -317,6 +341,8 @@ angular.module('starter.controllers', ['pascalprecht.translate']) $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); @@ -356,6 +382,9 @@ angular.module('starter.controllers', ['pascalprecht.translate']) $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"; @@ -556,12 +585,35 @@ console.log($scope.newComment); } }) -.controller('UsersCtrl', function($scope, $http, $ionicModal, $timeout) { +.controller('UsersCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading) { $scope.users=""; $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') .success(function(data, status, headers, config){ console.log('data success'); diff --git a/www/templates/help.html b/www/templates/help.html index 28895f0..8f720b6 100644 --- a/www/templates/help.html +++ b/www/templates/help.html @@ -1,7 +1,9 @@

{{'Help' | translate}}

- +

+ help instructions here +

diff --git a/www/templates/newaskingpackage.html b/www/templates/newaskingpackage.html index 9293c5e..e1242fe 100644 --- a/www/templates/newaskingpackage.html +++ b/www/templates/newaskingpackage.html @@ -29,14 +29,14 @@ {{'Hour' | translate}} -