4
4
angular . module ( 'adf.widget.redmine' , [ 'adf.provider' , 'smart-table' ] )
5
5
. constant ( "redmineEndpoint" , "http://www.redmine.org/" )
6
6
. config ( [ "dashboardProvider" , function ( dashboardProvider ) {
7
+
8
+ var edit = {
9
+ templateUrl : '{widgetsPath}/redmine/src/issues/edit/edit.html' ,
10
+ controller : 'editController' ,
11
+ controllerAs : 'vm' ,
12
+ resolve : {
13
+ /** @ngInject **/
14
+ projects : [ "redmineService" , function ( redmineService ) {
15
+ return redmineService . getProjects ( ) ;
16
+ } ]
17
+ }
18
+ } ;
19
+
7
20
dashboardProvider
8
21
. widget ( 'redmineIssues' , {
9
22
title : 'Redmine Issues' ,
@@ -13,24 +26,44 @@ angular.module('adf.widget.redmine', ['adf.provider', 'smart-table'])
13
26
controllerAs : 'vm' ,
14
27
resolve : {
15
28
/** @ngInject **/
16
- issues : [ "redmineService" , function ( redmineService ) {
17
- return redmineService . getIssues ( ) ;
29
+ issues : [ "redmineService" , "config" , function ( redmineService , config ) {
30
+ return redmineService . getIssues ( config ) ;
18
31
} ]
19
32
} ,
20
- edit : {
21
- templateUrl : '{widgetsPath}/redmine/src/issues/edit/edit.html'
22
- }
33
+ edit : edit
23
34
} ) ;
24
35
} ] ) ;
25
36
26
- angular . module ( "adf.widget.redmine" ) . run ( [ "$templateCache" , function ( $templateCache ) { $templateCache . put ( "{widgetsPath}/redmine/src/issues/view.html" , "<table st-table=rowCollection class=\"table table-striped\"><thead><tr><th>ID</th><th>Tracker</th><th>Status</th><th>Thema </th></tr></thead><tbody><tr ng-repeat=\"issue in vm.issues\"><td><a href=\'{{\"http://www.redmine.org/issues/\"+issue.id}}\'>{{issue.id}}</a></td><td>{{issue.tracker.name}}</td><td>{{issue.status.name}}</td><td>{{issue.subject}}</td></tr></tbody></table>" ) ;
27
- $templateCache . put ( "{widgetsPath}/redmine/src/issues/edit/edit.html" , "<form role=form><div class=form-group><label for=sample>Sample</label> <input type=text class=form-control id=sample ng-model=config.sample placeholder=\"Enter sample\"></div></form>" ) ; } ] ) ;
37
+ angular . module ( "adf.widget.redmine" ) . run ( [ "$templateCache" , function ( $templateCache ) { $templateCache . put ( "{widgetsPath}/redmine/src/issues/view.html" , "<table st-table=rowCollection class=\"table table-striped\"><thead><tr><th ng-if=vm.config.columns.id.show >ID</th><th ng-if=vm.config.columns.tracker.show >Tracker</th><th ng-if=vm.config.columns.status.show >Status</th><th ng-if=vm.config.columns.subject.show>Subject </th></tr></thead><tbody><tr ng-repeat=\"issue in vm.issues\"><td ng-if=vm.config.columns.id.show ><a href=\'{{\"http://www.redmine.org/issues/\"+issue.id}}\'>{{issue.id}}</a></td><td ng-if=vm.config.columns.tracker.show >{{issue.tracker.name}}</td><td ng-if=vm.config.columns.status.show >{{issue.status.name}}</td><td ng-if=vm.config.columns.subject.show >{{issue.subject}}</td></tr></tbody></table>" ) ;
38
+ $templateCache . put ( "{widgetsPath}/redmine/src/issues/edit/edit.html" , "<form role=form><div class=form-group><label for=project>Project</label><select name=project id=project class=form-control ng-model=config.project><option>All</option><option ng-repeat=\"project in vm.projects | orderBy: \'name\'\" value={{project.id}}>{{project.name}}</option></select></div><div class=form-group><label for=assgined_to_id>Assigned To</label> <span class=\"glyphicon glyphicon-info-sign\" uib-tooltip=\"Get issues which are assigned to the given user ID. <me> can be used instead an ID to fetch all issues from the logged in user. Leave empty if you want to see all issues.\"></span> <input name=assigned_to_id id=assgined_to_id class=form-control ng-model=config.assigned_to_id></div><div class=form-group><input type=checkbox name=showClosed ng-model=config.showClosed> Show closed issues</div><div class=form-group><label for=project>Columns to show:</label><li class=list-group-item ng-repeat=\"(key, entry) in vm.possibleColumns\"><input type=checkbox name={{key}} ng-model=config.columns[key].show> {{entry.name}}</li></div></form>" ) ; } ] ) ;
28
39
29
40
30
41
angular . module ( 'adf.widget.redmine' )
31
- . controller ( 'IssueController ' , [ "issues " , "config" , function ( issues , config ) {
42
+ . controller ( 'editController ' , [ "projects " , "config" , function ( projects , config ) {
32
43
var vm = this ;
44
+ vm . possibleColumns = {
45
+ "id" :{ "name" :"ID" , "show" : true } ,
46
+ "tracker" :{ "name" :"Tracker" , "show" : true } ,
47
+ "status" :{ "name" :"Status" , "show" : true } ,
48
+ "subject" :{ "name" :"Subject" , "show" : true }
49
+ } ;
50
+
51
+ if ( angular . equals ( { } , config ) ) {
52
+ config . columns = vm . possibleColumns ;
53
+ config . project = "" ;
54
+ config . assigned_to_id = "me" ;
55
+ config . showClosed = false ;
56
+ }
57
+
58
+ vm . projects = projects ;
59
+ } ] ) ;
60
+
61
+
33
62
63
+ angular . module ( 'adf.widget.redmine' )
64
+ . controller ( 'IssueController' , [ "issues" , "config" , function ( issues , config ) {
65
+ var vm = this ;
66
+ vm . config = config ;
34
67
vm . issues = issues . issues ;
35
68
} ] ) ;
36
69
@@ -47,11 +80,34 @@ angular.module('adf.widget.redmine')
47
80
return $http . get ( redmineEndpoint + param ) . then ( data ) ;
48
81
}
49
82
50
- function getIssues ( ) {
51
- return request ( 'issues.json?limit=2' ) ;
83
+ function getIssues ( config ) {
84
+ var params = generateIssuesParameter ( config ) ;
85
+ return request ( 'issues.json' + params ) ;
86
+ }
87
+
88
+ function generateIssuesParameter ( data ) {
89
+ var params = '?' ;
90
+ if ( data . project ) {
91
+ params += '&project_id=' + data . project ;
92
+ }
93
+ if ( data . assigned_to_id ) {
94
+ params += '&assigned_to_id=' + data . assigned_to_id ;
95
+ }
96
+ if ( data . showClosed ) {
97
+ params += '&status_id=*' ;
98
+ }
99
+ return params ;
52
100
}
101
+
102
+ function getProjects ( ) {
103
+ return request ( 'projects.json' ) . then ( function ( data ) {
104
+ return data . projects ;
105
+ } ) ;
106
+ }
107
+
53
108
return {
54
- getIssues : getIssues
109
+ getIssues : getIssues ,
110
+ getProjects : getProjects
55
111
} ;
56
112
} ] ) ;
57
113
} ) ( window ) ;
0 commit comments