Merge branch 'master' of https://github.com/sagidayan/SE-Hub into UI
# Conflicts: # templates/js/services/apiService.js
This commit is contained in:
commit
5ec2ed20bd
9 changed files with 203 additions and 48 deletions
|
@ -192,7 +192,65 @@ def getCampusesByUser(token):
|
||||||
return bad_request("Bad user Token")
|
return bad_request("Bad user Token")
|
||||||
|
|
||||||
arr = []
|
arr = []
|
||||||
for i in user['campuses_id_list']:
|
for i in user.campuses_id_list:
|
||||||
|
campus = Campus.get_by_id(int(i))
|
||||||
|
arr.append(dict(json.loads(campus.to_JSON())))
|
||||||
|
|
||||||
|
if len(arr) != 0:
|
||||||
|
return Response(response=json.dumps(arr),
|
||||||
|
status=200,
|
||||||
|
mimetype="application/json")
|
||||||
|
else:
|
||||||
|
return Response(response=[],
|
||||||
|
status=200,
|
||||||
|
mimetype="application/json")
|
||||||
|
|
||||||
|
@campus_routes.route('/api/campuses/getCampusesByUserID/', defaults={'token': None, 'id': None})
|
||||||
|
@campus_routes.route('/api/campuses/getCampusesByUserID/<string:token>/<string:id>', methods=['GET'])
|
||||||
|
@auto.doc()
|
||||||
|
def getCampusesByUserID(token, id):
|
||||||
|
"""
|
||||||
|
<span class="card-title">This Call will return an array of all Campuses of a certain User By ID</span>
|
||||||
|
<br>
|
||||||
|
<b>Route Parameters</b><br>
|
||||||
|
- token: 'seToken' of requesting user
|
||||||
|
- The ID of <b>Wanted</b> User Campuses
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<b>Payload</b><br>
|
||||||
|
- NONE <br>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<b>Response</b>
|
||||||
|
<br>
|
||||||
|
200 - JSON Array, Example:<br>
|
||||||
|
[<br>
|
||||||
|
{
|
||||||
|
'title': 'JCE',<br>
|
||||||
|
'email_ending': '@post.jce.ac.il',<br>
|
||||||
|
'master_user_id': 123453433341, (User that created the campus)<br>
|
||||||
|
'avatar_url': 'http://some.domain.com/imagefile.jpg',<br>
|
||||||
|
'id' : 1234567890<br>
|
||||||
|
},<br>
|
||||||
|
....<br>
|
||||||
|
{<br>
|
||||||
|
...<br>
|
||||||
|
}req<br>
|
||||||
|
]<br>
|
||||||
|
<br>
|
||||||
|
403 - Invalid Token<br>
|
||||||
|
"""
|
||||||
|
|
||||||
|
user = get_user_by_token(token)
|
||||||
|
if user is None:
|
||||||
|
return forbidden("Invalid Token")
|
||||||
|
|
||||||
|
user = get_user_by_id(int(id))
|
||||||
|
if user is None:
|
||||||
|
return no_content("No User")
|
||||||
|
|
||||||
|
arr = []
|
||||||
|
for i in user.campuses_id_list:
|
||||||
campus = Campus.get_by_id(int(i))
|
campus = Campus.get_by_id(int(i))
|
||||||
arr.append(dict(json.loads(campus.to_JSON())))
|
arr.append(dict(json.loads(campus.to_JSON())))
|
||||||
|
|
||||||
|
|
|
@ -268,6 +268,66 @@ def getUserByToken(token):
|
||||||
status=200,
|
status=200,
|
||||||
mimetype="application/json") # Real response!
|
mimetype="application/json") # Real response!
|
||||||
|
|
||||||
|
return no_content("No User Found")
|
||||||
|
|
||||||
|
@user_routes.route('/api/users/getUserById/', defaults={'token': None, 'id': None})
|
||||||
|
@user_routes.route('/api/users/getUserById/<string:token>/<string:id>', methods=["GET"])
|
||||||
|
@auto.doc()
|
||||||
|
def getUserById(token, id):
|
||||||
|
"""
|
||||||
|
<span class="card-title">>This Call will return a user by a given UserId</span>
|
||||||
|
<br>
|
||||||
|
<b>Route Parameters</b><br>
|
||||||
|
- seToken: 'seToken'
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<b>Payload</b><br>
|
||||||
|
- NONE
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<b>Response</b>
|
||||||
|
<br>
|
||||||
|
200 - JSON Example:<br>
|
||||||
|
<code>
|
||||||
|
{<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': [{<br>
|
||||||
|
'master_user_id': 111,<br>
|
||||||
|
'id': 5629499534213120,<br>
|
||||||
|
'email_ending': "@post.jce.ac.il",<br>
|
||||||
|
'avatar_url': "https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg",<br>
|
||||||
|
'title': "JCE"
|
||||||
|
}],<br>
|
||||||
|
'courses_id_list': ['a','b','c'],<br>
|
||||||
|
'id': 234253523<br>
|
||||||
|
}<br>
|
||||||
|
</code>
|
||||||
|
<br>
|
||||||
|
403 - No User Found
|
||||||
|
"""
|
||||||
|
if token is None or id is None:
|
||||||
|
return no_content("No Token/ID, No User Found")
|
||||||
|
|
||||||
|
if get_user_by_token(token) is None:
|
||||||
|
return forbidden('Invalid Token')
|
||||||
|
|
||||||
|
u = get_user_by_id(int(id))
|
||||||
|
if u is None:
|
||||||
|
return no_content('No user Found')
|
||||||
|
|
||||||
|
for index, c in enumerate(u.campuses_id_list):
|
||||||
|
c = json.loads(Campus.get_by_id(int(c)).to_JSON())
|
||||||
|
u.campuses_id_list[index] = c
|
||||||
|
|
||||||
|
return Response(response=u.to_JSON(),
|
||||||
|
status=200,
|
||||||
|
mimetype="application/json") # Real response!
|
||||||
|
|
||||||
return no_content("No User Found")
|
return no_content("No User Found")
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,10 @@ def get_user_by_token(token):
|
||||||
return u
|
return u
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_user_by_id(id):
|
||||||
|
u = User.get_by_id(id)
|
||||||
|
return u
|
||||||
|
|
||||||
def get_campus_by_campusName(campusName):
|
def get_campus_by_campusName(campusName):
|
||||||
query = Campus.all()
|
query = Campus.all()
|
||||||
query.filter("title = ", campusName)
|
query.filter("title = ", campusName)
|
||||||
|
|
|
@ -54,8 +54,8 @@
|
||||||
SE-Hub Docs Index
|
SE-Hub Docs Index
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
|
<center>
|
||||||
<div>
|
<div style="width: 40%">
|
||||||
<ul class="collection">
|
<ul class="collection">
|
||||||
<li class="collection-item dismissable"><div>Users Related API<a href="/api/users/help" class="secondary-content"><i class="mdi-content-send"></i></a></div></li>
|
<li class="collection-item dismissable"><div>Users Related API<a href="/api/users/help" class="secondary-content"><i class="mdi-content-send"></i></a></div></li>
|
||||||
<li class="collection-item dismissable"><div>Campuses Related API<a href="/api/campuses/help" class="secondary-content"><i class="mdi-content-send"></i></a></div></li>
|
<li class="collection-item dismissable"><div>Campuses Related API<a href="/api/campuses/help" class="secondary-content"><i class="mdi-content-send"></i></a></div></li>
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
<li class="collection-item dismissable"><div>Miscellaneous Methods<a href="/api/help/misc" class="secondary-content"><i class="mdi-content-send"></i></a></div></li>
|
<li class="collection-item dismissable"><div>Miscellaneous Methods<a href="/api/help/misc" class="secondary-content"><i class="mdi-content-send"></i></a></div></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
</center>
|
||||||
<footer class="page-footer">
|
<footer class="page-footer">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
@ -46,7 +46,7 @@ app.config(['$routeProvider', '$locationProvider',
|
||||||
templateUrl: 'templates/views/tasks.html',
|
templateUrl: 'templates/views/tasks.html',
|
||||||
controller: 'tasksController'
|
controller: 'tasksController'
|
||||||
})
|
})
|
||||||
.when('/myClasses', {
|
.when('/myClasses/:campusId', {
|
||||||
templateUrl: 'templates/views/myClasses.html',
|
templateUrl: 'templates/views/myClasses.html',
|
||||||
controller: 'myClassesController'
|
controller: 'myClassesController'
|
||||||
})
|
})
|
||||||
|
@ -54,7 +54,7 @@ app.config(['$routeProvider', '$locationProvider',
|
||||||
templateUrl: 'templates/views/newTask.html',
|
templateUrl: 'templates/views/newTask.html',
|
||||||
controller: 'newTasksController'
|
controller: 'newTasksController'
|
||||||
})
|
})
|
||||||
.when('/projects', {
|
.when('/projects/:classId', {
|
||||||
templateUrl: 'templates/views/projects.html',
|
templateUrl: 'templates/views/projects.html',
|
||||||
controller: 'projectsController'
|
controller: 'projectsController'
|
||||||
})
|
})
|
||||||
|
|
|
@ -23,20 +23,15 @@ angular.module('SeHub')
|
||||||
"style": "selected",
|
"style": "selected",
|
||||||
"route": "/home"
|
"route": "/home"
|
||||||
}, {
|
}, {
|
||||||
"title": "My Campuses",
|
"title": "Courses",
|
||||||
"icon": "fa fa-university",
|
"icon": "fa fa-graduation-cap",
|
||||||
"style": "",
|
"style": "",
|
||||||
"route": "/campuses"
|
"route": "/campuses"
|
||||||
}, {
|
}, {
|
||||||
"title": "My Classes",
|
"title": "Projects",
|
||||||
"icon": "fa fa-graduation-cap",
|
|
||||||
"style": "",
|
|
||||||
"route": "/myClasses"
|
|
||||||
}, {
|
|
||||||
"title": "My Projects",
|
|
||||||
"icon": "fa fa-cube",
|
"icon": "fa fa-cube",
|
||||||
"style": "",
|
"style": "",
|
||||||
"route": "/projects"
|
"route": "/myClasses"
|
||||||
}, {
|
}, {
|
||||||
"title": "Tasks",
|
"title": "Tasks",
|
||||||
"icon": "fa fa-clipboard",
|
"icon": "fa fa-clipboard",
|
||||||
|
|
|
@ -4,28 +4,30 @@ angular.module('SeHub')
|
||||||
function($scope, $rootScope, dataService, apiService, $cookies, $location, $routeParams) {
|
function($scope, $rootScope, dataService, apiService, $cookies, $location, $routeParams) {
|
||||||
|
|
||||||
var token = $cookies['com.sehub.www'];
|
var token = $cookies['com.sehub.www'];
|
||||||
|
var id = $routeParams.id;
|
||||||
$scope.loadingData = true;
|
$scope.loadingData = true;
|
||||||
$scope.isInRegisterMode = false;
|
$scope.isInRegisterMode = false;
|
||||||
|
|
||||||
$scope.title = "Profile " + $routeParams.id;
|
$scope.title = "Profile";
|
||||||
|
|
||||||
apiService.getUserByToken(token).success(function(data) {
|
apiService.getUserById(token, id).success(function(data) {
|
||||||
if (data.message == 'No User Found') {
|
if (data.message == 'No User Found') {
|
||||||
console.error("No User Found!");
|
console.error("No User Found!");
|
||||||
}
|
}
|
||||||
$scope.loadingData = false;
|
|
||||||
$scope.user = data;
|
$scope.user = data;
|
||||||
|
apiService.getCampusesByUserId(token, id).success(function(data) {
|
||||||
|
$scope.campuses = data;
|
||||||
console.log(data);
|
console.log(data);
|
||||||
if ($scope.user.isFirstLogin) {
|
|
||||||
$scope.menuObj = {};
|
|
||||||
$scope.isInRegisterMode = true;
|
|
||||||
$scope.loadingData = false;
|
$scope.loadingData = false;
|
||||||
$location.path('/register')
|
}).error(function(err) {
|
||||||
}
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$scope.isEditMode = false;
|
$scope.isEditMode = false;
|
||||||
$scope.profileMode = "Edit Profile";
|
$scope.profileMode = "Edit Profile";
|
||||||
$scope.profileModeIcon = "fa fa-pencil";
|
$scope.profileModeIcon = "fa fa-pencil";
|
||||||
|
@ -68,17 +70,17 @@ angular.module('SeHub')
|
||||||
"campus_avatar": "https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg"
|
"campus_avatar": "https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg"
|
||||||
}];
|
}];
|
||||||
|
|
||||||
$scope.campuses = [{
|
// $scope.campuses = [{
|
||||||
'title': 'JCE',
|
// 'title': 'JCE',
|
||||||
'email_ending': '@post.jce.ac.il',
|
// 'email_ending': '@post.jce.ac.il',
|
||||||
'master_user_id': 123453433341,
|
// 'master_user_id': 123453433341,
|
||||||
'avatar_url': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg'
|
// 'avatar_url': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg'
|
||||||
}, {
|
// }, {
|
||||||
'title': 'Stanford',
|
// 'title': 'Stanford',
|
||||||
'email_ending': '@post.jce.ac.il',
|
// 'email_ending': '@post.jce.ac.il',
|
||||||
'master_user_id': 123453433341,
|
// 'master_user_id': 123453433341,
|
||||||
'avatar_url': 'https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcR9M4uQgaJP1zyiCGw-dK31hU8buWqeuOi9vTXBd4Y8hQcFTZqA'
|
// 'avatar_url': 'https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcR9M4uQgaJP1zyiCGw-dK31hU8buWqeuOi9vTXBd4Y8hQcFTZqA'
|
||||||
}];
|
// }];
|
||||||
|
|
||||||
|
|
||||||
$scope.labels = ['Commits', 'Issues Assigned', 'Messages', 'Open Tasks'];
|
$scope.labels = ['Commits', 'Issues Assigned', 'Messages', 'Open Tasks'];
|
||||||
|
@ -89,9 +91,7 @@ angular.module('SeHub')
|
||||||
[28, 48, 40, 3]
|
[28, 48, 40, 3]
|
||||||
];
|
];
|
||||||
|
|
||||||
$scope.isUser = function(){
|
$scope.isUser = $scope.$parent.user.id.toString() /*The Actual User*/ === $routeParams.id /*The Profile User*/;
|
||||||
return $scope.user.id.toString() === $routeParams.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
|
@ -48,14 +48,25 @@ service.factory('apiService', ['$http', function($http) {
|
||||||
req = {
|
req = {
|
||||||
method : "GET",
|
method : "GET",
|
||||||
url : url
|
url : url
|
||||||
|
|
||||||
};
|
};
|
||||||
return $http(req);
|
return $http(req);
|
||||||
},
|
},
|
||||||
getAllMessages: function(){
|
getAllCourses: function(token){
|
||||||
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAll/" + token;
|
||||||
|
req = {
|
||||||
|
method : "GET",
|
||||||
|
url : url
|
||||||
|
|
||||||
|
};
|
||||||
|
return $http(req);
|
||||||
|
},
|
||||||
|
getAllMessages: function(token){
|
||||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAllMessages/" + token;
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAllMessages/" + token;
|
||||||
req = {
|
req = {
|
||||||
method : "GET",
|
method : "GET",
|
||||||
url : url
|
url : url
|
||||||
|
|
||||||
};
|
};
|
||||||
return $http(req);
|
return $http(req);
|
||||||
},
|
},
|
||||||
|
@ -65,6 +76,7 @@ service.factory('apiService', ['$http', function($http) {
|
||||||
method : "POST",
|
method : "POST",
|
||||||
url : url,
|
url : url,
|
||||||
data: payLoad
|
data: payLoad
|
||||||
|
|
||||||
};
|
};
|
||||||
return $http(req);
|
return $http(req);
|
||||||
},
|
},
|
||||||
|
@ -73,6 +85,7 @@ service.factory('apiService', ['$http', function($http) {
|
||||||
req = {
|
req = {
|
||||||
method : "GET",
|
method : "GET",
|
||||||
url : url
|
url : url
|
||||||
|
|
||||||
};
|
};
|
||||||
return $http(req);
|
return $http(req);
|
||||||
},
|
},
|
||||||
|
@ -82,14 +95,18 @@ service.factory('apiService', ['$http', function($http) {
|
||||||
method : "POST",
|
method : "POST",
|
||||||
url : url,
|
url : url,
|
||||||
data: payLoad
|
data: payLoad
|
||||||
|
|
||||||
};
|
};
|
||||||
return $http(req);
|
return $http(req);
|
||||||
},
|
},
|
||||||
getCampusesByUser: function(token){
|
getCampusesByUser: function(token){
|
||||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCampusesByUser/" + token;
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCampusesByUser/" + token;
|
||||||
|
getCampusesByUser: function(token){
|
||||||
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/campuses/getCampusesByUser/" + token;
|
||||||
req = {
|
req = {
|
||||||
method : "GET",
|
method : "GET",
|
||||||
url : url
|
url : url
|
||||||
|
|
||||||
};
|
};
|
||||||
return $http(req);
|
return $http(req);
|
||||||
},
|
},
|
||||||
|
@ -98,6 +115,7 @@ service.factory('apiService', ['$http', function($http) {
|
||||||
req = {
|
req = {
|
||||||
method : "GET",
|
method : "GET",
|
||||||
url : url
|
url : url
|
||||||
|
|
||||||
};
|
};
|
||||||
return $http(req);
|
return $http(req);
|
||||||
},
|
},
|
||||||
|
@ -106,6 +124,24 @@ service.factory('apiService', ['$http', function($http) {
|
||||||
req = {
|
req = {
|
||||||
method : "GET",
|
method : "GET",
|
||||||
url : url
|
url : url
|
||||||
|
|
||||||
|
};
|
||||||
|
return $http(req);
|
||||||
|
},
|
||||||
|
getUserById: function(token, id){
|
||||||
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/users/getUserById/" + token + "/" + id;
|
||||||
|
req = {
|
||||||
|
method : "GET",
|
||||||
|
url : url
|
||||||
|
};
|
||||||
|
return $http(req);
|
||||||
|
},
|
||||||
|
getCampusesByUserId: function(token, id){
|
||||||
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/campuses/getCampusesByUserID/" + token + "/" + id;
|
||||||
|
req = {
|
||||||
|
method : "GET",
|
||||||
|
url : url
|
||||||
|
|
||||||
};
|
};
|
||||||
return $http(req);
|
return $http(req);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<div>
|
<div>
|
||||||
<div class="loader" ng-if="loadingData">
|
<div class="loader" ng-if="loadingData" layout="row" layout-align="center">
|
||||||
|
|
||||||
<md-progress-circular md-mode="indeterminate"></md-progress-circular>
|
<md-progress-circular md-mode="indeterminate"></md-progress-circular>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<md-content layout-padding>
|
<md-content layout-padding>
|
||||||
<md-card layout-padding>
|
<md-card layout-padding>
|
||||||
|
@ -15,7 +17,7 @@
|
||||||
<img ng-src="{{user.avatar_url}}" alt="" style="width:20%">
|
<img ng-src="{{user.avatar_url}}" alt="" style="width:20%">
|
||||||
</div>
|
</div>
|
||||||
<div flex="70%">
|
<div flex="70%">
|
||||||
<md-button class="md-raised" ng-click="changeProfileMode()" ng-if="isUser()">
|
<md-button class="md-raised" ng-click="changeProfileMode()" ng-if="isUser">
|
||||||
<i ng-class="profileModeIcon"></i> {{profileMode}}
|
<i ng-class="profileModeIcon"></i> {{profileMode}}
|
||||||
</md-button>
|
</md-button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -78,7 +80,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="spacer"></div>
|
<div class="spacer"></div>
|
||||||
<div>
|
<div>
|
||||||
<md-button class="">
|
<md-button class="" ng-if="isUser">
|
||||||
X
|
X
|
||||||
</md-button>
|
</md-button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -96,11 +98,11 @@
|
||||||
<img alt="{{ person.name }}" ng-src="{{ campus.avatar_url }}" class="md-avatar" />
|
<img alt="{{ person.name }}" ng-src="{{ campus.avatar_url }}" class="md-avatar" />
|
||||||
</div>
|
</div>
|
||||||
<div class="port_spacer">
|
<div class="port_spacer">
|
||||||
{{ campus.title }} -
|
<strong>{{ campus.title }}</strong> {{campus.email_ending}}
|
||||||
</div>
|
</div>
|
||||||
<div class="spacer"></div>
|
<div class="spacer"></div>
|
||||||
<div>
|
<div>
|
||||||
<md-button class="">
|
<md-button class="" ng-if="isUser">
|
||||||
X
|
X
|
||||||
</md-button>
|
</md-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue