File tree Expand file tree Collapse file tree 3 files changed +31
-8
lines changed Expand file tree Collapse file tree 3 files changed +31
-8
lines changed Original file line number Diff line number Diff line change 1
1
< form role ="form ">
2
2
< div class ="form-group ">
3
3
< p > < label for ="repository "> Repository</ label >
4
- < select name ="repository " id ="repository " class ="form-control " ng-model ="config.repository ">
4
+ < select name ="repository " id ="repository " class ="form-control " ng-model ="config.repository " ng-init =" vm.getBranchesByRepositoryId(config.repository) " ng-change =" vm.getBranchesByRepositoryId(config.repository) " >
5
5
< option ng-repeat ="repository in vm.repositories | orderBy: 'name' " value ="{{repository.id}} ">
6
6
{{repository.name}}
7
7
</ option >
8
8
</ select >
9
9
</ p >
10
+ < p ng-if ="config.repository "> < label for ="branch "> Branch</ label >
11
+ < select name ="branch " id ="branch " class ="form-control " ng-model ="config.branch ">
12
+ < option ng-repeat ="branch in vm.branches| orderBy: 'name' " value ="{{branch.id}} ">
13
+ {{branch.name}}
14
+ </ option >
15
+ </ select >
16
+ </ p >
10
17
< label for ="path "> Path to Markdown File</ label >
11
18
< input type ="text " class ="form-control " id ="path " ng-model ="config.path ">
12
19
</ div >
Original file line number Diff line number Diff line change 3
3
'use strict' ;
4
4
5
5
angular . module ( 'adf.widget.scm' )
6
- . controller ( 'MarkdownPreviewEditController' , function ( repositories ) {
6
+ . controller ( 'MarkdownPreviewEditController' , function ( repositories , SCM ) {
7
7
var vm = this ;
8
8
vm . repositories = repositories ;
9
- vm . selected = repositories [ 1 ] ;
9
+
10
+ vm . getBranchesByRepositoryId = function ( repositoryId ) {
11
+ if ( repositoryId ) {
12
+ vm . selected = true ;
13
+ SCM . getBranchesByRepositoryId ( repositoryId ) . then ( function ( result ) {
14
+ if ( result . branch ) {
15
+ vm . branches = result . branch ;
16
+ }
17
+ } ) ;
18
+ }
19
+ } ;
20
+
10
21
} ) ;
Original file line number Diff line number Diff line change @@ -50,22 +50,27 @@ angular.module('adf.widget.scm')
50
50
return request ( 'plugins/statistic/' + id + '/commits-per-month.json' ) ;
51
51
}
52
52
53
- function getFileContent ( id , filePath ) {
54
- return request ( 'repositories/' + id + '/content?path=' + filePath ) ;
55
- }
56
-
57
53
function getCommits ( id , limit ) {
58
54
return request ( 'repositories/' + id + '/changesets.json?limit=' + limit ) . then ( function ( data ) {
59
55
return data . changesets ;
60
56
} ) ;
61
57
}
62
58
59
+ function getFileContent ( id , filePath ) {
60
+ return request ( 'repositories/' + id + '/content?path=' + filePath ) ;
61
+ }
62
+
63
+ function getBranchesByRepositoryId ( id ) {
64
+ return request ( 'repositories/' + id + '/branches' ) ;
65
+ }
66
+
63
67
return {
64
68
getRepositories : getRepositories ,
65
69
getRepository : getRepository ,
66
70
getCommitsByAuthor : getCommitsByAuthor ,
67
71
getCommitsByMonth : getCommitsByMonth ,
68
72
getCommits : getCommits ,
69
- getFileContent : getFileContent
73
+ getFileContent : getFileContent ,
74
+ getBranchesByRepositoryId : getBranchesByRepositoryId
70
75
} ;
71
76
} ) ;
You can’t perform that action at this time.
0 commit comments