Merge branch 'master' of https://github.com/sagidayan/SE-Hub into QA
This commit is contained in:
commit
ddfbbc04fe
42 changed files with 2569 additions and 972 deletions
|
@ -30,6 +30,7 @@ from SE_API.CampusRoutes import campus_routes
|
|||
from SE_API.CourseRoutes import course_routes
|
||||
from SE_API.ProjectRoutes import project_routes
|
||||
from SE_API.TaskRoutes import task_routes
|
||||
from SE_API.MessageRoutes import message_routes
|
||||
|
||||
|
||||
|
||||
|
@ -51,6 +52,7 @@ app.register_blueprint(campus_routes)
|
|||
app.register_blueprint(course_routes)
|
||||
app.register_blueprint(project_routes)
|
||||
app.register_blueprint(task_routes)
|
||||
app.register_blueprint(message_routes)
|
||||
|
||||
auto = Autodoc(app)
|
||||
|
||||
|
@ -137,12 +139,12 @@ def send_activation(token):
|
|||
return Response(status=200)
|
||||
|
||||
@app.route('/api/help')
|
||||
def documentation():
|
||||
def documentation_index():
|
||||
return app.send_static_file('API_Doc/api_doc_index.html')
|
||||
|
||||
# @app.route('/api/help/campuses')
|
||||
# def documentation():
|
||||
# return auto.html()
|
||||
@app.route('/api/help/misc')
|
||||
def documentation_misc():
|
||||
return auto.html()
|
||||
|
||||
@app.route('/home')
|
||||
def returnHome():
|
||||
|
|
|
@ -76,9 +76,10 @@ def create_campus(token):
|
|||
print e
|
||||
|
||||
user = get_user_by_token(token)
|
||||
|
||||
arr = []
|
||||
arr.append(str(user.key().id()))
|
||||
try:
|
||||
campus = Campus(title=payload['title'], email_ending=payload['email_ending'], master_user_id=user.key().id(), avatar_url=payload['avatar_url'])
|
||||
campus = Campus(title=payload['title'], email_ending=payload['email_ending'], master_user_id=user.key().id(), avatar_url=payload['avatar_url'], membersId=arr)
|
||||
except Exception:
|
||||
return bad_request()
|
||||
|
||||
|
@ -94,6 +95,53 @@ def create_campus(token):
|
|||
# PUT
|
||||
#----------------------------------------------------------
|
||||
|
||||
@campus_routes.route('/api/campuses/joinCampus/<string:token>/<string:campusId>', methods=["PUT"])
|
||||
@auto.doc()
|
||||
def joinCampus(token, campusId):
|
||||
"""
|
||||
<span class="card-title">This call will add the user (by token) to a specific campus</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'<br>
|
||||
- campusId: 123456789
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
- None <br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
<br>
|
||||
202 - Accepted
|
||||
<br>
|
||||
400 - Bad Request
|
||||
<br>
|
||||
403 - Invalid token or not a lecturer
|
||||
"""
|
||||
|
||||
user = get_user_by_token(token)
|
||||
if user is None:
|
||||
return bad_request("Wrong user Token")
|
||||
|
||||
campus = Campus.get_by_id(int(campusId))
|
||||
if campus is None:
|
||||
return bad_request("No such course")
|
||||
|
||||
if str(user.key().id()) in campus.membersId:
|
||||
return bad_request("User is already member in Project")
|
||||
|
||||
campus.membersId.append(str(user.key().id()))
|
||||
user.courses_id_list.append(str(campus.key().id()))
|
||||
|
||||
db.put(campus)
|
||||
db.put(user)
|
||||
db.save
|
||||
|
||||
return Response(response=campus.to_JSON(),
|
||||
status=202,
|
||||
mimetype="application/json")
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------
|
||||
# GET
|
||||
#----------------------------------------------------------
|
||||
|
@ -153,20 +201,130 @@ def get_campuses(token):
|
|||
return forbidden("Invalid Token")
|
||||
|
||||
|
||||
@campus_routes.route('/api/campuses/getCampusesByUser/<string:token>', methods=['GET'])
|
||||
@auto.doc()
|
||||
def getCampusesByUser(token):
|
||||
"""
|
||||
<span class="card-title">This Call will return an array of all Campuses of a certain User</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'
|
||||
<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 bad_request("Bad user Token")
|
||||
|
||||
arr = []
|
||||
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))
|
||||
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")
|
||||
|
||||
#----------------------------------------------------------
|
||||
# DELETE
|
||||
#----------------------------------------------------------
|
||||
|
||||
|
||||
@campus_routes.route('/api/campuses/deleteCampus/<string:token>/<string:campusid>', methods=['DELETE'])
|
||||
@campus_routes.route('/api/campuses/deleteCampus/<string:token>/<string:campusId>', methods=['DELETE'])
|
||||
@auto.doc()
|
||||
def deleteCampus(token,campusid):
|
||||
def deleteCampus(token,campusId):
|
||||
"""
|
||||
<span class="card-title">This Call will delete a specific campus</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'
|
||||
- campusid: 'campusid'
|
||||
- campusId: 1234567890
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
|
@ -192,7 +350,7 @@ def deleteCampus(token,campusid):
|
|||
return forbidden("Invalid token or not a lecturer!")
|
||||
|
||||
user = get_user_by_token(token)
|
||||
camp = Campus.get_by_id(int(campusid))
|
||||
camp = Campus.get_by_id(int(campusId))
|
||||
|
||||
if camp is None:
|
||||
return bad_request("no such campus")
|
||||
|
|
|
@ -47,13 +47,12 @@ def create_course(token):
|
|||
<br>
|
||||
<b>Payload</b><br>
|
||||
- JSON Object, Example: <br>
|
||||
{<br>
|
||||
'courseName': 'Advance Math',<br>
|
||||
'campusName': 'JCE',<br>
|
||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3}<br>
|
||||
'endDate': {'year': 2016, 'month' : 5, 'day' : 14}<br>
|
||||
'taskFlag': false<br>
|
||||
}<br>
|
||||
{<br>
|
||||
'courseName': 'Advance Math',<br>
|
||||
'campusId': 1234567890,<br>
|
||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},<br>
|
||||
'endDate': {'year': 2016, 'month' : 5, 'day' : 14}<br>
|
||||
}<br>
|
||||
<br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
|
@ -75,7 +74,7 @@ def create_course(token):
|
|||
try:
|
||||
payload = json.loads(request.data)
|
||||
except Exception as e:
|
||||
return bad_request()
|
||||
return bad_request("incorrect JSON format")
|
||||
|
||||
try:
|
||||
start_date = datetime.date(payload['startDate']['year'],payload['startDate']['month'],payload['startDate']['day'])
|
||||
|
@ -84,11 +83,12 @@ def create_course(token):
|
|||
if end_date <= start_date:
|
||||
return bad_request("end date cant be before (or same day) start date")
|
||||
|
||||
course = Course(courseName=payload['courseName'], campusName=payload['campusName'], master_id=user.key().id(),
|
||||
course = Course(courseName=payload['courseName'], campusId=payload['campusId'], master_id=user.key().id(),
|
||||
startDate=start_date, endDate=end_date)
|
||||
#check if name already exists
|
||||
try:
|
||||
query = Course.all()
|
||||
query.filter('campusId = ', payload['campusId'])
|
||||
query.filter("courseName = ", payload['courseName'])
|
||||
for c in query.run(limit=1):
|
||||
return forbidden("Course with same name already exists")
|
||||
|
@ -98,66 +98,70 @@ def create_course(token):
|
|||
|
||||
except Exception as e:
|
||||
print e
|
||||
return bad_request()
|
||||
return bad_request(2)
|
||||
|
||||
#add user to course membersId list
|
||||
course.membersId.append(str(user.key().id()))
|
||||
db.put(course)
|
||||
|
||||
#add course to user course list
|
||||
user.courses_id_list.append(str(course.key().id()))
|
||||
db.put(user)
|
||||
|
||||
db.save
|
||||
return Response(response=course.to_JSON(),
|
||||
status=201,
|
||||
mimetype="application/json")
|
||||
|
||||
|
||||
#----------------------------------------------------------
|
||||
# PUT
|
||||
#----------------------------------------------------------
|
||||
|
||||
|
||||
@course_routes.route('/api/courses/createMessage/<string:token>', methods=['POST'])
|
||||
@course_routes.route('/api/courses/joinCourse/<string:token>/<string:courseId>', methods=["PUT"])
|
||||
@auto.doc()
|
||||
def createMessage(token):
|
||||
def joinCourse(token, courseId):
|
||||
"""
|
||||
<span class="card-title">This call will create a new Message in the DB</span>
|
||||
<span class="card-title">This call will add the user (by token) to a specific course</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'
|
||||
- seToken: 'seToken'<br>
|
||||
- courseId: 123456789
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
- JSON Object, Example: <br>
|
||||
{<br>
|
||||
'courseName': 'Advance Math',<br>
|
||||
'message': 'The lecture today is canceled'<br>
|
||||
}<br>
|
||||
<br>
|
||||
- None <br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
<br>
|
||||
201 - Created
|
||||
202 - Accepted
|
||||
<br>
|
||||
400 - Bad Request
|
||||
<br>
|
||||
403 - Invalid token or not a lecturer
|
||||
"""
|
||||
if not request.data:
|
||||
return bad_request("no data")
|
||||
if not is_lecturer(token): #todo: change to lecturer id
|
||||
return forbidden("Invalid token or not a lecturer!")
|
||||
|
||||
user = get_user_by_token(token)
|
||||
if user is None:
|
||||
return bad_request("Wrong user Token")
|
||||
|
||||
#try to parse payload
|
||||
try:
|
||||
payload = json.loads(request.data)
|
||||
except Exception as e:
|
||||
return bad_request("here")
|
||||
course = Course.get_by_id(int(courseId))
|
||||
if course is None:
|
||||
return bad_request("No such course")
|
||||
|
||||
try:
|
||||
msg = Message(courseName=payload['courseName'], message=payload['message'], msgDate=datetime.datetime.now())
|
||||
except Exception as e:
|
||||
print e
|
||||
return bad_request("there")
|
||||
if str(user.key().id()) in course.membersId:
|
||||
return bad_request("User is already member in Course")
|
||||
|
||||
db.save(msg)
|
||||
course.membersId.append(str(user.key().id()))
|
||||
user.courses_id_list.append(str(course.key().id()))
|
||||
|
||||
db.put(course)
|
||||
db.put(user)
|
||||
db.save
|
||||
return created()
|
||||
|
||||
return Response(response=course.to_JSON(),
|
||||
status=202,
|
||||
mimetype="application/json")
|
||||
|
||||
|
||||
#----------------------------------------------------------
|
||||
|
@ -165,14 +169,14 @@ def createMessage(token):
|
|||
#----------------------------------------------------------
|
||||
|
||||
|
||||
@course_routes.route('/api/courses/getCourseByCampusName/<string:name>', methods=["GET"])
|
||||
@course_routes.route('/api/courses/getAllCoursesByCampus/<string:token>/<string:campusId>', methods=["GET"])
|
||||
@auto.doc()
|
||||
def getCourseByCampusName(name):
|
||||
def getAllCoursesByCampus(token, campusId):
|
||||
"""
|
||||
<span class="card-title">>This Call will return an array of all courses in a given campus</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- name: 'campus name'
|
||||
- campusId: 1234567890
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
|
@ -185,7 +189,7 @@ def getCourseByCampusName(name):
|
|||
<code>
|
||||
{<br>
|
||||
'courseName': 'Advance Math',<br>
|
||||
'campusName': 'JCE',<br>
|
||||
'campusId': 1234567890,<br>
|
||||
'startDate': '2015-14-3'<br>
|
||||
'endDate': '2015-29-6'<br>
|
||||
'taskFlag': 'False'<br>
|
||||
|
@ -195,9 +199,13 @@ def getCourseByCampusName(name):
|
|||
</code>
|
||||
<br>
|
||||
"""
|
||||
|
||||
if get_user_by_token(token) is None:
|
||||
return bad_request("Bad User Token")
|
||||
|
||||
arr = []
|
||||
query = Course.all()
|
||||
query.filter("campusName=", name)
|
||||
query.filter("campusId = ", int(campusId))
|
||||
|
||||
for c in query.run():
|
||||
arr.append(dict(json.loads(c.to_JSON())))
|
||||
|
@ -211,61 +219,123 @@ def getCourseByCampusName(name):
|
|||
status=200,
|
||||
mimetype="application/json")
|
||||
|
||||
@course_routes.route('/api/courses/getMessagesByCourseName/<string:name>', methods=["GET"])
|
||||
@course_routes.route('/api/courses/getUserCoursesByCampus/<string:token>/<string:campusId>', methods=['GET'])
|
||||
@auto.doc()
|
||||
def getMessagesByCourseName(name):
|
||||
def getUserCoursesByCampus(token, campusId):
|
||||
"""
|
||||
<span class="card-title">>This Call will return an array of all courses in a given campus</span>
|
||||
<span class="card-title">This Call will return an array of all Courses of a certain User in a specific Campus</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- name: 'campus name'
|
||||
- seToken: 'seToken'<br>
|
||||
- campusId: 1234354543<br>
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
- NONE
|
||||
- NONE <br>
|
||||
<br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
<br>
|
||||
200 - JSON Example:<br>
|
||||
<code>
|
||||
{<br>
|
||||
'courseName': 'Advance Math',<br>
|
||||
'campusName': 'JCE',<br>
|
||||
'startDate': '2015-14-3'<br>
|
||||
'endDate': '2015-29-6'<br>
|
||||
'taskFlag': false,<br>
|
||||
'id' : 1234567890<br>
|
||||
|
||||
}
|
||||
</code>
|
||||
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 bad_request("Bad user Token")
|
||||
|
||||
campus = Campus.get_by_id(int(campusId))
|
||||
if campus is None:
|
||||
return bad_request("No such Campus")
|
||||
|
||||
|
||||
arr = []
|
||||
query = Message.all()
|
||||
query.filter("courseName = ", name)
|
||||
|
||||
for m in query.run():
|
||||
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=False)
|
||||
for i in arr:
|
||||
del i['forSortDate']
|
||||
print arr
|
||||
for i in user.courses_id_list:
|
||||
course = Course.get_by_id(int(i))
|
||||
if course.campusId == campus.key().id():
|
||||
arr.append(dict(json.loads(course.to_JSON())))
|
||||
|
||||
if len(arr) != 0:
|
||||
return Response(response=json.dumps(arr),
|
||||
status=200,
|
||||
mimetype="application/json")
|
||||
else:
|
||||
return Response(response=[],
|
||||
return Response(response='[]',
|
||||
status=200,
|
||||
mimetype="application/json")
|
||||
|
||||
|
||||
@course_routes.route('/api/courses/getCoursesByUser/<string:token>/<string:userId>', methods=['GET'])
|
||||
@auto.doc()
|
||||
def getCoursesByUser(token, userId):
|
||||
"""
|
||||
<span class="card-title">This Call will return an array of all Courses of a certain User</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'<br>
|
||||
- userId: 1234354543<br>
|
||||
<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 bad_request("Bad user Token")
|
||||
|
||||
otherUser = User.get_by_id(int(userId))
|
||||
if otherUser is None:
|
||||
return bad_request("Bad user Id")
|
||||
|
||||
arr = []
|
||||
for i in otherUser.courses_id_list:
|
||||
print i
|
||||
course = Course.get_by_id(int(i))
|
||||
arr.append(dict(json.loads(course.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")
|
||||
#----------------------------------------------------------
|
||||
# PUT
|
||||
#----------------------------------------------------------
|
||||
|
@ -281,12 +351,12 @@ def getMessagesByCourseName(name):
|
|||
|
||||
@course_routes.route('/api/courses/deleteCourse/<string:token>/<string:courseid>', methods=['DELETE'])
|
||||
@auto.doc()
|
||||
def deleteCourse(token,courseid):
|
||||
def deleteCourse(token, courseid):
|
||||
"""
|
||||
<span class="card-title">This Call will delete a specific Course</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'
|
||||
- seToken: 'seToken'<br>
|
||||
- courseid: 'courseid'
|
||||
<br>
|
||||
<br>
|
||||
|
@ -327,64 +397,64 @@ def deleteCourse(token,courseid):
|
|||
return forbidden("lecturer is not owner of course")
|
||||
|
||||
|
||||
@course_routes.route('/api/courses/deleteCoursesByCampus/<string:token>/<string:campusName>', methods=['DELETE'])
|
||||
@auto.doc()
|
||||
def deleteCoursesByCampus(token,campusName):
|
||||
"""
|
||||
<span class="card-title">This Call will delete a specific campus's courses</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'
|
||||
- title: 'campusName'
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
- NONE <br>
|
||||
<br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
<br>
|
||||
202 - Deleted campus
|
||||
<br>
|
||||
204 - No Matching Campus Found
|
||||
<br>
|
||||
....<br>
|
||||
{<br>
|
||||
...<br>
|
||||
}req<br>
|
||||
|
||||
]<br>
|
||||
400 - Bad Request
|
||||
<br>
|
||||
403 - Invalid token or not a lecturer!<br>
|
||||
"""
|
||||
|
||||
if not is_lecturer(token): #todo: change to lecturer id
|
||||
return forbidden("Invalid token or not a lecturer!")
|
||||
|
||||
|
||||
user = get_user_by_token(token)
|
||||
campus = get_campus_by_campusName(campusName)
|
||||
if campus is None:
|
||||
return bad_request("Not a campus!")
|
||||
|
||||
#check user is owner of campus
|
||||
if campus.master_user_id != user.key().id():
|
||||
return forbidden("lecturer is not owner of campus!")
|
||||
|
||||
query = Course.all()
|
||||
|
||||
try:
|
||||
query.filter('campusName =', campusName)
|
||||
except Exception as e:
|
||||
print e
|
||||
return bad_request("invalid course title attribute")
|
||||
|
||||
for c in query.run():
|
||||
db.delete(c)
|
||||
db.save
|
||||
|
||||
return no_content()
|
||||
# @course_routes.route('/api/courses/deleteCoursesByCampus/<string:token>/<string:campusid>', methods=['DELETE'])
|
||||
# @auto.doc()
|
||||
# def deleteCoursesByCampus(token,campusName):
|
||||
# """
|
||||
# <span class="card-title">This Call will delete a specific campus's courses</span>
|
||||
# <br>
|
||||
# <b>Route Parameters</b><br>
|
||||
# - seToken: 'seToken'
|
||||
# - title: 'campusName'
|
||||
# <br>
|
||||
# <br>
|
||||
# <b>Payload</b><br>
|
||||
# - NONE <br>
|
||||
# <br>
|
||||
# <br>
|
||||
# <b>Response</b>
|
||||
# <br>
|
||||
# 202 - Deleted campus
|
||||
# <br>
|
||||
# 204 - No Matching Campus Found
|
||||
# <br>
|
||||
# ....<br>
|
||||
# {<br>
|
||||
# ...<br>
|
||||
# }req<br>
|
||||
#
|
||||
# ]<br>
|
||||
# 400 - Bad Request
|
||||
# <br>
|
||||
# 403 - Invalid token or not a lecturer!<br>
|
||||
# """
|
||||
#
|
||||
# if not is_lecturer(token): #todo: change to lecturer id
|
||||
# return forbidden("Invalid token or not a lecturer!")
|
||||
#
|
||||
#
|
||||
# user = get_user_by_token(token)
|
||||
# campus = get_campus_by_campusName(campusName)
|
||||
# if campus is None:
|
||||
# return bad_request("Not a campus!")
|
||||
#
|
||||
# #check user is owner of campus
|
||||
# if campus.master_user_id != user.key().id():
|
||||
# return forbidden("lecturer is not owner of campus!")
|
||||
#
|
||||
# query = Course.all()
|
||||
#
|
||||
# try:
|
||||
# query.filter('campusName =', campusName)
|
||||
# except Exception as e:
|
||||
# print e
|
||||
# return bad_request("invalid course title attribute")
|
||||
#
|
||||
# for c in query.run():
|
||||
# db.delete(c)
|
||||
# db.save
|
||||
#
|
||||
# return no_content()
|
||||
|
||||
|
||||
|
||||
|
|
61
SE_API/GitHub_API_Connector.py
Normal file
61
SE_API/GitHub_API_Connector.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
__author__ = 'sagi'
|
||||
import requests
|
||||
from GithubAPI.GithubAPI import GitHubAPI_Keys
|
||||
|
||||
githubKeys = GitHubAPI_Keys()
|
||||
|
||||
def get_repo_general_info(repo_url):
|
||||
url = 'https://api.github.com/repos/' + repo_url + '?client_id='+githubKeys.getId()+'&client_secret=' + githubKeys.getSecret()
|
||||
req = requests.get(url)
|
||||
return req.json()
|
||||
|
||||
|
||||
def get_repo_stats(repo_url):
|
||||
url = 'https://api.github.com/repos/' + repo_url + '/stats/contributors' + '?client_id='+githubKeys.getId()+'&client_secret=' + githubKeys.getSecret()
|
||||
req = requests.get(url)
|
||||
return req.json()
|
||||
|
||||
|
||||
def get_repo_issues(repo_url):
|
||||
url = 'https://api.github.com/repos/' + repo_url + '/issues' + '?client_id=' + githubKeys.getId() + '&client_secret=' + githubKeys.getSecret()
|
||||
req = requests.get(url)
|
||||
return req.json()
|
||||
|
||||
def get_repo_weekly_commits(repo_url):
|
||||
url = 'https://api.github.com/repos/' + repo_url + '/stats/participation' + '?client_id=' + githubKeys.getId() + '&client_secret=' + githubKeys.getSecret()
|
||||
req = requests.get(url)
|
||||
return req.json()['all']
|
||||
|
||||
def make_macro(stats, info):
|
||||
macro = {'labels': [], 'data': [[0]]}
|
||||
macro['labels'].append('Commits')
|
||||
macro['labels'].append('Open Issues')
|
||||
for stat in stats:
|
||||
macro['data'][0][0] += stat['total']
|
||||
macro['data'][0].append(info['open_issues'])
|
||||
|
||||
return macro
|
||||
|
||||
# def make_micro(stats, info):
|
||||
# micro = {'labels': [], 'data': [[]], 'series': []}
|
||||
# micro['labels'].append('Commits')
|
||||
# micro['labels'].append('Open Issues')
|
||||
# for stat in stats:
|
||||
# micro['data'][0][0] += stat['total']
|
||||
# micro['data'].append(info['open_issues'])
|
||||
#
|
||||
# return micro
|
||||
|
||||
def get_github_data(repo_url):
|
||||
project_info = {'stats': {}}
|
||||
github_stats = get_repo_stats(repo_url) #first Call
|
||||
project_info['info'] = get_repo_general_info(repo_url)
|
||||
issues = get_repo_issues(repo_url)
|
||||
weekly_commits = get_repo_weekly_commits(repo_url)
|
||||
github_stats = get_repo_stats(repo_url) #Second Call
|
||||
project_info['stats']['macro'] = make_macro(github_stats, project_info['info'])
|
||||
|
||||
project_info['stats']['weekly_commits'] = weekly_commits
|
||||
project_info['issues'] = issues
|
||||
|
||||
return project_info
|
246
SE_API/MessageRoutes.py
Normal file
246
SE_API/MessageRoutes.py
Normal file
|
@ -0,0 +1,246 @@
|
|||
__author__ = 'Aran'
|
||||
|
||||
from flask import Blueprint
|
||||
import json
|
||||
from GithubAPI.GithubAPI import GitHubAPI_Keys
|
||||
|
||||
from google.appengine.ext import db
|
||||
import requests
|
||||
import datetime
|
||||
from operator import itemgetter
|
||||
|
||||
|
||||
from flask import Flask, request, render_template, redirect, abort, Response
|
||||
|
||||
from flask.ext.github import GitHub
|
||||
from flask.ext.cors import CORS, cross_origin
|
||||
from flask.ext.autodoc import Autodoc
|
||||
|
||||
# DB Models
|
||||
from models.Course import Course
|
||||
from models.Project import Project
|
||||
from models.Message import Message
|
||||
|
||||
#Validation Utils Libs
|
||||
from SE_API.Validation_Utils import *
|
||||
from SE_API.Respones_Utils import *
|
||||
|
||||
|
||||
|
||||
message_routes = Blueprint("message_routes", __name__)
|
||||
auto = Autodoc()
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------
|
||||
# POST
|
||||
#----------------------------------------------------------
|
||||
|
||||
|
||||
@message_routes.route('/api/messages/create/<string:token>', methods=['POST'])
|
||||
@auto.doc()
|
||||
def createMessage(token):
|
||||
"""
|
||||
<span class="card-title">This call will create a new Message in the DB</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
- JSON Object, Example: <br>
|
||||
{<br>
|
||||
'groupId' : 123456789,<br>
|
||||
'message' : 'Class is canceled',<br>
|
||||
'date' : {<br>
|
||||
'year': 2015,<br>
|
||||
'month': 3,<br>
|
||||
'day': 14,<br>
|
||||
'hour': 16,<br>
|
||||
'minute': 53<br>
|
||||
},<br>
|
||||
'isProject' : true<br>
|
||||
}<br>
|
||||
<br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
<br>
|
||||
201 - Created
|
||||
<br>
|
||||
400 - Bad Request
|
||||
<br>
|
||||
403 - Invalid token or not a lecturer
|
||||
"""
|
||||
if not request.data:
|
||||
return bad_request("no data")
|
||||
if not is_lecturer(token): #todo: change to lecturer id
|
||||
return forbidden("Invalid token or not a lecturer!")
|
||||
|
||||
user = get_user_by_token(token)
|
||||
|
||||
#try to parse payload
|
||||
try:
|
||||
payload = json.loads(request.data)
|
||||
except Exception as e:
|
||||
return bad_request("here")
|
||||
|
||||
try:
|
||||
msg = Message(groupId=payload['groupId'], message=payload['message'], msgDate=datetime.datetime.now(), master_id=user.key().id())
|
||||
except Exception as e:
|
||||
print e
|
||||
return bad_request("there")
|
||||
|
||||
try:
|
||||
msg['isProject'] = payload['isProject']
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
db.put(msg)
|
||||
db.save
|
||||
return created()
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------
|
||||
# PUT
|
||||
#----------------------------------------------------------
|
||||
|
||||
|
||||
#----------------------------------------------------------
|
||||
# GET
|
||||
#----------------------------------------------------------
|
||||
|
||||
@message_routes.route('/api/messages/getMessagesByGroup/<string:token>/<string:groupId>', methods=["GET"])
|
||||
@auto.doc()
|
||||
def getMessagesByGroup(token, groupId):
|
||||
"""
|
||||
<span class="card-title">>This Call will return an array of all messages (sorted by date),<br>
|
||||
for a given group (course or project)</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>
|
||||
'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>
|
||||
}<br>
|
||||
</code>
|
||||
<br>
|
||||
"""
|
||||
if get_user_by_token(token) is None:
|
||||
return bad_request("No such User")
|
||||
|
||||
arr = []
|
||||
query = Message.all()
|
||||
query.filter("groupId = ", int(groupId))
|
||||
|
||||
for m in query.run():
|
||||
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)
|
||||
print arr
|
||||
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
|
||||
#----------------------------------------------------------
|
||||
|
||||
@message_routes.route('/api/messages/deleteMessage/<string:token>/<string:msgId>', methods=["DELETE"])
|
||||
@auto.doc()
|
||||
def deleteMessage(token, msgId):
|
||||
"""
|
||||
<span class="card-title">>This Call will delete a message by owner token</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- SeToken: token
|
||||
- msgId: 1234567890
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
- NONE
|
||||
<br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
<br>
|
||||
200 - JSON Example:<br>
|
||||
<code>
|
||||
{<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>
|
||||
}<br>
|
||||
</code>
|
||||
<br>
|
||||
"""
|
||||
|
||||
user = get_user_by_token(token)
|
||||
if user is None:
|
||||
return bad_request("No such User")
|
||||
|
||||
msg = Message.get_by_id(int(msgId))
|
||||
if msg is None:
|
||||
return bad_request("No such Message")
|
||||
|
||||
if msg.master_id != user.key().id():
|
||||
return forbidden("User is not the Creator of the message")
|
||||
|
||||
db.delete(msg)
|
||||
db.save
|
||||
return no_content()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------
|
||||
# DOCUMENTATION
|
||||
#----------------------------------------------------------
|
||||
|
||||
@message_routes.route('/api/messages/help')
|
||||
def documentation():
|
||||
return auto.html()
|
|
@ -21,6 +21,8 @@ from models.Project import Project
|
|||
from SE_API.Validation_Utils import *
|
||||
from SE_API.Respones_Utils import *
|
||||
|
||||
from GitHub_API_Connector import get_github_data
|
||||
|
||||
project_routes = Blueprint("project_routes", __name__)
|
||||
auto = Autodoc()
|
||||
|
||||
|
@ -42,7 +44,7 @@ def create_project(token):
|
|||
- JSON Object, Example: <br>
|
||||
{<br>
|
||||
'projectName': 'Advance Math',<br>
|
||||
'courseName': 'JCE',<br>
|
||||
'courseId': 1234567890,<br>
|
||||
'logo_url': 'http://location.domain.com/image.jpg',<br>
|
||||
'gitRepository': 'http://location.git.com/somthing'<br>
|
||||
}<br>
|
||||
|
@ -58,23 +60,28 @@ def create_project(token):
|
|||
"""
|
||||
if not request.data:
|
||||
return bad_request()
|
||||
payload = json.loads(request.data)
|
||||
#if not is_lecturer(token): #todo: change to lecturer id
|
||||
# return forbidden("Invalid token or not a lecturer!")
|
||||
try:
|
||||
payload = json.loads(request.data)
|
||||
except Exception as e:
|
||||
return bad_request("invalid JSON format")
|
||||
|
||||
user = get_user_by_token(token)
|
||||
if user is None:
|
||||
return bad_request("Wrong user Token")
|
||||
|
||||
#todo: check legality
|
||||
|
||||
try:
|
||||
project = Project(projectName=payload['projectName'], courseName=payload['courseName'], master_id=user.key().id(), gitRepository=payload['gitRepository'], membersId=[token])
|
||||
project = Project(projectName=payload['projectName'], courseId=payload['courseId'], master_id=user.key().id(), gitRepository=payload['gitRepository'], membersId=[token])
|
||||
except Exception as e:
|
||||
print e
|
||||
return bad_request()
|
||||
|
||||
db.put(project)
|
||||
|
||||
#update user projects list
|
||||
user.projects_id_list.append(str(project.key().id()))
|
||||
|
||||
db.put(user)
|
||||
db.save
|
||||
return Response(response=project.to_JSON(),
|
||||
status=200,
|
||||
|
@ -84,19 +91,118 @@ def create_project(token):
|
|||
# PUT
|
||||
#----------------------------------------------------------
|
||||
|
||||
@project_routes.route('/api/projects/joinProject/<string:token>/<string:projectId>', methods=["PUT"])
|
||||
@auto.doc()
|
||||
def joinProject(token, projectId):
|
||||
"""
|
||||
<span class="card-title">This call will add the user (by token) to a specific project</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'<br>
|
||||
- projectId: 123456789
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
- None <br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
<br>
|
||||
202 - Accepted
|
||||
<br>
|
||||
400 - Bad Request
|
||||
<br>
|
||||
403 - Invalid token or not a lecturer
|
||||
"""
|
||||
|
||||
user = get_user_by_token(token)
|
||||
if user is None:
|
||||
return bad_request("Wrong user Token")
|
||||
|
||||
project = Project.get_by_id(int(projectId))
|
||||
if project is None:
|
||||
return bad_request("No such Project")
|
||||
|
||||
if str(user.key().id()) in project.membersId:
|
||||
return bad_request("User is already member in Project")
|
||||
|
||||
project.membersId.append(str(user.key().id()))
|
||||
|
||||
db.put(project)
|
||||
db.save
|
||||
|
||||
return Response(response=project.to_JSON(),
|
||||
status=202,
|
||||
mimetype="application/json")
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------
|
||||
# GET
|
||||
#----------------------------------------------------------
|
||||
|
||||
@project_routes.route('/api/projects/getProjectsByCourseName/<string:name>', methods=["GET"])
|
||||
@project_routes.route('/api/projects/getProjectsByCourse/<string:token>/<string:courseId>', methods=["GET"])
|
||||
@auto.doc()
|
||||
def getProjectsByCourseName(name):
|
||||
def getProjectsByCourse(token, courseId):
|
||||
"""
|
||||
<span class="card-title">>This Call will return an array of all projects in a given course</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- name: 'course name'
|
||||
- seToken: token<br>
|
||||
- courseId: 1234567890
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
- NONE
|
||||
<br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
<br>
|
||||
200 - JSON Example:<br>
|
||||
<code>
|
||||
{<br>
|
||||
'projectName': 'Advance Math',<br>
|
||||
'courseId': 123456789,<br>
|
||||
'grade': 98,<br>
|
||||
'logo_url': 'http://location.domain.com/image.jpg',<br>
|
||||
'gitRepository': 'repoOwner/repoName',<br>
|
||||
'membersId': ['bob', 'dylan', 'quentin', 'terentino'],<br>
|
||||
'id' : 1234567890<br>
|
||||
}
|
||||
</code>
|
||||
<br>
|
||||
"""
|
||||
|
||||
if get_user_by_token(token) is None:
|
||||
return bad_request("Bad User Token")
|
||||
|
||||
arr = []
|
||||
query = Project.all()
|
||||
query.filter("courseId = ", int(courseId))
|
||||
|
||||
for p in query.run():
|
||||
proj = dict(json.loads(p.to_JSON()))
|
||||
proj['info'] = get_github_data(p.gitRepository)
|
||||
arr.append(proj)
|
||||
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")
|
||||
|
||||
|
||||
|
||||
@project_routes.route('/api/projects/getProjectsByUser/<string:token>', methods=["GET"])
|
||||
@auto.doc()
|
||||
def getProjectsByUser(token):
|
||||
"""
|
||||
<span class="card-title">>This Call will return an array of all projects in a given course</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- token: 'SEToken'
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
|
@ -120,13 +226,18 @@ def getProjectsByCourseName(name):
|
|||
<br>
|
||||
"""
|
||||
|
||||
arr = []
|
||||
query = Project.all()
|
||||
query.filter("courseName = ", name)
|
||||
user = get_user_by_token(token)
|
||||
if user is None:
|
||||
return bad_request("Bad Token")
|
||||
|
||||
|
||||
arr = []
|
||||
for p in user.projects_id_list:
|
||||
project = Project.get_by_id(int(p))
|
||||
projDict = dict(json.loads(project.to_JSON()))
|
||||
projDict['info'] = get_github_data(project.gitRepository)
|
||||
arr.append(projDict)
|
||||
|
||||
for p in query.run():
|
||||
arr.append(dict(json.loads(p.to_JSON())))
|
||||
print arr
|
||||
if len(arr) != 0:
|
||||
return Response(response=json.dumps(arr),
|
||||
status=200,
|
||||
|
@ -144,15 +255,15 @@ def getProjectsByCourseName(name):
|
|||
|
||||
|
||||
|
||||
@project_routes.route('/api/projects/deleteProject/<string:token>/<string:projectid>', methods=['DELETE'])
|
||||
@project_routes.route('/api/projects/deleteProject/<string:token>/<string:projectId>', methods=['DELETE'])
|
||||
@auto.doc()
|
||||
def deleteProject(token,projectid):
|
||||
def deleteProject(token,projectId):
|
||||
"""
|
||||
<span class="card-title">This Call will delete a specific Project</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'
|
||||
- courseid: 'projectid'
|
||||
- projectId: 'projectid'
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
|
@ -178,7 +289,9 @@ def deleteProject(token,projectid):
|
|||
# return forbidden("Invalid token or not a lecturer!")
|
||||
|
||||
user = get_user_by_token(token)
|
||||
p = Project.get_by_id(int(projectid))
|
||||
if user is None:
|
||||
return bad_request("Bad user Token")
|
||||
p = Project.get_by_id(int(projectId))
|
||||
|
||||
if p is None:
|
||||
return bad_request("no such Project")
|
||||
|
|
|
@ -153,14 +153,15 @@ def create_task(token):
|
|||
#----------------------------------------------------------
|
||||
|
||||
|
||||
@task_routes.route('/api/tasks/getAllTasks/<string:courseName>', methods=["GET"])
|
||||
@task_routes.route('/api/tasks/getAllTasksByCourse/<string:token>/<string:courseId>', methods=["GET"])
|
||||
@auto.doc()
|
||||
def getAllTasks(courseName):
|
||||
def getAllTasksByCourse(token, courseId):
|
||||
"""
|
||||
<span class="card-title">>This Call will return an array of all Tasks in a course by date</span>
|
||||
<span class="card-title">>This Call will return an array of all Tasks in a course ordered by date</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- name: 'course name'
|
||||
- SeToken: token<br>
|
||||
- courseId: 1234567890
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
|
@ -173,7 +174,7 @@ def getAllTasks(courseName):
|
|||
<code>
|
||||
{<br>
|
||||
'title' : 'Task1',<br>
|
||||
'courseName' : 'advance Math',<br>
|
||||
'courseId' : 12345678,<br>
|
||||
'description' : 'prepare by sunday',<br>
|
||||
'dueDate' : {
|
||||
'year' : 2015,
|
||||
|
@ -186,10 +187,12 @@ def getAllTasks(courseName):
|
|||
</code>
|
||||
<br>
|
||||
"""
|
||||
if get_user_by_token(token) is None:
|
||||
return bad_request("Bad User Token")
|
||||
|
||||
arr = []
|
||||
query = Task.all()
|
||||
query.filter("courseName = ", courseName)
|
||||
query.filter("courseId = ", courseId)
|
||||
|
||||
for t in query.run():
|
||||
taskDic =dict(json.loads(t.to_JSON()))
|
||||
|
@ -211,14 +214,15 @@ def getAllTasks(courseName):
|
|||
return no_content()
|
||||
|
||||
|
||||
@task_routes.route('/api/tasks/getAllFutureTasks/<string:courseName>', methods=["GET"])
|
||||
@task_routes.route('/api/tasks/getAllFutureTasks/<string:token>/<string:courseId>', methods=["GET"])
|
||||
@auto.doc()
|
||||
def getAllFutureTasks(courseName):
|
||||
def getAllFutureTasks(token, courseId):
|
||||
"""
|
||||
<span class="card-title">>This Call will return an array of all Future Tasks in a course, ordered by date</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- name: 'course name'
|
||||
- SeToken: token<br>
|
||||
- courseId: 1234567890
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
|
@ -245,9 +249,12 @@ def getAllFutureTasks(courseName):
|
|||
<br>
|
||||
"""
|
||||
|
||||
if get_user_by_token(token) is None:
|
||||
return bad_request("Bad User Token")
|
||||
|
||||
arr = []
|
||||
query = Task.all()
|
||||
query.filter("courseName = ", courseName)
|
||||
query.filter("courseId = ", courseId)
|
||||
|
||||
for t in query.run():
|
||||
taskDic =dict(json.loads(t.to_JSON()))
|
||||
|
@ -271,14 +278,15 @@ def getAllFutureTasks(courseName):
|
|||
|
||||
|
||||
|
||||
@task_routes.route('/api/tasks/getTaskComponents/<string:taskId>', methods=["GET"])
|
||||
@task_routes.route('/api/tasks/getTaskComponents/<string:token>/<string:taskId>', methods=["GET"])
|
||||
@auto.doc()
|
||||
def getTaskComponents(taskId):
|
||||
def getTaskComponents(token, taskId):
|
||||
"""
|
||||
<span class="card-title">>This Call will return an array of all components for a given task</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- taskId: integer
|
||||
- SeToken: token<br>
|
||||
- taskId: 1234567890
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
|
@ -311,6 +319,9 @@ def getTaskComponents(taskId):
|
|||
<br>
|
||||
"""
|
||||
|
||||
if get_user_by_token(token) is None:
|
||||
return bad_request("Bad User Token")
|
||||
|
||||
arr = []
|
||||
query = TaskComponent.all()
|
||||
query.filter("taskId = ", taskId)
|
||||
|
@ -336,15 +347,15 @@ def getTaskComponents(taskId):
|
|||
|
||||
|
||||
|
||||
@task_routes.route('/api/tasks/deleteTask/<string:token>/<string:taskid>', methods=['DELETE'])
|
||||
@task_routes.route('/api/tasks/deleteTask/<string:token>/<string:taskId>', methods=['DELETE'])
|
||||
@auto.doc()
|
||||
def deleteTask(token,taskid):
|
||||
def deleteTask(token, taskId):
|
||||
"""
|
||||
<span class="card-title">This Call will delete a specific Task</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'
|
||||
- taskid: 'taskid'
|
||||
- taskId: 'taskid'
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
|
@ -373,7 +384,7 @@ def deleteTask(token,taskid):
|
|||
#return forbidden("lecturer is not owner of course")
|
||||
|
||||
user = get_user_by_token(token)
|
||||
c = Task.get_by_id(int(taskid))
|
||||
c = Task.get_by_id(int(taskId))
|
||||
|
||||
if c is None:
|
||||
return bad_request("no such Task")
|
||||
|
@ -384,15 +395,15 @@ def deleteTask(token,taskid):
|
|||
return accepted("Task deleted")
|
||||
|
||||
|
||||
@task_routes.route('/api/tasks/deleteTaskComponents/<string:token>/<string:taskid>', methods=['DELETE'])
|
||||
@task_routes.route('/api/tasks/deleteTaskComponents/<string:token>/<string:taskId>', methods=['DELETE'])
|
||||
@auto.doc()
|
||||
def deleteTaskComponents(token,taskid):
|
||||
def deleteTaskComponents(token,taskId):
|
||||
"""
|
||||
<span class="card-title">This Call will delete a specific Task's components</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'
|
||||
- taskid: 'taskid'
|
||||
- taskId: 'taskid'
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
|
@ -421,7 +432,7 @@ def deleteTaskComponents(token,taskid):
|
|||
#return forbidden("lecturer is not owner of course")
|
||||
|
||||
user = get_user_by_token(token)
|
||||
t = Task.get_by_id(int(taskid))
|
||||
t = Task.get_by_id(int(taskId))
|
||||
|
||||
if t is None:
|
||||
return bad_request("no such Task")
|
||||
|
|
|
@ -17,6 +17,7 @@ from flask.ext.autodoc import Autodoc
|
|||
# DB Models
|
||||
from models.User import User
|
||||
from models.Course import Course
|
||||
from models.Project import Project
|
||||
|
||||
#Validation Utils Libs
|
||||
from SE_API.Validation_Utils import *
|
||||
|
@ -52,7 +53,6 @@ def updateUser(token):
|
|||
{<br>
|
||||
'name': 'new name',<br>
|
||||
'isLecturer': true,<br>
|
||||
'campusName': 'JCE'<br>
|
||||
}<br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
|
@ -79,10 +79,6 @@ def updateUser(token):
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
user.campusName = payload['campusName']
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
user.isLecturer = payload['isLecturer']
|
||||
|
@ -268,26 +264,267 @@ def getUserByToken(token):
|
|||
status=200,
|
||||
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")
|
||||
|
||||
|
||||
|
||||
@user_routes.route('/api/users/getUsersByCampus/<string:token>/<string:campusId>', methods=["GET"])
|
||||
@auto.doc()
|
||||
def getUsersByCampus(token, campusId):
|
||||
"""
|
||||
<span class="card-title">>This Call will return all users in Campus</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'<br>
|
||||
- campusId: 123456789
|
||||
<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': [75894378,5893482,894032],<br>
|
||||
'courses_id_list': [4324,432432,4324324]<br>
|
||||
}
|
||||
</code>
|
||||
<br>
|
||||
403 - No User Found
|
||||
"""
|
||||
if token is None:
|
||||
return no_content("Token Is Empty, No User Found")
|
||||
|
||||
user = get_user_by_token(token)
|
||||
if user is None:
|
||||
return bad_request("Bad User Token")
|
||||
|
||||
campus = Campus.get_by_id(int(campusId))
|
||||
if campus is None:
|
||||
return bad_request("No such Campus")
|
||||
|
||||
arr = []
|
||||
|
||||
for u in enumerate(campus.membersId):
|
||||
u = json.loads(User.get_by_id(int(u)).to_JSON())
|
||||
arr.append(dict(u))
|
||||
|
||||
if len(arr) != 0:
|
||||
return Response(response=json.dumps(arr),
|
||||
status=200,
|
||||
mimetype="application/json")
|
||||
else:
|
||||
return Response(response=[],
|
||||
status=200,
|
||||
mimetype="application/json")
|
||||
|
||||
|
||||
@user_routes.route('/api/users/getUsersByCourse/<string:token>/<string:courseId>', methods=["GET"])
|
||||
@auto.doc()
|
||||
def getUsersByCourse(token, courseId):
|
||||
"""
|
||||
<span class="card-title">>This Call will return all users in Course</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'<br>
|
||||
- courseId: 123456789
|
||||
<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': [1243567,7583584904],<br>
|
||||
'courses_id_list': [543543,54353453,543543534]<br>
|
||||
}
|
||||
</code>
|
||||
<br>
|
||||
403 - No User Found
|
||||
"""
|
||||
if token is None:
|
||||
return no_content("Token Is Empty, No User Found")
|
||||
|
||||
user = get_user_by_token(token)
|
||||
if user is None:
|
||||
return bad_request("Bad User Token")
|
||||
|
||||
course = Course.get_by_id(int(courseId))
|
||||
if course is None:
|
||||
return bad_request("No such Course")
|
||||
|
||||
arr = []
|
||||
|
||||
for u in enumerate(course.membersId):
|
||||
u = json.loads(User.get_by_id(int(u)).to_JSON())
|
||||
arr.append(dict(u))
|
||||
|
||||
if len(arr) != 0:
|
||||
return Response(response=json.dumps(arr),
|
||||
status=200,
|
||||
mimetype="application/json")
|
||||
else:
|
||||
return Response(response=[],
|
||||
status=200,
|
||||
mimetype="application/json")
|
||||
|
||||
|
||||
@user_routes.route('/api/users/getUsersByProject/<string:token>/<string:projectId>', methods=["GET"])
|
||||
@auto.doc()
|
||||
def getUsersByProject(token, projectId):
|
||||
"""
|
||||
<span class="card-title">>This Call will return all users in Project</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'<br>
|
||||
- projectId: 123456789
|
||||
<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': [43243532532,5325325325,532532342],<br>
|
||||
'courses_id_list': [53523,43432423,432432432432]<br>
|
||||
}
|
||||
</code>
|
||||
<br>
|
||||
403 - No User Found
|
||||
"""
|
||||
if token is None:
|
||||
return no_content("Token Is Empty, No User Found")
|
||||
|
||||
user = get_user_by_token(token)
|
||||
if user is None:
|
||||
return bad_request("Bad User Token")
|
||||
|
||||
project = Project.get_by_id(int(projectId))
|
||||
if project is None:
|
||||
return bad_request("No such Project")
|
||||
|
||||
arr = []
|
||||
|
||||
for u in enumerate(project.membersId):
|
||||
u = json.loads(User.get_by_id(int(u)).to_JSON())
|
||||
arr.append(dict(u))
|
||||
|
||||
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
|
||||
#----------------------------------------------------------
|
||||
|
||||
@user_routes.route('/api/users/removeUserFromCampus/<string:token>/<string:campusId>', methods=["PUT"])
|
||||
@user_routes.route('/api/users/removeUserFromCampus/<string:token>/<string:userId>/<string:campusId>', methods=["PUT"])
|
||||
@auto.doc()
|
||||
def removeUserFromCampus(token, campusId):
|
||||
def removeUserFromCampus(token, userId, campusId):
|
||||
"""
|
||||
<span class="card-title">>This Call will remove a Campus from a user Campus list</span>
|
||||
<span class="card-title">>This Call will remove a user from a campus</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'
|
||||
- seToken: 'seToken'<br>
|
||||
- userId: 0987654321,<br>
|
||||
- 'campusId': 1234567890<br>
|
||||
<br>
|
||||
<br>
|
||||
|
@ -303,18 +540,13 @@ def removeUserFromCampus(token, campusId):
|
|||
400 - Bad Request
|
||||
"""
|
||||
|
||||
if not request.data:
|
||||
return bad_request()
|
||||
requestingUser = get_user_by_token(token)
|
||||
if requestingUser is None:
|
||||
return bad_request("Bad User Token")
|
||||
|
||||
try:
|
||||
payload = json.loads(request.data)
|
||||
except Exception as e:
|
||||
return bad_request()
|
||||
|
||||
if not is_lecturer(token): #todo: change to lecturer id
|
||||
return forbidden("Invalid token or not a lecturer!")
|
||||
|
||||
user = get_user_by_token(token)
|
||||
userToRemove = User.get_by_id(int(userId))
|
||||
if userToRemove is None:
|
||||
return bad_request("No such user to remove")
|
||||
|
||||
#check Campus Exists
|
||||
campus = Campus.get_by_id(int(campusId))
|
||||
|
@ -322,18 +554,20 @@ def removeUserFromCampus(token, campusId):
|
|||
return bad_request("No such Campus!")
|
||||
|
||||
#check if user is owner of Campus
|
||||
if user.key().id() != campus.master_user_id:
|
||||
return forbidden("Lecturer is not owner of course")
|
||||
if requestingUser.key().id() != campus.master_user_id:
|
||||
# check if user want to delete itself
|
||||
if requestingUser.key().id() != userToRemove.key().id():
|
||||
return forbidden("No permission to delete user")
|
||||
|
||||
try:
|
||||
user.campuses_id_list.remove(campusId)
|
||||
userToRemove.campuses_id_list.remove(campusId)
|
||||
except Exception as e:
|
||||
print e
|
||||
return bad_request("user is not listed to this campus")
|
||||
|
||||
db.put(user)
|
||||
|
||||
db.put(userToRemove)
|
||||
db.save
|
||||
return Response(response=user.to_JSON(),
|
||||
return Response(response=userToRemove.to_JSON(),
|
||||
status=200,
|
||||
mimetype="application/json") # Real response!
|
||||
|
||||
|
@ -341,64 +575,128 @@ def removeUserFromCampus(token, campusId):
|
|||
|
||||
|
||||
|
||||
# @user_routes.route('/api/users/removeUserFromCourse/<string:token>/<string:courseId>', methods=["PUT"])
|
||||
# @auto.doc()
|
||||
# def removeUserFromCourse(token, courseId):
|
||||
# """
|
||||
# <span class="card-title">>This Call will remove a Course from a user Campus list</span>
|
||||
# <br>
|
||||
# <b>Route Parameters</b><br>
|
||||
# - seToken: 'seToken'
|
||||
# - 'courseId': 1234567890<br>
|
||||
# <br>
|
||||
# <br>
|
||||
# <b>Payload</b><br>
|
||||
# - NONE
|
||||
# {<br>
|
||||
# }<br>
|
||||
# <br>
|
||||
# <b>Response</b>
|
||||
# <br>
|
||||
# 200 - User updated
|
||||
# <br>
|
||||
# 400 - Bad Request
|
||||
# """
|
||||
#
|
||||
# if not request.data:
|
||||
# return bad_request()
|
||||
#
|
||||
# try:
|
||||
# payload = json.loads(request.data)
|
||||
# except Exception as e:
|
||||
# return bad_request()
|
||||
#
|
||||
# user = get_user_by_token(token)
|
||||
# if user is None:
|
||||
# return bad_request("No such user!")
|
||||
#
|
||||
#
|
||||
# #check Course Exists
|
||||
# course = Course.get_by_id(int(courseId))
|
||||
# if course is None:
|
||||
# return bad_request("No such Course!")
|
||||
#
|
||||
# #check if user is owner of Campus
|
||||
# if user.key().id() != course.master_id:
|
||||
# return forbidden("Lecturer is not owner of course")
|
||||
#
|
||||
# try:
|
||||
# user.campuses_id_list.remove(campusId)
|
||||
# except Exception as e:
|
||||
# print e
|
||||
# return bad_request("user is not listed to this campus")
|
||||
#
|
||||
# db.put(user)
|
||||
# db.save
|
||||
# return Response(response=user.to_JSON(),
|
||||
# status=200,
|
||||
# mimetype="application/json") # Real response!
|
||||
#
|
||||
#
|
||||
|
||||
@user_routes.route('/api/users/removeUserFromCourse/<string:token>/<string:userId>/<string:courseId>', methods=["PUT"])
|
||||
@auto.doc()
|
||||
def removeUserFromCourse(token, userId, courseId):
|
||||
"""
|
||||
<span class="card-title">>This Call will remove a user from a course</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'<br>
|
||||
- userId: 0987654321,<br>
|
||||
- 'courseId': 1234567890<br>
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
- NONE
|
||||
{<br>
|
||||
}<br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
<br>
|
||||
200 - User updated
|
||||
<br>
|
||||
400 - Bad Request
|
||||
"""
|
||||
|
||||
requestingUser = get_user_by_token(token)
|
||||
if requestingUser is None:
|
||||
return bad_request("Bad User Token")
|
||||
|
||||
userToRemove = User.get_by_id(int(userId))
|
||||
if userToRemove is None:
|
||||
return bad_request("No such user to remove")
|
||||
|
||||
#check Course Exists
|
||||
course = Course.get_by_id(int(courseId))
|
||||
if course is None:
|
||||
return bad_request("No such Course!")
|
||||
|
||||
#check if user is owner of Course
|
||||
if requestingUser.key().id() != course.master_id:
|
||||
# check if user want to delete itself
|
||||
if requestingUser.key().id() != userToRemove.key().id():
|
||||
return forbidden("No permission to delete user")
|
||||
|
||||
try:
|
||||
userToRemove.courses_id_list.remove(courseId)
|
||||
course.membersId.remove(userToRemove.key().id())
|
||||
except Exception as e:
|
||||
return bad_request("user is not listed to this course")
|
||||
|
||||
|
||||
|
||||
db.put(userToRemove)
|
||||
db.put(course)
|
||||
db.save
|
||||
return Response(response=userToRemove.to_JSON(),
|
||||
status=200,
|
||||
mimetype="application/json") # Real response!
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@user_routes.route('/api/users/removeUserFromProject/<string:token>/<string:userId>/<string:projectId>', methods=["PUT"])
|
||||
@auto.doc()
|
||||
def removeUserFromProject(token, userId, projectId):
|
||||
"""
|
||||
<span class="card-title">>This Call will remove a user from a project</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'<br>
|
||||
- userId: 0987654321,<br>
|
||||
- 'projectId': 1234567890<br>
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
- NONE
|
||||
{<br>
|
||||
}<br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
<br>
|
||||
200 - User updated
|
||||
<br>
|
||||
400 - Bad Request
|
||||
"""
|
||||
|
||||
requestingUser = get_user_by_token(token)
|
||||
if requestingUser is None:
|
||||
return bad_request("Bad User Token")
|
||||
|
||||
userToRemove = User.get_by_id(int(userId))
|
||||
if userToRemove is None:
|
||||
return bad_request("No such user to remove")
|
||||
|
||||
#check project Exists
|
||||
project = Project.get_by_id(int(projectId))
|
||||
if project is None:
|
||||
return bad_request("No such Project!")
|
||||
|
||||
#check if user is owner of project
|
||||
if requestingUser.key().id() != project.master_id:
|
||||
# check if user want to delete itself
|
||||
if requestingUser.key().id() != userToRemove.key().id():
|
||||
return forbidden("No permission to delete user")
|
||||
|
||||
try:
|
||||
userToRemove.projects_id_list.remove(projectId)
|
||||
project.membersId.remove(userToRemove.key().id())
|
||||
except Exception as e:
|
||||
return bad_request("user is not listed to this project")
|
||||
|
||||
|
||||
|
||||
db.put(userToRemove)
|
||||
db.put(project)
|
||||
db.save
|
||||
return Response(response=userToRemove.to_JSON(),
|
||||
status=200,
|
||||
mimetype="application/json") # Real response!
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -13,6 +13,10 @@ def get_user_by_token(token):
|
|||
return u
|
||||
return None
|
||||
|
||||
def get_user_by_id(id):
|
||||
u = User.get_by_id(id)
|
||||
return u
|
||||
|
||||
def get_campus_by_campusName(campusName):
|
||||
query = Campus.all()
|
||||
query.filter("title = ", campusName)
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
__author__ = 'etye'
|
||||
import unittest
|
||||
import requests
|
||||
import json
|
||||
from Testing.config import __CONFIG__
|
||||
class CoursesTestPlan(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
debug = __CONFIG__['DEBUG']
|
||||
if debug:
|
||||
url = __CONFIG__['PATHS']['DEBUG']
|
||||
else:
|
||||
url = __CONFIG__['PATHS']['PRODUCTION']
|
||||
cls.url_ = url
|
||||
request = requests.get(url+'api/qa/init')
|
||||
if 200 <= request.status_code <= 299:
|
||||
print 'Initialized'
|
||||
|
||||
def test_coursesCreate_Lecturer(self):
|
||||
headers = {'content-type': 'application/json'}
|
||||
url = 'http://se-hub.appspot.com/api/courses/create/_QA_TOKEN_TEST_LECTURER'
|
||||
params = {'seToken': 'seToken' }
|
||||
data = {
|
||||
'courseName': 'QA COURSE',
|
||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||
'projects': '@gay.lord.ultima.multi.omega',
|
||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
||||
}
|
||||
|
||||
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
||||
r = requests.post(url, params=params, data=json.dumps(data), headers=headers)
|
||||
'''
|
||||
payload = {
|
||||
'courseName': 'QA COURSE',
|
||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||
'projects': '@gay.lord.ultima.multi.omega',
|
||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
||||
}
|
||||
'''
|
||||
# r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER'],data=payload)
|
||||
#r = requests.post('http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER',data=payload)
|
||||
#self.assertEquals(r.status_code, 201)
|
||||
|
||||
def test_coursesCreate_InvalidToken(self):
|
||||
headers = {'content-type': 'application/json'}
|
||||
url = self.__class__.url_+'api/courses/create/invalidToken'
|
||||
data = {
|
||||
'courseName': 'QA COURSE',
|
||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||
'projects': '@gay.lord.ultima.multi.omega',
|
||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
||||
}
|
||||
params = {'seToken': 'seToken' }
|
||||
r = requests.post(url, params=params, data=json.dumps(data), headers=headers)
|
||||
self.assertEquals(r.status_code, 403)
|
||||
'''
|
||||
payload = {'courseName': 'Advance Math', 'campusName': 'JCE', 'startDate':'2015-14-3','endDate': '2015-29-6','taskFlag': 'False'}
|
||||
payload = {
|
||||
'courseName': 'QA COURSE',
|
||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||
'projects': '@gay.lord.ultima.multi.omega',
|
||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
||||
}
|
||||
r = requests.post(self.__class__.url_+'api/courses/create/invalidToken',data=payload)
|
||||
'''
|
||||
def test_coursesCreate_Student(self):
|
||||
headers = {'content-type': 'application/json'}
|
||||
url = self.__class__.url_+'api/courses/create/_QA_TOKEN_TEST_STUDENT'
|
||||
params = {'seToken': 'seToken' }
|
||||
data = {
|
||||
'courseName': 'QA COURSE',
|
||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||
'projects': '@gay.lord.ultima.multi.omega',
|
||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
||||
}
|
||||
|
||||
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
||||
r = requests.post(url, params=params, data=json.dumps(data), headers=headers)
|
||||
self.assertEquals(r.status_code, 403, 'message: ' + r.json()['message'])
|
||||
|
||||
def test_getCourseByCampusName(self):
|
||||
r = requests.get(self.__class__.url_+'api/courses/getCourseByCampusName/'+__CONFIG__['TOKENS']['CAMPUS_NAME'])
|
||||
self.assertEquals(r.status_code, 200)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -9,12 +9,15 @@ class Campus(db.Model):
|
|||
avatar_url = db.StringProperty(required=True)
|
||||
email_ending = db.StringProperty(required=True)
|
||||
master_user_id = db.IntegerProperty(required=True)
|
||||
membersId = db.StringListProperty(required=True, default=[])
|
||||
|
||||
|
||||
def to_JSON(self):
|
||||
data = {'title': self.title,
|
||||
'email_ending': self.email_ending,
|
||||
'master_user_id': self.master_user_id,
|
||||
'avatar_url': self.avatar_url,
|
||||
'membersId': self.membersId,
|
||||
'id' : self.key().id()
|
||||
}
|
||||
return json.dumps(data)
|
||||
|
|
|
@ -5,15 +5,16 @@ from google.appengine.ext import db
|
|||
|
||||
class Course(db.Model):
|
||||
courseName = db.StringProperty(required=True)
|
||||
campusName = db.StringProperty(required=True)
|
||||
campusId = db.IntegerProperty(required=True)
|
||||
master_id = db.IntegerProperty(required=True)
|
||||
# projects = db.StringListProperty(required=True,default=[])
|
||||
startDate = db.DateProperty(required=True)
|
||||
endDate = db.DateProperty(required=True)
|
||||
membersId = db.StringListProperty(required=True)
|
||||
|
||||
def to_JSON(self):
|
||||
data = {'courseName' : self.courseName,
|
||||
'campusName' : self.campusName,
|
||||
'campusId' : self.campusId,
|
||||
'master_id' : self.master_id,
|
||||
# 'projects' : self.projects,
|
||||
'startDate' : {
|
||||
|
@ -26,6 +27,7 @@ class Course(db.Model):
|
|||
'month': self.endDate.month,
|
||||
'day': self.endDate.day,
|
||||
},
|
||||
'membersId' : self.membersId,
|
||||
'id' : self.key().id()
|
||||
}
|
||||
return json.dumps(data)
|
||||
|
|
|
@ -4,13 +4,15 @@ __author__ = 'Aran'
|
|||
from google.appengine.ext import db
|
||||
|
||||
class Message(db.Model):
|
||||
courseName = db.StringProperty(required=True)
|
||||
groupId = db.IntegerProperty(required=True)
|
||||
message = db.StringProperty(required=True)
|
||||
msgDate = db.DateTimeProperty(required=True)
|
||||
master_id = db.IntegerProperty(required=True)
|
||||
isProject = db.BooleanProperty(default=False)
|
||||
|
||||
def to_JSON(self):
|
||||
data = {
|
||||
'courseName' : self.courseName,
|
||||
'groupId' : self.groupId,
|
||||
'message' : self.message,
|
||||
'date' : {
|
||||
'year': self.msgDate.year,
|
||||
|
@ -19,6 +21,8 @@ class Message(db.Model):
|
|||
'hour': self.msgDate.hour,
|
||||
'minute': self.msgDate.minute
|
||||
},
|
||||
'id' : self.key().id()
|
||||
'id' : self.key().id(),
|
||||
'master_id' : self.master_id,
|
||||
'isProject' : self.isProject
|
||||
}
|
||||
return json.dumps(data)
|
||||
|
|
|
@ -5,7 +5,7 @@ from google.appengine.ext import db
|
|||
|
||||
class Project(db.Model):
|
||||
projectName = db.StringProperty(required=True)
|
||||
courseName = db.StringProperty(required=True)
|
||||
courseId = db.IntegerProperty(required=True)
|
||||
master_id = db.IntegerProperty(required=True)
|
||||
grade = db.IntegerProperty(required=True, default=0)
|
||||
logo_url = db.StringProperty(required=False)
|
||||
|
@ -14,7 +14,7 @@ class Project(db.Model):
|
|||
|
||||
def to_JSON(self):
|
||||
data = {'projectName' : self.projectName,
|
||||
'courseName' : self.courseName,
|
||||
'courseId' : self.courseId,
|
||||
'master_id' : self.master_id,
|
||||
'grade' : self.grade,
|
||||
'logo_url' : self.logo_url,
|
||||
|
|
|
@ -6,14 +6,14 @@ from google.appengine.ext import db
|
|||
|
||||
class Task(db.Model):
|
||||
title = db.StringProperty(required=True)
|
||||
courseName = db.StringProperty(required=True)
|
||||
courseId = db.IntegerProperty(required=True)
|
||||
description = db.StringProperty(required=True,default=" ")
|
||||
dueDate = db.DateProperty(required=True)
|
||||
isPersonal = db.BooleanProperty(required=True, default=True)
|
||||
|
||||
def to_JSON(self):
|
||||
data = {'title' : self.title,
|
||||
'courseName' : self.courseName,
|
||||
'courseId' : self.courseId,
|
||||
'description' : self.description,
|
||||
'dueDate' : {
|
||||
'year': self.dueDate.year,
|
||||
|
|
|
@ -12,9 +12,9 @@ class User(db.Model):
|
|||
seToken = db.StringProperty(required=True)
|
||||
avatar_url = db.StringProperty(required=True)
|
||||
isFirstLogin = db.BooleanProperty(default=True)
|
||||
campusName = db.StringProperty(required=True, default=" ")
|
||||
campuses_id_list = db.StringListProperty(default=[])
|
||||
courses_id_list = db.StringListProperty(default=[])
|
||||
projects_id_list = db.StringListProperty(default=[])
|
||||
|
||||
def to_JSON(self):
|
||||
data = {'username' : self.username,
|
||||
|
@ -23,8 +23,9 @@ class User(db.Model):
|
|||
'isLecturer' : self.isLecturer,
|
||||
'avatar_url' : self.avatar_url,
|
||||
'isFirstLogin' : self.isFirstLogin,
|
||||
'campusName': self.campusName,
|
||||
'campuses_id_list': self.campuses_id_list,
|
||||
'courses_id_list': self.courses_id_list
|
||||
'courses_id_list': self.courses_id_list,
|
||||
'projects_id_list': self.projects_id_list,
|
||||
'id' : self.key().id()
|
||||
}
|
||||
return json.dumps(data)
|
||||
|
|
|
@ -54,18 +54,20 @@
|
|||
SE-Hub Docs Index
|
||||
</h1>
|
||||
|
||||
|
||||
<div>
|
||||
<center>
|
||||
<div style="width: 40%">
|
||||
<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>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>Courses Related API<a href="/api/courses/help" class="secondary-content"><i class="mdi-content-send"></i></a></div></li>
|
||||
<li class="collection-item dismissable"><div>Projects Related API<a href="/api/projects/help" class="secondary-content"><i class="mdi-content-send"></i></a></div></li>
|
||||
<li class="collection-item dismissable"><div>Tasks Related API<a href="/api/tasks/help" class="secondary-content"><i class="mdi-content-send"></i></a></div></li>
|
||||
<li class="collection-item dismissable"><div>Messages Related API<a href="/api/messages/help" class="secondary-content"><i class="mdi-content-send"></i></a></div></li>
|
||||
<li class="collection-item dismissable"><div>Validation Related API<a href="#!" 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>
|
||||
</div>
|
||||
|
||||
</center>
|
||||
<footer class="page-footer">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
|
|
@ -151,6 +151,38 @@ body.noscroll
|
|||
/*width: 100%;*/
|
||||
}
|
||||
|
||||
/*.hvr-curl-top-left {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
-webkit-transform: translateZ(0);
|
||||
transform: translateZ(0);
|
||||
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
|
||||
-webkit-backface-visibility: hidden;
|
||||
backface-visibility: hidden;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
position: relative;
|
||||
}*/
|
||||
|
||||
/* Grow Rotate */
|
||||
/*.campusCard {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
-webkit-transform: translateZ(0);
|
||||
transform: translateZ(0);
|
||||
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
|
||||
-webkit-backface-visibility: hidden;
|
||||
backface-visibility: hidden;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
-webkit-transition-duration: 0.3s;
|
||||
transition-duration: 0.3s;
|
||||
-webkit-transition-property: transform;
|
||||
transition-property: transform;
|
||||
}*/
|
||||
.campusCard:hover, .campusCard:focus, .campusCard:active {
|
||||
-webkit-transform: rotate(4deg);
|
||||
transform: rotate(4deg);
|
||||
}
|
||||
|
||||
/*.feedMessages
|
||||
{
|
||||
overflow: scroll;
|
||||
|
@ -197,6 +229,18 @@ body.noscroll
|
|||
border-radius: 1px black solid;
|
||||
}*/
|
||||
|
||||
.allCampusesShow
|
||||
{
|
||||
overflow:hidden;
|
||||
background-size: auto;
|
||||
|
||||
}
|
||||
.campusCard
|
||||
{
|
||||
/*height:80%;*/
|
||||
/*width:80%;*/
|
||||
}
|
||||
|
||||
.gray-font
|
||||
{
|
||||
color: #7f7f7f;
|
||||
|
@ -397,6 +441,11 @@ body.noscroll
|
|||
border-color: solid red;
|
||||
}
|
||||
|
||||
.cardAllCampuses
|
||||
{
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.addMessage
|
||||
{
|
||||
font-size: 2em;
|
||||
|
|
|
@ -38,15 +38,15 @@ app.config(['$routeProvider', '$locationProvider',
|
|||
templateUrl: 'templates/views/home.html',
|
||||
controller: 'homeController'
|
||||
})
|
||||
.when('/Settings', {
|
||||
templateUrl: 'templates/views/settings.html',
|
||||
controller: 'settingsController'
|
||||
.when('/profile/:id', {
|
||||
templateUrl: 'templates/views/profile.html',
|
||||
controller: 'profileController'
|
||||
})
|
||||
.when('/tasks', {
|
||||
templateUrl: 'templates/views/tasks.html',
|
||||
controller: 'tasksController'
|
||||
})
|
||||
.when('/myClasses', {
|
||||
.when('/myClasses/:campusId', {
|
||||
templateUrl: 'templates/views/myClasses.html',
|
||||
controller: 'myClassesController'
|
||||
})
|
||||
|
@ -54,13 +54,21 @@ app.config(['$routeProvider', '$locationProvider',
|
|||
templateUrl: 'templates/views/newTask.html',
|
||||
controller: 'newTasksController'
|
||||
})
|
||||
.when('/projects', {
|
||||
.when('/projects/:classId', {
|
||||
templateUrl: 'templates/views/projects.html',
|
||||
controller: 'projectsController'
|
||||
})
|
||||
.when('/newCourse', {
|
||||
templateUrl: 'templates/views/newCourse.html',
|
||||
controller: 'newCourseController'
|
||||
})
|
||||
.when('/campuses', {
|
||||
templateUrl: 'templates/views/campuses.html',
|
||||
controller: 'campusesController'
|
||||
})
|
||||
.when('/myProjects', {
|
||||
templateUrl: 'templates/views/myProjects.html',
|
||||
controller: 'myProjectsController'
|
||||
});
|
||||
}
|
||||
]);
|
||||
|
|
57
templates/js/controllers/campusesController.js
Normal file
57
templates/js/controllers/campusesController.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
angular.module('SeHub')
|
||||
.controller('campusesController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService, $rootScope)
|
||||
{
|
||||
$scope.campusesEmpty = false;
|
||||
var token = $cookies['com.sehub.www'];
|
||||
|
||||
var init = function()
|
||||
{
|
||||
$scope.threeSizedArray = [];
|
||||
var tempArr = [];
|
||||
var sizeOfSmallArrays = 3;
|
||||
for (var i = 0 ; i < $scope.campuses.length ; i++) {
|
||||
if(i % sizeOfSmallArrays !== 0){
|
||||
tempArr.push($scope.campuses[i]);
|
||||
}else{
|
||||
if(i !== 0){
|
||||
$scope.threeSizedArray.push(tempArr);
|
||||
tempArr = [];
|
||||
tempArr.push($scope.campuses[i]);
|
||||
}else{
|
||||
tempArr.push($scope.campuses[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
$scope.threeSizedArray.push(tempArr);
|
||||
}
|
||||
|
||||
$scope.goToCampus = function(campusId) // Will pass you to courses by specific campus
|
||||
{
|
||||
$location.path('/myClasses/' + campusId.toString());
|
||||
}
|
||||
|
||||
$scope.displayCampuses = function()
|
||||
{
|
||||
apiService.getCampusesByUser(token).success(function(data) // Get all the campuses
|
||||
{
|
||||
$scope.campuses = data;
|
||||
console.log("INSIDE " + $scope.campuses);
|
||||
init(); // Executing the function to initialize campuses display
|
||||
|
||||
}).error(function()
|
||||
{
|
||||
// TODO
|
||||
});
|
||||
// console.log($scope.campuses.length.toString());
|
||||
|
||||
if(!$scope.campuses) // If campuses is empty
|
||||
{
|
||||
$scope.campusesEmpty = true;
|
||||
}
|
||||
}
|
||||
|
||||
$scope.displayCampuses(); // Displaying all campuses by user
|
||||
|
||||
|
||||
|
||||
}]);
|
|
@ -13,7 +13,6 @@ angular.module('SeHub')
|
|||
|
||||
var imagePath = $scope.user.avatar_url;
|
||||
//var campusName = '';
|
||||
$scope.course = '';
|
||||
// $scope.campusName = '';
|
||||
|
||||
$scope.phones = [
|
||||
|
@ -35,13 +34,13 @@ angular.module('SeHub')
|
|||
console.log("Student Mode!");
|
||||
}
|
||||
|
||||
// apiService.getCourseByCampusName($scope.user.classes_id_list[0]).success(function(data)
|
||||
// apiService.getCourseByCampusName(token).success(function(data)
|
||||
// {
|
||||
// console.log("Campus Name is ON! " + $scope.user.classes_id_list[0])
|
||||
// console.log("Campus Name is ON! " + token)
|
||||
// $scope.course = data;
|
||||
// }).error(function()
|
||||
// }).error(function(err)
|
||||
// {
|
||||
// console.log("Error on ===> getCourseByCampusName")
|
||||
// console.log("Error ===> " + err + " ===> getCourseByCampusName")
|
||||
// });
|
||||
|
||||
|
||||
|
@ -51,8 +50,30 @@ angular.module('SeHub')
|
|||
}
|
||||
$scope.postMessageClicked = function() // Posting the message itself
|
||||
{
|
||||
|
||||
|
||||
if($scope.msg.msgToAdd != null)
|
||||
{
|
||||
jsonNewMsg = {
|
||||
'courseName': 'A', // TODO Should be ===> $scope.course.courseName
|
||||
'message': $scope.msg.msgToAdd
|
||||
};
|
||||
|
||||
// console.log("J: " + jsonNewMsg.toString() + "msg: " + $scope.msg.msgToAdd);
|
||||
|
||||
// apiService.createMessage(token, jsonNewMsg).success(function(data)
|
||||
// {
|
||||
// console.log("create Msg!");
|
||||
// }).error(function(err)
|
||||
// {
|
||||
// console.log("Error: " + err);
|
||||
// });
|
||||
|
||||
/*
|
||||
'courseName': 'Advance Math',
|
||||
'message': 'The lecture today is canceled'
|
||||
*/
|
||||
|
||||
console.log($scope.msg.msgToAdd);
|
||||
$scope.messages.push({"text": $scope.msg.msgToAdd});
|
||||
}
|
||||
|
@ -74,8 +95,6 @@ angular.module('SeHub')
|
|||
console.log("choose project Clicked!!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// animation
|
||||
$scope.isEnterd = top.setIsEnterd;
|
||||
}]);
|
|
@ -1,5 +1,7 @@
|
|||
angular.module('SeHub')
|
||||
.controller('mainController', ['$scope', '$rootScope', 'dataService','apiService', '$cookies', '$cookieStore', '$location', '$window',
|
||||
.controller('mainController',
|
||||
['$scope', '$rootScope', 'dataService', 'apiService', '$cookies',
|
||||
'$cookieStore', '$location', '$window',
|
||||
|
||||
function($scope, $rootScope, dataService, apiService, $cookies, $cookieStore, $location, $window) {
|
||||
top.setIsEnterd = true;
|
||||
|
@ -14,6 +16,39 @@ angular.module('SeHub')
|
|||
}
|
||||
$scope.loadingData = false;
|
||||
$scope.user = data;
|
||||
|
||||
$scope.menuItems = [{
|
||||
"title": "Dash Board",
|
||||
"icon": "fa fa-tachometer",
|
||||
"style": "selected",
|
||||
"route": "/home"
|
||||
}, {
|
||||
"title": "Explore",
|
||||
"icon": "fa fa-compass",
|
||||
"style": "",
|
||||
"route": "/campuses"
|
||||
}, {
|
||||
"title": "My Projects",
|
||||
"icon": "fa fa-cube",
|
||||
"style": "",
|
||||
"route": "/myProjects"
|
||||
}, {
|
||||
"title": "Tasks",
|
||||
"icon": "fa fa-clipboard",
|
||||
"style": "",
|
||||
"route": "/tasks"
|
||||
}, {
|
||||
"title": "Profile",
|
||||
"icon": "fa fa-cogs",
|
||||
"style": "",
|
||||
"route": "/profile/" + $scope.user.id.toString()
|
||||
}, {
|
||||
"title": "Log Out",
|
||||
"icon": "fa fa-power-off",
|
||||
"style": "",
|
||||
"route": "/logout"
|
||||
}];
|
||||
|
||||
dataService.initService($scope); //Start Data Sync Service (For User)
|
||||
console.log(data);
|
||||
if ($scope.user.isFirstLogin) {
|
||||
|
@ -27,44 +62,7 @@ angular.module('SeHub')
|
|||
|
||||
});
|
||||
|
||||
|
||||
|
||||
$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": "/myClasses"
|
||||
}, {
|
||||
"title": "My Projects",
|
||||
"icon": "fa fa-cube",
|
||||
"style": "",
|
||||
"route": "/projects"
|
||||
}, {
|
||||
"title": "Tasks",
|
||||
"icon": "fa fa-clipboard",
|
||||
"style": "",
|
||||
"route": "/tasks"
|
||||
}, {
|
||||
"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 = ""
|
||||
|
|
|
@ -1,14 +1,142 @@
|
|||
angular.module('SeHub')
|
||||
.controller('myClassesController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
|
||||
.controller('myClassesController', ['$scope', '$location', '$routeParams', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope',
|
||||
function ($scope, $location, $routeParams, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
|
||||
{
|
||||
$scope.isStudent = false;
|
||||
$scope.isCourse = false;
|
||||
$scope.isNewCourse = false;
|
||||
$scope.newClassName = false;
|
||||
$scope.user.createNewCourse = '';
|
||||
$scope.course = {};
|
||||
var token = $cookies['com.sehub.www'];
|
||||
$scope.user.finalDate = '';
|
||||
$scope.user.startDate = '';
|
||||
$scope.showMyClass = false;
|
||||
$scope.coursesEmpty = false;
|
||||
$scope.campusId;
|
||||
var campusId = $routeParams.campusId;
|
||||
|
||||
$scope.goToClass = function(classId)
|
||||
{
|
||||
console.log("Done! " + $scope.courses);
|
||||
$location.path('/projects/' + classId.toString()); // Will display all the projects in this course
|
||||
}
|
||||
|
||||
$scope.chooseCampusClicked = function()
|
||||
{
|
||||
$scope.isCourse = true;
|
||||
console.log("Choose campus Clicked!!");
|
||||
|
||||
apiService.getAllCampuses(token).success(function(data)
|
||||
{
|
||||
$scope.campuses = data;
|
||||
console.log("Campuses: ");
|
||||
console.log($scope.campuses);
|
||||
}).error(function(err)
|
||||
{
|
||||
console.log("Error: " + err);
|
||||
});
|
||||
}
|
||||
|
||||
$scope.createCourseClicked = function()
|
||||
{
|
||||
$scope.isNewCourse = !$scope.isNewCourse;
|
||||
}
|
||||
|
||||
$scope.submitNewClassClicked = function()
|
||||
{
|
||||
var i;
|
||||
if($scope.course.courseName != null && $scope.course.endDate != null && $scope.course.startDate != null)
|
||||
{
|
||||
for(i = 0; i < $scope.campuses.length; i++)
|
||||
{
|
||||
if($scope.course.campusName === $scope.campuses[i].title)
|
||||
{
|
||||
$scope.campusId = $scope.campuses[i].id;
|
||||
}
|
||||
}
|
||||
console.log("NOW: ");
|
||||
console.log($scope.campusId);
|
||||
|
||||
var jsonNewCourse =
|
||||
{
|
||||
'courseName': $scope.course.courseName,
|
||||
'campusId': $scope.campusId,
|
||||
'startDate': {
|
||||
'year' : $scope.course.startDate.getFullYear(),
|
||||
'day' : $scope.course.startDate.getDate(),
|
||||
'month': $scope.course.startDate.getMonth() + 1
|
||||
},
|
||||
'endDate': {
|
||||
'year' : $scope.course.endDate.getFullYear(),
|
||||
'day' : $scope.course.endDate.getDate(),
|
||||
'month': $scope.course.endDate.getMonth() + 1
|
||||
}
|
||||
};
|
||||
|
||||
console.log("Json here: " + $scope.chosenCampus);
|
||||
console.log(jsonNewCourse);
|
||||
|
||||
apiService.createCourse(token, jsonNewCourse).success(function(data)
|
||||
{
|
||||
console.log("createCourse API done");
|
||||
$mdDialog.show($mdDialog.alert().title('Course Created').content('You have created course successfully.')
|
||||
.ariaLabel('Email verification alert dialog').ok('Lets Start!').targetEvent())
|
||||
.then(function() {
|
||||
$location.path('/newCourse'); // TODO TODO TODO
|
||||
}); // Pop-up alert
|
||||
}).error(function(err)
|
||||
{
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$mdDialog.show($mdDialog.alert().title('Error - Creating Course').content('Some fields are missing.')
|
||||
.ariaLabel('Email verification alert dialog').ok('Try Again!').targetEvent());
|
||||
}
|
||||
}
|
||||
|
||||
var init = function()
|
||||
{
|
||||
$scope.holdArrays = [];
|
||||
var tempArr = [];
|
||||
var sizeOfSmallArrays = 3;
|
||||
for (var i = 0 ; i < $scope.courses.length ; i++) {
|
||||
if(i % sizeOfSmallArrays !== 0){
|
||||
tempArr.push($scope.courses[i]);
|
||||
}else{
|
||||
if(i !== 0){
|
||||
$scope.holdArrays.push(tempArr);
|
||||
tempArr = [];
|
||||
tempArr.push($scope.courses[i]);
|
||||
}else{
|
||||
tempArr.push($scope.courses[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
$scope.holdArrays.push(tempArr);
|
||||
}
|
||||
|
||||
//$scope.courses = ["lala", "aaa", "bbb", "ccc", "rrr"];
|
||||
|
||||
var displayCourses = function()
|
||||
{
|
||||
apiService.getAllCoursesByCampus(token, campusId).success(function(data) // Shows all classes from this campus
|
||||
{
|
||||
$scope.courses = data;
|
||||
console.log("success " + $scope.courses);
|
||||
init(); // Executing the function to initialize course display
|
||||
if(!$scope.courses)
|
||||
{
|
||||
$scope.coursesEmpty = true;
|
||||
}
|
||||
}).error(function(err)
|
||||
{
|
||||
console.log("error: " + err);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if($scope.user.isLecturer)
|
||||
{
|
||||
$scope.isStudent = false;
|
||||
|
@ -20,42 +148,7 @@ angular.module('SeHub')
|
|||
console.log("Student Mode!");
|
||||
}
|
||||
|
||||
|
||||
$scope.chooseCourseClicked = function()
|
||||
{
|
||||
$scope.isCourse = true;
|
||||
console.log("choose course Clicked!!");
|
||||
}
|
||||
|
||||
$scope.createCourseClicked = function()
|
||||
{
|
||||
$scope.isNewCourse = true;
|
||||
$scope.showMyClass = false;
|
||||
console.log("create course Clicked!!");
|
||||
}
|
||||
|
||||
$scope.showMyCourses = function()
|
||||
{
|
||||
$scope.showMyClass = true;
|
||||
$scope.isNewCourse = false;
|
||||
}
|
||||
|
||||
$scope.submitNewClassClicked = function()
|
||||
{
|
||||
if($scope.user.createNewCourse != '' && $scope.user.finalDate != '')
|
||||
{
|
||||
console.log("finalDate " + $scope.user.finalDate);
|
||||
console.log($scope.user.createNewCourse);
|
||||
$mdDialog.show($mdDialog.alert().title('Course Created').content('You have created course successfully.')
|
||||
.ariaLabel('Email verification alert dialog').ok('Lets Start!').targetEvent());
|
||||
// $window.location.href = 'templates/views/newCourse.html'; // TODO TODO TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
$mdDialog.show($mdDialog.alert().title('Error - Creating Course').content('You have encountered and error in creating the course.')
|
||||
.ariaLabel('Email verification alert dialog').ok('Try Again!').targetEvent());
|
||||
}
|
||||
}
|
||||
displayCourses(); // Will display the courses that the user related to // TODO!!
|
||||
|
||||
|
||||
|
||||
|
|
66
templates/js/controllers/myProjectsController.js
Normal file
66
templates/js/controllers/myProjectsController.js
Normal file
|
@ -0,0 +1,66 @@
|
|||
angular.module('SeHub')
|
||||
.controller('myProjectsController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
|
||||
{
|
||||
$scope.isEditPressed = false;
|
||||
$scope.myProjectsEmpty = false;
|
||||
var token = $cookies['com.sehub.www'];
|
||||
|
||||
$scope.user = $scope.$parent.user;
|
||||
|
||||
$scope.displayMyProjects = function()
|
||||
{
|
||||
apiService.getProjectsByUser(token).success(function(data)
|
||||
{
|
||||
console.log("Success " + data);
|
||||
$scope.myProjects = data;
|
||||
}).error(function(err)
|
||||
{
|
||||
console.log("Error: " + err);
|
||||
});
|
||||
if($scope.myProjects === null)
|
||||
{
|
||||
$scope.myProjectsEmpty = true;
|
||||
}
|
||||
}
|
||||
|
||||
$scope.goToMyProject = function()
|
||||
{
|
||||
console.log("projects only from classID: " + classId)
|
||||
$location.path('/thisProject' + classId);
|
||||
}
|
||||
|
||||
var init = function()
|
||||
{
|
||||
$scope.arrayHolder = [];
|
||||
var tempArr = [];
|
||||
var sizeOfSmallArrays = 3;
|
||||
for (var i = 0 ; i < $scope.projects.length ; i++) {
|
||||
if(i % sizeOfSmallArrays !== 0){
|
||||
tempArr.push($scope.projects[i]);
|
||||
}else{
|
||||
if(i !== 0){
|
||||
$scope.arrayHolder.push(tempArr);
|
||||
tempArr = [];
|
||||
tempArr.push($scope.projects[i]);
|
||||
}else{
|
||||
tempArr.push($scope.projects[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
$scope.arrayHolder.push(tempArr);
|
||||
}
|
||||
|
||||
$scope.editPressed = function()
|
||||
{
|
||||
$scope.isEditPressed = true;
|
||||
console.log("EditPressed " + $scope.isEditPressed);
|
||||
}
|
||||
$scope.removeProject = function()
|
||||
{
|
||||
console.log("Project has been removed!");
|
||||
}
|
||||
|
||||
|
||||
$scope.displayMyProjects(); // Will display all my projects
|
||||
|
||||
}]);
|
|
@ -1,10 +1,9 @@
|
|||
angular.module('SeHub')
|
||||
.controller('newCourseController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
|
||||
.controller('newCourseController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope',
|
||||
function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
|
||||
{
|
||||
|
||||
$scope.goBack = function()
|
||||
{
|
||||
$window.location.href = 'templates/views/myClasses.html';
|
||||
$location.path('/myClasses');
|
||||
}
|
||||
|
||||
}]);
|
|
@ -1,6 +1,8 @@
|
|||
angular.module('SeHub').controller('newTasksController', ['$scope',
|
||||
function($scope) {
|
||||
|
||||
$scope.newComp = {};
|
||||
$scope.newComp.isMandatory = false;
|
||||
|
||||
|
||||
$scope.componentTypes = [{
|
||||
|
@ -9,25 +11,105 @@ angular.module('SeHub').controller('newTasksController', ['$scope',
|
|||
"type": "textarea"
|
||||
}, {
|
||||
"type": "checkbox"
|
||||
}, {
|
||||
"type": "link"
|
||||
}, {
|
||||
"type": "radiobuttons"
|
||||
}];
|
||||
|
||||
$scope.task = {};
|
||||
$scope.task.task = {};
|
||||
$scope.task.components= [];
|
||||
$scope.task.isPersonal = false;
|
||||
$scope.task.components = [];
|
||||
$scope.task.isPersonal = false;
|
||||
|
||||
// $scope.task = [];
|
||||
|
||||
$scope.addComponent = function() {
|
||||
$scope.task.components.push($scope.newComp);
|
||||
var comp = {};
|
||||
var type = $scope.newComp.type;
|
||||
comp.type = type;
|
||||
comp.isMandatory = $scope.newComp.isMandatory;
|
||||
comp.label = "";
|
||||
var i = 0
|
||||
if (!(type === 'textbox' || type === 'textarea' || type === 'checkbox'))
|
||||
while ($scope.newComp.label[i]) {
|
||||
comp.label += $scope.newComp.label[i] + "|";
|
||||
i++;
|
||||
} else
|
||||
comp.label = $scope.newComp.label[i];
|
||||
|
||||
console.log(comp);
|
||||
$scope.task.components.push(comp);
|
||||
|
||||
// console.log($scope.newComp);
|
||||
$scope.newComp = {};
|
||||
$scope.newComp.isMandatory = false;
|
||||
$scope.compDetails = [];
|
||||
$scope.isRadioButton = false;
|
||||
}
|
||||
|
||||
$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.ComponentType = function(type) {
|
||||
if (type === 'textbox' || type === 'textarea' || type === 'checkbox')
|
||||
$scope.compDetails = [{
|
||||
detail: "Label"
|
||||
}];
|
||||
else if (type === 'radiobuttons') {
|
||||
$scope.compDetails = [{
|
||||
detail: "Label"
|
||||
}];
|
||||
$scope.compDetails.push({
|
||||
detail: "Option" + $scope.compDetails.length + ": "
|
||||
});
|
||||
} else if (type === 'link')
|
||||
$scope.compDetails = [{
|
||||
detail: "Label"
|
||||
}, {
|
||||
detail: "URL Path"
|
||||
}];
|
||||
|
||||
if (type === 'radiobuttons')
|
||||
$scope.isRadioButton = true;
|
||||
else
|
||||
$scope.isRadioButton = false;
|
||||
}
|
||||
|
||||
$scope.addMoreOptions = function() {
|
||||
$scope.compDetails.push({
|
||||
detail: "Option" + $scope.compDetails.length + ": "
|
||||
});
|
||||
}
|
||||
|
||||
$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});
|
||||
};
|
||||
}
|
||||
|
||||
$scope.RB = function(comp){
|
||||
console.info(comp);
|
||||
}
|
||||
|
||||
}
|
||||
]);
|
102
templates/js/controllers/profileController.js
Normal file
102
templates/js/controllers/profileController.js
Normal file
|
@ -0,0 +1,102 @@
|
|||
angular.module('SeHub')
|
||||
.controller('profileController', ['$scope', '$rootScope', 'dataService', 'apiService',
|
||||
'$cookies', '$location', '$routeParams',
|
||||
function($scope, $rootScope, dataService, apiService, $cookies, $location, $routeParams) {
|
||||
|
||||
var token = $cookies['com.sehub.www'];
|
||||
var id = $routeParams.id;
|
||||
$scope.loadingData = true;
|
||||
$scope.isInRegisterMode = false;
|
||||
|
||||
$scope.title = "Profile";
|
||||
|
||||
apiService.getUserById(token, id).success(function(data) {
|
||||
if (data.message == 'No User Found') {
|
||||
console.error("No User Found!");
|
||||
}
|
||||
$scope.user = data;
|
||||
apiService.getCampusesByUserId(token, id).success(function(data) {
|
||||
$scope.campuses = data;
|
||||
console.log(data);
|
||||
apiService.getCoursesByUserID(token, id).success(function(data){
|
||||
$scope.courses = data;
|
||||
}).error(function(err){
|
||||
console.error('In apiService.getCoursesByUserID', err);
|
||||
})
|
||||
|
||||
$scope.loadingData = false;
|
||||
}).error(function(err) {
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
$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 {
|
||||
apiService.updateUser(token, $scope.user).success(function(data) {
|
||||
console.info('User Saved');
|
||||
dataService.userBrodcast($scope.user);
|
||||
|
||||
}).error(function(e) {
|
||||
console.error('Fail To Save User');
|
||||
});
|
||||
$scope.profileMode = "Edit Profile";
|
||||
$scope.profileModeIcon = "fa fa-pencil";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DEBUG DATA
|
||||
*/
|
||||
// $scope.courses = [{
|
||||
// "courseName": "Advance Math",
|
||||
// "campusName": "JCE",
|
||||
// "startDate": {
|
||||
// "year": 2015,
|
||||
// "month": 4,
|
||||
// "day": 3
|
||||
// },
|
||||
// "endDate": {
|
||||
// "year": 2016,
|
||||
// "month": 5,
|
||||
// "day": 14
|
||||
// },
|
||||
// "taskFlag": false,
|
||||
// "campus_avatar": "https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg"
|
||||
// }];
|
||||
|
||||
// $scope.campuses = [{
|
||||
// 'title': 'JCE',
|
||||
// 'email_ending': '@post.jce.ac.il',
|
||||
// 'master_user_id': 123453433341,
|
||||
// 'avatar_url': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg'
|
||||
// }, {
|
||||
// 'title': 'Stanford',
|
||||
// 'email_ending': '@post.jce.ac.il',
|
||||
// 'master_user_id': 123453433341,
|
||||
// 'avatar_url': 'https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcR9M4uQgaJP1zyiCGw-dK31hU8buWqeuOi9vTXBd4Y8hQcFTZqA'
|
||||
// }];
|
||||
|
||||
|
||||
$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*/;
|
||||
|
||||
}
|
||||
]);
|
|
@ -1,15 +1,120 @@
|
|||
angular.module('SeHub')
|
||||
.controller('projectsController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
|
||||
.controller('projectsController', ['$scope', '$routeParams', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $routeParams, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
|
||||
{
|
||||
console.log("in projects controller");
|
||||
var token = $cookies['com.sehub.www'];
|
||||
var classId = $routeParams.classId;
|
||||
$scope.projectEmpty = false;
|
||||
|
||||
$scope.displayProjects = function()
|
||||
{
|
||||
console.log("in displayProjecs!!! ");
|
||||
apiService.getProjectsByCourse(token, classId).success(function(data) // Get all the campuses
|
||||
{
|
||||
$scope.projects = data;
|
||||
init(); // Executing the function to initialize projects display
|
||||
console.log("project created! not rly!! " + classId);
|
||||
}).error(function(err)
|
||||
{
|
||||
console.log("Error: " + err);
|
||||
});
|
||||
if($scope.projects = null)
|
||||
{
|
||||
$scope.projectEmpty = true;
|
||||
}
|
||||
}
|
||||
$scope.joinCourse = function()
|
||||
{
|
||||
apiService.joinCourse(token, classId).success(function(data)
|
||||
{
|
||||
console.log("Success!!");
|
||||
$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('/projects/' + classId); // TODO TODO TODO
|
||||
}); // Pop-up alert
|
||||
}).error(function(err)
|
||||
{
|
||||
$mdDialog.show($mdDialog.alert().title('Error Joining Course').content('You have failed joined the course.')
|
||||
.ariaLabel('Join course alert dialog').ok('Try Again!').targetEvent()); // Pop-up alert
|
||||
// .then(function() {
|
||||
// // $location.path('/newCourse'); // TODO TODO TODO
|
||||
// });
|
||||
});
|
||||
}
|
||||
|
||||
$scope.createProjectClicked = function()
|
||||
{
|
||||
console.log("project created! not rly!! ");
|
||||
console.log("project created! not rly!! " + classId);
|
||||
|
||||
// $window.location.href = 'http://localhost:8080/home#/tasks/new'; // Reference to 'newTask' page
|
||||
|
||||
}
|
||||
|
||||
// $scope.projects = ['AMI', 'LULU', 'XIN Zhau', 'LUMI lu', 'Shimi', 'Azligi zligi', 'Drugs'];
|
||||
|
||||
$scope.goToProject = function()
|
||||
{
|
||||
console.log("projects only from classID: " + classId)
|
||||
$location.path('/thisProject' + classId);
|
||||
}
|
||||
|
||||
var init = function()
|
||||
{
|
||||
$scope.arrayHolder = [];
|
||||
var tempArr = [];
|
||||
var sizeOfSmallArrays = 3;
|
||||
for (var i = 0 ; i < $scope.courses.length ; i++) {
|
||||
if(i % sizeOfSmallArrays !== 0){
|
||||
tempArr.push($scope.courses[i]);
|
||||
}else{
|
||||
if(i !== 0){
|
||||
$scope.arrayHolder.push(tempArr);
|
||||
tempArr = [];
|
||||
tempArr.push($scope.courses[i]);
|
||||
}else{
|
||||
tempArr.push($scope.courses[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
$scope.arrayHolder.push(tempArr);
|
||||
}
|
||||
|
||||
|
||||
// Running...
|
||||
$scope.displayProjects(); // Displaying all projects related to user
|
||||
|
||||
|
||||
|
||||
/*
|
||||
var jsonNewCourse =
|
||||
{
|
||||
'projectName': $scope.course.courseName,
|
||||
'courseId': classId,
|
||||
'startDate': {
|
||||
'year' : $scope.course.startDate.getFullYear(),
|
||||
'day' : $scope.course.startDate.getDate(),
|
||||
'month': $scope.course.startDate.getMonth() + 1
|
||||
},
|
||||
'endDate': {
|
||||
'year' : $scope.course.endDate.getFullYear(),
|
||||
'day' : $scope.course.endDate.getDate(),
|
||||
'month': $scope.course.endDate.getMonth() + 1
|
||||
}
|
||||
};*/
|
||||
|
||||
/*
|
||||
{
|
||||
'projectName': 'Advance Math',
|
||||
'courseName': 'JCE',
|
||||
'grade': 98,
|
||||
'logo_url': 'http://location.domain.com/image.jpg',
|
||||
'gitRepository': 'http://location.git.com/somthing',
|
||||
'membersId': ['bob', 'dylan', 'quentin', 'terentino'],
|
||||
'id' : 1234567890
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,141 +1,126 @@
|
|||
angular.module('SeHub')
|
||||
.controller('registerController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
|
||||
{
|
||||
$scope.userHasNoName = false;
|
||||
$scope.campusChecked = false;
|
||||
$scope.createCampusClicked = false;
|
||||
$scope.isEmpty = true; // if the academic email line is empty
|
||||
$scope.jsonCreateCampus =
|
||||
{
|
||||
"title": "Create Campus",
|
||||
"email": "email_ending",
|
||||
"avatar": "self.avatar.url"
|
||||
}
|
||||
|
||||
$rootScope.seToken = $cookies['com.sehub.www'];
|
||||
var token = $rootScope.seToken;
|
||||
|
||||
apiService.getUserByToken(token).success(function(data) // Get user token
|
||||
{
|
||||
$scope.user = data;
|
||||
|
||||
if(data.message == 'No User Found')
|
||||
console.error("No User Found!");
|
||||
console.log(data);
|
||||
|
||||
if($scope.user.name === ";")
|
||||
{
|
||||
$scope.user.name = "";
|
||||
$scope.user.name = $scope.user.username;
|
||||
$scope.userHasNoName = true;
|
||||
.controller('registerController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService, $rootScope) {
|
||||
$scope.userHasNoName = false;
|
||||
$scope.campusChecked = false;
|
||||
$scope.createCampusClicked = false;
|
||||
$scope.isEmpty = true; // if the academic email line is empty
|
||||
$scope.jsonCreateCampus = {
|
||||
"title": "Create Campus",
|
||||
"email": "email_ending",
|
||||
"avatar": "self.avatar.url"
|
||||
}
|
||||
|
||||
apiService.getAllCampuses($scope.user.seToken).success(function(data) // Get all the campuses
|
||||
{
|
||||
$scope.campuses = data;
|
||||
}).error(function()
|
||||
{
|
||||
// TODO
|
||||
});
|
||||
});
|
||||
$rootScope.seToken = $cookies['com.sehub.www'];
|
||||
var token = $rootScope.seToken;
|
||||
|
||||
$scope.dropdownClicked = function()
|
||||
{
|
||||
if($scope.campus){
|
||||
$scope.campusChecked = true;
|
||||
$scope.campusObj = null;
|
||||
for (var i = $scope.campuses.length - 1; i >= 0; i--) {
|
||||
if($scope.campuses[i].title == $scope.campus){
|
||||
$scope.campusObj = $scope.campuses[i];
|
||||
console.log($scope.campusObj); // TODO REMOVE!!
|
||||
}
|
||||
apiService.getUserByToken(token).success(function(data) // Get user token
|
||||
{
|
||||
$scope.user = data;
|
||||
|
||||
if (data.message == 'No User Found')
|
||||
console.error("No User Found!");
|
||||
console.log(data);
|
||||
|
||||
if ($scope.user.name === ";") {
|
||||
$scope.user.name = "";
|
||||
$scope.user.name = $scope.user.username;
|
||||
$scope.userHasNoName = true;
|
||||
}
|
||||
|
||||
apiService.getAllCampuses(token).success(function(data) // Get all the campuses
|
||||
{
|
||||
$scope.campuses = data;
|
||||
}).error(function() {
|
||||
// TODO
|
||||
});
|
||||
});
|
||||
|
||||
$scope.dropdownClicked = function() {
|
||||
if ($scope.campus) {
|
||||
$scope.campusChecked = true;
|
||||
$scope.campusObj = null;
|
||||
for (var i = $scope.campuses.length - 1; i >= 0; i--) {
|
||||
if ($scope.campuses[i].title == $scope.campus) {
|
||||
$scope.campusObj = $scope.campuses[i];
|
||||
console.log($scope.campusObj); // TODO REMOVE!!
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
$scope.submitClicked = function(ev) {
|
||||
var emailValid = false;
|
||||
|
||||
if ($scope.user.AcMail != null) {
|
||||
var fullMail = $scope.user.AcMail + $scope.campusObj.email_ending; // Holds the full academic email of the user
|
||||
|
||||
apiService.updateUser(token, $scope.user).success(function(data) {
|
||||
|
||||
}).error(function() {
|
||||
// TODO Error
|
||||
console.log("Error occured on updateUser");
|
||||
});
|
||||
|
||||
console.log("Mail: " + fullMail);
|
||||
|
||||
apiService.sendValidationMail(token, fullMail).success(function(data) {
|
||||
console.log("DONE - 200");
|
||||
$mdDialog
|
||||
.show($mdDialog.alert().title('E-mail Verification')
|
||||
.content('A verification e-mail has been sent to your email address.')
|
||||
.ariaLabel('Email verification alert dialog')
|
||||
.ok('Got it!')
|
||||
.targetEvent(ev))
|
||||
.then(function() {
|
||||
// TODO ADD- delete cookies and redirect only after pressed 'Got it'
|
||||
$cookieStore.remove("com.sehub.www"); // Removing the cookies
|
||||
$window.location.href = 'http://se-hub.appspot.com'; // Reference to 'welcome' page
|
||||
|
||||
}); // Pop-up alert for e-mail verification
|
||||
}).error(function() {
|
||||
$mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address.')
|
||||
.ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(ev));
|
||||
});
|
||||
} else // TODO Fix when success to show mdDialog until 'Got it' clicked
|
||||
{
|
||||
$mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address.')
|
||||
.ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(ev));
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
$scope.createCampus = function(ev) {
|
||||
$scope.createCampusClicked = !$scope.createCampusClicked;
|
||||
|
||||
$scope.submitClicked = function(ev)
|
||||
{
|
||||
var emailValid = false;
|
||||
var jsonUpdateUser =
|
||||
{
|
||||
"lecturerStat": "$scope.user.isLecturer",
|
||||
"campName": "$scope.campusName"
|
||||
}
|
||||
|
||||
if($scope.user.AcMail != null)
|
||||
{
|
||||
var fullMail = $scope.user.AcMail + $scope.campusObj.email_ending; // Holds the full academic email of the user
|
||||
|
||||
apiService.updateUser($scope.user.seToken, jsonUpdateUser).success(function(data)
|
||||
if (!$scope.isLecturer) // "!isLecturer" Means => I Am Lecturer; if i am a lecturer (when pressing -> getting last data value before pressing)
|
||||
{
|
||||
|
||||
}).error(function()
|
||||
{
|
||||
// TODO Error
|
||||
console.log("Error occured on updateUser");
|
||||
});
|
||||
|
||||
console.log("Mail: " + fullMail);
|
||||
|
||||
apiService.sendValidationMail($scope.user.seToken, fullMail).success(function(data)
|
||||
{
|
||||
console.log("DONE - 200");
|
||||
$mdDialog.show($mdDialog.alert().title('E-mail Verification').content('A verification e-mail has been sent to your email address.')
|
||||
.ariaLabel('Email verification alert dialog').ok('Got it!').targetEvent(ev)); // Pop-up alert for e-mail verification
|
||||
// TODO ADD- delete cookies and redirect only after pressed 'Got it'
|
||||
$cookieStore.remove("com.sehub.www"); // Removing the cookies
|
||||
$window.location.href = 'http://se-hub.appspot.com'; // Reference to 'welcome' page
|
||||
}).error(function()
|
||||
{
|
||||
$mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address.')
|
||||
.ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(ev));
|
||||
});
|
||||
}
|
||||
else // TODO Fix when success to show mdDialog until 'Got it' clicked
|
||||
{
|
||||
$mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address.')
|
||||
.ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(ev));
|
||||
};
|
||||
};
|
||||
|
||||
$scope.createCampus = function(ev)
|
||||
{
|
||||
$scope.createCampusClicked = true;
|
||||
|
||||
if(!$scope.isLecturer) // "!isLecturer" Means => I Am Lecturer; if i am a lecturer (when pressing -> getting last data value before pressing)
|
||||
{
|
||||
if($scope.user.campusMail != null)
|
||||
{
|
||||
validateEmail($scope.user.campusMail); // Verify the email according to "xxx@name.suffix"
|
||||
if ($scope.user.campusMail != null) {
|
||||
validateEmail($scope.user.campusMail); // Verify the email according to "xxx@name.suffix"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
validateEmail = function(email)
|
||||
{
|
||||
var result = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
|
||||
if (!result.test(email)) // TODO Fix when success to show mdDialog until 'Got it' clicked
|
||||
{
|
||||
$mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address.')
|
||||
.ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(email));
|
||||
}
|
||||
if(result.test(email)) // TODO Fix when success to show mdDialog until 'Got it' clicked
|
||||
{
|
||||
console.log("Im good");
|
||||
apiService.sendValidationMail($scope.user.seToken, email).success(function(data)
|
||||
validateEmail = function(email) {
|
||||
var result = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
|
||||
if (!result.test(email)) // TODO Fix when success to show mdDialog until 'Got it' clicked
|
||||
{
|
||||
console.log("DONE - 200");
|
||||
$mdDialog.show($mdDialog.alert().title('E-mail Verification').content('A verification e-mail has been sent to your email address.')
|
||||
.ariaLabel('Email verification alert dialog').ok('Got it!').targetEvent(email)); // Pop-up alert for e-mail verification
|
||||
// TODO ADD delete cookies and redirect only after pressed 'Got it'
|
||||
$cookieStore.remove("com.sehub.www"); // Removing the cookies
|
||||
$window.location.href = 'http://se-hub.appspot.com'; // Reference to 'welcome' page
|
||||
}).error(function()
|
||||
$mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address.')
|
||||
.ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(email));
|
||||
}
|
||||
if (result.test(email)) // TODO Fix when success to show mdDialog until 'Got it' clicked
|
||||
{
|
||||
$mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address or in the campus name.')
|
||||
.ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(email));
|
||||
});
|
||||
console.log("Im good");
|
||||
apiService.sendValidationMail(token, email).success(function(data) {
|
||||
console.log("DONE - 200");
|
||||
$mdDialog.show($mdDialog.alert().title('E-mail Verification').content('A verification e-mail has been sent to your email address.')
|
||||
.ariaLabel('Email verification alert dialog').ok('Got it!').targetEvent(email)); // Pop-up alert for e-mail verification
|
||||
// TODO ADD delete cookies and redirect only after pressed 'Got it'
|
||||
$cookieStore.remove("com.sehub.www"); // Removing the cookies
|
||||
$window.location.href = 'http://se-hub.appspot.com'; // Reference to 'welcome' page
|
||||
}).error(function() {
|
||||
$mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address or in the campus name.')
|
||||
.ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(email));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}]);
|
||||
}]);
|
|
@ -1,93 +0,0 @@
|
|||
angular.module('SeHub')
|
||||
.controller('settingsController', ['$scope', '$rootScope', 'dataService', 'apiService', '$cookies', '$location',
|
||||
function($scope, $rootScope, dataService, apiService, $cookies, $location) {
|
||||
|
||||
var token = $cookies['com.sehub.www'];
|
||||
|
||||
$scope.loadingData = true;
|
||||
$scope.isInRegisterMode = false;
|
||||
|
||||
$scope.title = "Settings"
|
||||
|
||||
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')
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$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 {
|
||||
apiService.updateUser(token, $scope.user).success(function(data) {
|
||||
console.info('User Saved');
|
||||
dataService.userBrodcast($scope.user);
|
||||
|
||||
}).error(function(e) {
|
||||
console.error('Fail To Save User');
|
||||
});
|
||||
$scope.profileMode = "Edit Profile";
|
||||
$scope.profileModeIcon = "fa fa-pencil";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DEBUG DATA
|
||||
*/
|
||||
$scope.courses = [{
|
||||
"courseName": "Advance Math",
|
||||
"campusName": "JCE",
|
||||
"startDate": {
|
||||
"year": 2015,
|
||||
"month": 4,
|
||||
"day": 3
|
||||
},
|
||||
"endDate": {
|
||||
"year": 2016,
|
||||
"month": 5,
|
||||
"day": 14
|
||||
},
|
||||
"taskFlag": false,
|
||||
"campus_avatar": "https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg"
|
||||
}];
|
||||
|
||||
$scope.campuses = [{
|
||||
'title': 'JCE',
|
||||
'email_ending': '@post.jce.ac.il',
|
||||
'master_user_id': 123453433341,
|
||||
'avatar_url': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg'
|
||||
}, {
|
||||
'title': 'Stanford',
|
||||
'email_ending': '@post.jce.ac.il',
|
||||
'master_user_id': 123453433341,
|
||||
'avatar_url': 'https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcR9M4uQgaJP1zyiCGw-dK31hU8buWqeuOi9vTXBd4Y8hQcFTZqA'
|
||||
}];
|
||||
|
||||
|
||||
$scope.labels = ['Commits', 'Issues Assigned', 'Messages', 'Open Tasks'];
|
||||
$scope.series = ['Project A', 'Project B'];
|
||||
|
||||
$scope.data = [
|
||||
[54, 3, 15, 3],
|
||||
[28, 48, 40, 3]
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
]);
|
|
@ -7,8 +7,7 @@ angular.module('SeHub')
|
|||
{
|
||||
var taskName = name;
|
||||
console.log("task created! " + taskName);
|
||||
$window.location.href = 'http://localhost:8080/home#/tasks/new'; // Reference to 'newTask' page
|
||||
|
||||
$location.path("/tasks/new"); // Reference to 'newTask' page
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,18 +37,17 @@ service.factory('apiService', ['$http', function($http) {
|
|||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/users/updateUser/" + token;
|
||||
|
||||
req = {
|
||||
method: "POST",
|
||||
method: "PUT",
|
||||
url: url,
|
||||
data: payLoad
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
getCourseByCampusName: function(token){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAll/" + token;
|
||||
getAllCoursesByCampus: function(token, campusId){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAllCoursesByCampus/" + token + '/' + campusId;
|
||||
req = {
|
||||
method : "GET",
|
||||
url : url,
|
||||
data: token
|
||||
url : url
|
||||
|
||||
};
|
||||
return $http(req);
|
||||
|
@ -71,14 +70,121 @@ service.factory('apiService', ['$http', function($http) {
|
|||
};
|
||||
return $http(req);
|
||||
},
|
||||
getCourseMessages: function(token, courseName){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCourseMessages/" + token + '/' + courseName;
|
||||
createMessage: function(token, payLoad){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/createMessage/" + token;
|
||||
req = {
|
||||
method : "POST",
|
||||
url : url,
|
||||
data: payLoad
|
||||
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
getMessagesByCourseName: function(token, courseName){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getMessagesByCourseName/" + token + '/' + courseName;
|
||||
req = {
|
||||
method : "GET",
|
||||
url : url
|
||||
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
createCourse: function(token, payLoad){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/create/" + token;
|
||||
req = {
|
||||
method : "POST",
|
||||
url : url,
|
||||
data: payLoad
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
getCampusesByUser: function(token){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/campuses/getCampusesByUser/" + token;
|
||||
req = {
|
||||
method : "GET",
|
||||
url : url
|
||||
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
getCoursesByUser: function(token, campusId){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCoursesByUser/" + token + "/" + campusId;
|
||||
req = {
|
||||
method : "GET",
|
||||
url : url
|
||||
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
getProjectsByCourse: function(token, classId){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getProjectsByCourse/" + token + "/" + classId;
|
||||
req = {
|
||||
method : "GET",
|
||||
url : url
|
||||
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
getProjectsByUser: function(token){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/projects/getProjectsByUser/" + token;
|
||||
req = {
|
||||
method : "GET",
|
||||
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);
|
||||
},
|
||||
joinCourse: function(token, courseId){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/joinCourse/" + token + "/" + courseId;
|
||||
req = {
|
||||
method : "PUT",
|
||||
url : url
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
createMessage: function(token, payLoad){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/create/" + token;
|
||||
req = {
|
||||
method : "POST",
|
||||
url : url,
|
||||
data: payLoad
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
createProject: function(token, payLoad){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/projects/create/" + token;
|
||||
req = {
|
||||
method : "POST",
|
||||
url : url,
|
||||
data: payLoad
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
getCoursesByUserID: function(token, userId){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCoursesByUser/" + token + "/" + userId;
|
||||
req = {
|
||||
method : "GET",
|
||||
url : url
|
||||
};
|
||||
return $http(req);
|
||||
}
|
||||
};
|
||||
}]);
|
41
templates/views/campuses.html
Normal file
41
templates/views/campuses.html
Normal file
|
@ -0,0 +1,41 @@
|
|||
<div class = "myCampuses">
|
||||
<md-content layout-padding layout-margin>
|
||||
<h1 layout-margin style="margin-left:15px"><i class="fa fa-university"></i> Pick A Campus</h1>
|
||||
</md-content>
|
||||
<md-card class="cardAllCampuses">
|
||||
<div ng-if = "!scope.campusesEmpty">
|
||||
<div flex = "99" layout = "row" ng-repeat = "t in threeSizedArray" value = "{{t}}" layout-padding>
|
||||
<div flex = "32" layout = "column" ng-repeat = "campus in t" value = "{{campus}}" >
|
||||
<div ng-if="t.length != 1">
|
||||
<md-button ng-click = "goToCampus(campus.id)" style="width:100%; height:32%;" layout-padding class = "md-raised" >
|
||||
<!-- <img src="{{campus.avatar_url}}" style = "width:14%; height:auto;"> -->
|
||||
<md-card style="width:97%;height:97%">
|
||||
<img ng-src="{{campus.avatar_url}}" class="md-card-image" alt="Washed Out">
|
||||
<md-card-content>
|
||||
<h2 class="md-title">{{campus.title}}</h2>
|
||||
</md-card-content>
|
||||
</md-card>
|
||||
</md-button>
|
||||
</div>
|
||||
<div ng-if="t.length == 1">
|
||||
<md-button ng-click = "goToCampus(campus.id)" style="width:32%; height:32%;" layout-padding class = "md-raised" >
|
||||
<!-- <img src="{{campus.avatar_url}}" style = "width:14%; height:auto;"> -->
|
||||
<md-card style="width:97%;height:97%">
|
||||
<img ng-src="{{campus.avatar_url}}" class="md-card-image" alt="Washed Out">
|
||||
<md-card-content>
|
||||
<h2 class="md-title">{{campus.title}}</h2>
|
||||
</md-card-content>
|
||||
</md-card>
|
||||
</md-button>
|
||||
</div>
|
||||
<div class="spacer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-if = "scope.campusesEmpty">
|
||||
<md-card layout-padding>
|
||||
You Are Not Related To Any Campus, You May Join A Campus.
|
||||
</md-card>
|
||||
</div>
|
||||
</md-card>
|
||||
</div>
|
|
@ -99,71 +99,16 @@
|
|||
<md-button ng-click="clearAllClicked()" ng class="md-raised md-primary">Clear All</md-button>
|
||||
</div>
|
||||
<div class="port_spacer"></div>
|
||||
<md-input-container>
|
||||
<label> Write Your Desired Message Here And Press Post</label>
|
||||
<input type="text" minlength="1" ng-model="msg.msgToAdd" required>
|
||||
</md-input-container>
|
||||
</div>
|
||||
</md-content>
|
||||
|
||||
<md-content layout-padding layout-margin>
|
||||
<h1>
|
||||
<em><i class="fa fa-folder-open"></i> Project Evaluation</em>
|
||||
</h1>
|
||||
<md-select placeholder="Choose Project" ng-model="project" ng-click="chooseProjectClicked()" style="z-index: 300" class="projectDropDown">
|
||||
</md-select>
|
||||
<div layout = "column" layout-margin layout-padding>
|
||||
<div layout="row">
|
||||
<a href="http://localhost:8080/home#/projects">
|
||||
<md-card flex class = "projectExhibit" >
|
||||
Press On Me
|
||||
</md-card>
|
||||
</a>
|
||||
<a href="http://localhost:8080/home#/projects">
|
||||
<md-card flex class = "projectExhibit">
|
||||
Press On Me
|
||||
</md-card>
|
||||
</a>
|
||||
|
||||
<a href="http://localhost:8080/home#/projects">
|
||||
<md-card flex class = "projectExhibit">
|
||||
Press On Me
|
||||
</md-card>
|
||||
</a>
|
||||
</div>
|
||||
<div layout="row">
|
||||
<a href="http://localhost:8080/home#/projects">
|
||||
<md-card flex class = "projectExhibit">
|
||||
Press On Me
|
||||
</md-card>
|
||||
</a>
|
||||
<a href="http://localhost:8080/home#/projects">
|
||||
<md-card flex class = "projectExhibit">
|
||||
Press On Me
|
||||
</md-card>
|
||||
</a>
|
||||
<a href="http://localhost:8080/home#/projects">
|
||||
<md-card flex class = "projectExhibit">
|
||||
Press On Me
|
||||
</md-card>
|
||||
</a>
|
||||
</div>
|
||||
<div layout="row">
|
||||
<a href="http://localhost:8080/home#/projects">
|
||||
<md-card flex class = "projectExhibit">
|
||||
Press On Me
|
||||
</md-card>
|
||||
</a>
|
||||
<a href="http://localhost:8080/home#/projects">
|
||||
<md-card flex class = "projectExhibit">
|
||||
Press On Me
|
||||
</md-card>
|
||||
</a>
|
||||
<a href="http://localhost:8080/home#/projects">
|
||||
<md-card flex class = "projectExhibit">
|
||||
Press On Me
|
||||
</md-card>
|
||||
</a>
|
||||
<div layout-padding layout = "row">
|
||||
<div flex = "60">
|
||||
<md-input-container>
|
||||
<label> Write Your Desired Message Here And Press Post</label>
|
||||
<input type="text" minlength="1" ng-model="msg.msgToAdd" required></input>
|
||||
</md-input-container>
|
||||
</div>
|
||||
<div flex = "30">
|
||||
<md-select placeholder="Choose Course" ng-model="course" ng-click="chooseCourseClicked()" style="z-index: 300" class="courseDropDown"></md-select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</md-content>
|
||||
|
|
|
@ -109,13 +109,15 @@
|
|||
<!-- Controllers -->
|
||||
<script src="templates/js/controllers/mainController.js"></script>
|
||||
<script src="templates/js/controllers/homeController.js"></script>
|
||||
<script src="templates/js/controllers/settingsController.js"></script>
|
||||
<script src="templates/js/controllers/profileController.js"></script>
|
||||
<script src="templates/js/controllers/registerController.js"></script>
|
||||
<script src="templates/js/controllers/tasksController.js"></script>
|
||||
<script src="templates/js/controllers/myClassesController.js"></script>
|
||||
<script src="templates/js/controllers/newTasksController.js"></script>
|
||||
<script src="templates/js/controllers/projectsController.js"></script>
|
||||
<script src="templates/js/controllers/newCourseController.js"></script>
|
||||
<script src="templates/js/controllers/campusesController.js"></script>
|
||||
<script src="templates/js/controllers/myProjectsController.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -2,150 +2,92 @@
|
|||
<md-content layout-padding layout-margin>
|
||||
<h1 layout-margin style="margin-left:15px"><i class="fa fa-graduation-cap"></i> My Classes</h1>
|
||||
</md-content>
|
||||
<md-card class="cardAllcourses">
|
||||
<div flex = "99" layout = "row" ng-repeat = "t in holdArrays" value = "{{t}}" layout-padding>
|
||||
<div flex = "32" layout = "column" ng-repeat = "course in t" value = "{{course}}" >
|
||||
<div ng-if = "!scope.coursesEmpty">
|
||||
<div ng-if="t.length != 1">
|
||||
<md-button ng-click = "goToClass(course.id)" style="width:100%; height:32%;" layout-padding class = "md-raised" >
|
||||
<md-card style="width:97%;height:97%">
|
||||
<md-card-content>
|
||||
<h2 class="md-title">{{course.courseName}}</h2> <!-- Should Be "course.title" -->
|
||||
</md-card-content>
|
||||
</md-card>
|
||||
</md-button>
|
||||
</div>
|
||||
<div ng-if="t.length == 1">
|
||||
<md-button ng-click = "goToClass(course.id)" style="width:32%; height:32%;" layout-padding class = "md-raised" >
|
||||
<md-card style="width:97%;height:97%">
|
||||
<md-card-content>
|
||||
<h2 class="md-title">{{course.courseName}}</h2> <!-- Should Be "course.title" -->
|
||||
</md-card-content>
|
||||
</md-card>
|
||||
</md-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="spacer"></div>
|
||||
<div ng-if = "scope.coursesEmpty">
|
||||
You Are Not Related To Any Course, You May Join Any Course You Wish.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div flex = "99" class = "allcoursesShow" layout = "row" ng-repeat = "t in holdArrays" value = "{{t}}">
|
||||
<div flex ="32" layout = "column" ng-repeat = "course in t" value = "{{course}}" layout-padding>
|
||||
<div ng-if = "!scope.coursesEmpty">
|
||||
<md-card ng-click = "goToClass(course.id)" style="width:32%; height:32%;" layout-padding class = "campusCard">
|
||||
{{course.id}}
|
||||
</md-card>
|
||||
</div>
|
||||
<div ng-if = "scope.coursesEmpty">
|
||||
You Are Not Related To Any Course, You May Join Any Course You Wish.
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</md-card>
|
||||
<div ng-if="user.isLecturer"> <!-- Lecturer Mode -->
|
||||
<div layout="row">
|
||||
<div layout-margin layout-padding>
|
||||
<md-button ng-click="createCourseClicked()" ng class="md-raised md-primary">Create Class</md-button>
|
||||
</div>
|
||||
<div layout-margin layout-padding>
|
||||
<md-button ng-click="showMyCourses()" ng class="md-raised md-primary">Show My Classes</md-button>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-if="isNewCourse">
|
||||
<md-content>
|
||||
<md-content layout-padding layout="row" layout-sm="column">
|
||||
<md-input-container>
|
||||
<label>User Name</label>
|
||||
<input ng-model="user.name">
|
||||
</md-input-container>
|
||||
<md-input-container>
|
||||
<label>Email</label>
|
||||
<input ng-model="user.email" type="email">
|
||||
</md-input-container>
|
||||
</md-content>
|
||||
<md-content layout-padding>
|
||||
<form name="createNewCourseForm">
|
||||
<div layout layout-sm="column">
|
||||
<md-input-container style="width:80%">
|
||||
<label>Class Name</label>
|
||||
<input ng-model="user.createNewCourse" min-length="1" required>
|
||||
</md-input-container>
|
||||
<md-input-container flex>
|
||||
<label>Course Finish Date</label>
|
||||
<input type="date" ng-model="user.finalDate" required>
|
||||
</md-input-container>
|
||||
</div>
|
||||
<div layout layout-sm="column">
|
||||
<md-input-container flex>
|
||||
<label>First name</label>
|
||||
<input ng-model="user.firstName">
|
||||
</md-input-container>
|
||||
<md-input-container flex>
|
||||
<label>Last Name</label>
|
||||
<input ng-model="theMax">
|
||||
</md-input-container>
|
||||
</div>
|
||||
<md-input-container flex>
|
||||
<label>General Info (optional)</label>
|
||||
<textarea ng-model="user.courseInfo" columns="1" md-maxlength="150"></textarea>
|
||||
<md-content layout-padding>
|
||||
<md-card layout-padding>
|
||||
<div layout layout-sm="column">
|
||||
<!-- <input ng-model="course.campusName" required> -->
|
||||
<md-select placeholder = "Campus name" ng-model="course.campusName" ng-click = "chooseCampusClicked()" required>
|
||||
<md-option ng-repeat="c in campuses" value="{{c.title}}">
|
||||
{{c.title}}
|
||||
</md-option>
|
||||
</md-select>
|
||||
</div>
|
||||
<div layout layout-sm="column">
|
||||
<md-input-container style="width:80%">
|
||||
<label flex = "50">Class Name</label>
|
||||
<input ng-model="course.courseName" min-length="1" required>
|
||||
</md-input-container>
|
||||
</form>
|
||||
</md-content>
|
||||
<md-input-container flex = "20">
|
||||
<label>Course Start Date</label>
|
||||
<input type="date" ng-model="course.startDate" required>
|
||||
</md-input-container>
|
||||
<md-input-container flex = "20">
|
||||
<label>Course Finish Date</label>
|
||||
<input type="date" ng-model="course.endDate" required>
|
||||
</md-input-container>
|
||||
</div>
|
||||
</md-card>
|
||||
|
||||
<div layout-padding layout-margin>
|
||||
<md-button ng-click="submitNewClassClicked()" class="md-raised md-primary">Submit New Class</md-button>
|
||||
</div>
|
||||
</md-content>
|
||||
</div>
|
||||
<div layout-margin layout-padding ng-if="showMyClass">
|
||||
<!-- <div layout-margin layout-padding ng-if="showMyClass">
|
||||
<md-select placeholder="Choose Existing Course" ng-model="course" ng-click="chooseCourseClicked()" class="courseDropDown">
|
||||
<md-option ng-repeat="c in courses" value="{{c.course}}">{{c.course}}</md-option>
|
||||
</md-select>
|
||||
</div>
|
||||
<!-- <md-content>
|
||||
<div layout="row">
|
||||
<div flex="65">
|
||||
<md-card>
|
||||
<p class = "messagesFeed">Messages</p>
|
||||
</md-card>
|
||||
</div>
|
||||
<div flex="34">
|
||||
<md-card>
|
||||
<p class = "tasksFeed">Tasks</p>
|
||||
</md-card>
|
||||
</div>
|
||||
</div>
|
||||
<div layout="row">
|
||||
<div flex="65">
|
||||
<md-card>
|
||||
<div class = "messagesContent">
|
||||
<md-card ng-repeat = "msg in messages">
|
||||
<div layout="column">
|
||||
<div layout="row" layout-margin layout-padding>
|
||||
<div flex="10" class="md-avatar">
|
||||
<img ng-src="{{user.avatar_url}}" style="width:100%">
|
||||
</div>
|
||||
<div flex>
|
||||
<div layout = "column">
|
||||
<div>
|
||||
<b>{{user.name}}</b>
|
||||
</div>
|
||||
<div>
|
||||
class_name
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div flex="69" class="msgSent" layout-margin layout-padding>
|
||||
{{msg.text}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</md-card>
|
||||
</div>
|
||||
</md-card>
|
||||
</div>
|
||||
<div flex="34">
|
||||
<md-card>
|
||||
<p class = "tasksContent">
|
||||
For Task 3 Press: <a href="http://localhost:8080/home#/tasks">Task #3</a>
|
||||
<br></br>
|
||||
For Task 4 Press: <a href="http://localhost:8080/home#/home">Task #4</a>
|
||||
<br></br>
|
||||
For Task 5 Press: <a href="http://localhost:8080/home#/home">Task #5</a>
|
||||
<br></br>
|
||||
For Task 6 Press: <a href="http://localhost:8080/home#/home">Task #6</a>
|
||||
<br></br>
|
||||
For Task 7 Press: <a href="http://localhost:8080/home#/home">Task #7</a>
|
||||
<br></br>
|
||||
For Task 8 Press: <a href="http://localhost:8080/home#/home">Task #8</a>
|
||||
</p>
|
||||
</md-card>
|
||||
</div>
|
||||
</div>
|
||||
<div class ="addMessage" layout="row" layout-margin layout padding>
|
||||
<div>
|
||||
<md-button ng-click="addMessageClicked()" ng class="md-raised md-primary"><i class="fa fa-comments"></i></md-button>
|
||||
</div>
|
||||
<div ng-if="addMsg">
|
||||
<md-select placeholder="Choose Course" ng-model="course" ng-click="chooseCourseClicked()" class="courseDropDown">
|
||||
<md-option ng-repeat="c in courses" value="{{c.course}}">{{c.course}}</md-option>
|
||||
</md-select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div ng-if="addMsg">
|
||||
<div layout = "row" layout-margin layout padding layout-align = "left center">
|
||||
<md-button ng-click="postMessageClicked()" ng class="md-raised md-primary">Post</md-button>
|
||||
<md-button ng-click="clearAllClicked()" ng class="md-raised md-primary">Clear All</md-button>
|
||||
</div>
|
||||
<div class="port_spacer"></div>
|
||||
<md-input-container>
|
||||
<label> Write Your Desired Message Here And Press Post</label>
|
||||
<input type="text" minlength="1" ng-model="msg.msgToAdd" required>
|
||||
</md-input-container>
|
||||
</div>
|
||||
</md-content> -->
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<div ng-if="isStudent"> <!-- Student Mode -->
|
||||
|
|
117
templates/views/myProjects.html
Normal file
117
templates/views/myProjects.html
Normal file
|
@ -0,0 +1,117 @@
|
|||
<div class = "myProjects">
|
||||
<md-content layout-padding layout-margin>
|
||||
<h1 layout-margin style="margin-left:15px"><i class="fa fa-cube"></i> {{user.name}}'s projects</h1>
|
||||
<md-card class="cardAllProjects">
|
||||
<div flex = "99" layout = "row" ng-repeat = "t in holdArrays" value = "{{t}}" layout-padding>
|
||||
<div flex = "32" layout = "column" ng-repeat = "project in t" value = "{{project}}" >
|
||||
<div ng-if = "!scope.myProjectsEmpty">
|
||||
<div ng-if="t.length != 1">
|
||||
<md-button ng-click = "goToMyProjects(project.id)" style="width:100%; height:32%;" layout-padding class = "md-raised" >
|
||||
<md-card style="width:97%;height:97%">
|
||||
<md-card-content>
|
||||
<h2 class="md-title">{{project.id}}</h2>
|
||||
</md-card-content>
|
||||
</md-card>
|
||||
</md-button>
|
||||
</div>
|
||||
<div ng-if="t.length == 1">
|
||||
<md-button ng-click = "goToMyProjects(project.id)" style="width:32%; height:32%;" layout-padding class = "md-raised" >
|
||||
<md-card style="width:97%;height:97%">
|
||||
<md-card-content>
|
||||
<h2 class="md-title">{{project.id}}</h2>
|
||||
</md-card-content>
|
||||
</md-card>
|
||||
</md-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="spacer"></div>
|
||||
<div ng-if = "scope.myProjectsEmpty">
|
||||
You Do Not Have Any Project, You May Create One.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- <div flex ="99" class = "allProjectsShow" layout = "row" ng-repeat = "t in arrayHolder" value = "{{t}}">
|
||||
<div flex = "32" layout = "column" ng-repeat = "project in t" value = "{{project}}" layout-padding>
|
||||
<div ng-if = "!scope.myProjectsEmpty">
|
||||
<md-card layout-padding ng-click = "goToMyProject(project.id)" style="width:32%; height:32%;" class = "projectCard">
|
||||
{{project.id}}
|
||||
</md-card>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-if = "scope.myProjectsEmpty">
|
||||
You Do Not Have Any Project, You May Create One.
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
</md-card>
|
||||
</md-content>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- div layout-padding layout-margin>
|
||||
<div layout = "row" layout-padding layout-margin>
|
||||
<div flex = "49">
|
||||
Project Creator: {{user.name}} Should Be Project creator
|
||||
</div>
|
||||
<div flex = "49" >
|
||||
<div ng-if="user.isLecturer">
|
||||
<div layout = "row" layout-padding>
|
||||
<div>
|
||||
<md-button ng-click="editPressed()" class="md-raised md-primary">Edit</md-button>
|
||||
</div>
|
||||
<div ng-if="isEditPressed">
|
||||
<md-button ng-click="removeProject()" class="md-raised md-primary">Remove</md-button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div layout = "row" layout-padding layout-margin>
|
||||
<div flex = "49">
|
||||
<md-card>
|
||||
Here Will Be Graph - Commits Over Period Of Time
|
||||
</md-card>
|
||||
</div>
|
||||
<div flex = "49">
|
||||
<md-card>
|
||||
Here Will Be Graph (by columns) - Commits, Issues, Open Tasks
|
||||
</md-card>
|
||||
</div>
|
||||
</div>
|
||||
<div flex>
|
||||
<md-card>
|
||||
<md-content class="md-padding">
|
||||
<md-tabs md-dynamic-height md-border-bottom>
|
||||
<md-tab label="Commits">
|
||||
<md-content class="md-padding">
|
||||
<h1 class="md-display-2">Commits</h1>
|
||||
<p>Commits...</p>
|
||||
</md-content>
|
||||
</md-tab>
|
||||
<md-tab label="Issues">
|
||||
<md-content class="md-padding">
|
||||
<h1 class="md-display-2">Issues</h1>
|
||||
<p>Issues...</p>
|
||||
</md-content>
|
||||
</md-tab>
|
||||
<md-tab label="Bugs">
|
||||
<md-content class="md-padding">
|
||||
<h1 class="md-display-2">Bugs</h1>
|
||||
<p> Bugs Bugs Bugs..</p>
|
||||
</md-content>
|
||||
</md-tab>
|
||||
<md-tab label="WhatEver">
|
||||
<md-content class="md-padding">
|
||||
<h1 class="md-display-2">WhatEver</h1>
|
||||
<p>Bla Bla Bla..</p>
|
||||
</md-content>
|
||||
</md-tab>
|
||||
</md-tabs>
|
||||
</md-content>
|
||||
</md-card>
|
||||
</div>
|
||||
</div> -->
|
|
@ -1,6 +1,6 @@
|
|||
<div class = "newCourse">
|
||||
<md-content layout-padding layout-margin>
|
||||
<h1 layout-margin style="margin-left:15px"><i class="fa fa-graduation-cap"></i> My New Course</h1>
|
||||
<h1 layout-margin style="margin-left:15px"><i class="fa fa-graduation-cap"></i> {{user.name}}'s' New Course</h1>
|
||||
<md-button ng-click="goBack()" class="md-raised md-primary">Go Back</md-button>
|
||||
</md-content>
|
||||
</div>
|
|
@ -1,72 +1,81 @@
|
|||
<div layout-padding>
|
||||
<div layout="row">
|
||||
<div flex="20" layout-padding>
|
||||
<h2>
|
||||
<i class="fa fa-info-circle"></i> Task Info:
|
||||
</h2>
|
||||
<div flex="40" layout-padding>
|
||||
<md-card layout-padding>
|
||||
<h2>
|
||||
<i class="fa fa-info-circle"></i> Task Info:
|
||||
</h2>
|
||||
<div layout="column">
|
||||
<div>
|
||||
<md-input-container>
|
||||
<label>Title</label>
|
||||
<input ng-model="task.task.title" required>
|
||||
</md-input-container>
|
||||
</div>
|
||||
<div>
|
||||
<md-input-container>
|
||||
<label>Description</label>
|
||||
<textarea ng-model="task.task.description" required></textarea>
|
||||
</md-input-container>
|
||||
</div>
|
||||
<div>
|
||||
<md-switch ng-model="task.isPersonal" aria-label="Switch 1">
|
||||
This Is: a {{(task.isPersonal) ? "Personal" : "Project"}} Task
|
||||
</md-switch>
|
||||
</div>
|
||||
<div>
|
||||
Due Date:
|
||||
<datepicker date-format="d MMMM yyyy" style="width:100%" ng-click="dueTime()">
|
||||
<input ng-model="task.date" type="text"/>
|
||||
</datepicker>
|
||||
</div>
|
||||
<div layout="row">
|
||||
<div flex="60"></div>
|
||||
<div>
|
||||
<md-button class="md-raised md-primary"><i class="fa fa-paper-plane"></i> Submit</md-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</md-card>
|
||||
<div layout="column">
|
||||
<div>
|
||||
<md-input-container>
|
||||
<label>Title</label>
|
||||
<input ng-model="task.task.title" required>
|
||||
</md-input-container>
|
||||
</div>
|
||||
<div>
|
||||
<md-input-container>
|
||||
<label>Description</label>
|
||||
<textarea ng-model="task.task.description" required></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<md-switch ng-model="task.isPersonal" aria-label="Switch 1">
|
||||
This Is: a {{(task.isPersonal) ? "Personal" : "Project"}} Task
|
||||
</md-switch>
|
||||
</div>
|
||||
<div>
|
||||
Due Date:
|
||||
<datepicker date-format="d MMMM yyyy" style="width:100%" ng-click="dueTime()">
|
||||
<input ng-model="task.date" type="text"/>
|
||||
</datepicker>
|
||||
</div>
|
||||
<div layout="row">
|
||||
<div flex="60"></div>
|
||||
<div>
|
||||
<md-button class="md-raised md-primary"><i class="fa fa-paper-plane"></i> Submit</md-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<md-card layout-padding>
|
||||
<div>
|
||||
<h2>
|
||||
<i class="fa fa-cubes"></i> Add A component:
|
||||
</h2>
|
||||
</div>
|
||||
<div>
|
||||
Select Type:
|
||||
<md-select placeholder="Component Type" ng-model="newComp.type" ng-change="ComponentType(newComp.type)">
|
||||
<md-option ng-repeat="component in componentTypes" value="{{component.type}}">{{component.type}}</md-option>
|
||||
</md-select>
|
||||
</div>
|
||||
<div>
|
||||
<md-input-container ng-repeat="detail in compDetails">
|
||||
<label>{{detail.detail}}</label>
|
||||
<input ng-model="newComp.label[$index]" required>
|
||||
</md-input-container>
|
||||
</div>
|
||||
<div ng-if="isRadioButton">
|
||||
<md-button ng-click="addMoreOptions()" >
|
||||
Add An Option
|
||||
</md-button>
|
||||
</div>
|
||||
<div>
|
||||
<md-switch ng-model="newComp.isMandatory" aria-label="Switch 1">
|
||||
Mandatory?: {{ newComp.isMandatory}}
|
||||
</md-switch>
|
||||
</div>
|
||||
<div layout="row">
|
||||
<div flex="65"></div>
|
||||
<md-button class="md-raised" ng-click="addComponent()"><i class="fa fa-plus"></i> Add To Task</md-button>
|
||||
</div>
|
||||
</md-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div layout="column" flex="30" layout-padding>
|
||||
|
||||
<div>
|
||||
<h2>
|
||||
<i class="fa fa-cubes"></i> Add A component:
|
||||
</h2>
|
||||
</div>
|
||||
<div>
|
||||
Select Type:
|
||||
<md-select placeholder="Component Type" ng-model="newComp.type">
|
||||
<md-option ng-repeat="component in componentTypes" value="{{component.type}}">{{component.type}}</md-option>
|
||||
</md-select>
|
||||
</div>
|
||||
<div>
|
||||
<md-input-container>
|
||||
<label>Label</label>
|
||||
<input ng-model="newComp.label" required>
|
||||
</md-input-container>
|
||||
</div>
|
||||
<div>
|
||||
<md-switch ng-model="newComp.isMandatory" aria-label="Switch 1">
|
||||
Mandatory?: {{ newComp.isMandatory}}
|
||||
</md-switch>
|
||||
</div>
|
||||
<div layout="row">
|
||||
<div flex="65"></div>
|
||||
<md-button class="md-raised" ng-click="addComponent()"><i class="fa fa-plus"></i> Add To Task</md-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div flex="50" layout-padding>
|
||||
<div flex="60" layout-padding>
|
||||
<!-- <md-card style="background-image: url('http://www.stationeryhq.com/content/images/thumbs/0000324_clipboard_500.png')">
|
||||
|
||||
</md-card> -->
|
||||
|
@ -80,6 +89,9 @@
|
|||
<p>{{ dueTimeFromNow }}</p>
|
||||
<p>{{task.task.description}}</p>
|
||||
<p>{{(task.isPersonal) ? "Personal" : "Project"}} Task</p>
|
||||
|
||||
<md-divider ng-if="!$last"></md-divider>
|
||||
|
||||
<div ng-repeat="component in task.components">
|
||||
<!-- if text box -->
|
||||
<div ng-if="component.type == 'textbox'">
|
||||
|
@ -101,6 +113,20 @@
|
|||
{{ component.label}}
|
||||
</md-checkbox>
|
||||
</div>
|
||||
<!-- if Link -->
|
||||
<div ng-if="component.type == 'link'" layout="column" ng-init="initLinkComp(component)" style="width: 100%" layout-align="center">
|
||||
<md-button ng-href="{{component.href}}" style="width: 100%" target="_blank">
|
||||
<i class="fa fa-link"></i> {{component.title}}
|
||||
</md-button>
|
||||
</div>
|
||||
<!-- if RadioButtons -->
|
||||
<div ng-if="component.type == 'radiobuttons'" ng-init="initRadioButtonsComp(component)">
|
||||
{{component.title}}
|
||||
<md-radio-group ng-model="component.value" ng-change="RB(component)">
|
||||
<md-radio-button ng-repeat="option in component.values" value="{{option.text}}" class="md-primary">{{option.text}}</md-radio-button>
|
||||
</md-radio-group>
|
||||
</div>
|
||||
<md-divider ng-if="!$last"></md-divider>
|
||||
</div>
|
||||
</md-card>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<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>
|
||||
|
||||
</div>
|
||||
<md-content layout-padding>
|
||||
<md-card layout-padding>
|
||||
|
@ -15,7 +17,7 @@
|
|||
<img ng-src="{{user.avatar_url}}" alt="" style="width:20%">
|
||||
</div>
|
||||
<div flex="70%">
|
||||
<md-button class="md-raised" ng-click="changeProfileMode()">
|
||||
<md-button class="md-raised" ng-click="changeProfileMode()" ng-if="isUser">
|
||||
<i ng-class="profileModeIcon"></i> {{profileMode}}
|
||||
</md-button>
|
||||
</div>
|
||||
|
@ -78,7 +80,7 @@
|
|||
</div>
|
||||
<div class="spacer"></div>
|
||||
<div>
|
||||
<md-button class="">
|
||||
<md-button class="" ng-if="isUser">
|
||||
X
|
||||
</md-button>
|
||||
</div>
|
||||
|
@ -96,11 +98,11 @@
|
|||
<img alt="{{ person.name }}" ng-src="{{ campus.avatar_url }}" class="md-avatar" />
|
||||
</div>
|
||||
<div class="port_spacer">
|
||||
{{ campus.title }} -
|
||||
<strong>{{ campus.title }}</strong> {{campus.email_ending}}
|
||||
</div>
|
||||
<div class="spacer"></div>
|
||||
<div>
|
||||
<md-button class="">
|
||||
<md-button class="" ng-if="isUser">
|
||||
X
|
||||
</md-button>
|
||||
</div>
|
|
@ -1,6 +1,23 @@
|
|||
<div class = "projects">
|
||||
<h1 style="margin-left:15px"><i class="fa fa-graduation-cap"></i> Class {{course.courseName}}</h1>
|
||||
<div layout-padding layout-margin>
|
||||
<md-button ng-click = "joinCourse()" ng class = "md-raised"> Join Course</md-button>
|
||||
</div>
|
||||
<md-card class="cardAllProjects">
|
||||
<div flex ="99" class = "allProjectsShow" layout = "row" ng-repeat = "t in arrayHolder" value = "{{t}}">
|
||||
<div flex = "32" layout = "column" ng-repeat = "project in t" value = "{{project}}" layout-padding>
|
||||
<div ng-if = "!scope.projectEmpty">
|
||||
<md-card layout-padding ng-click = "goToProject(project.id)" style="width:32%; height:32%;" class = "projectCard">
|
||||
{{project.id}}
|
||||
</md-card>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-if = "scope.projectEmpty">
|
||||
You Are Not Related To Any Course, You May Join Any Course You Wish.
|
||||
</div>
|
||||
</div>
|
||||
</md-card>
|
||||
<md-content layout-padding layout-margin>
|
||||
<h1 style="margin-left:15px"><i class="fa fa-file-cube-o"></i> Projects</h1>
|
||||
<md-button ng-click="createProjectClicked()" ng class="md-raised md-primary">Create Project</md-button>
|
||||
</md-content>
|
||||
</div>
|
|
@ -1,6 +1,52 @@
|
|||
<div class = "tasks">
|
||||
<md-content layout-padding layout-margin>
|
||||
<h1 style="margin-left:15px"><i class="fa fa-file-text-o"></i> Tasks</h1>
|
||||
<md-button ng-click="createTaskClicked(taskName)" ng class="md-raised md-primary">Create Task</md-button>
|
||||
<div ng-if="user.isLecturer">
|
||||
<md-button ng-click="createTaskClicked(taskName)" ng class="md-raised md-primary">Create Task</md-button>
|
||||
|
||||
<div flex>
|
||||
<md-card>
|
||||
<md-content class="md-padding">
|
||||
<md-tabs md-dynamic-height md-border-bottom>
|
||||
<md-tab label="Submitted">
|
||||
<md-content class="md-padding">
|
||||
<h1 class="md-display-2">Submitted</h1>
|
||||
<p>Submitted...</p>
|
||||
</md-content>
|
||||
</md-tab>
|
||||
<md-tab label="Delayed">
|
||||
<md-content class="md-padding">
|
||||
<h1 class="md-display-2">Delayed</h1>
|
||||
<p>Delayed...</p>
|
||||
</md-content>
|
||||
</md-tab>
|
||||
<md-tab label="Not Submitted">
|
||||
<md-content class="md-padding">
|
||||
<h1 class="md-display-2">Not Submitted</h1>
|
||||
<p> Not Submitted ..</p>
|
||||
</md-content>
|
||||
</md-tab>
|
||||
<md-tab label="WhatEver">
|
||||
<md-content class="md-padding">
|
||||
<h1 class="md-display-2">WhatEver</h1>
|
||||
<p>Bla Bla Bla..</p>
|
||||
</md-content>
|
||||
</md-tab>
|
||||
</md-tabs>
|
||||
</md-content>
|
||||
</md-card>
|
||||
</div>
|
||||
|
||||
<!-- Should Be In Table List -->
|
||||
<div class = "allProjectsShow" flex = "99" layout = "row" ng-repeat = "t in threeSizedArray" value = "{{t}}" layout-padding>
|
||||
<div flex = "32" layout = "column" ng-repeat = "project in t" value = "{{project}}">
|
||||
<md-button ng-click = "goToProject(project.id)" style="width:32%; height:32%;" flex="32" layout-padding class = "md-raised">
|
||||
<!-- <img src="{{campus.avatar_url}}" style = "width:14%; height:auto;"> -->
|
||||
{{project.title}}
|
||||
</md-button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Should Be In Table List -->
|
||||
</div>
|
||||
</md-content>
|
||||
</div>
|
Loading…
Reference in a new issue