Skip to content

Commit 42de5fe

Browse files
committed
released v0.5.0
1 parent df4c21c commit 42de5fe

File tree

5 files changed

+172
-88
lines changed

5 files changed

+172
-88
lines changed

Diff for: bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "adf-widget-scm",
3-
"version": "0.4.1",
3+
"version": "0.5.0",
44
"main": "dist/adf-widget-scm.js",
55
"ignore": [
66
"bower.json",

Diff for: dist/adf-widget-scm.js

+168-84
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,21 @@ angular.module('adf.widget.scm', ['adf.provider', 'chart.js', 'ngSanitize', 'btf
133133
},
134134
edit: edit
135135
})
136+
.widget('scm-activities', {
137+
title: 'SCM Activities',
138+
description: 'SCM Activities for all repositories',
139+
category: category,
140+
templateUrl: '{widgetsPath}/scm/src/activities/activityView.html',
141+
controller: 'ActivitiesController',
142+
controllerAs: 'vm',
143+
reload: true,
144+
resolve: {
145+
activities: ["SCM", function(SCM){
146+
var result = null;
147+
result = SCM.getActivities();
148+
return result;
149+
}]
150+
}})
136151
.widget('scm-markdown-content', {
137152
title: 'SCM Markdown Content',
138153
description: 'Displays a Markdown Content Preview',
@@ -165,43 +180,13 @@ angular.module('adf.widget.scm', ['adf.provider', 'chart.js', 'ngSanitize', 'btf
165180
});
166181
}]);
167182

168-
angular.module("adf.widget.scm").run(["$templateCache", function($templateCache) {$templateCache.put("{widgetsPath}/scm/src/charts/line-chart.html","<div><div class=\"alert alert-info\" ng-if=!vm.chart>Please insert a repository path in the widget configuration</div><div ng-if=\"vm.repository.status == 404 || vm.repository.status == 500\" class=\"alert alert-danger\"><b>Error {{vm.repository.status}}</b> the endpoint could not be reached, this could mean that the selected repository does not exist or that the statistics plugin is not installed</div><div ng-if=vm.chart><canvas id=line class=\"chart chart-line\" chart-data=vm.chart.data chart-labels=vm.chart.labels chart-series=vm.chart.series chart-options=vm.chart.options></canvas></div></div>");
169-
$templateCache.put("{widgetsPath}/scm/src/charts/pie-chart.html","<div><div class=\"alert alert-info\" ng-if=!vm.chart>Please insert a repository path in the widget configuration</div><div ng-if=\"vm.repository.status == 404 || vm.repository.status == 500\" class=\"alert alert-danger\"><b>Error {{vm.repository.status}}</b> the endpoint could not be reached, this could mean that the selected repository does not exist or that the statistics plugin is not installed</div><div ng-if=vm.chart><canvas id=pie class=\"chart chart-pie\" chart-legend=true chart-data=vm.chart.data chart-labels=vm.chart.labels chart-options=vm.chart.options></canvas></div></div>");
183+
angular.module("adf.widget.scm").run(["$templateCache", function($templateCache) {$templateCache.put("{widgetsPath}/scm/src/activities/activityView.html","<div><div ng-if=!vm.activities class=\"alert alert-info\">There are no activities for your available repositories.</div><div ng-if=\"vm.status == 404 || vm.status == 500\" class=\"alert alert-danger\"><b>Error {{vm.status}}:</b> The endpoint could not be reached, this could mean that the activity plugin is not installed.</div><div ng-if=vm.activities><ul class=media-list><li class=media ng-repeat=\"activity in vm.activities\"><div ng-if=vm.gravatarHash(activity) class=media-left><img class=\"media-object img-thumbnail\" ng-src=\"http://www.gravatar.com/avatar/{{vm.gravatarHash(activity)}}?s=64&d=identicon\"></div><div class=media-body><b>{{activity.repoName}}</b><p ng-bind-html=activity.changeset.description></p><small>{{activity.changeset.author.name}}, {{activity.changeset.date | date: \'yyyy-MM-dd HH:mm\'}}</small></div></li></ul></div></div>");
170184
$templateCache.put("{widgetsPath}/scm/src/edit/edit.html","<form role=form><div class=form-group><label for=repository>Repository</label><select name=repository id=repository class=form-control ng-model=config.repository><option ng-repeat=\"repository in vm.repositories | orderBy: \'name\'\" value={{repository.id}}>{{repository.name}}</option></select></div></form>");
171-
$templateCache.put("{widgetsPath}/scm/src/commits/view.html","<div><div ng-if=!config.repository class=\"alert alert-info\">Please configure a repository</div><div ng-if=\"vm.repository.status == 404 || vm.repository.status == 500\" class=\"alert alert-danger\"><b>Error {{vm.repository.status}}</b> the endpoint could not be reached, this could mean that the selected repository does not exist</div><div ng-if=config.repository><ul class=media-list><li class=media ng-repeat=\"commit in vm.commits\"><div ng-if=vm.gravatarHash(commit) class=media-left><img class=\"media-object img-thumbnail\" ng-src=\"http://www.gravatar.com/avatar/{{vm.gravatarHash(commit)}}?s=64&d=identicon\"></div><div class=media-body><p ng-bind-html=commit.description></p><small>{{commit.author.name}}, {{commit.date | date: \'yyyy-MM-dd HH:mm\'}}</small></div></li></ul></div></div>");
185+
$templateCache.put("{widgetsPath}/scm/src/charts/line-chart.html","<div><div class=\"alert alert-info\" ng-if=!vm.chart>Please insert a repository path in the widget configuration</div><div ng-if=\"vm.repository.status == 404 || vm.repository.status == 500\" class=\"alert alert-danger\"><b>Error {{vm.repository.status}}</b> the endpoint could not be reached, this could mean that the selected repository does not exist or that the statistics plugin is not installed</div><div ng-if=vm.chart><canvas id=line class=\"chart chart-line\" chart-data=vm.chart.data chart-labels=vm.chart.labels chart-series=vm.chart.series chart-options=vm.chart.options></canvas></div></div>");
186+
$templateCache.put("{widgetsPath}/scm/src/charts/pie-chart.html","<div><div class=\"alert alert-info\" ng-if=!vm.chart>Please insert a repository path in the widget configuration</div><div ng-if=\"vm.repository.status == 404 || vm.repository.status == 500\" class=\"alert alert-danger\"><b>Error {{vm.repository.status}}</b> the endpoint could not be reached, this could mean that the selected repository does not exist or that the statistics plugin is not installed</div><div ng-if=vm.chart><canvas id=pie class=\"chart chart-pie\" chart-legend=true chart-data=vm.chart.data chart-labels=vm.chart.labels chart-options=vm.chart.options></canvas></div></div>");
172187
$templateCache.put("{widgetsPath}/scm/src/markdownPreview/edit.html","<form role=form><div class=form-group><p><label for=repository>Repository</label><select name=repository id=repository class=form-control ng-model=config.repository ng-init=vm.getBranchesByRepositoryId(config.repository) ng-change=vm.getBranchesByRepositoryId(config.repository)><option ng-repeat=\"repository in vm.repositories | orderBy: \'name\'\" value={{repository.id}}>{{repository.name}}</option></select></p><p ng-if=vm.branches><label for=branch>Branch</label><select name=branch id=branch class=form-control ng-model=config.branch><option ng-repeat=\"branch in vm.branches| orderBy: \'name\'\" value={{branch.id}}>{{branch.name}}</option></select></p><label for=path>Path to Markdown File</label> <input type=text class=form-control id=path ng-model=config.path></div></form>");
173-
$templateCache.put("{widgetsPath}/scm/src/markdownPreview/view.html","<style>\n div.markdownContent{\n overflow: auto;\n width: 100%;\n }\n</style><div class=\"alert alert-info\" ng-if=!vm.fileContent>Please configure a specific file</div><div ng-if=vm.fileContent btf-markdown=vm.fileContent class=markdownContent></div><div class=\"alert alert-danger\" ng-if=\"vm.fileContent.status == 500 || vm.fileContent.status == 404\"><b>Error {{vm.fileContent.status}}</b> Markdown-File not found. Please check your configuration and try again.</div>");}]);
174-
175-
176-
angular.module('adf.widget.scm')
177-
.controller('MarkdownPreviewEditController', ["repositories", "SCM", function (repositories, SCM) {
178-
var vm = this;
179-
vm.repositories = repositories;
180-
181-
vm.getBranchesByRepositoryId = function (repositoryId) {
182-
if (repositoryId) {
183-
SCM.getBranchesByRepositoryId(repositoryId).then(function (result) {
184-
// catch repositories without branch support
185-
if (result.status == 400) {
186-
vm.branches = null;
187-
}else{
188-
vm.branches = result.branch;
189-
}
190-
});
191-
}
192-
};
193-
194-
}]);
195-
196-
197-
198-
angular.module('adf.widget.scm')
199-
.controller('MarkdownPreviewController', ["repository", "fileContent", function (repository, fileContent) {
200-
var vm = this;
201-
vm.repository = repository;
202-
vm.fileContent = fileContent;
203-
}]);
204-
188+
$templateCache.put("{widgetsPath}/scm/src/markdownPreview/view.html","<style>\n div.markdownContent{\n overflow: auto;\n width: 100%;\n }\n</style><div class=\"alert alert-info\" ng-if=!vm.fileContent>Please configure a specific file</div><div ng-if=vm.fileContent btf-markdown=vm.fileContent class=markdownContent></div><div class=\"alert alert-danger\" ng-if=\"vm.fileContent.status == 500 || vm.fileContent.status == 404\"><b>Error {{vm.fileContent.status}}</b> Markdown-File not found. Please check your configuration and try again.</div>");
189+
$templateCache.put("{widgetsPath}/scm/src/commits/view.html","<div><div ng-if=!config.repository class=\"alert alert-info\">Please configure a repository</div><div ng-if=\"vm.repository.status == 404 || vm.repository.status == 500\" class=\"alert alert-danger\"><b>Error {{vm.repository.status}}</b> the endpoint could not be reached, this could mean that the selected repository does not exist</div><div ng-if=config.repository><ul class=media-list><li class=media ng-repeat=\"commit in vm.commits\"><div ng-if=vm.gravatarHash(commit) class=media-left><img class=\"media-object img-thumbnail\" ng-src=\"http://www.gravatar.com/avatar/{{vm.gravatarHash(commit)}}?s=64&d=identicon\"></div><div class=media-body><p ng-bind-html=commit.description></p><small>{{commit.author.name}}, {{commit.date | date: \'yyyy-MM-dd HH:mm\'}}</small></div></li></ul></div></div>");}]);
205190
/*
206191
* The MIT License
207192
*
@@ -229,62 +214,51 @@ angular.module('adf.widget.scm')
229214

230215

231216
angular.module('adf.widget.scm')
232-
.controller('CommitsController', ["$sce", "config", "repository", "commits", function ($sce, config, repository, commits) {
233-
var vm = this;
217+
.controller('CommitsController', ["$sce", "config", "repository", "commits", "SCM", function ($sce, config, repository, commits, SCM) {
218+
var vm = this;
234219

235-
vm.repository = repository;
220+
vm.repository = repository;
236221

237-
// allow html descriptions
238-
angular.forEach(commits, function (commit) {
239-
commit.description = $sce.trustAsHtml(commit.description);
240-
});
241-
vm.commits = commits;
242-
243-
vm.gravatarHash = function (commit) {
244-
var hash;
245-
if (commit.properties) {
246-
for (var i = 0; i < commit.properties.length; i++) {
247-
if (commit.properties[0].key === 'gravatar-hash') {
248-
hash = commit.properties[0].value;
249-
break;
222+
// allow html descriptions
223+
angular.forEach(commits, function (commit) {
224+
commit.description = $sce.trustAsHtml(commit.description);
225+
});
226+
vm.commits = commits;
227+
228+
vm.gravatarHash = function (commit) {
229+
return SCM.getGravatarHash(commit.properties);
230+
};
231+
}]);
232+
233+
234+
235+
angular.module('adf.widget.scm')
236+
.controller('MarkdownPreviewEditController', ["repositories", "SCM", function (repositories, SCM) {
237+
var vm = this;
238+
vm.repositories = repositories;
239+
240+
vm.getBranchesByRepositoryId = function (repositoryId) {
241+
if (repositoryId) {
242+
SCM.getBranchesByRepositoryId(repositoryId).then(function (result) {
243+
// catch repositories without branch support
244+
if (result.status == 400) {
245+
vm.branches = null;
246+
}else{
247+
vm.branches = result.branch;
250248
}
251-
}
249+
});
252250
}
253-
return hash;
254251
};
255-
}]);
256252

257-
/*
258-
* The MIT License
259-
*
260-
* Copyright (c) 2016, Sebastian Sdorra
261-
*
262-
* Permission is hereby granted, free of charge, to any person obtaining a copy
263-
* of this software and associated documentation files (the "Software"), to deal
264-
* in the Software without restriction, including without limitation the rights
265-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
266-
* copies of the Software, and to permit persons to whom the Software is
267-
* furnished to do so, subject to the following conditions:
268-
*
269-
* The above copyright notice and this permission notice shall be included in
270-
* all copies or substantial portions of the Software.
271-
*
272-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
273-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
274-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
275-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
276-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
277-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
278-
* SOFTWARE.
279-
*/
253+
}]);
280254

281255

282256

283257
angular.module('adf.widget.scm')
284-
.controller('ScmEditController', ["repositories", function(repositories){
258+
.controller('MarkdownPreviewController', ["repository", "fileContent", function (repository, fileContent) {
285259
var vm = this;
286-
287-
vm.repositories = repositories;
260+
vm.repository = repository;
261+
vm.fileContent = fileContent;
288262
}]);
289263

290264
/*
@@ -337,7 +311,12 @@ angular.module('adf.widget.scm')
337311
}
338312
}
339313
]
340-
}
314+
},
315+
legend: {
316+
display: true,
317+
position: "bottom"
318+
},
319+
responsive: true
341320
};
342321
var chartData = [];
343322
var chart = {
@@ -426,7 +405,12 @@ angular.module('adf.widget.scm')
426405
}
427406
}
428407
]
429-
}
408+
},
409+
legend: {
410+
display: true,
411+
position: "bottom"
412+
},
413+
responsive: true
430414
};
431415
var chart = {
432416
labels: [],
@@ -492,7 +476,8 @@ angular.module('adf.widget.scm')
492476
legend: {
493477
display: true,
494478
position: "bottom"
495-
}
479+
},
480+
responsive: true
496481
};
497482

498483
var chart = {
@@ -538,6 +523,85 @@ angular.module('adf.widget.scm')
538523

539524

540525

526+
angular.module('adf.widget.scm')
527+
.controller('ScmEditController', ["repositories", function(repositories){
528+
var vm = this;
529+
530+
vm.repositories = repositories;
531+
}]);
532+
533+
/*
534+
* The MIT License
535+
*
536+
* Copyright (c) 2016, Sebastian Sdorra
537+
*
538+
* Permission is hereby granted, free of charge, to any person obtaining a copy
539+
* of this software and associated documentation files (the "Software"), to deal
540+
* in the Software without restriction, including without limitation the rights
541+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
542+
* copies of the Software, and to permit persons to whom the Software is
543+
* furnished to do so, subject to the following conditions:
544+
*
545+
* The above copyright notice and this permission notice shall be included in
546+
* all copies or substantial portions of the Software.
547+
*
548+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
549+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
550+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
551+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
552+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
553+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
554+
* SOFTWARE.
555+
*/
556+
557+
558+
559+
angular.module('adf.widget.scm')
560+
.controller('ActivitiesController', ["$sce", "activities", "SCM", function ($sce, activities, SCM) {
561+
var vm = this;
562+
vm.status = activities.status;
563+
564+
// allow html descriptions
565+
angular.forEach(activities.activities, function (activity) {
566+
activity.changeset.description = $sce.trustAsHtml(activity.changeset.description);
567+
activity.repoName = activity["repository-name"];
568+
});
569+
570+
// handling and displaying only 15 activities
571+
if (activities.activities) {
572+
vm.activities = activities.activities.slice(0, 15);
573+
}
574+
575+
vm.gravatarHash = function (activity) {
576+
return SCM.getGravatarHash(activity.changeset.properties);
577+
};
578+
}]);
579+
/*
580+
* The MIT License
581+
*
582+
* Copyright (c) 2016, Sebastian Sdorra
583+
*
584+
* Permission is hereby granted, free of charge, to any person obtaining a copy
585+
* of this software and associated documentation files (the "Software"), to deal
586+
* in the Software without restriction, including without limitation the rights
587+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
588+
* copies of the Software, and to permit persons to whom the Software is
589+
* furnished to do so, subject to the following conditions:
590+
*
591+
* The above copyright notice and this permission notice shall be included in
592+
* all copies or substantial portions of the Software.
593+
*
594+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
595+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
596+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
597+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
598+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
599+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
600+
* SOFTWARE.
601+
*/
602+
603+
604+
541605
angular.module('adf.widget.scm')
542606
.factory('SCM', ["scmEndpoint", "$http", function (scmEndpoint, $http) {
543607

@@ -573,6 +637,11 @@ angular.module('adf.widget.scm')
573637
});
574638
}
575639

640+
641+
function getActivities(){
642+
return request('activity.json');
643+
}
644+
576645
function getFileContent(id, filePath) {
577646
return request('repositories/' + id + '/content?path=' + filePath);
578647
}
@@ -581,14 +650,29 @@ angular.module('adf.widget.scm')
581650
return request('repositories/' + id + '/branches');
582651
}
583652

653+
function getGravatarHash(properties) {
654+
var hash;
655+
if (properties){
656+
for (var i=0; i<properties.length; i++){
657+
if (properties[0].key === 'gravatar-hash'){
658+
hash = properties[0].value;
659+
break;
660+
}
661+
}
662+
}
663+
return hash;
664+
}
665+
584666
return {
585667
getRepositories: getRepositories,
586668
getRepository: getRepository,
587669
getCommitsByAuthor: getCommitsByAuthor,
588670
getCommitsByMonth: getCommitsByMonth,
589671
getCommits: getCommits,
672+
getActivities: getActivities,
590673
getFileContent: getFileContent,
591-
getBranchesByRepositoryId: getBranchesByRepositoryId
674+
getBranchesByRepositoryId: getBranchesByRepositoryId,
675+
getGravatarHash: getGravatarHash
592676
};
593677
}]);
594678
})(window);

0 commit comments

Comments
 (0)