From 1b83af30a4e935f2037a6e9153cb438c29adfbfc Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 29 Dec 2012 15:56:48 +0100 Subject: o Starting on a generic paging component. o Showing recent jobs on the jenkins server page. --- src/main/webapp/apps/buildApp/build.html | 30 ++++++++ src/main/webapp/apps/buildApp/buildApp.js | 15 ++++ src/main/webapp/apps/core/CoreResources.js | 14 ++-- src/main/webapp/apps/core/PagingTableService.js | 64 +++++++++++++++++ .../webapp/apps/jenkinsApp/JenkinsResources.js | 17 +++++ .../webapp/apps/jenkinsApp/JenkinsServerService.js | 9 --- src/main/webapp/apps/jenkinsApp/jenkinsApp.js | 19 ++--- src/main/webapp/apps/jenkinsApp/server.html | 81 ++++++++++++++++------ src/main/webapp/apps/personApp/person.html | 4 +- 9 files changed, 206 insertions(+), 47 deletions(-) create mode 100644 src/main/webapp/apps/buildApp/build.html create mode 100644 src/main/webapp/apps/buildApp/buildApp.js create mode 100644 src/main/webapp/apps/core/PagingTableService.js create mode 100644 src/main/webapp/apps/jenkinsApp/JenkinsResources.js delete mode 100644 src/main/webapp/apps/jenkinsApp/JenkinsServerService.js (limited to 'src/main/webapp/apps') diff --git a/src/main/webapp/apps/buildApp/build.html b/src/main/webapp/apps/buildApp/build.html new file mode 100644 index 0000000..b2d4bd9 --- /dev/null +++ b/src/main/webapp/apps/buildApp/build.html @@ -0,0 +1,30 @@ +
+ + + +
+

Participants

+ + + + + + + + + +
Date{{build.date | date:'medium'}}
Status + SUCCESS + FAILURE +
+

Participants

+ +

+ {{participant.name}} +

+ +
+ +
diff --git a/src/main/webapp/apps/buildApp/buildApp.js b/src/main/webapp/apps/buildApp/buildApp.js new file mode 100644 index 0000000..187b240 --- /dev/null +++ b/src/main/webapp/apps/buildApp/buildApp.js @@ -0,0 +1,15 @@ +'use strict'; + +var buildApp = angular.module('buildApp', ['build', 'buildParticipant']).config(function ($routeProvider) { + $routeProvider. + when('/', {controller: BuildCtrl, templateUrl: '/apps/buildApp/build.html?noCache=' + noCache}); +}); + +function BuildCtrl($scope, Build, BuildParticipant) { + Build.get({uuid: uuid}, function(build) { + window.build = $scope.build = build; + }); + BuildParticipant.query({uuid: uuid}, function(persons) { + $scope.participants = persons; + }); +} diff --git a/src/main/webapp/apps/core/CoreResources.js b/src/main/webapp/apps/core/CoreResources.js index 96d4b24..74ac184 100644 --- a/src/main/webapp/apps/core/CoreResources.js +++ b/src/main/webapp/apps/core/CoreResources.js @@ -4,14 +4,16 @@ function Person($resource) { return $resource('/resource/core/person/:uuid', {uuid: '@uuid'}); } -angular. - module('person', ['ngResource']). - factory('Person', Person); +angular.module('person', ['ngResource']).factory('Person', Person); function Build($resource) { return $resource('/resource/core/build/:uuid', {uuid: '@uuid'}); } -angular. - module('build', ['ngResource']). - factory('Build', Build); +angular.module('build', ['ngResource']).factory('Build', Build); + +function BuildParticipant($resource) { + return $resource('/resource/core/build-participant/:uuid', {uuid: '@uuid'}); +} + +angular.module('buildParticipant', ['ngResource']).factory('BuildParticipant', BuildParticipant); diff --git a/src/main/webapp/apps/core/PagingTableService.js b/src/main/webapp/apps/core/PagingTableService.js new file mode 100644 index 0000000..689a225 --- /dev/null +++ b/src/main/webapp/apps/core/PagingTableService.js @@ -0,0 +1,64 @@ +function PagingTableService() { + var create = function ($scope, fetchCallback) { + var self = { + rows: [], + startIndex: 0, + count: 10 + }; + + var update = function(){ + fetchCallback(self.startIndex, self.count, function(data) { + self.rows = data.rows; + }); + }; + + self.first = function () { + self.startIndex = 0; + update(); + }; + + self.next = function () { + this.startIndex += this.count; + update(); + }; + + self.prev = function () { + if (self.startIndex == 0) { + return; + } + self.startIndex -= self.count; + update(); + }; + + // Do an initial fetch + update(); + + return self; + }; + + var defaultCallback = function(Resource, args) { + return function(startIndex, count, cb) { + console.log("fetching", arguments); + args.startIndex = startIndex; + args.count = count; + Resource.query(args, function(data, headers) { + var totalResults = headers("total-results"); + console.log("got data", arguments); + console.log("totalResults", totalResults); + cb({ + totalResults: totalResults, + rows: data + }); + }); + }; + }; + + return { + create: create, + defaultCallback: defaultCallback + } +} + +angular. + module('pagingTableService', ['ngResource']). + factory('PagingTableService', PagingTableService); diff --git a/src/main/webapp/apps/jenkinsApp/JenkinsResources.js b/src/main/webapp/apps/jenkinsApp/JenkinsResources.js new file mode 100644 index 0000000..0026932 --- /dev/null +++ b/src/main/webapp/apps/jenkinsApp/JenkinsResources.js @@ -0,0 +1,17 @@ +'use strict'; + +function JenkinsServer($resource) { + return $resource('/resource/jenkins/server/:uuid', {uuid: '@uuid'}); +} + +angular. + module('jenkinsServer', ['ngResource']). + factory('JenkinsServer', JenkinsServer); + +function JenkinsJob($resource) { + return $resource('/resource/jenkins/job/:uuid', {uuid: '@uuid'}); +} + +angular. + module('jenkinsJob', ['ngResource']). + factory('JenkinsJob', JenkinsJob); diff --git a/src/main/webapp/apps/jenkinsApp/JenkinsServerService.js b/src/main/webapp/apps/jenkinsApp/JenkinsServerService.js deleted file mode 100644 index b26c9b1..0000000 --- a/src/main/webapp/apps/jenkinsApp/JenkinsServerService.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -function JenkinsServerService($resource) { - return $resource('/resource/jenkins/server/:uuid', {uuid: '@uuid'}); -} - -angular. - module('jenkinsServerService', ['ngResource']). - factory('JenkinsServerService', JenkinsServerService); diff --git a/src/main/webapp/apps/jenkinsApp/jenkinsApp.js b/src/main/webapp/apps/jenkinsApp/jenkinsApp.js index 5477039..e51c9f3 100644 --- a/src/main/webapp/apps/jenkinsApp/jenkinsApp.js +++ b/src/main/webapp/apps/jenkinsApp/jenkinsApp.js @@ -1,6 +1,6 @@ 'use strict'; -var jenkinsApp = angular.module('jenkinsApp', ['jenkinsServerService']).config(function ($routeProvider, $locationProvider) { +var jenkinsApp = angular.module('jenkinsApp', ['jenkinsServer', 'jenkinsJob', 'pagingTableService']).config(function ($routeProvider) { $routeProvider. when('/', {controller: ServerListCtrl, templateUrl: '/apps/jenkinsApp/server-list.html?noCache=' + noCache}); $routeProvider. @@ -11,12 +11,12 @@ var jenkinsApp = angular.module('jenkinsApp', ['jenkinsServerService']).config(f // $locationProvider.html5Mode(true); }); -function ServerListCtrl($scope, $location, JenkinsServerService) { - JenkinsServerService.query(function (servers) { +function ServerListCtrl($scope, $location, JenkinsServer) { + JenkinsServer.query(function (servers) { $scope.servers = servers; }); - $scope.showServers = function (uuid) { + $scope.showServers = function () { $location.path('/'); }; @@ -25,13 +25,16 @@ function ServerListCtrl($scope, $location, JenkinsServerService) { }; } -function ServerCtrl($scope, $location, $routeParams, JenkinsServerService) { - window.x = $routeParams; - JenkinsServerService.get({uuid: $routeParams.uuid}, function (server) { +function ServerCtrl($scope, $location, $routeParams, JenkinsServer, JenkinsJob, PagingTableService) { + var serverUuid = $routeParams.uuid; + + JenkinsServer.get({uuid: serverUuid}, function (server) { $scope.server = server; }); - $scope.showServers = function (uuid) { + $scope.jobs = PagingTableService.create($scope, PagingTableService.defaultCallback(JenkinsJob, {server: serverUuid})); + + $scope.showServers = function () { $location.path('/'); }; diff --git a/src/main/webapp/apps/jenkinsApp/server.html b/src/main/webapp/apps/jenkinsApp/server.html index 9b27dfe..8a784e8 100644 --- a/src/main/webapp/apps/jenkinsApp/server.html +++ b/src/main/webapp/apps/jenkinsApp/server.html @@ -1,25 +1,60 @@ - +
+ + + + - +

Overview

+ + + + + + + + + + + + + + + +
URL{{server.url}}
Enabled{{server.enabled}}
Stats{{server.jobCount}} jobs, {{server.buildCount}} builds
- - - - - - - - - - - - - - - -
URL{{server.url}}
Enabled{{server.enabled}}
Stats{{server.jobCount}} jobs, {{server.buildCount}} builds
+

Recent Jobs

+ + + + + + + + + + + + + + + + + + +
Job
{{job.createdDate | date:'medium'}}{{job.displayName}}{{job.uuid}}
+ +
+ +
diff --git a/src/main/webapp/apps/personApp/person.html b/src/main/webapp/apps/personApp/person.html index d9524ae..83aea0a 100644 --- a/src/main/webapp/apps/personApp/person.html +++ b/src/main/webapp/apps/personApp/person.html @@ -28,12 +28,14 @@ Date Success + {{build.date | date:'medium'}} {{build.success}} + Details @@ -41,7 +43,7 @@

Builds

- +
-- cgit v1.2.3
Date