From c216111dda268e8f782555b0a851fa844120a44c Mon Sep 17 00:00:00 2001 From: Christoph Wolfes Date: Wed, 10 May 2017 13:06:58 +0200 Subject: [PATCH] updated dist folder --- dist/adf-widget-jenkins.js | 252 ++------------------------------- dist/adf-widget-jenkins.min.js | 2 +- 2 files changed, 9 insertions(+), 245 deletions(-) diff --git a/dist/adf-widget-jenkins.js b/dist/adf-widget-jenkins.js index ab7b4a1..8e8a6d4 100644 --- a/dist/adf-widget-jenkins.js +++ b/dist/adf-widget-jenkins.js @@ -1,246 +1,10 @@ (function(window, undefined) {'use strict'; - - -var jenkinsWidget = angular.module('adf.widget.jenkins', ['adf.provider', 'chart.js']) - .constant("jenkinsEndpoint", { - "url": "http://builds.apache.org" - }) - .config(registerWidget); - -function registerWidget(dashboardProvider) { - dashboardProvider - .widget('jenkins', { - title: 'Jenkins Project View', - description: 'Widget to display custom jenkins job', - templateUrl: '{widgetsPath}/jenkins/src/view.html', - resolve: { - data: ["jenkinsApi", "config", "jenkinsEndpoint", function(jenkinsApi, config, jenkinsEndpoint) { - if (config.apiUrl) { - return jenkinsApi.getJobData(config.apiUrl, config.project); - } else if (jenkinsEndpoint.url && config.project) { - return jenkinsApi.getJobData(jenkinsEndpoint.url, config.project); - } - }] - }, - controller: 'jenkinsJobList', - controllerAs: 'vm', - edit: { - templateUrl: '{widgetsPath}/jenkins/src/edit.html', - controller: 'projectViewEditController', - controllerAs: 'vm' - } - }) - .widget('jenkinsStats', { - title: 'Jenkins Global Statistics', - description: 'Widget to diplay chart statistics from jenkins', - templateUrl: '{widgetsPath}/jenkins/src/charts/view.html', - resolve: { - data: ["jenkinsApi", "config", "jenkinsEndpoint", function(jenkinsApi, config, jenkinsEndpoint) { - if (config.apiUrl) { - return jenkinsApi.getJobStats(config.apiUrl); - } else if (jenkinsEndpoint.url) { - return jenkinsApi.getJobStats(jenkinsEndpoint.url); - } - return 'Please Setup the Widget'; - }] - }, - controller: 'jenkinsChart', - controllerAs: 'jc', - edit: { - templateUrl: '{widgetsPath}/jenkins/src/charts/edit.html' - } - }); -} -registerWidget.$inject = ["dashboardProvider"]; - -angular.module("adf.widget.jenkins").run(["$templateCache", function($templateCache) {$templateCache.put("{widgetsPath}/jenkins/src/edit.html","

"); -$templateCache.put("{widgetsPath}/jenkins/src/view.html","

{{vm.data.projectFullName}}


{{vm.data.lastCommitMsg}}

{{vm.data.lastCommitBy}}
"); +angular.module("adf.widget.jenkins").run(["$templateCache", function($templateCache) {$templateCache.put("{widgetsPath}/jenkins/src/jenkins.js","\'use strict\'; var jenkinsWidget = angular.module(\'adf.widget.jenkins\', [\'adf.provider\', \'chart.js\', \'ui.bootstrap\']) .constant(\"jenkinsEndpoint\", { \"url\": \"http://builds.apache.org\" }) .config(registerWidget); function registerWidget(dashboardProvider) { dashboardProvider .widget(\'jenkinsBuildReport\', { title: \'Jenkins Build Report\', description: \'Displays current build information\', templateUrl: \'{widgetsPath}/jenkins/src/view.html\', resolve: { data: function(jenkinsApi, config, jenkinsEndpoint) { if (config.apiUrl) { return jenkinsApi.getJobData(config.apiUrl, config.project); } else if (jenkinsEndpoint.url && config.project) { return jenkinsApi.getJobData(jenkinsEndpoint.url, config.project); } } }, controller: \'jenkinsJobList\', controllerAs: \'vm\', edit: { templateUrl: \'{widgetsPath}/jenkins/src/edit.html\', controller: \'projectViewEditController\', controllerAs: \'vm\' } }) .widget(\'jenkinsGlobalStatistics\', { title: \'Jenkins Global Statistics\', description: \'Displays all build jobs as pie chart\', templateUrl: \'{widgetsPath}/jenkins/src/charts/view.html\', resolve: { data: function(jenkinsApi, config, jenkinsEndpoint) { if (config.apiUrl) { return jenkinsApi.getJobStats(config.apiUrl); } else if (jenkinsEndpoint.url) { return jenkinsApi.getJobStats(jenkinsEndpoint.url); } return \'Please Setup the Widget\'; } }, controller: \'jenkinsChart\', controllerAs: \'jc\', edit: { templateUrl: \'{widgetsPath}/jenkins/src/charts/edit.html\' } }); }"); +$templateCache.put("{widgetsPath}/jenkins/src/projectViewEditController.js","\'use strict\'; angular.module(\'adf.widget.jenkins\') .controller(\'projectViewEditController\', function(jenkinsApi, $scope, jenkinsEndpoint) { var vm = this; $scope.updateProjects = function() { var url; if ($scope.config.apiUrl) { url = $scope.config.apiUrl; } else { url = jenkinsEndpoint.url; } vm.projects = []; jenkinsApi.crawlJenkinsJobs(url).then(function(data) { data.forEach(function(project) { var proj = { name: project.name }; vm.projects.push(proj); }); }); }; $scope.updateProjects(); });"); +$templateCache.put("{widgetsPath}/jenkins/src/service.js","\'use strict\'; jenkinsWidget .factory(\'jenkinsApi\', jenkinsApi); //function factory jenkinsStats function jenkinsApi($http) { const imgURLBuildSuccess = \'src/img/successful.png\'; const imgURLBuildFailed = \'src/img/failed.png\'; const imgURLBuildUnstable = \'src/img/unstable.png\'; const defaultMsgNoAuthor = \'No author found\'; const defaultMsgNoCommitInfo = \'No commit information found\'; /* *Connection settings should be fixed in dashboard dogu */ //get all jobs function createApiConnection(apiUrl) { return apiUrl + \'/api/json/jobs\'; } //get info about specific project function createProjectConnection(apiUrl, project) { return apiUrl + \'/job/\' + project + \'/lastBuild/api/json\'; } //buildstate statistics overall function parseStats(jobList) { var countStable = 0; var countUnstable = 0; var countFail = 0; var countDisabled = 0; var countAborted = 0; var total = jobList.length; for (var i = 0; i < total; i++) { if (jobList[i].color == \'blue\') { countStable++; } if (jobList[i].color == \'red\') { countFail++; } if (jobList[i].color == \'yellow\') { countUnstable++; } if (jobList[i].color == \'notbuilt\' || jobList[i].color == \'disabled\') { countDisabled++; } if (jobList[i].color == \'aborted\') { countAborted++; } } return { stable: countStable, fail: countFail, unstable: countUnstable, aborted: countAborted, disabled: countDisabled, total: total }; } function crawlJenkinsJobs(instanceURL) { var connection = instanceURL + \'/api/json?tree=jobs[name,buildable,color,jobs[name,buildable,color,jobs[name,buildable,color,jobs[name,buildable,color,jobs]]]]&pretty\'; return $http({ method: \'GET\', url: connection, headers: { \'Accept\': \'application/json\' } }).then(function (response) { var jobItems = []; jobItems = resolveJobFolder(response.data, jobItems); return jobItems; }) } function resolveJobFolder(job, jobItems) { var folderName = job.name; job.jobs.forEach(function (job) { if (job.buildable) { if (folderName === undefined || folderName == null) { jobItems.push({name: job.name, color: job.color}); } else { jobItems.push({name: folderName + \" / \" + job.name, color: job.color}); } } if (job.jobs) { resolveJobFolder(job, jobItems); } }); return jobItems; } //returns all jobs in jenkins instance function getJobList(apiUrl) { var connection = createApiConnection(apiUrl); return $http({ method: \'GET\', url: connection, headers: { \'Accept\': \'application/json\' } }).then(function (response) { return response.data.jobs; }) } //returns information for a defined range of builds function getLastBuilds(apiUrl) { return getJobList(apiUrl); } //returns last build information for a scpecific project function getJobData(apiUrl, project) { var connection = createProjectConnection(apiUrl, project); return $http({ method: \'GET\', url: connection, headers: { \'Accept\': \'application/json\' } }).then(function (response) { var status = response.data.result; var url = response.data.url; var projectFullName = response.data.fullDisplayName; var imgUrl = imgURLBuildUnstable; if (status == \"SUCCESS\") { imgUrl = imgURLBuildSuccess; } else if (status == \"FAILURE\") { imgUrl = imgURLBuildFailed; } var lastCommit = response.data.changeSet.items[0]; var lastCommitMsg = defaultMsgNoCommitInfo; var lastCommitBy = defaultMsgNoAuthor; if (lastCommit) { lastCommitBy = lastCommit.author.fullName; lastCommitMsg = lastCommit.msg; } return { status: status, url: url, lastCommitBy: lastCommitBy, lastCommitMsg: lastCommitMsg, imgUrl: imgUrl, projectFullName: projectFullName }; }) } //returns statistics over the whole jenkins instance function getJobStats(apiUrl) { return crawlJenkinsJobs(apiUrl).then(parseStats); } //setup the functions called by widget return { getJobList: getJobList, getJobStats: getJobStats, getJobData: getJobData, getLastBuilds: getLastBuilds, crawlJenkinsJobs: crawlJenkinsJobs }; }"); +$templateCache.put("{widgetsPath}/jenkins/src/stats.controller.js","\'use strict\'; jenkinsWidget.controller(\'jenkinsJobList\', function(data) { var vm = this; vm.data = data; });"); +$templateCache.put("{widgetsPath}/jenkins/src/charts/buildChart.js","\'use strict\' jenkinsWidget.controller(\'jenkinsChart\', function(data) { //get chart data var jc = this; jc.data = data; //configure chart var labels = [\"Stable\", \"Fail\",\"Unstable\",\"Diabled\"]; var values = [jc.data.stable,jc.data.fail,jc.data.unstable,jc.data.disabled]; var colors = [\'#009587\',\'#F34235\',\'#FEC006\',\'#DCDCDC\']; jc.chartLabels = labels; jc.chartValues = values; jc.chartColors = colors; });"); +$templateCache.put("{widgetsPath}/jenkins/src/edit.html","

"); +$templateCache.put("{widgetsPath}/jenkins/src/view.html","

{{vm.data.projectFullName}}

Last Commit: {{vm.data.lastCommitMsg}}

Author: {{vm.data.lastCommitBy}}
"); $templateCache.put("{widgetsPath}/jenkins/src/charts/edit.html","

"); -$templateCache.put("{widgetsPath}/jenkins/src/charts/view.html","

{{jc.data.stable || 0}}

stable builds

{{jc.data.unstable || 0}}

unstable builds

{{jc.data.fail || 0}}

failed builds

{{jc.data.aborted+jc.data.disabled || 0}}

disabled builds
");}]); -'use strict' - -jenkinsWidget.controller('jenkinsChart', ["data", function(data) { - //get chart data - var jc = this; - jc.data = data; - - //configure chart - var labels = ["Stable", "Fail","Unstable","Diabled"]; - var values = [jc.data.stable,jc.data.fail,jc.data.unstable,jc.data.disabled]; - var colors = ['#01B7EB','#F7464A','#FDB45C','#DCDCDC']; - jc.chartLabels = labels; - jc.chartValues = values; - jc.chartColors = colors; -}]); - - - -jenkinsWidget.controller('jenkinsJobList', ["data", function(data) { - var vm = this; - vm.data = data; - -}]); - - - -jenkinsWidget - .factory('jenkinsApi', jenkinsApi); - - -//function factory jenkinsStats -function jenkinsApi($http) { - - - /* - *Connection settings should be fixed in dashboard dogu - */ - - //get all jobs - function createApiConnection(apiUrl) { - return apiUrl + '/api/json/jobs'; - } - - //get info about specific project - function createProjectConnection(apiUrl, project) { - return apiUrl + '/job/' + project + '/lastBuild/api/json'; - } - - - //buildstate statistics overall - function parseStats(jobList) { - var countStable = 0; - var countUnstable = 0; - var countFail = 0; - var countDisabled = 0; - var countAborted = 0; - var total = jobList.length; - for (var i = 0; i < total; i++) { - if (jobList[i].color == 'blue') { - countStable++; - } - if (jobList[i].color == 'red') { - countFail++; - } - if (jobList[i].color == 'yellow') { - countUnstable++; - } - if (jobList[i].color == 'notbuilt' || jobList[i].color == 'disabled') { - countDisabled++; - } - if (jobList[i].color == 'aborted') { - countAborted++; - } - } - var jenkinsStats = { - stable: countStable, - fail: countFail, - unstable: countUnstable, - aborted: countAborted, - disabled: countDisabled, - total: total - }; - return jenkinsStats; - } - - //returns all jobs in jenkins instance - function getJobList(apiUrl) { - var connection = createApiConnection(apiUrl); - return $http({ - method: 'GET', - url: connection, - headers: { - 'Accept': 'application/json' - } - }).then(function(response) { - return response.data.jobs; - }) - } - - //returns information for a defined range of builds - function getLastBuilds(apiUrl, numberOfBuilds) { - return getJobList(apiUrl).then(getBuilds(apiUrl)); - } - - - //returns last build information for a scpecific project - function getJobData(apiUrl, project) { - var connection = createProjectConnection(apiUrl, project); - return $http({ - method: 'GET', - url: connection, - headers: { - 'Accept': 'application/json' - } - }).then(function(response) { - var status = response.data.result; - var url = response.data.url; - var projectFullName = response.data.fullDisplayName; - var imgUrl = ""; - if (status == "SUCCESS") { - imgUrl = "http://iconmonstr.com/wp-content/g/gd/makefg.php?i=../assets/preview/2013/png/iconmonstr-thumb-18.png&r=0&g=0&b=0"; - } - if (status == "FAILURE") { - imgUrl = "http://iconmonstr.com/wp-content/g/gd/makefg.php?i=../assets/preview/2013/png/iconmonstr-thumb-24.png&r=0&g=0&b=0"; - } - var lastCommit = response.data.changeSet.items[0]; - var lastCommitMsg="Kein Infos zum letzen Commit"; - var lastCommitBy="Keine Infos zum Autor"; - if (lastCommit){ - lastCommitBy = lastCommit.author.fullName; - lastCommitMsg = lastCommit.msg; - } - - var projectInfo = { - status: status, - url: url, - lastCommitBy: lastCommitBy, - lastCommitMsg: lastCommitMsg, - imgUrl: imgUrl, - projectFullName: projectFullName - }; - - return projectInfo; - }) - } - - //returns statistics over the whole jenkins instance - function getJobStats(apiUrl) { - return getJobList(apiUrl).then(parseStats); - } - - //setup the functions called by widget - return { - getJobList: getJobList, - getJobStats: getJobStats, - getJobData: getJobData, - getLastBuilds: getLastBuilds - }; -} -jenkinsApi.$inject = ["$http"]; - - - -angular.module('adf.widget.jenkins') - .controller('projectViewEditController', ["jenkinsApi", "$scope", "jenkinsEndpoint", function(jenkinsApi, $scope, jenkinsEndpoint) { - - var vm = this; - $scope.updateProjects = function() { - var url; - if ($scope.config.apiUrl) { - url = $scope.config.apiUrl; - } else { - url = jenkinsEndpoint.url; - } - vm.projects = []; - jenkinsApi.getJobList(url).then(function(data) { - data.forEach(function(project) { - var proj = { - name: project.name - } - vm.projects.push(proj); - }); - }); - } - $scope.updateProjects(); - }]); -})(window); \ No newline at end of file +$templateCache.put("{widgetsPath}/jenkins/src/charts/view.html","

{{jc.data.stable || 0}}

stable builds

{{jc.data.unstable || 0}}

unstable builds

{{jc.data.fail || 0}}

failed builds

{{jc.data.aborted+jc.data.disabled || 0}}

disabled builds
");}]);})(window); \ No newline at end of file diff --git a/dist/adf-widget-jenkins.min.js b/dist/adf-widget-jenkins.min.js index 779fb5a..e79c96a 100644 --- a/dist/adf-widget-jenkins.min.js +++ b/dist/adf-widget-jenkins.min.js @@ -1 +1 @@ -!function(t,e){"use strict";function n(t){t.widget("jenkins",{title:"Jenkins Project View",description:"Widget to display custom jenkins job",templateUrl:"{widgetsPath}/jenkins/src/view.html",resolve:{data:["jenkinsApi","config","jenkinsEndpoint",function(t,e,n){return e.apiUrl?t.getJobData(e.apiUrl,e.project):n.url&&e.project?t.getJobData(n.url,e.project):void 0}]},controller:"jenkinsJobList",controllerAs:"vm",edit:{templateUrl:"{widgetsPath}/jenkins/src/edit.html",controller:"projectViewEditController",controllerAs:"vm"}}).widget("jenkinsStats",{title:"Jenkins Global Statistics",description:"Widget to diplay chart statistics from jenkins",templateUrl:"{widgetsPath}/jenkins/src/charts/view.html",resolve:{data:["jenkinsApi","config","jenkinsEndpoint",function(t,e,n){return e.apiUrl?t.getJobStats(e.apiUrl):n.url?t.getJobStats(n.url):"Please Setup the Widget"}]},controller:"jenkinsChart",controllerAs:"jc",edit:{templateUrl:"{widgetsPath}/jenkins/src/charts/edit.html"}})}function a(t){function e(t){return t+"/api/json/jobs"}function n(t,e){return t+"/job/"+e+"/lastBuild/api/json"}function a(t){for(var e=0,n=0,a=0,o=0,i=0,r=t.length,l=0;r>l;l++)"blue"==t[l].color&&e++,"red"==t[l].color&&a++,"yellow"==t[l].color&&n++,"notbuilt"!=t[l].color&&"disabled"!=t[l].color||o++,"aborted"==t[l].color&&i++;var s={stable:e,fail:a,unstable:n,aborted:i,disabled:o,total:r};return s}function o(n){var a=e(n);return t({method:"GET",url:a,headers:{Accept:"application/json"}}).then(function(t){return t.data.jobs})}function i(t,e){return o(t).then(getBuilds(t))}function r(e,a){var o=n(e,a);return t({method:"GET",url:o,headers:{Accept:"application/json"}}).then(function(t){var e=t.data.result,n=t.data.url,a=t.data.fullDisplayName,o="";"SUCCESS"==e&&(o="http://iconmonstr.com/wp-content/g/gd/makefg.php?i=../assets/preview/2013/png/iconmonstr-thumb-18.png&r=0&g=0&b=0"),"FAILURE"==e&&(o="http://iconmonstr.com/wp-content/g/gd/makefg.php?i=../assets/preview/2013/png/iconmonstr-thumb-24.png&r=0&g=0&b=0");var i=t.data.changeSet.items[0],r="Kein Infos zum letzen Commit",l="Keine Infos zum Autor";i&&(l=i.author.fullName,r=i.msg);var s={status:e,url:n,lastCommitBy:l,lastCommitMsg:r,imgUrl:o,projectFullName:a};return s})}function l(t){return o(t).then(a)}return{getJobList:o,getJobStats:l,getJobData:r,getLastBuilds:i}}var o=angular.module("adf.widget.jenkins",["adf.provider","chart.js"]).constant("jenkinsEndpoint",{url:"http://builds.apache.org"}).config(n);n.$inject=["dashboardProvider"],angular.module("adf.widget.jenkins").run(["$templateCache",function(t){t.put("{widgetsPath}/jenkins/src/edit.html",'

'),t.put("{widgetsPath}/jenkins/src/view.html",'

{{vm.data.lastCommitMsg}}

{{vm.data.lastCommitBy}}
'),t.put("{widgetsPath}/jenkins/src/charts/edit.html",'

'),t.put("{widgetsPath}/jenkins/src/charts/view.html",'

{{jc.data.stable || 0}}

stable builds

{{jc.data.unstable || 0}}

unstable builds

{{jc.data.fail || 0}}

failed builds

{{jc.data.aborted+jc.data.disabled || 0}}

disabled builds
')}]),o.controller("jenkinsChart",["data",function(t){var e=this;e.data=t;var n=["Stable","Fail","Unstable","Diabled"],a=[e.data.stable,e.data.fail,e.data.unstable,e.data.disabled],o=["#01B7EB","#F7464A","#FDB45C","#DCDCDC"];e.chartLabels=n,e.chartValues=a,e.chartColors=o}]),o.controller("jenkinsJobList",["data",function(t){var e=this;e.data=t}]),o.factory("jenkinsApi",a),a.$inject=["$http"],angular.module("adf.widget.jenkins").controller("projectViewEditController",["jenkinsApi","$scope","jenkinsEndpoint",function(t,e,n){var a=this;e.updateProjects=function(){var o;o=e.config.apiUrl?e.config.apiUrl:n.url,a.projects=[],t.getJobList(o).then(function(t){t.forEach(function(t){var e={name:t.name};a.projects.push(e)})})},e.updateProjects()}])}(window); \ No newline at end of file +!function(t,e){"use strict";angular.module("adf.widget.jenkins").run(["$templateCache",function(t){t.put("{widgetsPath}/jenkins/src/jenkins.js","'use strict'; var jenkinsWidget = angular.module('adf.widget.jenkins', ['adf.provider', 'chart.js', 'ui.bootstrap']) .constant(\"jenkinsEndpoint\", { \"url\": \"http://builds.apache.org\" }) .config(registerWidget); function registerWidget(dashboardProvider) { dashboardProvider .widget('jenkinsBuildReport', { title: 'Jenkins Build Report', description: 'Displays current build information', templateUrl: '{widgetsPath}/jenkins/src/view.html', resolve: { data: function(jenkinsApi, config, jenkinsEndpoint) { if (config.apiUrl) { return jenkinsApi.getJobData(config.apiUrl, config.project); } else if (jenkinsEndpoint.url && config.project) { return jenkinsApi.getJobData(jenkinsEndpoint.url, config.project); } } }, controller: 'jenkinsJobList', controllerAs: 'vm', edit: { templateUrl: '{widgetsPath}/jenkins/src/edit.html', controller: 'projectViewEditController', controllerAs: 'vm' } }) .widget('jenkinsGlobalStatistics', { title: 'Jenkins Global Statistics', description: 'Displays all build jobs as pie chart', templateUrl: '{widgetsPath}/jenkins/src/charts/view.html', resolve: { data: function(jenkinsApi, config, jenkinsEndpoint) { if (config.apiUrl) { return jenkinsApi.getJobStats(config.apiUrl); } else if (jenkinsEndpoint.url) { return jenkinsApi.getJobStats(jenkinsEndpoint.url); } return 'Please Setup the Widget'; } }, controller: 'jenkinsChart', controllerAs: 'jc', edit: { templateUrl: '{widgetsPath}/jenkins/src/charts/edit.html' } }); }"),t.put("{widgetsPath}/jenkins/src/projectViewEditController.js","'use strict'; angular.module('adf.widget.jenkins') .controller('projectViewEditController', function(jenkinsApi, $scope, jenkinsEndpoint) { var vm = this; $scope.updateProjects = function() { var url; if ($scope.config.apiUrl) { url = $scope.config.apiUrl; } else { url = jenkinsEndpoint.url; } vm.projects = []; jenkinsApi.crawlJenkinsJobs(url).then(function(data) { data.forEach(function(project) { var proj = { name: project.name }; vm.projects.push(proj); }); }); }; $scope.updateProjects(); });"),t.put("{widgetsPath}/jenkins/src/service.js","'use strict'; jenkinsWidget .factory('jenkinsApi', jenkinsApi); //function factory jenkinsStats function jenkinsApi($http) { const imgURLBuildSuccess = 'src/img/successful.png'; const imgURLBuildFailed = 'src/img/failed.png'; const imgURLBuildUnstable = 'src/img/unstable.png'; const defaultMsgNoAuthor = 'No author found'; const defaultMsgNoCommitInfo = 'No commit information found'; /* *Connection settings should be fixed in dashboard dogu */ //get all jobs function createApiConnection(apiUrl) { return apiUrl + '/api/json/jobs'; } //get info about specific project function createProjectConnection(apiUrl, project) { return apiUrl + '/job/' + project + '/lastBuild/api/json'; } //buildstate statistics overall function parseStats(jobList) { var countStable = 0; var countUnstable = 0; var countFail = 0; var countDisabled = 0; var countAborted = 0; var total = jobList.length; for (var i = 0; i < total; i++) { if (jobList[i].color == 'blue') { countStable++; } if (jobList[i].color == 'red') { countFail++; } if (jobList[i].color == 'yellow') { countUnstable++; } if (jobList[i].color == 'notbuilt' || jobList[i].color == 'disabled') { countDisabled++; } if (jobList[i].color == 'aborted') { countAborted++; } } return { stable: countStable, fail: countFail, unstable: countUnstable, aborted: countAborted, disabled: countDisabled, total: total }; } function crawlJenkinsJobs(instanceURL) { var connection = instanceURL + '/api/json?tree=jobs[name,buildable,color,jobs[name,buildable,color,jobs[name,buildable,color,jobs[name,buildable,color,jobs]]]]&pretty'; return $http({ method: 'GET', url: connection, headers: { 'Accept': 'application/json' } }).then(function (response) { var jobItems = []; jobItems = resolveJobFolder(response.data, jobItems); return jobItems; }) } function resolveJobFolder(job, jobItems) { var folderName = job.name; job.jobs.forEach(function (job) { if (job.buildable) { if (folderName === undefined || folderName == null) { jobItems.push({name: job.name, color: job.color}); } else { jobItems.push({name: folderName + \" / \" + job.name, color: job.color}); } } if (job.jobs) { resolveJobFolder(job, jobItems); } }); return jobItems; } //returns all jobs in jenkins instance function getJobList(apiUrl) { var connection = createApiConnection(apiUrl); return $http({ method: 'GET', url: connection, headers: { 'Accept': 'application/json' } }).then(function (response) { return response.data.jobs; }) } //returns information for a defined range of builds function getLastBuilds(apiUrl) { return getJobList(apiUrl); } //returns last build information for a scpecific project function getJobData(apiUrl, project) { var connection = createProjectConnection(apiUrl, project); return $http({ method: 'GET', url: connection, headers: { 'Accept': 'application/json' } }).then(function (response) { var status = response.data.result; var url = response.data.url; var projectFullName = response.data.fullDisplayName; var imgUrl = imgURLBuildUnstable; if (status == \"SUCCESS\") { imgUrl = imgURLBuildSuccess; } else if (status == \"FAILURE\") { imgUrl = imgURLBuildFailed; } var lastCommit = response.data.changeSet.items[0]; var lastCommitMsg = defaultMsgNoCommitInfo; var lastCommitBy = defaultMsgNoAuthor; if (lastCommit) { lastCommitBy = lastCommit.author.fullName; lastCommitMsg = lastCommit.msg; } return { status: status, url: url, lastCommitBy: lastCommitBy, lastCommitMsg: lastCommitMsg, imgUrl: imgUrl, projectFullName: projectFullName }; }) } //returns statistics over the whole jenkins instance function getJobStats(apiUrl) { return crawlJenkinsJobs(apiUrl).then(parseStats); } //setup the functions called by widget return { getJobList: getJobList, getJobStats: getJobStats, getJobData: getJobData, getLastBuilds: getLastBuilds, crawlJenkinsJobs: crawlJenkinsJobs }; }"),t.put("{widgetsPath}/jenkins/src/stats.controller.js","'use strict'; jenkinsWidget.controller('jenkinsJobList', function(data) { var vm = this; vm.data = data; });"),t.put("{widgetsPath}/jenkins/src/charts/buildChart.js","'use strict' jenkinsWidget.controller('jenkinsChart', function(data) { //get chart data var jc = this; jc.data = data; //configure chart var labels = [\"Stable\", \"Fail\",\"Unstable\",\"Diabled\"]; var values = [jc.data.stable,jc.data.fail,jc.data.unstable,jc.data.disabled]; var colors = ['#009587','#F34235','#FEC006','#DCDCDC']; jc.chartLabels = labels; jc.chartValues = values; jc.chartColors = colors; });"),t.put("{widgetsPath}/jenkins/src/edit.html",'

'),t.put("{widgetsPath}/jenkins/src/view.html",'

{{vm.data.projectFullName}}

Last Commit: {{vm.data.lastCommitMsg}}

Author: {{vm.data.lastCommitBy}}
'),t.put("{widgetsPath}/jenkins/src/charts/edit.html",'

'),t.put("{widgetsPath}/jenkins/src/charts/view.html",'

{{jc.data.stable || 0}}

stable builds

{{jc.data.unstable || 0}}

unstable builds

{{jc.data.fail || 0}}

failed builds

{{jc.data.aborted+jc.data.disabled || 0}}

disabled builds
')}])}(window); \ No newline at end of file