Merge branch 'master' of https://github.com/sagidayan/SE-Hub into API_Dev
This commit is contained in:
commit
0c6af92021
6 changed files with 261 additions and 112 deletions
|
@ -187,6 +187,98 @@ def getMessagesByGroup(token, groupId):
|
||||||
status=200,
|
status=200,
|
||||||
mimetype="application/json")
|
mimetype="application/json")
|
||||||
|
|
||||||
|
@message_routes.route('/api/messages/getAllUserMessages/<string:token>', methods=["GET"])
|
||||||
|
@auto.doc()
|
||||||
|
def getAllUserMessages(token):
|
||||||
|
"""
|
||||||
|
<span class="card-title">>This Call will return an array of all messages (sorted by date),<br>
|
||||||
|
</span>
|
||||||
|
<br>
|
||||||
|
<b>Route Parameters</b><br>
|
||||||
|
- SeToken: token <br>
|
||||||
|
- groupId: 1234567890
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<b>Payload</b><br>
|
||||||
|
- NONE
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<b>Response</b>
|
||||||
|
<br>
|
||||||
|
200 - JSON Example:<br>
|
||||||
|
<code>[<br>
|
||||||
|
{<br>
|
||||||
|
'groupId' : 1234567890,<br>
|
||||||
|
'message' : 'hello all',<br>
|
||||||
|
'date' : {<br>
|
||||||
|
'year': 2015,<br>
|
||||||
|
'month': 5,<br>
|
||||||
|
'day': 5,<br>
|
||||||
|
'hour': 5,<br>
|
||||||
|
'minute': 5<br>
|
||||||
|
},<br>
|
||||||
|
'id' : 1234567890,<br>
|
||||||
|
'master_id' : 1234567890,<br>
|
||||||
|
'isProject' : false,<br>
|
||||||
|
'user': {<br>
|
||||||
|
'username': 'DarkLord',<br>
|
||||||
|
'name': 'Darth Vader',<br>
|
||||||
|
'email': 'darkLord@death.planet,<br>
|
||||||
|
'isLecturer': 'True',<br>
|
||||||
|
'seToken': 'xxxxxx-xxxxx-xxxxx-xxxxxx',<br>
|
||||||
|
'avatar_url': 'http://location.git.com/somthing'<br>
|
||||||
|
'isFirstLogin': False,<br>
|
||||||
|
'campuses_id_list': [43243532532,5325325325,532532342],<br>
|
||||||
|
'courses_id_list': [53523,43432423,432432432432]<br>
|
||||||
|
'id': 1234567890 <br>
|
||||||
|
},<br>
|
||||||
|
'group': {The Group Object Project OR Campus (according to isProject)}<br><br>
|
||||||
|
|
||||||
|
}<br>
|
||||||
|
]<br>
|
||||||
|
</code>
|
||||||
|
<br>
|
||||||
|
"""
|
||||||
|
user = get_user_by_token(token)
|
||||||
|
if user is None:
|
||||||
|
return bad_request("No such User")
|
||||||
|
|
||||||
|
arr = []
|
||||||
|
|
||||||
|
query = Message.all()
|
||||||
|
query.filter('isProject =', False)
|
||||||
|
for m in query.run():
|
||||||
|
if str(m.groupId) in user.courses_id_list:
|
||||||
|
msgDic = dict(json.loads(m.to_JSON()))
|
||||||
|
#add a key 'forSortDate' for sorting dates
|
||||||
|
msgTime = datetime.datetime(msgDic['date']['year'], msgDic['date']['month'], msgDic['date']['day'], msgDic['date']['hour'], msgDic['date']['minute'])
|
||||||
|
msgDic['forSortDate'] = msgTime
|
||||||
|
arr.append(msgDic)
|
||||||
|
|
||||||
|
query = Message.all()
|
||||||
|
query.filter('isProject =', True)
|
||||||
|
for m in query.run():
|
||||||
|
if str(m.groupId) in user.projects_id_list:
|
||||||
|
msgDic = dict(json.loads(m.to_JSON()))
|
||||||
|
#add a key 'forSortDate' for sorting dates
|
||||||
|
msgTime = datetime.datetime(msgDic['date']['year'], msgDic['date']['month'], msgDic['date']['day'], msgDic['date']['hour'], msgDic['date']['minute'])
|
||||||
|
msgDic['forSortDate'] = msgTime
|
||||||
|
arr.append(msgDic)
|
||||||
|
|
||||||
|
arr = sorted(arr, key=itemgetter('forSortDate'), reverse=True)
|
||||||
|
for i in arr:
|
||||||
|
del i['forSortDate']
|
||||||
|
print arr
|
||||||
|
|
||||||
|
if len(arr) != 0:
|
||||||
|
return Response(response=json.dumps(arr),
|
||||||
|
status=200,
|
||||||
|
mimetype="application/json")
|
||||||
|
else:
|
||||||
|
return Response(response=[],
|
||||||
|
status=200,
|
||||||
|
mimetype="application/json")
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
# DELETE
|
# DELETE
|
||||||
|
|
|
@ -1,77 +1,98 @@
|
||||||
angular.module('SeHub')
|
angular.module('SeHub')
|
||||||
.controller('classController', ['$scope', '$routeParams', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $routeParams, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
|
.controller('classController', ['$scope', '$routeParams', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function($scope, $routeParams, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService, $rootScope) {
|
||||||
{
|
var token = $cookies['com.sehub.www'];
|
||||||
var token = $cookies['com.sehub.www'];
|
var classId = $routeParams.classId;
|
||||||
var classId = $routeParams.classId;
|
$scope.project = {};
|
||||||
$scope.project = {};
|
$scope.project.courseName = $routeParams.className;
|
||||||
$scope.project.courseName = $routeParams.className;
|
$scope.projectsEmpty = true;
|
||||||
$scope.projectsEmpty = true;
|
$scope.isCreateProjectClicked = false;
|
||||||
$scope.isCreateProjectClicked = false;
|
$scope.submitNewCourseClicked = false;
|
||||||
$scope.submitNewCourseClicked = false;
|
$scope.loadingData = true;
|
||||||
$scope.loadingData = true;
|
$scope.isInCourse = false;
|
||||||
$scope.isInCourse = false;
|
var startDate = null;
|
||||||
|
var endDate = null;
|
||||||
|
var nowDate = new Date();
|
||||||
|
var one_day=1000*60*60*24;
|
||||||
|
var dayDeltaOfCourse;
|
||||||
|
var courseElapseTime;
|
||||||
|
$scope.isCourseOver = false;
|
||||||
|
$scope.createSctionStatus = "fa fa-angle-down";
|
||||||
|
|
||||||
$scope.displayProjects = function()
|
$scope.displayProjects = function() {
|
||||||
{
|
apiService.getCourseById(token, classId)
|
||||||
apiService.getProjectsByCourse(token, classId).success(function(data) // Get all the campuses
|
.success(function(data) {
|
||||||
{
|
startDate = new Date(data.startDate.year, data.startDate.month-1, data.startDate.day);
|
||||||
$scope.loadingData = false;
|
endDate = new Date(data.endDate.year, data.endDate.month-1, data.endDate.day)
|
||||||
$scope.projects = data;
|
$scope.course = data;
|
||||||
if($scope.projects != null && $scope.projects.length > 0)
|
$scope.course.startDate = startDate.toDateString();
|
||||||
{
|
$scope.course.endDate = endDate.toDateString();
|
||||||
$scope.projectsEmpty = false;
|
dayDeltaOfCourse = (endDate.getTime() - startDate.getTime()) / one_day;
|
||||||
}
|
courseElapseTime = (nowDate.getTime() - startDate.getTime()) / one_day;
|
||||||
init(); // Executing the function to initialize projects display
|
if(courseElapseTime < 0)
|
||||||
console.log("project created! not rly!! " + classId);
|
courseElapseTime = 0;
|
||||||
}).error(function(err)
|
else if(courseElapseTime > dayDeltaOfCourse){
|
||||||
{
|
$scope.isCourseOver = true;
|
||||||
console.log("Error: " + err);
|
courseElapseTime = dayDeltaOfCourse;
|
||||||
});
|
}
|
||||||
}
|
$scope.courseTimePresentege = ((courseElapseTime/dayDeltaOfCourse) * 100).toString();
|
||||||
$scope.joinCourse = function()
|
console.log($scope.courseTimePresentege);
|
||||||
{
|
|
||||||
apiService.joinCourse(token, classId).success(function(data)
|
|
||||||
{
|
|
||||||
$scope.isInCourse = true;
|
|
||||||
$mdDialog.show($mdDialog.alert().title('Joined Course').content('You have successfully joined course.')
|
|
||||||
.ariaLabel('Join course alert dialog').ok('Lets Start!').targetEvent())
|
|
||||||
.then(function() {
|
|
||||||
$location.path('/class/' + classId); // TODO TODO TODO
|
|
||||||
}); // Pop-up alert
|
|
||||||
}).error(function(err)
|
|
||||||
{
|
|
||||||
$mdDialog.show($mdDialog.alert().title('Error Joining Course').content(err.message + '.')
|
|
||||||
.ariaLabel('Join course alert dialog').ok('Try Again!').targetEvent()); // Pop-up alert
|
|
||||||
// .then(function() {
|
|
||||||
// // $location.path('/newCourse'); // TODO TODO TODO
|
|
||||||
// });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.createProjectClicked = function()
|
apiService.getProjectsByCourse(token, classId).success(function(data) // Get all the campuses
|
||||||
{
|
{
|
||||||
// console.log("project created! is it ?!???! " + classId);
|
$scope.loadingData = false;
|
||||||
$scope.isCreateProjectClicked = !$scope.isCreateProjectClicked;
|
$scope.projects = data;
|
||||||
}
|
if ($scope.projects != null && $scope.projects.length > 0) {
|
||||||
|
$scope.projectsEmpty = false;
|
||||||
|
}
|
||||||
|
init(); // Executing the function to initialize projects display
|
||||||
|
}).error(function(err) {
|
||||||
|
console.error("Error: " + err);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.error(function(err) {
|
||||||
|
console.error("Error: " + err);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
$scope.joinCourse = function() {
|
||||||
|
apiService.joinCourse(token, classId).success(function(data) {
|
||||||
|
$scope.isInCourse = true;
|
||||||
|
$mdDialog.show($mdDialog.alert().title('Joined Course').content('You have successfully joined course.')
|
||||||
|
.ariaLabel('Join course alert dialog').ok('Lets Start!').targetEvent())
|
||||||
|
.then(function() {
|
||||||
|
$location.path('/class/' + classId); // TODO TODO TODO
|
||||||
|
}); // Pop-up alert
|
||||||
|
}).error(function(err) {
|
||||||
|
$mdDialog.show($mdDialog.alert().title('Error Joining Course').content(err.message + '.')
|
||||||
|
.ariaLabel('Join course alert dialog').ok('Try Again!').targetEvent()); // Pop-up alert
|
||||||
|
// .then(function() {
|
||||||
|
// // $location.path('/newCourse'); // TODO TODO TODO
|
||||||
|
// });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$scope.submitNewProject = function()
|
$scope.createProjectClicked = function() {
|
||||||
{
|
// console.log("project created! is it ?!???! " + classId);
|
||||||
loadingData = true;
|
$scope.isCreateProjectClicked = !$scope.isCreateProjectClicked;
|
||||||
// debugger;
|
if($scope.isCreateProjectClicked)
|
||||||
var intClassId = parseInt(classId);
|
$scope.createSctionStatus = "fa fa-angle-up";
|
||||||
// console.log($scope);
|
else
|
||||||
var jsonNewProj =
|
$scope.createSctionStatus = "fa fa-angle-down";
|
||||||
{
|
}
|
||||||
'projectName': $scope.project.projectName,
|
|
||||||
'courseId': intClassId,
|
|
||||||
'gitRepository': $scope.project.repoOwner + '/' + $scope.project.gitRepoName
|
|
||||||
};
|
|
||||||
console.log(jsonNewProj);
|
|
||||||
|
|
||||||
if($scope.project.logoUrl)
|
$scope.submitNewProject = function() {
|
||||||
jsonNewProj.logo_url = $scope.project.logoUrl;
|
loadingData = true;
|
||||||
|
// debugger;
|
||||||
|
var intClassId = parseInt(classId);
|
||||||
|
// console.log($scope);
|
||||||
|
var jsonNewProj = {
|
||||||
|
'projectName': $scope.project.projectName,
|
||||||
|
'courseId': intClassId,
|
||||||
|
'gitRepository': $scope.project.repoOwner + '/' + $scope.project.gitRepoName
|
||||||
|
};
|
||||||
|
console.log(jsonNewProj);
|
||||||
|
|
||||||
|
if ($scope.project.logoUrl)
|
||||||
|
jsonNewProj.logo_url = $scope.project.logoUrl;
|
||||||
|
|
||||||
apiService.createProject(token, jsonNewProj).success(function(data)
|
apiService.createProject(token, jsonNewProj).success(function(data)
|
||||||
{
|
{
|
||||||
|
@ -124,4 +145,5 @@ angular.module('SeHub')
|
||||||
$scope.displayProjects(); // Displaying all projects related to user
|
$scope.displayProjects(); // Displaying all projects related to user
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}]);
|
}]);
|
|
@ -74,8 +74,6 @@ angular.module('SeHub')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("Json here: " + $scope.chosenCampus);
|
|
||||||
console.log(jsonNewCourse);
|
|
||||||
|
|
||||||
apiService.createCourse(token, jsonNewCourse).success(function(data)
|
apiService.createCourse(token, jsonNewCourse).success(function(data)
|
||||||
{
|
{
|
||||||
|
@ -88,7 +86,8 @@ angular.module('SeHub')
|
||||||
}); // Pop-up alert
|
}); // Pop-up alert
|
||||||
}).error(function(err)
|
}).error(function(err)
|
||||||
{
|
{
|
||||||
console.log(err);
|
$mdDialog.show($mdDialog.alert().title('Error Creating Class').content(err)
|
||||||
|
.ariaLabel('Create Class alert dialog').ok('Try Again!').targetEvent()); // Pop-up alert
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -181,8 +181,8 @@ service.factory('apiService', ['$http', function($http) {
|
||||||
};
|
};
|
||||||
return $http(req);
|
return $http(req);
|
||||||
},
|
},
|
||||||
getCampuseById: function(token, id){
|
getCourseById: function(token, id){
|
||||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCoursesById/" + id;
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCoursesById/" + token + "/" + id;
|
||||||
req = {
|
req = {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: url
|
url: url
|
||||||
|
|
|
@ -1,43 +1,38 @@
|
||||||
<div class = "class">
|
<div class = "class">
|
||||||
<h1 style="margin-left:15px"><i class="fa fa-graduation-cap"></i> Class {{project.courseName}}</h1>
|
<div layout="column" layout-align="center center" style="width:100%">
|
||||||
<div layout-paddig layout-margin class="loader" ng-if="loadingData">
|
<!-- Course Title -->
|
||||||
<md-progress-circular md-mode="indeterminate"></md-progress-circular>
|
<div flex>
|
||||||
</div>
|
<h1 style="margin-left:15px">
|
||||||
<div ng-if = "projectsEmpty && !loadingData" layout-padding layout-margin>
|
<i class="fa fa-graduation-cap"></i> Class {{project.courseName}}
|
||||||
You Are Not Related To Any Project.
|
<span ng-if="isCourseOver"> - <i>This Course Is Over</i></span>
|
||||||
</div>
|
</h1>
|
||||||
<div ng-if = "!projectsEmpty">
|
</div>
|
||||||
<md-card class="cardAllProjects">
|
<!-- Course Time Line -->
|
||||||
<div flex ="99" class = "allProjectsShow" layout = "row" ng-repeat = "t in arrayHolder" value = "{{t}}" layout-padding>
|
<div layout="row" layout-align="center center" style="width: 100%">
|
||||||
<div flex = "32" layout = "column" ng-repeat = "project in t" value = "{{project}}" layout-padding>
|
<div>
|
||||||
<div ng-if="t.length != 1">
|
{{course.startDate}}
|
||||||
<md-button ng-click = "goToProject(project.id)" style="width:100%; height:32%;" layout-padding class = "md-raised">
|
</div>
|
||||||
{{project.projectName}}
|
<div flex="70">
|
||||||
<div layout-align="center center" style=" width:70%;">
|
<md-progress-linear md-mode="determinate" value="{{courseTimePresentege}}"></md-progress-linear>
|
||||||
<canvas layout-padding layout-margin id="project.projectName" class="chart chart-bar" data="project.info.stats.macro.data" labels="project.info.stats.macro.labels"></canvas>
|
</div>
|
||||||
</div>
|
<div>
|
||||||
</md-card>
|
{{course.endDate}}
|
||||||
</div>
|
</div>
|
||||||
<div ng-if="t.length == 1">
|
|
||||||
<md-button ng-click = "goToProject(project.id)" style="width:32%; height:32%;" layout-padding class = "md-raised">
|
|
||||||
{{project.projectName}}
|
|
||||||
<!-- <div style="height:100%; width:32%;"> -->
|
|
||||||
<canvas layout-padding layout-margin id="project.projectName" class="chart chart-bar" data="project.info.stats.macro.data" labels="project.info.stats.macro.labels"></canvas>
|
|
||||||
<!-- </div> -->
|
|
||||||
</md-card>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</md-card>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ng-if="!isInCourse" layout-padding layout-margin>
|
<!-- Course Management Buttons -->
|
||||||
<md-button ng-click = "joinCourse()" ng class = "md-raised md-primary"> Join Class</md-button>
|
<div layout-padding layout-margin layout="row" layout-align="left">
|
||||||
|
<div ng-if="!isInCourse" layout-margin>
|
||||||
|
<md-button ng-click = "joinCourse()" ng class = "md-raised md-primary" ng-disabled="isCourseOver"><i class="fa fa-plus"></i> Join Class</md-button>
|
||||||
|
</div>
|
||||||
|
<div layout-margin>
|
||||||
|
<md-content>
|
||||||
|
<md-button ng-click="createProjectClicked()" ng class="md-raised md-primary" ng-disabled="isCourseOver">Create Project <i ng-class="createSctionStatus"></i></md-button>
|
||||||
|
</md-content>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div ng-if = "user.isLecturer"> -->
|
<!-- Create Project Section -->
|
||||||
<md-content layout-padding layout-margin>
|
|
||||||
<md-button ng-click="createProjectClicked()" ng class="md-raised md-primary">Create Project</md-button>
|
|
||||||
</md-content>
|
|
||||||
<div ng-if = "isCreateProjectClicked">
|
<div ng-if = "isCreateProjectClicked">
|
||||||
<md-card layout-padding style="width:60%">
|
<md-card layout-padding style="width:60%">
|
||||||
<div layout="column">
|
<div layout="column">
|
||||||
|
@ -84,6 +79,47 @@
|
||||||
</div>
|
</div>
|
||||||
</md-card>
|
</md-card>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div layout-paddig layout-margin class="loader" ng-if="loadingData">
|
||||||
|
<md-progress-circular md-mode="indeterminate"></md-progress-circular>
|
||||||
|
</div>
|
||||||
|
<div ng-if = "projectsEmpty && !loadingData" layout-padding layout-margin>
|
||||||
|
You Are Not Related To Any Project.
|
||||||
|
</div>
|
||||||
|
<div ng-if = "!projectsEmpty">
|
||||||
|
<md-card class="cardAllProjects">
|
||||||
|
<div flex ="99" class = "allProjectsShow" layout = "row" ng-repeat = "t in arrayHolder" value = "{{t}}" layout-padding>
|
||||||
|
<div flex = "32" layout = "column" ng-repeat = "project in t" value = "{{project}}" layout-padding>
|
||||||
|
<div ng-if="t.length != 1">
|
||||||
|
<md-button ng-click = "goToProject(project.id)" style="width:100%; height:32%;" layout-padding class = "md-raised">
|
||||||
|
<div style="height: 30%" layout="row">
|
||||||
|
<div class="spacer"></div>
|
||||||
|
<div>
|
||||||
|
<img ng-src="{{project.logo_url}}" alt=""
|
||||||
|
ng-if="project.logo_url" style="display: block;width:auto;height:100%;">
|
||||||
|
<span ng-if="!project.logo_url">{{project.projectName}}</span>
|
||||||
|
</div>
|
||||||
|
<div class="spacer"></div>
|
||||||
|
</div>
|
||||||
|
<div layout-align="center center" style=" width:70%;">
|
||||||
|
<canvas layout-padding layout-margin id="project.projectName" class="chart chart-bar" data="project.info.stats.macro.data" labels="project.info.stats.macro.labels"></canvas>
|
||||||
|
</div>
|
||||||
|
</md-card>
|
||||||
|
</div>
|
||||||
|
<div ng-if="t.length == 1">
|
||||||
|
<md-button ng-click = "goToProject(project.id)" style="width:32%; height:32%;" layout-padding class = "md-raised">
|
||||||
|
{{project.projectName}}
|
||||||
|
<!-- <div style="height:100%; width:32%;"> -->
|
||||||
|
<canvas layout-padding layout-margin id="project.projectName" class="chart chart-bar" data="project.info.stats.macro.data" labels="project.info.stats.macro.labels"></canvas>
|
||||||
|
<!-- </div> -->
|
||||||
|
</md-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</md-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- </div> -->
|
<!-- </div> -->
|
||||||
<div layout-margin>
|
<div layout-margin>
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
<b>{{user.name}}</b>
|
<b>{{user.name}}</b>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{{c.courseName}}
|
{{courseObj.courseName}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -142,8 +142,8 @@
|
||||||
<md-card ng-repeat = "msg in messages">
|
<md-card ng-repeat = "msg in messages">
|
||||||
<div layout="column">
|
<div layout="column">
|
||||||
<div layout="row" layout-margin layout-padding>
|
<div layout="row" layout-margin layout-padding>
|
||||||
<div flex="10" class="md-avatar">
|
<div flex="10">
|
||||||
<img ng-src="{{user.avatar_url}}" style="width:100%">
|
<img ng-src="{{user.avatar_url}}" class="roundUserAvatar" style = "width:70%;">
|
||||||
</div>
|
</div>
|
||||||
<div flex>
|
<div flex>
|
||||||
<div layout = "column">
|
<div layout = "column">
|
||||||
|
|
Loading…
Reference in a new issue