Skip to content

Commit 617e7bf

Browse files
author
Christoph Wolfes
committed
refactored code
1 parent 22d6dcc commit 617e7bf

File tree

9 files changed

+39
-44
lines changed

9 files changed

+39
-44
lines changed

src/charts/commitsByAuthor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
'use strict';
2626

2727
angular.module('adf.widget.scm')
28-
.controller('CommitsByAuthorController', function(config, repository, commitsByAuthor){
28+
.controller('CommitsByAuthorController', function (config, repository, commitsByAuthor) {
2929
var vm = this;
3030

3131
if (repository && commitsByAuthor) {
@@ -37,7 +37,7 @@ angular.module('adf.widget.scm')
3737

3838
angular.forEach(commitsByAuthor.author, function (entry) {
3939
var author = entry.value;
40-
data[author]= entry.count;
40+
data[author] = entry.count;
4141
});
4242

4343
var options = {

src/charts/commitsByMonth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ angular.module('adf.widget.scm')
4040
id: 'y-axis-1',
4141
display: true,
4242
position: 'left',
43-
ticks: { fixedStepSize: 1 },
43+
ticks: {fixedStepSize: 1},
4444
scaleLabel: {
4545
display: true,
4646
labelString: 'Commits'

src/charts/commitsLastCommits.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
'use strict';
2626

2727
angular.module('adf.widget.scm')
28-
.controller('LastCommitsController', function($filter, config, repository, commits){
28+
.controller('LastCommitsController', function ($filter, config, repository, commits) {
2929
var vm = this;
3030

3131
if (repository && commits) {
@@ -40,7 +40,7 @@ angular.module('adf.widget.scm')
4040
id: 'y-axis-1',
4141
display: true,
4242
position: 'left',
43-
ticks: { fixedStepSize: 1 },
43+
ticks: {fixedStepSize: 1},
4444
scaleLabel: {
4545
display: true,
4646
labelString: 'Commits'
@@ -59,11 +59,11 @@ angular.module('adf.widget.scm')
5959
};
6060

6161
var data = {};
62-
angular.forEach(commits, function(commit){
62+
angular.forEach(commits, function (commit) {
6363
var date = new Date(commit.date);
6464
var key = date.getUTCFullYear() + '-' + (date.getUTCMonth() + 1) + '-' + date.getUTCDate();
6565
var entry = data[key];
66-
if (entry){
66+
if (entry) {
6767
entry.count += 1;
6868
} else {
6969
data[key] = {
@@ -73,7 +73,7 @@ angular.module('adf.widget.scm')
7373
}
7474
});
7575

76-
angular.forEach(data, function(entry) {
76+
angular.forEach(data, function (entry) {
7777
chart.labels.push(entry.date);
7878
chartData.push(entry.count);
7979
});

src/commits/commits.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@
2525
'use strict';
2626

2727
angular.module('adf.widget.scm')
28-
.controller('CommitsController', function($sce, config, repository, commits){
28+
.controller('CommitsController', function ($sce, config, repository, commits) {
2929
var vm = this;
3030

3131
vm.repository = repository;
3232

3333
// allow html descriptions
34-
angular.forEach(commits, function(commit){
34+
angular.forEach(commits, function (commit) {
3535
commit.description = $sce.trustAsHtml(commit.description);
3636
});
3737
vm.commits = commits;
3838

39-
vm.gravatarHash = function(commit){
39+
vm.gravatarHash = function (commit) {
4040
var hash;
41-
if (commit.properties){
42-
for (var i=0; i<commit.properties.length; i++){
43-
if (commit.properties[0].key === 'gravatar-hash'){
41+
if (commit.properties) {
42+
for (var i = 0; i < commit.properties.length; i++) {
43+
if (commit.properties[0].key === 'gravatar-hash') {
4444
hash = commit.properties[0].value;
4545
break;
4646
}

src/markdownPreview/edit.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
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" ng-init="vm.getBranchesByRepositoryId(config.repository)" ng-change="vm.getBranchesByRepositoryId(config.repository)">
4+
<select name="repository" id="repository" class="form-control" ng-model="config.repository"
5+
ng-init="vm.getBranchesByRepositoryId(config.repository)"
6+
ng-change="vm.getBranchesByRepositoryId(config.repository)">
57
<option ng-repeat="repository in vm.repositories | orderBy: 'name'" value="{{repository.id}}">
68
{{repository.name}}
79
</option>

src/markdownPreview/markdownPreview.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
2-
31
'use strict';
42

53
angular.module('adf.widget.scm')
6-
.controller('MarkdownPreviewController', function(repository,fileContent){
4+
.controller('MarkdownPreviewController', function (repository, fileContent) {
75
var vm = this;
86
vm.repository = repository;
97
vm.fileContent = fileContent;

src/markdownPreview/markdownPreviewEdit.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
2-
31
'use strict';
42

53
angular.module('adf.widget.scm')
6-
.controller('MarkdownPreviewEditController', function(repositories, SCM){
4+
.controller('MarkdownPreviewEditController', function (repositories, SCM) {
75
var vm = this;
86
vm.repositories = repositories;
97

10-
vm.getBranchesByRepositoryId = function(repositoryId){
11-
if (repositoryId){
12-
vm.selected = true;
13-
SCM.getBranchesByRepositoryId(repositoryId).then(function(result){
14-
if (result.branch){
8+
vm.getBranchesByRepositoryId = function (repositoryId) {
9+
if (repositoryId) {
10+
SCM.getBranchesByRepositoryId(repositoryId).then(function (result) {
11+
if (result.branch) {
1512
vm.branches = result.branch;
1613
}
1714
});

src/scm.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
'use strict';
2626

27-
angular.module('adf.widget.scm', ['adf.provider', 'chart.js', 'ngSanitize', 'btford.markdown'])
27+
angular.module('adf.widget.scm', ['adf.provider', 'chart.js', 'ngSanitize', 'btford.markdown'])
2828
.config(function (dashboardProvider) {
2929

3030
// category for widget add dialog
@@ -141,15 +141,13 @@ angular.module('adf.widget.scm', ['adf.provider', 'chart.js', 'ngSanitize', 'bt
141141
reload: true,
142142
resolve: {
143143
repository: resolveRepository,
144-
fileContent: function(SCM, config){
144+
fileContent: function (SCM, config) {
145145
var result = null;
146-
if (config.repository && config.path){
147-
result = SCM.getFileContent(config.repository,config.path);
146+
if (config.repository && config.path) {
147+
result = SCM.getFileContent(config.repository, config.path);
148148
}
149149
return result;
150150
}
151-
152-
153151
},
154152
edit: {
155153
templateUrl: '{widgetsPath}/scm/src/markdownPreview/edit.html',

src/service.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,42 @@
2525
'use strict';
2626

2727
angular.module('adf.widget.scm')
28-
.factory('SCM', function(scmEndpoint, $http){
29-
function data(response){
28+
.factory('SCM', function (scmEndpoint, $http) {
29+
function data(response) {
3030
return response.data;
3131
}
3232

33-
function request(url){
33+
function request(url) {
3434
return $http.get(scmEndpoint + url).then(data);
3535
}
3636

37-
function getRepositories(){
37+
function getRepositories() {
3838
return request('repositories.json');
3939
}
4040

41-
function getRepository(id){
41+
function getRepository(id) {
4242
return request('repositories/' + id + '.json');
4343
}
4444

45-
function getCommitsByAuthor(id){
45+
function getCommitsByAuthor(id) {
4646
return request('plugins/statistic/' + id + '/commits-per-author.json');
4747
}
4848

49-
function getCommitsByMonth(id){
49+
function getCommitsByMonth(id) {
5050
return request('plugins/statistic/' + id + '/commits-per-month.json');
5151
}
5252

53-
function getCommits(id, limit){
54-
return request('repositories/' + id + '/changesets.json?limit=' + limit).then(function(data){
53+
function getCommits(id, limit) {
54+
return request('repositories/' + id + '/changesets.json?limit=' + limit).then(function (data) {
5555
return data.changesets;
5656
});
5757
}
5858

59-
function getFileContent(id, filePath){
60-
return request('repositories/'+id+'/content?path='+filePath);
59+
function getFileContent(id, filePath) {
60+
return request('repositories/' + id + '/content?path=' + filePath);
6161
}
6262

63-
function getBranchesByRepositoryId(id){
63+
function getBranchesByRepositoryId(id) {
6464
return request('repositories/' + id + '/branches');
6565
}
6666

0 commit comments

Comments
 (0)