Changed settings into profile. + in controller

This commit is contained in:
Sagi Dayan 2015-06-25 00:10:08 +03:00
parent e3fe428900
commit e135ee020a
5 changed files with 54 additions and 46 deletions

View file

@ -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',

View file

@ -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,20 +16,6 @@ angular.module('SeHub')
}
$scope.loadingData = false;
$scope.user = data;
dataService.initService($scope); //Start Data Sync Service (For User)
console.log(data);
if ($scope.user.isFirstLogin) {
$scope.menuObj = {};
$scope.isInRegisterMode = true;
$scope.loadingData = false;
$location.path('/register')
} else {
$location.path('/home')
}
});
$scope.menuItems = [{
"title": "Dash Board",
@ -55,10 +43,10 @@ angular.module('SeHub')
"style": "",
"route": "/tasks"
}, {
"title": "Settings",
"title": "Profile",
"icon": "fa fa-cogs",
"style": "",
"route": "/Settings"
"route": "/profile/" + $scope.user.id.toString()
}, {
"title": "Log Out",
"icon": "fa fa-power-off",
@ -66,6 +54,21 @@ angular.module('SeHub')
"route": "/logout"
}];
dataService.initService($scope); //Start Data Sync Service (For User)
console.log(data);
if ($scope.user.isFirstLogin) {
$scope.menuObj = {};
$scope.isInRegisterMode = true;
$scope.loadingData = false;
$location.path('/register')
} else {
$location.path('/home')
}
});
$scope.menuClicked = function(item) {
var route = ""
if (item.title == "Log Out") {

View file

@ -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;
}
}
]);

View file

@ -109,7 +109,7 @@
<!-- Controllers -->
<script src="templates/js/controllers/mainController.js"></script>
<script src="templates/js/controllers/homeController.js"></script>
<script src="templates/js/controllers/settingsController.js"></script>
<script src="templates/js/controllers/profileController.js"></script>
<script src="templates/js/controllers/registerController.js"></script>
<script src="templates/js/controllers/tasksController.js"></script>
<script src="templates/js/controllers/myClassesController.js"></script>

View file

@ -15,7 +15,7 @@
<img ng-src="{{user.avatar_url}}" alt="" style="width:20%">
</div>
<div flex="70%">
<md-button class="md-raised" ng-click="changeProfileMode()">
<md-button class="md-raised" ng-click="changeProfileMode()" ng-if="isUser()">
<i ng-class="profileModeIcon"></i> {{profileMode}}
</md-button>
</div>