Merge branch 'master' of https://github.com/sagidayan/SE-Hub into API_Dev
This commit is contained in:
commit
5627ad7f5d
10 changed files with 265 additions and 17 deletions
|
@ -185,6 +185,7 @@ def oauth(oauth_token):
|
|||
|
||||
tempName = ";"
|
||||
|
||||
if 'email' in user_data:
|
||||
if user_data["email"] == "":
|
||||
for email in userEmails:
|
||||
if email["primary"] and email["verified"]:
|
||||
|
|
|
@ -3,6 +3,7 @@ import json
|
|||
__author__ = 'Aran'
|
||||
from google.appengine.ext import db
|
||||
|
||||
|
||||
class User(db.Model):
|
||||
username = db.StringProperty(required=True)
|
||||
name = db.StringProperty(required=False)
|
||||
|
@ -26,6 +27,36 @@ class User(db.Model):
|
|||
'campuses_id_list': self.campuses_id_list,
|
||||
'courses_id_list': self.courses_id_list,
|
||||
'projects_id_list': self.projects_id_list,
|
||||
'id' : self.key().id()
|
||||
'id' : self.key().id(),
|
||||
'stats': get_stats(self)
|
||||
}
|
||||
return json.dumps(data)
|
||||
|
||||
def get_stats(user):
|
||||
from models.Project import Project
|
||||
from models.Message import Message
|
||||
labels = ['Commits', 'Open Issues Assigned', 'Messages', 'Unfinished Tasks']
|
||||
data = [0, 0, 0, 0]
|
||||
for pid in user.projects_id_list:
|
||||
project = Project.get_by_id(int(pid))
|
||||
info = json.loads(project.info)
|
||||
stats = info["stats"]['micro']
|
||||
p_data = stats['data']
|
||||
p_series = stats['series']
|
||||
try:
|
||||
user_index = p_series.index(user.username)
|
||||
#adding commits
|
||||
data[0] = data[0] + p_data[user_index][0]
|
||||
#adding open issues
|
||||
data[1] = data[1] + p_data[user_index][1]
|
||||
except Exception:
|
||||
pass
|
||||
messages = Message.all().filter('master_id =', user.key().id())
|
||||
for m in messages.run():
|
||||
data[2] = data[2] + 1
|
||||
|
||||
#need to do tasks
|
||||
####
|
||||
|
||||
data = [data]
|
||||
return {'data': data, 'labels': labels}
|
|
@ -48,6 +48,14 @@ app.config(['$routeProvider', '$locationProvider',
|
|||
templateUrl: 'templates/views/newTask.html',
|
||||
controller: 'newTasksController'
|
||||
})
|
||||
.when('/tasks/overview/:taskId/:submitterId', {
|
||||
templateUrl: 'templates/views/task.html',
|
||||
controller: 'taskController'
|
||||
})
|
||||
.when('/tasks/fill/:taskId', {
|
||||
templateUrl: 'templates/views/task.html',
|
||||
controller: 'taskController'
|
||||
})
|
||||
.when('/class/:classId/:className', {
|
||||
templateUrl: 'templates/views/class.html',
|
||||
controller: 'classController'
|
||||
|
@ -71,3 +79,9 @@ app.config(['$routeProvider', '$locationProvider',
|
|||
}
|
||||
]);
|
||||
|
||||
app.config(function($mdThemingProvider) {
|
||||
$mdThemingProvider.theme('default')
|
||||
.primaryPalette('teal')
|
||||
.accentPalette('blue-grey');
|
||||
|
||||
});
|
|
@ -10,9 +10,11 @@ angular.module('SeHub')
|
|||
$scope.loadingData = true;
|
||||
$scope.isInRegisterMode = false;
|
||||
|
||||
apiService.getUserByToken(token).success(function(data) {
|
||||
if (data.message == 'No User Found') {
|
||||
apiService.getUserByToken(token).success(function(data, status) {
|
||||
if (status == 204) {
|
||||
console.error("No User Found!");
|
||||
$cookieStore.remove('com.sehub.www');
|
||||
window.location = 'http://se-hub.appstpot.com/';
|
||||
}
|
||||
$scope.loadingData = false;
|
||||
$scope.user = data;
|
||||
|
@ -60,6 +62,10 @@ angular.module('SeHub')
|
|||
$location.path('/home')
|
||||
}
|
||||
|
||||
}).error(function(err){
|
||||
console.error(err);
|
||||
$cookieStore.remove('com.sehub.www');
|
||||
window.location = DEBUG ? 'http://localhost:8080' : 'http://se-hub.appstpot.com/';
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ angular.module('SeHub')
|
|||
$scope.loadingData = true;
|
||||
$scope.isInRegisterMode = false;
|
||||
$scope.userExists = false;
|
||||
$scope.isUser = false;
|
||||
|
||||
$scope.title = "Profile";
|
||||
|
||||
|
@ -36,6 +37,13 @@ angular.module('SeHub')
|
|||
console.error("++++++++++++++++++++");
|
||||
});
|
||||
|
||||
$scope.labels = data.stats.labels;
|
||||
//$scope.series = ['Project A', 'Project B'];
|
||||
|
||||
$scope.data = data.stats.data;
|
||||
|
||||
$scope.isUser = $scope.$parent.user.id.toString() /*The Actual User*/ === $routeParams.id /*The Profile User*/ ;
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
@ -62,15 +70,7 @@ angular.module('SeHub')
|
|||
}
|
||||
}
|
||||
|
||||
$scope.labels = ['Commits', 'Issues Assigned', 'Messages', 'Open Tasks'];
|
||||
//$scope.series = ['Project A', 'Project B'];
|
||||
|
||||
$scope.data = [
|
||||
[54, 3, 15, 3] //,
|
||||
//[28, 48, 40, 3]
|
||||
];
|
||||
|
||||
$scope.isUser = $scope.$parent.user.id.toString() /*The Actual User*/ === $routeParams.id /*The Profile User*/ ;
|
||||
|
||||
}
|
||||
]);
|
126
templates/js/controllers/taskController.js
Normal file
126
templates/js/controllers/taskController.js
Normal file
|
@ -0,0 +1,126 @@
|
|||
angular.module('SeHub')
|
||||
.controller('taskController', ['$scope', '$rootScope', 'dataService', 'apiService',
|
||||
'$cookies', '$location', '$routeParams', '$mdDialog',
|
||||
|
||||
function($scope, $rootScope, dataService, apiService, $cookies, $location, $routeParams, $mdDialog) {
|
||||
|
||||
var taskId = $routeParams.taskId;
|
||||
var submitterId = $routeParams.submitterId;
|
||||
|
||||
|
||||
if (submitterId) { //In This Case we Only Want to show The Content of the Submitter
|
||||
$scope.readOnly = true;
|
||||
} else { //In This Case We Need An Empty Task To Be Able To Fill It
|
||||
$scope.readOnly = false;
|
||||
}
|
||||
|
||||
$scope.dateInit = function(date) {
|
||||
d = moment(new Date(date.year, date.month - 1, date.day));
|
||||
$scope.task.date = d.format("d MMMM YYYY");
|
||||
}
|
||||
|
||||
|
||||
$scope.dueTime = function() {
|
||||
if (!$scope.task.date || $scope.task.date === '')
|
||||
$scope.dueTimeFromNow = "";
|
||||
var d = new Date($scope.task.date);
|
||||
$scope.dueTimeFromNow = moment(d).fromNow();
|
||||
}
|
||||
|
||||
$scope.initLinkComp = function(component) {
|
||||
var arr = component.label.split("|");
|
||||
for (var i = 0; i < arr.length - 1; i++) {
|
||||
if (i == 0)
|
||||
component.title = arr[i];
|
||||
else
|
||||
component.href = arr[i];
|
||||
};
|
||||
}
|
||||
|
||||
$scope.initRadioButtonsComp = function(component) {
|
||||
var arr = component.label.split("|");
|
||||
component.values = [];
|
||||
for (var i = 0; i < arr.length - 1; i++) {
|
||||
if (i == 0)
|
||||
component.title = arr[i];
|
||||
else
|
||||
component.values.push({
|
||||
text: arr[i],
|
||||
id: i
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function validateComponents() {
|
||||
for (var i = 0; i < $scope.task.components.length; i++) {
|
||||
if ($scope.task.components[i].isMandatory && (!$scope.task.components[i].value || $scope.task.components[i].value == ''))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$scope.submitTask = function(event) { //Dialog will pop-up if not all mandatory fields are filled
|
||||
if (validateComponents()) {
|
||||
alert('All Shit Are Filled');
|
||||
return;
|
||||
}
|
||||
$mdDialog.show(
|
||||
$mdDialog.alert()
|
||||
.title('Hey There...')
|
||||
.content('You Must Fill All Mandatory Fields In Order To Submit The Task')
|
||||
.ariaLabel('Not All Mandatory Are Filled')
|
||||
.ok('Got it!')
|
||||
.targetEvent(event)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*=================================
|
||||
= Mock Data =
|
||||
=================================*/
|
||||
|
||||
$scope.task = {
|
||||
"title": "task1",
|
||||
"courseId": 1234567890,
|
||||
"description": "one line\nsecondline\nthirdline",
|
||||
"dueDate": {
|
||||
"year": 2010,
|
||||
"month": 2,
|
||||
"day": 4
|
||||
},
|
||||
"isPersonal": true,
|
||||
"components": [{
|
||||
"type": "radiobuttons",
|
||||
"label": "pick One|this|orthis|MaybeThis",
|
||||
"isMandatory": true,
|
||||
"order": 1
|
||||
}, {
|
||||
"type": "checkbox",
|
||||
"label": "tick Me",
|
||||
"isMandatory": true,
|
||||
"order": 2
|
||||
}, {
|
||||
"type": "textarea",
|
||||
"label": "fill shit",
|
||||
"isMandatory": false,
|
||||
"order": 3
|
||||
}]
|
||||
};
|
||||
|
||||
$scope.dateInit($scope.task.dueDate);
|
||||
|
||||
$scope.dueTime = function() {
|
||||
if (!$scope.task.date || $scope.task.date === '')
|
||||
$scope.dueTimeFromNow = "";
|
||||
var d = new Date($scope.task.date);
|
||||
$scope.descriptionInit = function(desc) {
|
||||
desc.replace('\n', '<br>');
|
||||
}
|
||||
$scope.descriptionInit($scope.task.description);
|
||||
$scope.dueTimeFromNow = moment(d).fromNow();
|
||||
}
|
||||
|
||||
}
|
||||
]); //End Controller
|
|
@ -112,6 +112,7 @@
|
|||
<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/taskController.js"></script>
|
||||
<script src="templates/js/controllers/myClassesController.js"></script>
|
||||
<script src="templates/js/controllers/newTasksController.js"></script>
|
||||
<script src="templates/js/controllers/classController.js"></script>
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
<h3><i class="fa fa-clipboard"></i> {{task.task.title}}</h3>
|
||||
<h4>Due At: {{ task.date }}</h4>
|
||||
<p>{{ dueTimeFromNow }}</p>
|
||||
<p>{{task.task.description}}</p>
|
||||
<p style="white-space: pre-wrap;">{{task.task.description}}</p>
|
||||
<p>{{(task.isPersonal) ? "Personal" : "Project"}} Task</p>
|
||||
|
||||
<md-divider ng-if="!$last"></md-divider>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<md-card layout-padding>
|
||||
<h1><i class="fa fa-cogs"></i> {{title}}</h1>
|
||||
<div layout="row">
|
||||
<div>
|
||||
<div flex='40'>
|
||||
<md-card layout-padding>
|
||||
<div id="profile" layout="column">
|
||||
<!-- User Profile Box -->
|
||||
|
|
69
templates/views/task.html
Normal file
69
templates/views/task.html
Normal file
|
@ -0,0 +1,69 @@
|
|||
<div layout='row'>
|
||||
<div flex='20'></div>
|
||||
<div layout="coulumn" flex="60">
|
||||
<md-card layout-padding style="width:100%">
|
||||
<h1><i class="fa fa-clipboard"></i> {{task.title}}</h1>
|
||||
<h4>Due At: {{ task.date }}</h4>
|
||||
<p>{{ dueTimeFromNow }}</p>
|
||||
<p style="white-space: pre-wrap;">{{task.description}}</p>
|
||||
<p>{{(task.isPersonal) ? "Personal" : "Project"}} Task</p>
|
||||
|
||||
<!-- <md-divider></md-divider> -->
|
||||
|
||||
<div ng-repeat="component in task.components">
|
||||
<md-card layout-padding>
|
||||
<div ng-if="component.isMandatory && !(component.value && component.value != '')">
|
||||
<font color="red">
|
||||
<i class="fa fa-certificate"></i>
|
||||
</font>
|
||||
</div>
|
||||
<!-- if text box -->
|
||||
<div ng-if="component.type == 'textbox'">
|
||||
<md-input-container>
|
||||
<label>{{component.label}}</label>
|
||||
<input ng-model="component.value" ng-disabled="readOnly">
|
||||
</md-input-container>
|
||||
</div>
|
||||
<!-- if Text Area -->
|
||||
<div ng-if="component.type == 'textarea'">
|
||||
<md-input-container>
|
||||
<label>{{component.label}}</label>
|
||||
<textarea ng-model="component.value" ng-disabled="readOnly"></textarea>
|
||||
</md-input-container>
|
||||
</div>
|
||||
<!-- if Checkbox -->
|
||||
<div ng-if="component.type == 'checkbox'">
|
||||
<md-checkbox ng-model="component.value" aria-label="Checkbox 1" ng-disabled="readOnly">
|
||||
{{ 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)" ng-disabled="readOnly">
|
||||
<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-card>
|
||||
</div>
|
||||
<div layout='row' ng-if='!readOnly'>
|
||||
<div class='spacer'></div>
|
||||
<div style='position:relative;'>
|
||||
<md-button class='md-primary' ng-click='submitTask($event)'>Submit</md-button>
|
||||
</div>
|
||||
</div>
|
||||
</md-card>
|
||||
</div>
|
||||
|
||||
<div flex='20'></div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in a new issue