From 17f0f740d800a8fd38582a2564813911de597002 Mon Sep 17 00:00:00 2001 From: arnaucode Date: Thu, 26 Jan 2017 14:13:32 +0100 Subject: [PATCH] post new offering travel, and user page --- www/css/style.css | 133 ++++++++++++++++++++++++------------ www/js/app.js | 31 ++++++++- www/js/footerMenu.js | 3 +- www/js/login.js | 2 +- www/js/menu.js | 7 +- www/js/offerCar.js | 20 +++++- www/js/signup.js | 4 +- www/js/user.js | 26 ++----- www/templates/main.html | 8 +-- www/templates/menu.html | 28 ++++---- www/templates/offerCar.html | 9 +-- www/templates/signup.html | 2 +- www/templates/travels.html | 2 +- www/templates/user.html | 12 ++-- www/templates/users.html | 2 +- 15 files changed, 181 insertions(+), 108 deletions(-) diff --git a/www/css/style.css b/www/css/style.css index cef31f2..6fec15d 100644 --- a/www/css/style.css +++ b/www/css/style.css @@ -1,50 +1,95 @@ -/* Empty. Add your own CSS if you like */ -.o-imgMenu{ - width: 25px!important; - height: 25px!important; +.o_noPaddingMargin{ + padding: 0!important; + margin: 0!important; } -.o-imgTitle{ - width: 40px!important; - height: 40px!important; +.o_mainRow{ + height: calc(100%/4); } -.o-imgSelectAvatar{ - width: 45px!important; - height: 45px!important; +.o_floatRight{ + float: right; } -.o-bold{ - font-weight: bold!important; +/* + SISTEMA DE COLORS + + users: blue + routines: red + diets: yellow + + la nomenclatura és: + o_bColor + la 'o' és de 'own', per saber que és una classe pròpia nostra i que no colisioni amb les classes dels frameworks css + la 'b' és de background, si és una 'f' és de font + a part podem posar ColorDark o ColorLight per fer un color més fosc o més clar +*/ +.o_bSidenav{ + background: #333b42!important; + color: #c6ccd2!important; } -.o-float-right{ - float: right; +.o_fWhiteLight{ + color: #c6ccd2!important; +} +.o_bGrey{ + background: #e6e6e6!important; + color: #000000!important; +} +.o_bGreyLight{ + background: #CFD8DC!important; + color: #000000!important; +} +/* backgrounds color: bColor */ +.o_bRed{ + background: rgb(252,87,85)!important; + color: #ffffff!important; +} +.o_bRedLight{ + background: #E57373!important; + color: #ffffff!important; +} +.o_bRedDark{ + background: rgb(218, 89, 120)!important; + color: #ffffff!important; +} +.o_bGreen{ + background: rgb(123,195,70)!important; + color: #ffffff!important; +} +.o_bGreenLight{ + background: #81C784!important; + color: #ffffff!important; +} +.o_bGreenDark{ + background: rgb(54,188,155)!important; + color: #ffffff!important; +} +.o_bBlue{ + background: rgb(104,195,240)!important; + color: #ffffff!important; +} +.o_bBlueDark{ + background: rgb(72,118,180)!important; + color: #ffffff!important; +} +.o_bYellow{ + background: rgb(251,187,61)!important; + color: #ffffff!important; +} +.o_bYellowDark{ + background: #F9A825!important; + color: #ffffff!important; +} +.o_bOrange{ + background: rgb(251, 126, 61)!important; + color: #ffffff!important; +} +.o_bOrangeDark{ + background: #FF7043!important; + color: #ffffff!important; +} +.o_bPurple{ + background: #9575CD!important; + color: #ffffff!important; } -.o-text-right{ - text-align: right; -} -.o-mini-text{ - font-size: 12px; - display: inline-block; -} -.o-img-joined{ - width: 20px!important; - height: 20px!important; -} -.o-img-new{ - width: 30px!important; - height: 30px!important; -} -.o-badgeCollectivized{ - background: #33CD5F; - padding: 5px; - border-radius: 5px; - font-size: 12px; - color: #ffffff; - font-weight: bold; -} -.o-badge-calm{ - background: #11C1F3; - padding: 5px; - border-radius: 7px; - font-size: 12px; - color: #ffffff; - font-weight: bold; +.o_bPurpleDark{ + background: #512DA8!important; + color: #ffffff!important; } diff --git a/www/js/app.js b/www/js/app.js index 643eaea..d930588 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -131,7 +131,7 @@ angular.module('starter', [ } }) .state('app.user', { - url: '/users/:username', + url: '/users/:userid', views: { 'menuContent': { templateUrl: 'templates/user.html', @@ -201,4 +201,31 @@ angular.module('starter', [ $translateProvider.useSanitizeValueStrategy('escape'); - }]); + }]) + .factory('httpInterceptor', function httpInterceptor($q, $window, $location) { + return { + request: function (config) { + return config; + }, + requestError: function (config) { + return config; + }, + response: function (res) { + return res; + }, + responseError: function (res) { + return res; + } + } + }) + .factory('api', function ($http) { + return { + init: function () { + $http.defaults.headers.common['X-Access-Token'] = localStorage.getItem("cim_app_token"); + $http.defaults.headers.post['X-Access-Token'] = localStorage.getItem("cim_app_token"); + } + }; + }) + .run(function (api) { + api.init(); + }); diff --git a/www/js/footerMenu.js b/www/js/footerMenu.js index d5e2bbb..1da29a0 100644 --- a/www/js/footerMenu.js +++ b/www/js/footerMenu.js @@ -1,5 +1,6 @@ angular.module('app.footerMenu', ['pascalprecht.translate']) .controller('FooterMenuCtrl', function($scope, $stateParams, $translate, $filter) { - + $scope.storageuser = JSON.parse(localStorage.getItem("cim_app_userdata")); + console.log($scope.storageuser); }); diff --git a/www/js/login.js b/www/js/login.js index e582874..18bbbbf 100644 --- a/www/js/login.js +++ b/www/js/login.js @@ -9,7 +9,7 @@ angular.module('app.login', ['pascalprecht.translate']) console.log('Doing login', $scope.loginData); $http({ - url: urlapi + 'auth', + url: urlapi + 'login', method: "POST", data: $scope.loginData }) diff --git a/www/js/menu.js b/www/js/menu.js index b0077b9..bc0eab6 100644 --- a/www/js/menu.js +++ b/www/js/menu.js @@ -2,8 +2,11 @@ angular.module('app.menu', ['pascalprecht.translate']) .controller('MenuCtrl', function($scope) { - $scope.storageuser = JSON.parse(localStorage.getItem("cim_app_userdata")); - console.log($scope.storageuser); + if (localStorage.getItem("cim_app_userdata")) { + $scope.storageuser = JSON.parse(localStorage.getItem("cim_app_userdata")); + console.log($scope.storageuser); + } + $scope.logout = function() { localStorage.removeItem("cim_app_token"); localStorage.removeItem("cim_app_userdata"); diff --git a/www/js/offerCar.js b/www/js/offerCar.js index 4156324..6e16c9a 100644 --- a/www/js/offerCar.js +++ b/www/js/offerCar.js @@ -1,5 +1,23 @@ angular.module('app.offerCar', ['pascalprecht.translate']) -.controller('OfferCarCtrl', function($scope, $stateParams, $translate, $filter) { +.controller('OfferCarCtrl', function($scope, $stateParams, $translate, + $http, $filter) { + $scope.newtravel={}; + $scope.createTravel =function(){ + $scope.newtravel.type="offering"; + $http({ + url: urlapi + 'travels', + method: "POST", + data: $scope.newtravel + }) + .then(function(data) { + console.log(data); + window.location="#app/travels" + }, + function(data) { // optional + // failed + console.log(data); + }); + }; }); diff --git a/www/js/signup.js b/www/js/signup.js index 7d42798..a7e5391 100644 --- a/www/js/signup.js +++ b/www/js/signup.js @@ -6,7 +6,7 @@ angular.module('app.signup', ['pascalprecht.translate']) console.log('Doing signup', $scope.signupData); if ($scope.emptyParams($scope.signupData)) { $http({ - url: urlapi + 'users', + url: urlapi + 'signup', method: "POST", data: $scope.signupData }) @@ -49,7 +49,7 @@ angular.module('app.signup', ['pascalprecht.translate']) if (obj.password == undefined) { return (false); } - if (obj.mail == undefined) { + if (obj.email == undefined) { return (false); } /*if(obj.avatar==undefined) diff --git a/www/js/user.js b/www/js/user.js index c2d585e..ca8b608 100644 --- a/www/js/user.js +++ b/www/js/user.js @@ -1,32 +1,14 @@ angular.module('app.user', ['pascalprecht.translate']) .controller('UserCtrl', function($scope, $stateParams, $http, $filter, $ionicModal) { - 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"); - $scope.users= JSON.parse(localStorage.getItem('c_users')); - $scope.user = $filter('filter')($scope.users, {username: $stateParams.username}, true)[0]; - //$scope.user=""; - console.log($stateParams.username); - /*$http.get(urlapi + 'users/byusername/'+$stateParams.username) - .success(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){ - console.log('data error'); - }) - .then(function(result){ - user = result.data; - });*/ - $http.get(urlapi + 'travels/user/'+$stateParams.username) + + $scope.user={}; + $http.get(urlapi + 'users/getByUserId/'+$stateParams.userid) .success(function(data, status, headers,config){ console.log('data success'); console.log(data); // for browser console - $scope.travels = data; // for UI + $scope.user = data; // for UI }) .error(function(data, status, headers,config){ console.log('data error'); diff --git a/www/templates/main.html b/www/templates/main.html index 3675d1b..35b90f3 100644 --- a/www/templates/main.html +++ b/www/templates/main.html @@ -1,18 +1,18 @@ - + Travels - + Users - + Settings - + Help diff --git a/www/templates/menu.html b/www/templates/menu.html index 8e741be..92ee752 100644 --- a/www/templates/menu.html +++ b/www/templates/menu.html @@ -1,6 +1,6 @@ - + @@ -11,7 +11,7 @@ -
+
Notifications @@ -25,36 +25,36 @@ - - -

{{'Menu' | translate }}

+ + +

{{'Menu' | translate }}

- + {{'Main' | translate }} - + {{storageuser.username}} - + {{'Travels' | translate }} - + {{'Users' | translate }} - + {{'Notifications' | translate }} {{userdata.notifications.length}} - + {{'Settings' | translate }} - + {{'Help' | translate }} - - {{'Logout' | translate }} + + {{'Logout' | translate }} diff --git a/www/templates/offerCar.html b/www/templates/offerCar.html index 335595b..910421d 100644 --- a/www/templates/offerCar.html +++ b/www/templates/offerCar.html @@ -1,6 +1,6 @@ -
+

- -

- +
diff --git a/www/templates/signup.html b/www/templates/signup.html index f7af90a..8151bfd 100644 --- a/www/templates/signup.html +++ b/www/templates/signup.html @@ -18,7 +18,7 @@
- +

{{travel.title}}