diff --git a/SE_API/API.py b/SE_API/API.py index 972c39e..387ba41 100644 --- a/SE_API/API.py +++ b/SE_API/API.py @@ -52,10 +52,6 @@ app.register_blueprint(project_routes) auto = Autodoc(app) -@app.errorhandler(404) -def page_not_found(e): - return app.send_static_file('views/404/index.html') - @app.route('/') def wellcomePage(): return app.send_static_file('index.html') diff --git a/SE_API/CampusRoutes.py b/SE_API/CampusRoutes.py index 11af4b3..c52fe9c 100644 --- a/SE_API/CampusRoutes.py +++ b/SE_API/CampusRoutes.py @@ -79,7 +79,6 @@ def create_campus(token): except Exception: return bad_request() - send_create_campus_request(user.email, user.name, campus.title) notify_se_hub_campus_request(campus, campus.title) return ok() diff --git a/SE_API/UserRoutes.py b/SE_API/UserRoutes.py index 0bc26d1..d66fdea 100644 --- a/SE_API/UserRoutes.py +++ b/SE_API/UserRoutes.py @@ -25,7 +25,7 @@ from SE_API.Respones_Utils import * user_routes = Blueprint("user_routes", __name__) auto = Autodoc() - +@user_routes.route('/api/users/getUserByToken/', defaults={'token': None}) @user_routes.route('/api/users/getUserByToken/', methods=["GET"]) @auto.doc() def getUserByToken(token): @@ -59,6 +59,9 @@ def getUserByToken(token):
403 - No User Found """ + if token is None: + return no_content("Token Is Empty, No User Found") + query = User.all() query.filter("seToken =", token) diff --git a/templates/js/controllers/mainController.js b/templates/js/controllers/mainController.js index bad88a9..08b10d6 100644 --- a/templates/js/controllers/mainController.js +++ b/templates/js/controllers/mainController.js @@ -1,78 +1,89 @@ angular.module('SeHub') - .controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function($scope, $rootScope, apiService, $cookies, $location) { + .controller('mainController', ['$scope', '$rootScope', 'dataService','apiService', '$cookies', '$cookieStore', '$location', '$window', - var token = $cookies['com.sehub.www']; + function($scope, $rootScope, dataService, apiService, $cookies, $cookieStore, $location, $window) { - $scope.loadingData = true; - $scope.isInRegisterMode = false; + var token = $cookies['com.sehub.www']; - apiService.getUserByToken(token).success(function(data) { - if (data.message == 'No User Found') { - console.error("No User Found!"); - } - $scope.loadingData = false; - $scope.user = data; - console.log(data); - if ($scope.user.isFirstLogin) { - $scope.menuObj = {}; - $scope.isInRegisterMode = true; - $scope.loadingData = false; - $location.path('/register') - } else { - $location.path('/home') - } + $scope.loadingData = true; + $scope.isInRegisterMode = false; - }) - - $scope.menuItems = [{ - "title": "Home", - "icon": "fa fa-home", - "style": "selected", - "route": "/home" - }, { - "title": "My Campuses", - "icon": "fa fa-university", - "style": "", - "route": "/campuses" - }, { - "title": "My Classes", - "icon": "fa fa-graduation-cap", - "style": "", - "route": "/campuses" - }, { - "title": "My Projects", - "icon": "fa fa-cube", - "style": "", - "route": "/campuses" - }, { - "title": "Tasks", - "icon": "fa fa-clipboard", - "style": "", - "route": "/campuses" - }, { - "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 = "" - for (var i = $scope.menuItems.length - 1; i >= 0; i--) { - if($scope.menuItems[i].title === item.title){ - $scope.menuItems[i].style="selected"; - route = $scope.menuItems[i].route; - }else{ - $scope.menuItems[i].style = ""; + apiService.getUserByToken(token).success(function(data) { + if (data.message == 'No User Found') { + console.error("No User Found!"); } - }; - $location.path(route); + $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", + "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": "/campuses" + }, { + "title": "My Projects", + "icon": "fa fa-cube", + "style": "", + "route": "/campuses" + }, { + "title": "Tasks", + "icon": "fa fa-clipboard", + "style": "", + "route": "/campuses" + }, { + "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 = "" + if (item.title == "Log Out") { + console.info('Logging Out!'); + $cookieStore.remove('com.sehub.www'); + $window.location.href = 'http://se-hub.appspot.com'; // Reference to 'welcome' page + } + for (var i = $scope.menuItems.length - 1; i >= 0; i--) { + if ($scope.menuItems[i].title === item.title) { + $scope.menuItems[i].style = "selected"; + route = $scope.menuItems[i].route; + } else { + $scope.menuItems[i].style = ""; + } + }; + $location.path(route); + } + + } - - - }]); \ No newline at end of file + ]); \ No newline at end of file diff --git a/templates/js/controllers/settingsController.js b/templates/js/controllers/settingsController.js index 4968b42..b13edc8 100644 --- a/templates/js/controllers/settingsController.js +++ b/templates/js/controllers/settingsController.js @@ -1,5 +1,6 @@ angular.module('SeHub') - .controller('settingsController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function($scope, $rootScope, apiService, $cookies, $location) { + .controller('settingsController', ['$scope', '$rootScope', 'dataService','apiService', '$cookies', '$location', + function($scope, $rootScope, dataService ,apiService, $cookies, $location) { var token = $cookies['com.sehub.www']; @@ -24,7 +25,33 @@ angular.module('SeHub') }); + $scope.isEditMode = false; + $scope.profileMode = "Edit Profile"; + $scope.profileModeIcon = "fa fa-pencil"; + $scope.changeProfileMode = function() { + $scope.isEditMode = !$scope.isEditMode; + if ($scope.isEditMode) { + $scope.profileMode = "Save Profile"; + $scope.profileModeIcon = "fa fa-floppy-o"; + } else { + dataService.userBrodcast($scope.user); + $scope.profileMode = "Edit Profile"; + $scope.profileModeIcon = "fa fa-pencil"; + } + } + + // { + // name: ";" + // isLecturer: false + // email: "sagidayan@gmail.com" + // username: "sagidayan" + // seToken: "76cd4178-94dd-4cb4-b464-111d2239e567" + // isFirstLogin: true + // campuses_id_list: [0] + // classes_id_list: [0] + // avatar_url: "https://avatars.githubusercontent.com/u/2984053?v=3" + // } }]); \ No newline at end of file diff --git a/templates/js/services/dataService.js b/templates/js/services/dataService.js new file mode 100644 index 0000000..af915c7 --- /dev/null +++ b/templates/js/services/dataService.js @@ -0,0 +1,21 @@ +var DEBUG = true; + +angular.module('seHub.services'). + +factory('dataService', ['$http', function($http) { + var scope = null; + + + return { + initService: function(mainScope) { + // this.token = user.seToken; + // this.user = user; + scope = mainScope; + }, + userBrodcast: function(user) { + scope.user = JSON.parse(JSON.stringify(user)); + } + + + }; +}]); \ No newline at end of file diff --git a/templates/views/index.html b/templates/views/index.html index cd629d1..c683489 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -81,6 +81,7 @@ + diff --git a/templates/views/settings.html b/templates/views/settings.html index 0c4b980..70c88f7 100644 --- a/templates/views/settings.html +++ b/templates/views/settings.html @@ -5,6 +5,59 @@

{{title}}

+
+
+ +
+
+
+ +
+
+ + {{profileMode}} + +
+
+
+
+
+

{{user.name}}

+
+
+ Email: {{user.email}} +
+
+ I Am a: {{(user.isLecturer) ? "Lecturer" : "Student"}} +
+
+ + +
+
+ + + + +
+
+ + + + +
+
+ + I Am a: {{(user.isLecturer) ? "Lecturer" : "Student"}} + +
+
+
+
+
+ + +
\ No newline at end of file