- createCourse - changed to create

-create project function - added (work in progress)
This commit is contained in:
Matan Bar Yosef 2015-06-29 15:20:57 +03:00
parent 0cc88bc9b9
commit ab3f4737ba
3 changed files with 87 additions and 16 deletions

View file

@ -4,6 +4,8 @@ angular.module('SeHub')
var token = $cookies['com.sehub.www'];
var classId = $routeParams.classId;
$scope.projectEmpty = false;
$scope.isCreateProjectClicked = false;
$scope.submitNewCourseClicked = false;
$scope.displayProjects = function()
{
@ -44,9 +46,40 @@ angular.module('SeHub')
$scope.createProjectClicked = function()
{
console.log("project created! not rly!! " + classId);
// $window.location.href = 'http://localhost:8080/home#/tasks/new'; // Reference to 'newTask' page
console.log("project created! is it ?!???! " + classId);
$scope.isCreateProjectClicked = !$scope.isCreateProjectClicked;
var jsonNewProj =
{
'projectName': $scope.project.name,
'courseId': $scope.project.repoOwner,
'gitRepository': $scope.project.gitRepoOwner + '/' + $scope.project.gitRepoName
};
if($scope.project.logoUrl)
jsonNewProj.logo_url = $scope.project.logoUrl;
if($scope.submitNewCourseClicked)
{
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)
{
$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.submitNewProject = function()
{
$scope.submitNewCourseClicked = true;
}
// $scope.projects = ['AMI', 'LULU', 'XIN Zhau', 'LUMI lu', 'Shimi', 'Azligi zligi', 'Drugs'];
@ -89,16 +122,8 @@ angular.module('SeHub')
{
'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
}
'logo_url':
'gitRepository':
};*/
/*

View file

@ -169,7 +169,7 @@ service.factory('apiService', ['$http', function($http) {
};
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;
req = {
method : "POST",

View file

@ -1,7 +1,7 @@
<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>
<md-button ng-click = "joinCourse()" ng class = "md-raised md-primary"> Join Course</md-button>
</div>
<md-card class="cardAllProjects">
<div flex ="99" class = "allProjectsShow" layout = "row" ng-repeat = "t in arrayHolder" value = "{{t}}">
@ -12,7 +12,7 @@
</md-card>
</div>
</div>
<div ng-if = "scope.projectEmpty">
<div ng-if = "projectEmpty">
You Are Not Related To Any Course, You May Join Any Course You Wish.
</div>
</div>
@ -20,4 +20,50 @@
<md-content layout-padding layout-margin>
<md-button ng-click="createProjectClicked()" ng class="md-raised md-primary">Create Project</md-button>
</md-content>
<div ng-if = "isCreateProjectClicked">
<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.name" min-length="1" 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>
/
</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>