Skip to content

Commit

Permalink
Merge pull request #3 from rwth-acis/develop
Browse files Browse the repository at this point in the history
FOSDEM release
  • Loading branch information
KristjanLiiva committed Feb 5, 2015
2 parents 3a00779 + 2e7777d commit 771b89f
Show file tree
Hide file tree
Showing 13 changed files with 1,038 additions and 335 deletions.
15 changes: 15 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<!-- endbower -->
<!-- endbuild -->

<base href="/">

<!-- 1. Load webcomponents.js for polyfill support. -->
<script src="bower_components/webcomponentsjs/webcomponents.js"></script>

Expand Down Expand Up @@ -38,7 +40,9 @@
<link rel="import" href="bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="bower_components/paper-input/paper-input.html">
<link rel="import" href="bower_components/paper-dialog/paper-dialog.html">
<link rel="import" href="bower_components/paper-dialog/paper-action-dialog.html">
<link rel="import" href="bower_components/paper-toast/paper-toast.html">
<link rel="import" href="bower_components/paper-fab/paper-fab.html">


<!--Might be missing from bower-->
Expand All @@ -49,6 +53,9 @@
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->

<!--Not added automatically-->
<link rel="import" href="styles/mdi.html">

</head>
<body unresolved>
<!--[if lt IE 7]>
Expand Down Expand Up @@ -86,14 +93,22 @@
<script src="bower_components/angular-touch/angular-touch.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/ng-polymer-elements/ng-polymer-elements.js"></script>
<script src="bower_components/ngstorage/ngStorage.js"></script>
<script src="bower_components/oauth-ng/dist/oauth-ng.js"></script>
<script src="bower_components/ng-file-upload/angular-file-upload.js"></script>
<!-- endbower -->
<!-- endbuild -->

<!-- build:js({.tmp,app}) scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/controllers/main.js"></script>
<script src="scripts/controllers/requirement.js"></script>
<script src="scripts/controllers/create.js"></script>
<script src="scripts/controllers/createComponent.js"></script>
<script src="scripts/controllers/about.js"></script>
<script src="scripts/services/reqbazservice.js"></script>
<script src="scripts/services/utilityservice.js"></script>
<script src="scripts/directives/contenteditable.js"></script>
<!-- endbuild -->

</body>
Expand Down
10 changes: 7 additions & 3 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ angular
'ngRoute',
'ngSanitize',
'ngTouch',
'ng-polymer-elements'
'ng-polymer-elements',
'oauth',
'angularFileUpload'
])
.config(function ($routeProvider) {
.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
Expand All @@ -31,4 +33,6 @@ angular
.otherwise({
redirectTo: '/'
});
});

$locationProvider.html5Mode(true).hashPrefix('!');
}]);
102 changes: 102 additions & 0 deletions app/scripts/controllers/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
'use strict';

/**
* @ngdoc function
* @name requirementsBazaarWebFrontendApp.controller:CreateCtrl
* @description
* # CreateCtrl
* Controller of the requirementsBazaarWebFrontendApp
*/
angular.module('requirementsBazaarWebFrontendApp')
.controller('CreateCtrl', function ($scope, reqBazService, UtilityService, $upload) {

$scope.showCreateDiv = false;
$scope.newName = '';
$scope.newDesc = '';

$scope.createAttachments = [];

//Creating a requirement
$scope.submitReq = function(){
if(!UtilityService.isEmpty($scope.newName,'Choose requirement name') && !UtilityService.isEmpty($scope.newDesc,'Choose requirement description')) {
if($scope.createAttachments.length !== 0){
//TODO save the attachments
$scope.createAttachments = [];
UtilityService.showFeedback('Warning: Attachments were not included !');
}
console.log('submit requirement');
var requirement = {title: $scope.newName, description: $scope.newDesc, projectId: $scope.activeProject.id, leadDeveloperId: 1, creatorId: 1};
reqBazService.createRequirement($scope.activeProject.id, $scope.activeComponent.id, requirement)
.success(function (message) {
console.log(message);
if (message.hasOwnProperty('errorCode')) {
UtilityService.showFeedback('Warning: Requirement was not created !');
} else {
//Add missing values to the newly created requirement
requirement.id = message.id;
requirement.creator = {firstName: 'loading'};
requirement.leadDeveloper = {firstName: 'loading'};
requirement.followers = [];
requirement.developers = [];
requirement.contributors = [];
requirement.attachments = [];
requirement.components = [];

//Add the requirement to the first position
$scope.requirements.splice(0, 0, requirement);
$scope.clearSubmit();
}
})
.error(function (error) {
//This error only catches unknown server errors, usual errorCodes are sent with success message
console.log(error);
UtilityService.showFeedback('Warning: Requirement was not created !');
});
}
};


$scope.submitProject = function(){
if(!UtilityService.isEmpty($scope.newName,'Choose project name') && !UtilityService.isEmpty($scope.newDesc, 'Choose project description')){
console.log('submit new project');
var project = {description: $scope.newDesc, name: $scope.newName, visibility: 'PUBLIC', leaderId: 1};
reqBazService.createProject(project)
.success(function (message) {
console.log(message);
if(message.hasOwnProperty('errorCode')){
UtilityService.showFeedback('Warning: Project was not created !');
}else {
UtilityService.showFeedback('Project was created');

//The project is added to be the first element and will be active
project.id = message.id;
$scope.activeProject = project;
$scope.projects.splice(0, 0, $scope.activeProject);
$scope.selectProj($scope.activeProject);
$scope.clearSubmit();
}
})
.error(function (error) {
console.log(error);
UtilityService.showFeedback('Warning: Project was not created !');
});
}
};

$scope.clearSubmit = function(){
$scope.newName = '';
$scope.newDesc = '';
$scope.showCreateDiv = false;
};

$scope.newAttachments = function(files){
if(files[0].type.indexOf('image/') > -1){
$scope.createAttachments.push({'file':files[0],'URL':URL.createObjectURL(files[0])});
}
if(files[0].type.indexOf('application/pdf') > -1 || files[0].type.indexOf('video/') > -1){
console.log('is pdf or video');
$scope.createAttachments.push({'file':files[0],'URL':null});
}
console.log($scope.createAttachments);
};
});
49 changes: 49 additions & 0 deletions app/scripts/controllers/createComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use strict';

/**
* @ngdoc function
* @name requirementsBazaarWebFrontendApp.controller:CreateComponentCtrl
* @description
* # CreateComponentCtrl
* Controller of the requirementsBazaarWebFrontendApp
*/
angular.module('requirementsBazaarWebFrontendApp')
.controller('CreateComponentCtrl', function ($scope, reqBazService, UtilityService, $upload) {

//Creates a new component
$scope.showCreateCompDiv = false;
$scope.newCompName = '';
$scope.newCompDesc = '';
$scope.submitNewComponent = function(){
if(!UtilityService.isEmpty($scope.newCompName,'Provide a name for the component')) {
console.log('submit new component');
var component = {description: $scope.newCompDesc, name: $scope.newCompName, leaderId: 1, projectId: $scope.activeProject.id};
reqBazService.createComponent($scope.activeProject.id,component)
.success(function (message) {
console.log(message);
if(message.hasOwnProperty('errorCode')){
UtilityService.showFeedback('Warning: Component was not created !');
}else {
UtilityService.showFeedback('Component was created');
component.id = message.id;

//The component is added to be the first element and will be active
$scope.activeComponent = component;
$scope.components.splice(0, 0, $scope.activeComponent);
$scope.selectComp($scope.activeComponent);
$scope.clearComponentSubmit();
}
})
.error(function (error) {
console.log(error);
UtilityService.showFeedback('Warning: Component was not created !');
});
}
};

$scope.clearComponentSubmit = function(){
$scope.newCompName = '';
$scope.newCompDesc = '';
$scope.showCreateCompDiv = false;
};
});
Loading

0 comments on commit 771b89f

Please sign in to comment.