Skip to content

Commit 771b89f

Browse files
committed
Merge pull request #3 from rwth-acis/develop
FOSDEM release
2 parents 3a00779 + 2e7777d commit 771b89f

File tree

13 files changed

+1038
-335
lines changed

13 files changed

+1038
-335
lines changed

app/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<!-- endbower -->
1212
<!-- endbuild -->
1313

14+
<base href="/">
15+
1416
<!-- 1. Load webcomponents.js for polyfill support. -->
1517
<script src="bower_components/webcomponentsjs/webcomponents.js"></script>
1618

@@ -38,7 +40,9 @@
3840
<link rel="import" href="bower_components/paper-icon-button/paper-icon-button.html">
3941
<link rel="import" href="bower_components/paper-input/paper-input.html">
4042
<link rel="import" href="bower_components/paper-dialog/paper-dialog.html">
43+
<link rel="import" href="bower_components/paper-dialog/paper-action-dialog.html">
4144
<link rel="import" href="bower_components/paper-toast/paper-toast.html">
45+
<link rel="import" href="bower_components/paper-fab/paper-fab.html">
4246

4347

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

56+
<!--Not added automatically-->
57+
<link rel="import" href="styles/mdi.html">
58+
5259
</head>
5360
<body unresolved>
5461
<!--[if lt IE 7]>
@@ -86,14 +93,22 @@
8693
<script src="bower_components/angular-touch/angular-touch.js"></script>
8794
<script src="bower_components/angular-route/angular-route.js"></script>
8895
<script src="bower_components/ng-polymer-elements/ng-polymer-elements.js"></script>
96+
<script src="bower_components/ngstorage/ngStorage.js"></script>
97+
<script src="bower_components/oauth-ng/dist/oauth-ng.js"></script>
98+
<script src="bower_components/ng-file-upload/angular-file-upload.js"></script>
8999
<!-- endbower -->
90100
<!-- endbuild -->
91101

92102
<!-- build:js({.tmp,app}) scripts/scripts.js -->
93103
<script src="scripts/app.js"></script>
94104
<script src="scripts/controllers/main.js"></script>
105+
<script src="scripts/controllers/requirement.js"></script>
106+
<script src="scripts/controllers/create.js"></script>
107+
<script src="scripts/controllers/createComponent.js"></script>
95108
<script src="scripts/controllers/about.js"></script>
96109
<script src="scripts/services/reqbazservice.js"></script>
110+
<script src="scripts/services/utilityservice.js"></script>
111+
<script src="scripts/directives/contenteditable.js"></script>
97112
<!-- endbuild -->
98113

99114
</body>

app/scripts/app.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ angular
1616
'ngRoute',
1717
'ngSanitize',
1818
'ngTouch',
19-
'ng-polymer-elements'
19+
'ng-polymer-elements',
20+
'oauth',
21+
'angularFileUpload'
2022
])
21-
.config(function ($routeProvider) {
23+
.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
2224
$routeProvider
2325
.when('/', {
2426
templateUrl: 'views/main.html',
@@ -31,4 +33,6 @@ angular
3133
.otherwise({
3234
redirectTo: '/'
3335
});
34-
});
36+
37+
$locationProvider.html5Mode(true).hashPrefix('!');
38+
}]);

app/scripts/controllers/create.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
'use strict';
2+
3+
/**
4+
* @ngdoc function
5+
* @name requirementsBazaarWebFrontendApp.controller:CreateCtrl
6+
* @description
7+
* # CreateCtrl
8+
* Controller of the requirementsBazaarWebFrontendApp
9+
*/
10+
angular.module('requirementsBazaarWebFrontendApp')
11+
.controller('CreateCtrl', function ($scope, reqBazService, UtilityService, $upload) {
12+
13+
$scope.showCreateDiv = false;
14+
$scope.newName = '';
15+
$scope.newDesc = '';
16+
17+
$scope.createAttachments = [];
18+
19+
//Creating a requirement
20+
$scope.submitReq = function(){
21+
if(!UtilityService.isEmpty($scope.newName,'Choose requirement name') && !UtilityService.isEmpty($scope.newDesc,'Choose requirement description')) {
22+
if($scope.createAttachments.length !== 0){
23+
//TODO save the attachments
24+
$scope.createAttachments = [];
25+
UtilityService.showFeedback('Warning: Attachments were not included !');
26+
}
27+
console.log('submit requirement');
28+
var requirement = {title: $scope.newName, description: $scope.newDesc, projectId: $scope.activeProject.id, leadDeveloperId: 1, creatorId: 1};
29+
reqBazService.createRequirement($scope.activeProject.id, $scope.activeComponent.id, requirement)
30+
.success(function (message) {
31+
console.log(message);
32+
if (message.hasOwnProperty('errorCode')) {
33+
UtilityService.showFeedback('Warning: Requirement was not created !');
34+
} else {
35+
//Add missing values to the newly created requirement
36+
requirement.id = message.id;
37+
requirement.creator = {firstName: 'loading'};
38+
requirement.leadDeveloper = {firstName: 'loading'};
39+
requirement.followers = [];
40+
requirement.developers = [];
41+
requirement.contributors = [];
42+
requirement.attachments = [];
43+
requirement.components = [];
44+
45+
//Add the requirement to the first position
46+
$scope.requirements.splice(0, 0, requirement);
47+
$scope.clearSubmit();
48+
}
49+
})
50+
.error(function (error) {
51+
//This error only catches unknown server errors, usual errorCodes are sent with success message
52+
console.log(error);
53+
UtilityService.showFeedback('Warning: Requirement was not created !');
54+
});
55+
}
56+
};
57+
58+
59+
$scope.submitProject = function(){
60+
if(!UtilityService.isEmpty($scope.newName,'Choose project name') && !UtilityService.isEmpty($scope.newDesc, 'Choose project description')){
61+
console.log('submit new project');
62+
var project = {description: $scope.newDesc, name: $scope.newName, visibility: 'PUBLIC', leaderId: 1};
63+
reqBazService.createProject(project)
64+
.success(function (message) {
65+
console.log(message);
66+
if(message.hasOwnProperty('errorCode')){
67+
UtilityService.showFeedback('Warning: Project was not created !');
68+
}else {
69+
UtilityService.showFeedback('Project was created');
70+
71+
//The project is added to be the first element and will be active
72+
project.id = message.id;
73+
$scope.activeProject = project;
74+
$scope.projects.splice(0, 0, $scope.activeProject);
75+
$scope.selectProj($scope.activeProject);
76+
$scope.clearSubmit();
77+
}
78+
})
79+
.error(function (error) {
80+
console.log(error);
81+
UtilityService.showFeedback('Warning: Project was not created !');
82+
});
83+
}
84+
};
85+
86+
$scope.clearSubmit = function(){
87+
$scope.newName = '';
88+
$scope.newDesc = '';
89+
$scope.showCreateDiv = false;
90+
};
91+
92+
$scope.newAttachments = function(files){
93+
if(files[0].type.indexOf('image/') > -1){
94+
$scope.createAttachments.push({'file':files[0],'URL':URL.createObjectURL(files[0])});
95+
}
96+
if(files[0].type.indexOf('application/pdf') > -1 || files[0].type.indexOf('video/') > -1){
97+
console.log('is pdf or video');
98+
$scope.createAttachments.push({'file':files[0],'URL':null});
99+
}
100+
console.log($scope.createAttachments);
101+
};
102+
});
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
'use strict';
2+
3+
/**
4+
* @ngdoc function
5+
* @name requirementsBazaarWebFrontendApp.controller:CreateComponentCtrl
6+
* @description
7+
* # CreateComponentCtrl
8+
* Controller of the requirementsBazaarWebFrontendApp
9+
*/
10+
angular.module('requirementsBazaarWebFrontendApp')
11+
.controller('CreateComponentCtrl', function ($scope, reqBazService, UtilityService, $upload) {
12+
13+
//Creates a new component
14+
$scope.showCreateCompDiv = false;
15+
$scope.newCompName = '';
16+
$scope.newCompDesc = '';
17+
$scope.submitNewComponent = function(){
18+
if(!UtilityService.isEmpty($scope.newCompName,'Provide a name for the component')) {
19+
console.log('submit new component');
20+
var component = {description: $scope.newCompDesc, name: $scope.newCompName, leaderId: 1, projectId: $scope.activeProject.id};
21+
reqBazService.createComponent($scope.activeProject.id,component)
22+
.success(function (message) {
23+
console.log(message);
24+
if(message.hasOwnProperty('errorCode')){
25+
UtilityService.showFeedback('Warning: Component was not created !');
26+
}else {
27+
UtilityService.showFeedback('Component was created');
28+
component.id = message.id;
29+
30+
//The component is added to be the first element and will be active
31+
$scope.activeComponent = component;
32+
$scope.components.splice(0, 0, $scope.activeComponent);
33+
$scope.selectComp($scope.activeComponent);
34+
$scope.clearComponentSubmit();
35+
}
36+
})
37+
.error(function (error) {
38+
console.log(error);
39+
UtilityService.showFeedback('Warning: Component was not created !');
40+
});
41+
}
42+
};
43+
44+
$scope.clearComponentSubmit = function(){
45+
$scope.newCompName = '';
46+
$scope.newCompDesc = '';
47+
$scope.showCreateCompDiv = false;
48+
};
49+
});

0 commit comments

Comments
 (0)