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,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 = ""

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>