commit
7d6050d775
3 changed files with 122 additions and 67 deletions
|
@ -3,30 +3,37 @@ angular.module('SeHub')
|
||||||
{
|
{
|
||||||
var token = $cookies['com.sehub.www'];
|
var token = $cookies['com.sehub.www'];
|
||||||
var classId = $routeParams.classId;
|
var classId = $routeParams.classId;
|
||||||
$scope.projectEmpty = false;
|
$scope.projectsEmpty = true;
|
||||||
|
$scope.isCreateProjectClicked = false;
|
||||||
|
$scope.submitNewCourseClicked = false;
|
||||||
|
$scope.project = {};
|
||||||
|
$scope.loadingData = true;
|
||||||
|
$scope.isInCourse = false;
|
||||||
|
|
||||||
$scope.displayProjects = function()
|
$scope.displayProjects = function()
|
||||||
{
|
{
|
||||||
console.log("in displayProjecs!!! ");
|
console.log("in displayProjecs!!! ");
|
||||||
apiService.getProjectsByCourse(token, classId).success(function(data) // Get all the campuses
|
apiService.getProjectsByCourse(token, classId).success(function(data) // Get all the campuses
|
||||||
{
|
{
|
||||||
|
$scope.loadingData = false;
|
||||||
$scope.projects = data;
|
$scope.projects = data;
|
||||||
|
if($scope.projects != null && $scope.projects.length > 0)
|
||||||
|
{
|
||||||
|
$scope.projectsEmpty = false;
|
||||||
|
}
|
||||||
init(); // Executing the function to initialize projects display
|
init(); // Executing the function to initialize projects display
|
||||||
console.log("project created! not rly!! " + classId);
|
console.log("project created! not rly!! " + classId);
|
||||||
}).error(function(err)
|
}).error(function(err)
|
||||||
{
|
{
|
||||||
console.log("Error: " + err);
|
console.log("Error: " + err);
|
||||||
});
|
});
|
||||||
if($scope.projects = null)
|
|
||||||
{
|
|
||||||
$scope.projectEmpty = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$scope.joinCourse = function()
|
$scope.joinCourse = function()
|
||||||
{
|
{
|
||||||
apiService.joinCourse(token, classId).success(function(data)
|
apiService.joinCourse(token, classId).success(function(data)
|
||||||
{
|
{
|
||||||
console.log("Success!!");
|
$scope.isInCourse = true;
|
||||||
$mdDialog.show($mdDialog.alert().title('Joined Course').content('You have successfully joined course.')
|
$mdDialog.show($mdDialog.alert().title('Joined Course').content('You have successfully joined course.')
|
||||||
.ariaLabel('Join course alert dialog').ok('Lets Start!').targetEvent())
|
.ariaLabel('Join course alert dialog').ok('Lets Start!').targetEvent())
|
||||||
.then(function() {
|
.then(function() {
|
||||||
|
@ -34,7 +41,7 @@ angular.module('SeHub')
|
||||||
}); // Pop-up alert
|
}); // Pop-up alert
|
||||||
}).error(function(err)
|
}).error(function(err)
|
||||||
{
|
{
|
||||||
$mdDialog.show($mdDialog.alert().title('Error Joining Course').content('You have failed joined the course.')
|
$mdDialog.show($mdDialog.alert().title('Error Joining Course').content(err.message + '.')
|
||||||
.ariaLabel('Join course alert dialog').ok('Try Again!').targetEvent()); // Pop-up alert
|
.ariaLabel('Join course alert dialog').ok('Try Again!').targetEvent()); // Pop-up alert
|
||||||
// .then(function() {
|
// .then(function() {
|
||||||
// // $location.path('/newCourse'); // TODO TODO TODO
|
// // $location.path('/newCourse'); // TODO TODO TODO
|
||||||
|
@ -44,12 +51,43 @@ angular.module('SeHub')
|
||||||
|
|
||||||
$scope.createProjectClicked = function()
|
$scope.createProjectClicked = function()
|
||||||
{
|
{
|
||||||
console.log("project created! not rly!! " + classId);
|
// console.log("project created! is it ?!???! " + classId);
|
||||||
|
$scope.isCreateProjectClicked = !$scope.isCreateProjectClicked;
|
||||||
// $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.submitNewProject = function()
|
||||||
|
{
|
||||||
|
// debugger;
|
||||||
|
var intClassId = parseInt(classId);
|
||||||
|
// console.log($scope);
|
||||||
|
var jsonNewProj =
|
||||||
|
{
|
||||||
|
'projectName': $scope.project.projectName,
|
||||||
|
'courseId': intClassId,
|
||||||
|
'gitRepository': $scope.project.repoOwner + '/' + $scope.project.gitRepoName
|
||||||
|
};
|
||||||
|
console.log(jsonNewProj);
|
||||||
|
|
||||||
|
if($scope.project.logoUrl)
|
||||||
|
jsonNewProj.logo_url = $scope.project.logoUrl;
|
||||||
|
|
||||||
|
|
||||||
|
apiService.create(token, jsonNewProj).success(function(data)
|
||||||
|
{
|
||||||
|
$mdDialog.show($mdDialog.alert().title('Project Created').content('You have successfully created project.')
|
||||||
|
.ariaLabel('Project created alert dialog').ok('Great!').targetEvent());
|
||||||
|
// .then(function() {
|
||||||
|
// $location.path('/projects/' + classId); // TODO TODO TODO
|
||||||
|
// }); // Pop-up alert
|
||||||
|
|
||||||
|
}).error(function(err)
|
||||||
|
{
|
||||||
|
console.log("Error: " + err.message);
|
||||||
|
$mdDialog.show($mdDialog.alert().title('Error Creating Project').content('You have failed Creating the project.')
|
||||||
|
.ariaLabel('Create project alert dialog').ok('Try Again!').targetEvent()); // Pop-up alert
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$scope.goToProject = function()
|
$scope.goToProject = function()
|
||||||
{
|
{
|
||||||
|
@ -62,16 +100,16 @@ angular.module('SeHub')
|
||||||
$scope.arrayHolder = [];
|
$scope.arrayHolder = [];
|
||||||
var tempArr = [];
|
var tempArr = [];
|
||||||
var sizeOfSmallArrays = 3;
|
var sizeOfSmallArrays = 3;
|
||||||
for (var i = 0 ; i < $scope.courses.length ; i++) {
|
for (var i = 0 ; i < $scope.projects.length ; i++) {
|
||||||
if(i % sizeOfSmallArrays !== 0){
|
if(i % sizeOfSmallArrays !== 0){
|
||||||
tempArr.push($scope.courses[i]);
|
tempArr.push($scope.projects[i]);
|
||||||
}else{
|
}else{
|
||||||
if(i !== 0){
|
if(i !== 0){
|
||||||
$scope.arrayHolder.push(tempArr);
|
$scope.arrayHolder.push(tempArr);
|
||||||
tempArr = [];
|
tempArr = [];
|
||||||
tempArr.push($scope.courses[i]);
|
tempArr.push($scope.projects[i]);
|
||||||
}else{
|
}else{
|
||||||
tempArr.push($scope.courses[i]);
|
tempArr.push($scope.projects[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -83,39 +121,4 @@ angular.module('SeHub')
|
||||||
$scope.displayProjects(); // Displaying all projects related to user
|
$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
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}]);
|
}]);
|
|
@ -117,7 +117,7 @@ service.factory('apiService', ['$http', function($http) {
|
||||||
return $http(req);
|
return $http(req);
|
||||||
},
|
},
|
||||||
getProjectsByCourse: function(token, classId){
|
getProjectsByCourse: function(token, classId){
|
||||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getProjectsByCourse/" + token + "/" + classId;
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/projects/getProjectsByCourse/" + token + "/" + classId;
|
||||||
req = {
|
req = {
|
||||||
method : "GET",
|
method : "GET",
|
||||||
url : url
|
url : url
|
||||||
|
@ -169,7 +169,7 @@ service.factory('apiService', ['$http', function($http) {
|
||||||
};
|
};
|
||||||
return $http(req);
|
return $http(req);
|
||||||
},
|
},
|
||||||
createProject: function(token, payLoad){
|
create: function(token, payLoad){
|
||||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/projects/create/" + token;
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/projects/create/" + token;
|
||||||
req = {
|
req = {
|
||||||
method : "POST",
|
method : "POST",
|
||||||
|
|
|
@ -1,23 +1,75 @@
|
||||||
<div class = "projects">
|
<div class = "projects">
|
||||||
<h1 style="margin-left:15px"><i class="fa fa-graduation-cap"></i> Class {{course.courseName}}</h1>
|
<h1 style="margin-left:15px"><i class="fa fa-graduation-cap"></i> Class {{project.title}}</h1>
|
||||||
<div layout-padding layout-margin>
|
<div layout-paddig layout-margin class="loader" ng-if="loadingData">
|
||||||
<md-button ng-click = "joinCourse()" ng class = "md-raised"> Join Course</md-button>
|
<md-progress-circular md-mode="indeterminate"></md-progress-circular>
|
||||||
</div>
|
</div>
|
||||||
|
<div ng-if = "projectsEmpty && !loadingData" layout-padding layout-margin>
|
||||||
|
You Are Not Related To Any Project.
|
||||||
|
</div>
|
||||||
|
<div ng-if = "!projectsEmpty">
|
||||||
<md-card class="cardAllProjects">
|
<md-card class="cardAllProjects">
|
||||||
<div flex ="99" class = "allProjectsShow" layout = "row" ng-repeat = "t in arrayHolder" value = "{{t}}">
|
<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 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">
|
<md-card layout-padding ng-click = "goToProject(project.id)" style="width:32%; height:32%;" class = "projectCard">
|
||||||
{{project.id}}
|
{{project.projectName}}
|
||||||
|
<canvas layout-padding layout-margin id="project.projectName" class="chart chart-bar" data="project.info.stats.macro.data"
|
||||||
|
labels="project.info.stats.macro.labels"></canvas>
|
||||||
</md-card>
|
</md-card>
|
||||||
</div>
|
</div>
|
||||||
</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-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div ng-if="!isInCourse" layout-padding layout-margin>
|
||||||
|
<md-button ng-click = "joinCourse()" ng class = "md-raised md-primary"> Join Course</md-button>
|
||||||
|
</div>
|
||||||
<md-content layout-padding layout-margin>
|
<md-content layout-padding layout-margin>
|
||||||
<md-button ng-click="createProjectClicked()" ng class="md-raised md-primary">Create Project</md-button>
|
<md-button ng-click="createProjectClicked()" ng class="md-raised md-primary">Create Project</md-button>
|
||||||
</md-content>
|
</md-content>
|
||||||
|
<div ng-if = "isCreateProjectClicked">
|
||||||
|
<md-card layout-padding style="width:60%">
|
||||||
|
<div layout="column">
|
||||||
|
<div>
|
||||||
|
<md-input-container>
|
||||||
|
<label flex>Project Name</label>
|
||||||
|
<input type = "text" ng-model="project.projectName" required>
|
||||||
|
</md-input-container>
|
||||||
|
</div>
|
||||||
|
<div layout = "row">
|
||||||
|
<div>
|
||||||
|
<md-input-container flex>
|
||||||
|
<label>GitHub Repository Owner</label>
|
||||||
|
<input type="text" ng-model="project.repoOwner" required>
|
||||||
|
</md-input-container>
|
||||||
|
</div>
|
||||||
|
<!-- <div>
|
||||||
|
<p>/</p>
|
||||||
|
</div> -->
|
||||||
|
<div>
|
||||||
|
<md-input-container flex>
|
||||||
|
<label>GitHub Repository Name</label>
|
||||||
|
<input type="text" ng-model="project.gitRepoName" required>
|
||||||
|
</md-input-container>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
<b>Example</b>: http://www.github.com/userName/repoName
|
||||||
|
<br/>userName will be GitHub Repository Owner
|
||||||
|
<br/>repoName wil be GitHub Repository Name
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<md-input-container flex>
|
||||||
|
<label>Logo Url (optional)</label>
|
||||||
|
<input type="text" ng-model="project.logoUrl">
|
||||||
|
</md-input-container>
|
||||||
|
</div>
|
||||||
|
<div layout-padding layout-margin>
|
||||||
|
<md-button ng-click="submitNewProject()" ng class="md-raised md-primary">Submit Project</md-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</md-card>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
Loading…
Reference in a new issue