Skip to content

Commit 75eb03f

Browse files
author
Christoph Wolfes
committed
added markdown preview widget
1 parent c8c5dc3 commit 75eb03f

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

src/markdownPreview/edit.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
<form role="form">
22
<div class="form-group">
33
<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)">
55
<option ng-repeat="repository in vm.repositories | orderBy: 'name'" value="{{repository.id}}">
66
{{repository.name}}
77
</option>
88
</select>
99
</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>
1017
<label for="path">Path to Markdown File</label>
1118
<input type="text" class="form-control" id="path" ng-model="config.path">
1219
</div>

src/markdownPreview/markdownPreviewEdit.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,19 @@
33
'use strict';
44

55
angular.module('adf.widget.scm')
6-
.controller('MarkdownPreviewEditController', function(repositories){
6+
.controller('MarkdownPreviewEditController', function(repositories, SCM){
77
var vm = this;
88
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+
1021
});

src/service.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,27 @@ angular.module('adf.widget.scm')
5050
return request('plugins/statistic/' + id + '/commits-per-month.json');
5151
}
5252

53-
function getFileContent(id, filePath){
54-
return request('repositories/'+id+'/content?path='+filePath);
55-
}
56-
5753
function getCommits(id, limit){
5854
return request('repositories/' + id + '/changesets.json?limit=' + limit).then(function(data){
5955
return data.changesets;
6056
});
6157
}
6258

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+
6367
return {
6468
getRepositories: getRepositories,
6569
getRepository: getRepository,
6670
getCommitsByAuthor: getCommitsByAuthor,
6771
getCommitsByMonth: getCommitsByMonth,
6872
getCommits: getCommits,
69-
getFileContent: getFileContent
73+
getFileContent: getFileContent,
74+
getBranchesByRepositoryId: getBranchesByRepositoryId
7075
};
7176
});

0 commit comments

Comments
 (0)