From e135ee020a178c79665baca34557c8dae63d3869 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Thu, 25 Jun 2015 00:10:08 +0300 Subject: [PATCH] Changed settings into profile. + in controller --- templates/js/app.js | 6 +- templates/js/controllers/mainController.js | 79 ++++++++++--------- templates/js/controllers/profileController.js | 11 ++- templates/views/index.html | 2 +- templates/views/profile.html | 2 +- 5 files changed, 54 insertions(+), 46 deletions(-) diff --git a/templates/js/app.js b/templates/js/app.js index 4ecf22f..99a5e63 100644 --- a/templates/js/app.js +++ b/templates/js/app.js @@ -38,9 +38,9 @@ app.config(['$routeProvider', '$locationProvider', templateUrl: 'templates/views/home.html', controller: 'homeController' }) - .when('/Settings', { - templateUrl: 'templates/views/settings.html', - controller: 'settingsController' + .when('/profile/:id', { + templateUrl: 'templates/views/profile.html', + controller: 'profileController' }) .when('/tasks', { templateUrl: 'templates/views/tasks.html', diff --git a/templates/js/controllers/mainController.js b/templates/js/controllers/mainController.js index f2e7e1e..5cfa78f 100644 --- a/templates/js/controllers/mainController.js +++ b/templates/js/controllers/mainController.js @@ -1,5 +1,7 @@ angular.module('SeHub') - .controller('mainController', ['$scope', '$rootScope', 'dataService','apiService', '$cookies', '$cookieStore', '$location', '$window', + .controller('mainController', + ['$scope', '$rootScope', 'dataService', 'apiService', '$cookies', + '$cookieStore', '$location', '$window', function($scope, $rootScope, dataService, apiService, $cookies, $cookieStore, $location, $window) { top.setIsEnterd = true; @@ -14,6 +16,44 @@ angular.module('SeHub') } $scope.loadingData = false; $scope.user = data; + + $scope.menuItems = [{ + "title": "Dash Board", + "icon": "fa fa-tachometer", + "style": "selected", + "route": "/home" + }, { + "title": "My Campuses", + "icon": "fa fa-university", + "style": "", + "route": "/campuses" + }, { + "title": "My Classes", + "icon": "fa fa-graduation-cap", + "style": "", + "route": "/myClasses" + }, { + "title": "My Projects", + "icon": "fa fa-cube", + "style": "", + "route": "/projects" + }, { + "title": "Tasks", + "icon": "fa fa-clipboard", + "style": "", + "route": "/tasks" + }, { + "title": "Profile", + "icon": "fa fa-cogs", + "style": "", + "route": "/profile/" + $scope.user.id.toString() + }, { + "title": "Log Out", + "icon": "fa fa-power-off", + "style": "", + "route": "/logout" + }]; + dataService.initService($scope); //Start Data Sync Service (For User) console.log(data); if ($scope.user.isFirstLogin) { @@ -27,44 +67,7 @@ angular.module('SeHub') }); - - $scope.menuItems = [{ - "title": "Dash Board", - "icon": "fa fa-tachometer", - "style": "selected", - "route": "/home" - }, { - "title": "My Campuses", - "icon": "fa fa-university", - "style": "", - "route": "/campuses" - }, { - "title": "My Classes", - "icon": "fa fa-graduation-cap", - "style": "", - "route": "/myClasses" - }, { - "title": "My Projects", - "icon": "fa fa-cube", - "style": "", - "route": "/projects" - }, { - "title": "Tasks", - "icon": "fa fa-clipboard", - "style": "", - "route": "/tasks" - }, { - "title": "Settings", - "icon": "fa fa-cogs", - "style": "", - "route": "/Settings" - }, { - "title": "Log Out", - "icon": "fa fa-power-off", - "style": "", - "route": "/logout" - }]; $scope.menuClicked = function(item) { var route = "" diff --git a/templates/js/controllers/profileController.js b/templates/js/controllers/profileController.js index 6f8fd18..40ce310 100644 --- a/templates/js/controllers/profileController.js +++ b/templates/js/controllers/profileController.js @@ -1,13 +1,14 @@ angular.module('SeHub') - .controller('profileController', ['$scope', '$rootScope', 'dataService', 'apiService', '$cookies', '$location', - function($scope, $rootScope, dataService, apiService, $cookies, $location) { + .controller('profileController', ['$scope', '$rootScope', 'dataService', 'apiService', + '$cookies', '$location', '$routeParams', + function($scope, $rootScope, dataService, apiService, $cookies, $location, $routeParams) { var token = $cookies['com.sehub.www']; $scope.loadingData = true; $scope.isInRegisterMode = false; - $scope.title = "Profile" + $scope.title = "Profile " + $routeParams.id; apiService.getUserByToken(token).success(function(data) { if (data.message == 'No User Found') { @@ -15,6 +16,7 @@ angular.module('SeHub') } $scope.loadingData = false; $scope.user = data; + console.log(data); if ($scope.user.isFirstLogin) { $scope.menuObj = {}; @@ -87,6 +89,9 @@ angular.module('SeHub') [28, 48, 40, 3] ]; + $scope.isUser = function(){ + return $scope.user.id.toString() === $routeParams.id; + } } ]); \ No newline at end of file diff --git a/templates/views/index.html b/templates/views/index.html index 03ff1ee..f719a34 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -109,7 +109,7 @@ - + diff --git a/templates/views/profile.html b/templates/views/profile.html index c90b019..2b2a26e 100644 --- a/templates/views/profile.html +++ b/templates/views/profile.html @@ -15,7 +15,7 @@
- + {{profileMode}}