diff --git a/bower.json b/bower.json
index 0f571c7..2e38a9d 100644
--- a/bower.json
+++ b/bower.json
@@ -23,9 +23,10 @@
],
"description": "SCM-Manager related widgets",
"dependencies": {
- "angular": ">=1.4 <=1.6",
- "angular-dashboard-framework": "~0.12.0",
- "angular-chart.js": "^0.10.2"
+ "angular": ">=1.4 <=1.6.4",
+ "angular-dashboard-framework": "v0.12.x",
+ "angular-chart.js": "^1.1.0",
+ "angular-markdown-directive": "^0.3.1"
},
"devDependencies": {
"angular-local-storage": ">=0.2"
diff --git a/package.json b/package.json
index 2a6dda5..dc88d58 100644
--- a/package.json
+++ b/package.json
@@ -20,7 +20,7 @@
"gulp-connect": "~2.2.0",
"gulp-csslint": "^0.1.5",
"gulp-headerfooter": "^1.0.3",
- "gulp-if": "^1.2.5",
+ "gulp-if": "2.x",
"gulp-inject": "^1.2.0",
"gulp-jshint": "^1.9.4",
"gulp-less": "^3.0.2",
diff --git a/src/charts/commitsByAuthor.js b/src/charts/commitsByAuthor.js
index 846c776..575a130 100644
--- a/src/charts/commitsByAuthor.js
+++ b/src/charts/commitsByAuthor.js
@@ -25,8 +25,9 @@
'use strict';
angular.module('adf.widget.scm')
- .controller('CommitsByAuthorController', function(config, repository, commitsByAuthor){
+ .controller('CommitsByAuthorController', function (config, repository, commitsByAuthor) {
var vm = this;
+ vm.repository = repository;
if (repository && commitsByAuthor) {
vm.chart = createChart();
@@ -37,14 +38,22 @@ angular.module('adf.widget.scm')
angular.forEach(commitsByAuthor.author, function (entry) {
var author = entry.value;
- data[author]= entry.count;
+ data[author] = entry.count;
});
+ var options = {
+ legend: {
+ display: true,
+ position: "bottom"
+ }
+ };
+
var chart = {
labels: [],
data: [],
series: ["Commits"],
- class: "chart-pie"
+ class: "chart-pie",
+ options: options
};
angular.forEach(data, function (count, author) {
diff --git a/src/charts/commitsByMonth.js b/src/charts/commitsByMonth.js
index fa3052b..667ea20 100644
--- a/src/charts/commitsByMonth.js
+++ b/src/charts/commitsByMonth.js
@@ -25,27 +25,41 @@
'use strict';
angular.module('adf.widget.scm')
- .controller('CommitsByMonthController', function(config, repository, commitsByMonth) {
+ .controller('CommitsByMonthController', function (config, repository, commitsByMonth) {
var vm = this;
+ vm.repository = repository;
+
if (commitsByMonth) {
vm.chart = createChart();
}
- function parseDate(input) {
- var parts = input.split('-');
- return Date.UTC(parseInt(parts[0]), parseInt(parts[1]) - 1, 1);
- }
-
function createChart() {
var chartData = [];
+ var options = {
+ scales: {
+ yAxes: [
+ {
+ id: 'y-axis-1',
+ display: true,
+ position: 'left',
+ ticks: {fixedStepSize: 1},
+ scaleLabel: {
+ display: true,
+ labelString: 'Commits'
+ }
+ }
+ ]
+ }
+ };
var chart = {
labels: [],
data: [chartData],
series: ["Commits"],
- class: "chart-line"
+ class: "chart-line",
+ options: options
};
- angular.forEach(commitsByMonth.month, function(month) {
+ angular.forEach(commitsByMonth.month, function (month) {
chart.labels.push(month.value);
chartData.push(month.count);
});
diff --git a/src/charts/commitsLastCommits.js b/src/charts/commitsLastCommits.js
index fa95e15..2b79719 100644
--- a/src/charts/commitsLastCommits.js
+++ b/src/charts/commitsLastCommits.js
@@ -25,28 +25,46 @@
'use strict';
angular.module('adf.widget.scm')
- .controller('LastCommitsController', function($filter, config, repository, commits){
+ .controller('LastCommitsController', function ($filter, config, repository, commits) {
var vm = this;
+ vm.repository = repository;
if (repository && commits) {
vm.chart = createChart();
}
function createChart() {
+ var options = {
+ scales: {
+ yAxes: [
+ {
+ id: 'y-axis-1',
+ display: true,
+ position: 'left',
+ ticks: {fixedStepSize: 1},
+ scaleLabel: {
+ display: true,
+ labelString: 'Commits'
+ }
+ }
+ ]
+ }
+ };
var chartData = [];
var chart = {
labels: [],
data: [chartData],
series: ["Commits"],
- class: "chart-line"
+ class: "chart-line",
+ options: options
};
var data = {};
- angular.forEach(commits, function(commit){
+ angular.forEach(commits, function (commit) {
var date = new Date(commit.date);
var key = date.getUTCFullYear() + '-' + (date.getUTCMonth() + 1) + '-' + date.getUTCDate();
var entry = data[key];
- if (entry){
+ if (entry) {
entry.count += 1;
} else {
data[key] = {
@@ -56,8 +74,7 @@ angular.module('adf.widget.scm')
}
});
- angular.forEach(data, function(entry) {
- console.log(entry);
+ angular.forEach(data, function (entry) {
chart.labels.push(entry.date);
chartData.push(entry.count);
});
diff --git a/src/charts/line-chart.html b/src/charts/line-chart.html
index 1b9a62a..01d9592 100644
--- a/src/charts/line-chart.html
+++ b/src/charts/line-chart.html
@@ -2,10 +2,15 @@
Please insert a repository path in the widget configuration
+
+ Error {{vm.repository.status}} the endpoint could not be reached, this could mean that the selected repository does not exist
+ or that the statistics plugin is not installed
+
+
diff --git a/src/charts/pie-chart.html b/src/charts/pie-chart.html
index f97e9b1..dee52c8 100644
--- a/src/charts/pie-chart.html
+++ b/src/charts/pie-chart.html
@@ -2,10 +2,15 @@
Please insert a repository path in the widget configuration
+
+ Error {{vm.repository.status}} the endpoint could not be reached, this could mean that the selected repository does not exist
+ or that the statistics plugin is not installed
+
+
diff --git a/src/commits/commits.js b/src/commits/commits.js
index 04a81f6..76a7848 100644
--- a/src/commits/commits.js
+++ b/src/commits/commits.js
@@ -25,22 +25,22 @@
'use strict';
angular.module('adf.widget.scm')
- .controller('CommitsController', function($sce, config, repository, commits){
+ .controller('CommitsController', function ($sce, config, repository, commits) {
var vm = this;
vm.repository = repository;
// allow html descriptions
- angular.forEach(commits, function(commit){
+ angular.forEach(commits, function (commit) {
commit.description = $sce.trustAsHtml(commit.description);
});
vm.commits = commits;
- vm.gravatarHash = function(commit){
+ vm.gravatarHash = function (commit) {
var hash;
- if (commit.properties){
- for (var i=0; i
Please configure a repository
+
+ Error {{vm.repository.status}} the endpoint could not be reached, this could mean that the selected repository does not exist
+
+
diff --git a/src/markdownPreview/edit.html b/src/markdownPreview/edit.html
new file mode 100644
index 0000000..d77266b
--- /dev/null
+++ b/src/markdownPreview/edit.html
@@ -0,0 +1,24 @@
+
+
diff --git a/src/markdownPreview/markdownPreview.js b/src/markdownPreview/markdownPreview.js
new file mode 100644
index 0000000..4b897ff
--- /dev/null
+++ b/src/markdownPreview/markdownPreview.js
@@ -0,0 +1,8 @@
+'use strict';
+
+angular.module('adf.widget.scm')
+ .controller('MarkdownPreviewController', function (repository, fileContent) {
+ var vm = this;
+ vm.repository = repository;
+ vm.fileContent = fileContent;
+ });
diff --git a/src/markdownPreview/markdownPreviewEdit.js b/src/markdownPreview/markdownPreviewEdit.js
new file mode 100644
index 0000000..889541e
--- /dev/null
+++ b/src/markdownPreview/markdownPreviewEdit.js
@@ -0,0 +1,21 @@
+'use strict';
+
+angular.module('adf.widget.scm')
+ .controller('MarkdownPreviewEditController', function (repositories, SCM) {
+ var vm = this;
+ vm.repositories = repositories;
+
+ vm.getBranchesByRepositoryId = function (repositoryId) {
+ if (repositoryId) {
+ SCM.getBranchesByRepositoryId(repositoryId).then(function (result) {
+ // catch repositories without branch support
+ if (result.status == 400) {
+ vm.branches = null;
+ }else{
+ vm.branches = result.branch;
+ }
+ });
+ }
+ };
+
+ });
diff --git a/src/markdownPreview/view.html b/src/markdownPreview/view.html
new file mode 100644
index 0000000..d494146
--- /dev/null
+++ b/src/markdownPreview/view.html
@@ -0,0 +1,15 @@
+
+
+ Please configure a specific file
+
+
+
+
+ Error {{vm.fileContent.status}} Markdown-File not found. Please check your configuration and try again.
+
+
diff --git a/src/scm.js b/src/scm.js
index 1e10232..5a4c9d0 100644
--- a/src/scm.js
+++ b/src/scm.js
@@ -24,8 +24,8 @@
'use strict';
-angular.module('adf.widget.scm', ['adf.provider', 'chart.js'])
- .config(function(dashboardProvider){
+angular.module('adf.widget.scm', ['adf.provider', 'chart.js', 'ngSanitize', 'btford.markdown'])
+ .config(function (dashboardProvider) {
// category for widget add dialog
var category = 'SCM-Manager';
@@ -36,15 +36,15 @@ angular.module('adf.widget.scm', ['adf.provider', 'chart.js'])
controllerAs: 'vm',
resolve: {
/** @ngInject **/
- repositories: function(SCM){
+ repositories: function (SCM) {
return SCM.getRepositories();
}
}
};
- var resolveRepository = function(SCM, config){
+ var resolveRepository = function (SCM, config) {
var result = null;
- if (config.repository){
+ if (config.repository) {
result = SCM.getRepository(config.repository);
}
return result;
@@ -53,7 +53,7 @@ angular.module('adf.widget.scm', ['adf.provider', 'chart.js'])
dashboardProvider
.widget('scm-commits-by-author', {
title: 'SCM Commits By Author',
- description: 'SCM-Manager pie chart for commit count by author',
+ description: 'Displays pie chart for commit count by author',
category: category,
templateUrl: '{widgetsPath}/scm/src/charts/pie-chart.html',
controller: 'CommitsByAuthorController',
@@ -61,9 +61,9 @@ angular.module('adf.widget.scm', ['adf.provider', 'chart.js'])
reload: true,
resolve: {
repository: resolveRepository,
- commitsByAuthor: function(SCM, config){
+ commitsByAuthor: function (SCM, config) {
var result = null;
- if (config.repository){
+ if (config.repository) {
result = SCM.getCommitsByAuthor(config.repository);
}
return result;
@@ -73,7 +73,7 @@ angular.module('adf.widget.scm', ['adf.provider', 'chart.js'])
})
.widget('scm-commits-by-month', {
title: 'SCM Commits By Month',
- description: 'SCM-Manager line chart for commit count by month',
+ description: 'Displays line chart for commit count by month',
category: category,
templateUrl: '{widgetsPath}/scm/src/charts/line-chart.html',
controller: 'CommitsByMonthController',
@@ -81,9 +81,9 @@ angular.module('adf.widget.scm', ['adf.provider', 'chart.js'])
reload: true,
resolve: {
repository: resolveRepository,
- commitsByMonth: function(SCM, config){
+ commitsByMonth: function (SCM, config) {
var result = null;
- if (config.repository){
+ if (config.repository) {
result = SCM.getCommitsByMonth(config.repository);
}
return result;
@@ -92,8 +92,8 @@ angular.module('adf.widget.scm', ['adf.provider', 'chart.js'])
edit: edit
})
.widget('scm-commits-last-commits', {
- title: 'SCM Commits line chart',
- description: 'SCM-Manager line char for the last 50 commits',
+ title: 'SCM Last Commit Chart',
+ description: 'Displays line chart for the last 50 commits',
category: category,
templateUrl: '{widgetsPath}/scm/src/charts/line-chart.html',
controller: 'LastCommitsController',
@@ -101,9 +101,9 @@ angular.module('adf.widget.scm', ['adf.provider', 'chart.js'])
reload: true,
resolve: {
repository: resolveRepository,
- commits: function(SCM, config){
+ commits: function (SCM, config) {
var result = null;
- if (config.repository){
+ if (config.repository) {
result = SCM.getCommits(config.repository, 50);
}
return result;
@@ -113,7 +113,7 @@ angular.module('adf.widget.scm', ['adf.provider', 'chart.js'])
})
.widget('scm-commits', {
title: 'SCM Commits',
- description: 'SCM-Manager commits',
+ description: 'Displays last commits',
category: category,
templateUrl: '{widgetsPath}/scm/src/commits/view.html',
controller: 'CommitsController',
@@ -121,14 +121,44 @@ angular.module('adf.widget.scm', ['adf.provider', 'chart.js'])
reload: true,
resolve: {
repository: resolveRepository,
- commits: function(SCM, config){
+ commits: function (SCM, config) {
var result = null;
- if (config.repository){
+ if (config.repository) {
result = SCM.getCommits(config.repository, 10);
}
return result;
}
},
edit: edit
+ })
+ .widget('scm-markdown-content', {
+ title: 'SCM Markdown Content',
+ description: 'Displays a Markdown Content Preview',
+ category: category,
+ templateUrl: '{widgetsPath}/scm/src/markdownPreview/view.html',
+ controller: 'MarkdownPreviewController',
+ controllerAs: 'vm',
+ reload: true,
+ resolve: {
+ repository: resolveRepository,
+ fileContent: function (SCM, config) {
+ var result = null;
+ if (config.repository && config.path) {
+ result = SCM.getFileContent(config.repository, config.path);
+ }
+ return result;
+ }
+ },
+ edit: {
+ templateUrl: '{widgetsPath}/scm/src/markdownPreview/edit.html',
+ controller: 'MarkdownPreviewEditController',
+ controllerAs: 'vm',
+ resolve: {
+ /** @ngInject **/
+ repositories: function (SCM) {
+ return SCM.getRepositories();
+ }
+ }
+ }
});
});
diff --git a/src/service.js b/src/service.js
index 24f66d8..0d0e5cc 100644
--- a/src/service.js
+++ b/src/service.js
@@ -25,43 +25,55 @@
'use strict';
angular.module('adf.widget.scm')
- .factory('SCM', function(scmEndpoint, $http){
-
- function data(response){
- return response.data;
- }
+ .factory('SCM', function (scmEndpoint, $http) {
- function request(url){
- return $http.get(scmEndpoint + url).then(data);
+ function request(url) {
+ return $http.get(scmEndpoint + url).then(function (response) {
+ if (response.status == 200) {
+ return response.data;
+ }
+ }, function (error) {
+ return error;
+ });
}
- function getRepositories(){
+ function getRepositories() {
return request('repositories.json');
}
- function getRepository(id){
+ function getRepository(id) {
return request('repositories/' + id + '.json');
}
- function getCommitsByAuthor(id){
+ function getCommitsByAuthor(id) {
return request('plugins/statistic/' + id + '/commits-per-author.json');
}
- function getCommitsByMonth(id){
+ function getCommitsByMonth(id) {
return request('plugins/statistic/' + id + '/commits-per-month.json');
}
- function getCommits(id, limit){
- return request('repositories/' + id + '/changesets.json?limit=' + limit).then(function(data){
+ function getCommits(id, limit) {
+ return request('repositories/' + id + '/changesets.json?limit=' + limit).then(function (data) {
return data.changesets;
});
}
+ function getFileContent(id, filePath) {
+ return request('repositories/' + id + '/content?path=' + filePath);
+ }
+
+ function getBranchesByRepositoryId(id) {
+ return request('repositories/' + id + '/branches');
+ }
+
return {
getRepositories: getRepositories,
getRepository: getRepository,
getCommitsByAuthor: getCommitsByAuthor,
getCommitsByMonth: getCommitsByMonth,
- getCommits: getCommits
+ getCommits: getCommits,
+ getFileContent: getFileContent,
+ getBranchesByRepositoryId: getBranchesByRepositoryId
};
});