From 85c8af1f74a2fe1a741f57e14ef1857d1c364d55 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Tue, 7 Jul 2015 21:05:41 +0300 Subject: [PATCH 1/8] API Hot Fix - #Error On login without email --- SE_API/API.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/SE_API/API.py b/SE_API/API.py index 1f79300..340b5f8 100644 --- a/SE_API/API.py +++ b/SE_API/API.py @@ -185,10 +185,11 @@ def oauth(oauth_token): tempName = ";" - if user_data["email"] == "": - for email in userEmails: - if email["primary"] and email["verified"]: - tempEmail = email["email"] + if 'email' in user_data: + if user_data["email"] == "": + for email in userEmails: + if email["primary"] and email["verified"]: + tempEmail = email["email"] else: tempEmail = user_data["email"] From 33003c048699dec7db4099f3cc3f106a026e9b80 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Fri, 24 Jul 2015 00:57:14 +0300 Subject: [PATCH 2/8] Begining of the Task filling/viewing controller and html view --- templates/js/app.js | 8 ++ templates/js/controllers/taskController.js | 101 +++++++++++++++++++++ templates/views/index.html | 1 + templates/views/task.html | 61 +++++++++++++ 4 files changed, 171 insertions(+) create mode 100644 templates/js/controllers/taskController.js create mode 100644 templates/views/task.html diff --git a/templates/js/app.js b/templates/js/app.js index 4940008..5f4777f 100644 --- a/templates/js/app.js +++ b/templates/js/app.js @@ -48,6 +48,14 @@ app.config(['$routeProvider', '$locationProvider', templateUrl: 'templates/views/newTask.html', controller: 'newTasksController' }) + .when('/tasks/overview/:taskId/:submitterId', { + templateUrl: 'templates/views/task.html', + controller: 'taskController' + }) + .when('/tasks/fill/:taskId', { + templateUrl: 'templates/views/task.html', + controller: 'taskController' + }) .when('/class/:classId/:className', { templateUrl: 'templates/views/class.html', controller: 'classController' diff --git a/templates/js/controllers/taskController.js b/templates/js/controllers/taskController.js new file mode 100644 index 0000000..bf45630 --- /dev/null +++ b/templates/js/controllers/taskController.js @@ -0,0 +1,101 @@ +angular.module('SeHub') + .controller('taskController', ['$scope', '$rootScope', 'dataService', 'apiService', + '$cookies', '$location', '$routeParams', + function($scope, $rootScope, dataService, apiService, $cookies, $location, $routeParams) { + + var taskId = $routeParams.taskId; + var submitterId = $routeParams.submitterId; + + + if (submitterId) { //In This Case we Only Want to show The Content of the Submitter + $scope.readOnly = true; + } else { //In This Case We Need An Empty Task To Be Able To Fill It + $scope.readOnly = false; + } + + $scope.dateInit = function(date){ + d = moment(new Date(date.year, date.month - 1, date.day)); + $scope.task.date = d.format("d MMMM YYYY"); + } + + + $scope.dueTime = function() { + if (!$scope.task.date || $scope.task.date === '') + $scope.dueTimeFromNow = ""; + var d = new Date($scope.task.date); + $scope.dueTimeFromNow = moment(d).fromNow(); + } + + $scope.initLinkComp = function(component) { + var arr = component.label.split("|"); + for (var i = 0; i < arr.length - 1; i++) { + if (i == 0) + component.title = arr[i]; + else + component.href = arr[i]; + }; + } + + $scope.initRadioButtonsComp = function(component) { + var arr = component.label.split("|"); + component.values = []; + for (var i = 0; i < arr.length - 1; i++) { + if (i == 0) + component.title = arr[i]; + else + component.values.push({ + text: arr[i], + id: i + }); + }; + } + + + + /*================================= + = Mock Data = + =================================*/ + + $scope.task = { + "title": "task1", + "courseId": 1234567890, + "description": "one line\nsecondline\nthirdline", + "dueDate": { + "year": 2010, + "month": 2, + "day": 4 + }, + "isPersonal": true, + "components": [{ + "type": "radiobuttons", + "label": "pick One|this|orthis|MaybeThis", + "isMandatory": true, + "order": 1 + }, { + "type": "checkbox", + "label": "tick Me", + "isMandatory": true, + "order": 2 + }, { + "type": "textarea", + "label": "fill shit", + "isMandatory": false, + "order": 3 + }] + }; + + $scope.dateInit($scope.task.dueDate); + + $scope.dueTime = function() { + if (!$scope.task.date || $scope.task.date === '') + $scope.dueTimeFromNow = ""; + var d = new Date($scope.task.date); + $scope.descriptionInit = function(desc){ + desc.replace('\n', '
'); + } + $scope.descriptionInit($scope.task.description); + $scope.dueTimeFromNow = moment(d).fromNow(); + } + + } + ]); //End Controller \ No newline at end of file diff --git a/templates/views/index.html b/templates/views/index.html index 0196f52..9c1d9bd 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -112,6 +112,7 @@ + diff --git a/templates/views/task.html b/templates/views/task.html new file mode 100644 index 0000000..d987f25 --- /dev/null +++ b/templates/views/task.html @@ -0,0 +1,61 @@ +
+
+ +
+ +

{{task.title}}

+

Due At: {{ task.date }}

+

{{ dueTimeFromNow }}

+

+

{{(task.isPersonal) ? "Personal" : "Project"}} Task

+ + + +
+ +
+ + + +
+ +
+ + + + +
+ +
+ + + + +
+ +
+ + {{ component.label}} + +
+ +
+ + {{component.title}} + +
+ +
+ {{component.title}} + + {{option.text}} + +
+
+
+
+
+
+ + +
\ No newline at end of file From e9dab54c2cfa53e74576afb4bbc9070c3d7d40f8 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sat, 25 Jul 2015 14:20:29 +0300 Subject: [PATCH 3/8] Added invalid Token redirection to Welcome app.js --- templates/js/controllers/mainController.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/templates/js/controllers/mainController.js b/templates/js/controllers/mainController.js index 9fd22a2..2e6c04d 100644 --- a/templates/js/controllers/mainController.js +++ b/templates/js/controllers/mainController.js @@ -1,3 +1,5 @@ +var DEBUG = true; + angular.module('SeHub') .controller('mainController', ['$scope', '$rootScope', 'dataService', 'apiService', '$cookies', @@ -10,9 +12,11 @@ angular.module('SeHub') $scope.loadingData = true; $scope.isInRegisterMode = false; - apiService.getUserByToken(token).success(function(data) { - if (data.message == 'No User Found') { + apiService.getUserByToken(token).success(function(data, status) { + if (status == 204) { console.error("No User Found!"); + $cookieStore.remove('com.sehub.www'); + window.location = DEBUG ? 'http://localhost:8080' : 'http://se-hub.appstpot.com/'; } $scope.loadingData = false; $scope.user = data; @@ -60,6 +64,10 @@ angular.module('SeHub') $location.path('/home') } + }).error(function(err){ + console.error(err); + $cookieStore.remove('com.sehub.www'); + window.location = DEBUG ? 'http://localhost:8080' : 'http://se-hub.appstpot.com/'; }); From fcaa93a713ddc219569c0d227a3b508c8a52ef9b Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sat, 25 Jul 2015 18:25:26 +0300 Subject: [PATCH 4/8] Changed app color theme & fix to mainController --- templates/js/app.js | 6 ++++++ templates/js/controllers/mainController.js | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/templates/js/app.js b/templates/js/app.js index 5f4777f..cb5558a 100644 --- a/templates/js/app.js +++ b/templates/js/app.js @@ -79,3 +79,9 @@ app.config(['$routeProvider', '$locationProvider', } ]); +app.config(function($mdThemingProvider) { + $mdThemingProvider.theme('default') + .primaryPalette('teal') + .accentPalette('blue-grey'); + +}); \ No newline at end of file diff --git a/templates/js/controllers/mainController.js b/templates/js/controllers/mainController.js index 2e6c04d..b5e5632 100644 --- a/templates/js/controllers/mainController.js +++ b/templates/js/controllers/mainController.js @@ -1,5 +1,3 @@ -var DEBUG = true; - angular.module('SeHub') .controller('mainController', ['$scope', '$rootScope', 'dataService', 'apiService', '$cookies', @@ -16,7 +14,7 @@ angular.module('SeHub') if (status == 204) { console.error("No User Found!"); $cookieStore.remove('com.sehub.www'); - window.location = DEBUG ? 'http://localhost:8080' : 'http://se-hub.appstpot.com/'; + window.location = 'http://se-hub.appstpot.com/'; } $scope.loadingData = false; $scope.user = data; From 35df7cd3e3bb15d20d91bc80de6827f3b2c7bc9b Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sat, 25 Jul 2015 18:25:45 +0300 Subject: [PATCH 5/8] Tasks: More Improvements --- templates/js/controllers/taskController.js | 47 +++++++++++++++++----- templates/views/newTask.html | 2 +- templates/views/task.html | 36 ++++++++++------- 3 files changed, 59 insertions(+), 26 deletions(-) diff --git a/templates/js/controllers/taskController.js b/templates/js/controllers/taskController.js index bf45630..4133f05 100644 --- a/templates/js/controllers/taskController.js +++ b/templates/js/controllers/taskController.js @@ -1,7 +1,8 @@ angular.module('SeHub') .controller('taskController', ['$scope', '$rootScope', 'dataService', 'apiService', - '$cookies', '$location', '$routeParams', - function($scope, $rootScope, dataService, apiService, $cookies, $location, $routeParams) { + '$cookies', '$location', '$routeParams', '$mdDialog', + + function($scope, $rootScope, dataService, apiService, $cookies, $location, $routeParams, $mdDialog) { var taskId = $routeParams.taskId; var submitterId = $routeParams.submitterId; @@ -13,7 +14,7 @@ angular.module('SeHub') $scope.readOnly = false; } - $scope.dateInit = function(date){ + $scope.dateInit = function(date) { d = moment(new Date(date.year, date.month - 1, date.day)); $scope.task.date = d.format("d MMMM YYYY"); } @@ -50,6 +51,30 @@ angular.module('SeHub') }; } + function validateComponents() { + for (var i = 0; i < $scope.task.components.length; i++) { + if ($scope.task.components[i].isMandatory && (!$scope.task.components[i].value || $scope.task.components[i].value == '')) + return false; + } + return true; + } + + $scope.submitTask = function(event) { //Dialog will pop-up if not all mandatory fields are filled + if (validateComponents()) { + alert('All Shit Are Filled'); + return; + } + $mdDialog.show( + $mdDialog.alert() + .title('Hey There...') + .content('You Must Fill All Mandatory Fields In Order To Submit The Task') + .ariaLabel('Not All Mandatory Are Filled') + .ok('Got it!') + .targetEvent(event) + ); + + } + /*================================= @@ -87,15 +112,15 @@ angular.module('SeHub') $scope.dateInit($scope.task.dueDate); $scope.dueTime = function() { - if (!$scope.task.date || $scope.task.date === '') - $scope.dueTimeFromNow = ""; - var d = new Date($scope.task.date); - $scope.descriptionInit = function(desc){ - desc.replace('\n', '
'); + if (!$scope.task.date || $scope.task.date === '') + $scope.dueTimeFromNow = ""; + var d = new Date($scope.task.date); + $scope.descriptionInit = function(desc) { + desc.replace('\n', '
'); + } + $scope.descriptionInit($scope.task.description); + $scope.dueTimeFromNow = moment(d).fromNow(); } - $scope.descriptionInit($scope.task.description); - $scope.dueTimeFromNow = moment(d).fromNow(); - } } ]); //End Controller \ No newline at end of file diff --git a/templates/views/newTask.html b/templates/views/newTask.html index e9ae941..0a7a855 100644 --- a/templates/views/newTask.html +++ b/templates/views/newTask.html @@ -87,7 +87,7 @@

{{task.task.title}}

Due At: {{ task.date }}

{{ dueTimeFromNow }}

-

{{task.task.description}}

+

{{task.task.description}}

{{(task.isPersonal) ? "Personal" : "Project"}} Task

diff --git a/templates/views/task.html b/templates/views/task.html index d987f25..760a2fb 100644 --- a/templates/views/task.html +++ b/templates/views/task.html @@ -1,19 +1,18 @@ -
-
- -
+
+
+
-

{{task.title}}

+

{{task.title}}

Due At: {{ task.date }}

{{ dueTimeFromNow }}

-

+

{{task.description}}

{{(task.isPersonal) ? "Personal" : "Project"}} Task

-
+
@@ -22,40 +21,49 @@
- +
- +
- + {{ component.label}}
- {{component.title}} + {{component.title}}
{{component.title}} - + {{option.text}}
+
+
+
+ Submit +
+
-
+ +
-
\ No newline at end of file +
+ + \ No newline at end of file From c36a4041b6e62efb91a6044814766e6d605bffef Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sat, 1 Aug 2015 13:35:59 +0300 Subject: [PATCH 6/8] User Profile - Now Getting Real Stats (commits, issues, messages) --- models/User.py | 61 ++++++++++++++++++- templates/js/controllers/profileController.js | 16 ++--- templates/views/profile.html | 2 +- 3 files changed, 69 insertions(+), 10 deletions(-) diff --git a/models/User.py b/models/User.py index b413008..88e6222 100644 --- a/models/User.py +++ b/models/User.py @@ -3,6 +3,7 @@ import json __author__ = 'Aran' from google.appengine.ext import db + class User(db.Model): username = db.StringProperty(required=True) name = db.StringProperty(required=False) @@ -26,6 +27,64 @@ class User(db.Model): 'campuses_id_list': self.campuses_id_list, 'courses_id_list': self.courses_id_list, 'projects_id_list': self.projects_id_list, - 'id' : self.key().id() + 'id' : self.key().id(), + 'stats': get_stats(self) } return json.dumps(data) + +def get_stats(user): + from models.Project import Project + from models.Message import Message + labels = ['Commits', 'Open Issues Assigned', 'Messages', 'Unfinished Tasks'] + data = [0, 0, 0, 0] + for pid in user.projects_id_list: + project = Project.get_by_id(int(pid)) + info = json.loads(project.info) + stats = info["stats"]['micro'] + p_data = stats['data'] + p_series = stats['series'] + user_index = p_series.index(user.username) + #adding commits + data[0] = data[0] + p_data[user_index][0] + #adding open issues + data[1] = data[1] + p_data[user_index][1] + messages = Message.all().filter('master_id =', user.key().id()) + for m in messages.run(): + data[2] = data[2] + 1 + + #need to do tasks + #### + + data = [data] + return {'data': data, 'labels': labels} + +""" +info: Object +commits: Array[30] +info: Object +issues: Array[7] +stats: Object +macro: Object +micro: Object +data: Array[4] +0: Array[2] +0: 13 +1: 1 +length: 2 +__proto__: Array[0] +1: Array[2] +2: Array[2] +3: Array[2] +length: 4 +__proto__: Array[0] +labels: Array[2] +0: "Commits" +1: "Open Issues" +length: 2 +__proto__: Array[0] +series: Array[4] +0: "etyemy" +1: "devMatan" +2: "aranzaiger" +3: "sagidayan" +""" \ No newline at end of file diff --git a/templates/js/controllers/profileController.js b/templates/js/controllers/profileController.js index d07c0b8..670f604 100644 --- a/templates/js/controllers/profileController.js +++ b/templates/js/controllers/profileController.js @@ -8,6 +8,7 @@ angular.module('SeHub') $scope.loadingData = true; $scope.isInRegisterMode = false; $scope.userExists = false; + $scope.isUser = false; $scope.title = "Profile"; @@ -36,6 +37,13 @@ angular.module('SeHub') console.error("++++++++++++++++++++"); }); + $scope.labels = data.stats.labels; + //$scope.series = ['Project A', 'Project B']; + + $scope.data = data.stats.data; + + $scope.isUser = $scope.$parent.user.id.toString() /*The Actual User*/ === $routeParams.id /*The Profile User*/ ; + }); @@ -62,15 +70,7 @@ angular.module('SeHub') } } - $scope.labels = ['Commits', 'Issues Assigned', 'Messages', 'Open Tasks']; - //$scope.series = ['Project A', 'Project B']; - $scope.data = [ - [54, 3, 15, 3] //, - //[28, 48, 40, 3] - ]; - - $scope.isUser = $scope.$parent.user.id.toString() /*The Actual User*/ === $routeParams.id /*The Profile User*/ ; } ]); \ No newline at end of file diff --git a/templates/views/profile.html b/templates/views/profile.html index a4b6769..78bb3e2 100644 --- a/templates/views/profile.html +++ b/templates/views/profile.html @@ -8,7 +8,7 @@

{{title}}

-
+
From 222fb2cab018e04dbc32677ba22352f64704bcd0 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sat, 1 Aug 2015 13:36:28 +0300 Subject: [PATCH 7/8] Cleaning --- models/User.py | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/models/User.py b/models/User.py index 88e6222..db6a3a3 100644 --- a/models/User.py +++ b/models/User.py @@ -56,35 +56,4 @@ def get_stats(user): #### data = [data] - return {'data': data, 'labels': labels} - -""" -info: Object -commits: Array[30] -info: Object -issues: Array[7] -stats: Object -macro: Object -micro: Object -data: Array[4] -0: Array[2] -0: 13 -1: 1 -length: 2 -__proto__: Array[0] -1: Array[2] -2: Array[2] -3: Array[2] -length: 4 -__proto__: Array[0] -labels: Array[2] -0: "Commits" -1: "Open Issues" -length: 2 -__proto__: Array[0] -series: Array[4] -0: "etyemy" -1: "devMatan" -2: "aranzaiger" -3: "sagidayan" -""" \ No newline at end of file + return {'data': data, 'labels': labels} \ No newline at end of file From 7118bab5985052c1b5da8b38324cb194994d7a33 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sat, 1 Aug 2015 13:45:05 +0300 Subject: [PATCH 8/8] Fixing A posible Bug in the API getting User Stats --- models/User.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/models/User.py b/models/User.py index db6a3a3..b2b2755 100644 --- a/models/User.py +++ b/models/User.py @@ -43,11 +43,14 @@ def get_stats(user): stats = info["stats"]['micro'] p_data = stats['data'] p_series = stats['series'] - user_index = p_series.index(user.username) - #adding commits - data[0] = data[0] + p_data[user_index][0] - #adding open issues - data[1] = data[1] + p_data[user_index][1] + try: + user_index = p_series.index(user.username) + #adding commits + data[0] = data[0] + p_data[user_index][0] + #adding open issues + data[1] = data[1] + p_data[user_index][1] + except Exception: + pass messages = Message.all().filter('master_id =', user.key().id()) for m in messages.run(): data[2] = data[2] + 1