From f258856102530e15ddd12c46e969f55055d4ccfc Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Wed, 17 Jun 2015 00:07:21 +0300 Subject: [PATCH 1/6] #43 - Settings Page: Some More UI Thinking About UI and Implementing it --- .../js/controllers/settingsController.js | 25 ++++++++++++++++ templates/views/settings.html | 30 +++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/templates/js/controllers/settingsController.js b/templates/js/controllers/settingsController.js index 4968b42..1afbabc 100644 --- a/templates/js/controllers/settingsController.js +++ b/templates/js/controllers/settingsController.js @@ -24,7 +24,32 @@ 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 { + $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/views/settings.html b/templates/views/settings.html index 0c4b980..fd1cf52 100644 --- a/templates/views/settings.html +++ b/templates/views/settings.html @@ -5,6 +5,36 @@

{{title}}

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

{{user.name}}

+
+
+ Email: {{user.email}} +
+
+ I Am a: {{(user.isLecturer) ? "Lecturer" : "Student"}} +
+
+
+
+
+ + +
\ No newline at end of file From 980d81324ce7b3c576ddffa8fed85c98941d2387 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Wed, 17 Jun 2015 00:16:26 +0300 Subject: [PATCH 2/6] #43 - Settings Page: Profile Edit Mode --- templates/views/settings.html | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/templates/views/settings.html b/templates/views/settings.html index fd1cf52..96b3f74 100644 --- a/templates/views/settings.html +++ b/templates/views/settings.html @@ -15,10 +15,12 @@
- {{profileMode}} + {{profileMode}}
+ +

{{user.name}}

@@ -29,6 +31,25 @@ I Am a: {{(user.isLecturer) ? "Lecturer" : "Student"}}
+
+
+ + + + +
+
+ + + + +
+
+ + I Am a: {{(user.isLecturer) ? "Lecturer" : "Student"}} + +
+
From f87a14b2da4768979fb0e99ba522d53db44950f4 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Wed, 17 Jun 2015 20:07:20 +0300 Subject: [PATCH 3/6] Fix issue #24 --- SE_API/API.py | 4 ---- SE_API/CampusRoutes.py | 1 - SE_API/UserRoutes.py | 5 ++++- 3 files changed, 4 insertions(+), 6 deletions(-) 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) From 3465ff3465acc33c4aaafd934791c61fc0de7f39 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Wed, 17 Jun 2015 20:14:53 +0300 Subject: [PATCH 4/6] Added Logout Function --- templates/js/controllers/mainController.js | 150 +++++++++++---------- 1 file changed, 79 insertions(+), 71 deletions(-) diff --git a/templates/js/controllers/mainController.js b/templates/js/controllers/mainController.js index bad88a9..9b4a18d 100644 --- a/templates/js/controllers/mainController.js +++ b/templates/js/controllers/mainController.js @@ -1,78 +1,86 @@ angular.module('SeHub') - .controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function($scope, $rootScope, apiService, $cookies, $location) { + .controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$cookieStore', '$location', '$window', - var token = $cookies['com.sehub.www']; + function($scope, $rootScope, 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; + 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 From c264d908fbf259d5163a6995ef41a94050737f5b Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Wed, 17 Jun 2015 20:59:45 +0300 Subject: [PATCH 5/6] Added New dataService - to sync mainController data with other scopes --- templates/js/controllers/mainController.js | 9 ++++++--- templates/js/controllers/settingsController.js | 4 +++- templates/views/index.html | 1 + templates/views/settings.html | 2 ++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/templates/js/controllers/mainController.js b/templates/js/controllers/mainController.js index 9b4a18d..08b10d6 100644 --- a/templates/js/controllers/mainController.js +++ b/templates/js/controllers/mainController.js @@ -1,7 +1,7 @@ angular.module('SeHub') - .controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$cookieStore', '$location', '$window', + .controller('mainController', ['$scope', '$rootScope', 'dataService','apiService', '$cookies', '$cookieStore', '$location', '$window', - function($scope, $rootScope, apiService, $cookies, $cookieStore, $location, $window) { + function($scope, $rootScope, dataService, apiService, $cookies, $cookieStore, $location, $window) { var token = $cookies['com.sehub.www']; @@ -14,6 +14,7 @@ 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 = {}; @@ -24,7 +25,9 @@ angular.module('SeHub') $location.path('/home') } - }) + }); + + $scope.menuItems = [{ "title": "Dash Board", diff --git a/templates/js/controllers/settingsController.js b/templates/js/controllers/settingsController.js index 1afbabc..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']; @@ -34,6 +35,7 @@ angular.module('SeHub') $scope.profileMode = "Save Profile"; $scope.profileModeIcon = "fa fa-floppy-o"; } else { + dataService.userBrodcast($scope.user); $scope.profileMode = "Edit Profile"; $scope.profileModeIcon = "fa fa-pencil"; } 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 96b3f74..70c88f7 100644 --- a/templates/views/settings.html +++ b/templates/views/settings.html @@ -31,6 +31,8 @@ I Am a: {{(user.isLecturer) ? "Lecturer" : "Student"}} + +
From 46f374430d13665d3de60756eca946909db17b11 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Wed, 17 Jun 2015 21:00:37 +0300 Subject: [PATCH 6/6] missing js File --- templates/js/services/dataService.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 templates/js/services/dataService.js 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