- myProjects (work in progress)

This commit is contained in:
Matan Bar Yosef 2015-06-29 19:20:56 +03:00
parent 82dd89ce8f
commit 42a5e8b108
7 changed files with 42 additions and 225 deletions

View file

@ -54,9 +54,9 @@ app.config(['$routeProvider', '$locationProvider',
templateUrl: 'templates/views/newTask.html',
controller: 'newTasksController'
})
.when('/projects/:classId', {
templateUrl: 'templates/views/projects.html',
controller: 'projectsController'
.when('/class/:projectId', {
templateUrl: 'templates/views/class.html',
controller: 'classController'
})
.when('/newCourse', {
templateUrl: 'templates/views/newCourse.html',
@ -66,6 +66,10 @@ app.config(['$routeProvider', '$locationProvider',
templateUrl: 'templates/views/campuses.html',
controller: 'campusesController'
})
.when('/project/:projectId', {
templateUrl: 'templates/views/project.html',
controller: 'projectController'
})
.when('/myProjects', {
templateUrl: 'templates/views/myProjects.html',
controller: 'myProjectsController'

View file

@ -18,7 +18,7 @@ angular.module('SeHub')
$scope.goToClass = function(classId)
{
console.log("Done! " + $scope.courses);
$location.path('/projects/' + classId.toString()); // Will display all the projects in this course
$location.path('/class/' + classId.toString()); // Will display all the projects in this course
}
$scope.chooseCampusClicked = function()

View file

@ -2,31 +2,39 @@ 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.loadingDate = true;
$scope.myProjectsEmpty = true;
$scope.user = $scope.$parent.user;
var token = $cookies['com.sehub.www'];
console.log(token);
$scope.displayMyProjects = function()
{
apiService.getProjectsByUser(token).success(function(data)
{
console.log("Success " + data);
$scope.loadingDate = false;
$scope.myProjects = data;
if($scope.myProjects != null && $scope.myProjects.length > 0)
{
$scope.myProjectsEmpty = false;
}
}).error(function(err)
{
console.log("Error: " + err);
console.log("Error: " + err.message);
});
if($scope.myProjects === null)
{
$scope.myProjectsEmpty = true;
}
}
$scope.goToMyProject = function()
$scope.goToProject = function(projectId)
{
console.log("projects only from classID: " + classId)
$location.path('/thisProject' + classId);
for (var i = 0; i < $scope.myProjects; i++)
{
if($scope.myProjects.id === projectId)
{
console.log("project ID: " + projectId)
$location.path('/project/' + projectId);
}
};
}
var init = function()

View file

@ -1,124 +0,0 @@
angular.module('SeHub')
.controller('projectsController', ['$scope', '$routeParams', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $routeParams, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
{
var token = $cookies['com.sehub.www'];
var classId = $routeParams.classId;
$scope.projectsEmpty = true;
$scope.isCreateProjectClicked = false;
$scope.submitNewCourseClicked = false;
$scope.project = {};
$scope.loadingData = true;
$scope.isInCourse = false;
$scope.displayProjects = function()
{
console.log("in displayProjecs!!! ");
apiService.getProjectsByCourse(token, classId).success(function(data) // Get all the campuses
{
$scope.loadingData = false;
$scope.projects = data;
if($scope.projects != null && $scope.projects.length > 0)
{
$scope.projectsEmpty = false;
}
init(); // Executing the function to initialize projects display
console.log("project created! not rly!! " + classId);
}).error(function(err)
{
console.log("Error: " + err);
});
}
$scope.joinCourse = function()
{
apiService.joinCourse(token, classId).success(function(data)
{
$scope.isInCourse = true;
$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(err.message + '.')
.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! is it ?!???! " + classId);
$scope.isCreateProjectClicked = !$scope.isCreateProjectClicked;
}
$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()
{
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);
}
// Running...
$scope.displayProjects(); // Displaying all projects related to user
}]);

View file

@ -114,10 +114,11 @@
<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/classController.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>
<script src="templates/js/controllers/projectController.js"></script>
</body>
</html>

View file

@ -1,12 +1,18 @@
<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>
<h1 layout-margin style="margin-left:15px"><i class="fa fa-cube"></i> {{user.name}}'s projects</h1>
<div ng-if="loadingData" layout-paddig layout-margin class="loader">
<md-progress-circular md-mode="indeterminate"></md-progress-circular>
</div>
<div ng-if = "myProjectsEmpty && !loadingData" layout-padding layout-margin>
You Are Not Related To Any Project.
</div>
<div ng-if="!myProjects">
<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-button ng-click="goToProject(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>
@ -15,7 +21,7 @@
</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-button ng-click = "goToProject(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>
@ -30,7 +36,8 @@
</div>
</div>
</div>
</md-card>
</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>
@ -44,10 +51,6 @@
You Do Not Have Any Project, You May Create One.
</div>
</div> -->
</md-card>
</md-content>
</div>

View file

@ -1,75 +0,0 @@
<div class = "projects">
<h1 style="margin-left:15px"><i class="fa fa-graduation-cap"></i> Class {{project.title}}</h1>
<div layout-paddig layout-margin class="loader" ng-if="loadingData">
<md-progress-circular md-mode="indeterminate"></md-progress-circular>
</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">
<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>
<md-card layout-padding ng-click = "goToProject(project.id)" style="width:32%; height:32%;" class = "projectCard">
{{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>
</div>
</div>
</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-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.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>