From 39636be7b018b9121696ce7bdc462ab2c3c8185d Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 11 Jan 2013 17:11:28 +0100 Subject: o Creating bin/web for running the web application. --- src/main/resources/webapp/apps/app.css | 58 +++++++++++ src/main/resources/webapp/apps/app.js | 97 ++++++++++++++++++ src/main/resources/webapp/apps/buildApp/build.html | 30 ++++++ .../resources/webapp/apps/buildApp/buildApp.js | 12 +++ .../resources/webapp/apps/core/CoreResources.js | 25 +++++ .../webapp/apps/core/PagingTableService.js | 72 ++++++++++++++ src/main/resources/webapp/apps/core/navbar.html | 17 ++++ .../resources/webapp/apps/frontPageApp/badge.html | 30 ++++++ .../webapp/apps/frontPageApp/badgeList.html | 46 +++++++++ .../webapp/apps/frontPageApp/buildList.html | 50 ++++++++++ .../webapp/apps/frontPageApp/frontPage.html | 31 ++++++ .../webapp/apps/frontPageApp/frontPageApp.js | 110 +++++++++++++++++++++ .../resources/webapp/apps/frontPageApp/person.html | 100 +++++++++++++++++++ .../webapp/apps/frontPageApp/personList.html | 47 +++++++++ .../webapp/apps/jenkinsApp/JenkinsResources.js | 25 +++++ .../resources/webapp/apps/jenkinsApp/build.html | 43 ++++++++ .../resources/webapp/apps/jenkinsApp/jenkinsApp.js | 57 +++++++++++ src/main/resources/webapp/apps/jenkinsApp/job.html | 61 ++++++++++++ .../webapp/apps/jenkinsApp/server-list.html | 32 ++++++ .../resources/webapp/apps/jenkinsApp/server.html | 64 ++++++++++++ 20 files changed, 1007 insertions(+) create mode 100755 src/main/resources/webapp/apps/app.css create mode 100755 src/main/resources/webapp/apps/app.js create mode 100755 src/main/resources/webapp/apps/buildApp/build.html create mode 100755 src/main/resources/webapp/apps/buildApp/buildApp.js create mode 100644 src/main/resources/webapp/apps/core/CoreResources.js create mode 100755 src/main/resources/webapp/apps/core/PagingTableService.js create mode 100755 src/main/resources/webapp/apps/core/navbar.html create mode 100755 src/main/resources/webapp/apps/frontPageApp/badge.html create mode 100755 src/main/resources/webapp/apps/frontPageApp/badgeList.html create mode 100755 src/main/resources/webapp/apps/frontPageApp/buildList.html create mode 100755 src/main/resources/webapp/apps/frontPageApp/frontPage.html create mode 100755 src/main/resources/webapp/apps/frontPageApp/frontPageApp.js create mode 100755 src/main/resources/webapp/apps/frontPageApp/person.html create mode 100755 src/main/resources/webapp/apps/frontPageApp/personList.html create mode 100644 src/main/resources/webapp/apps/jenkinsApp/JenkinsResources.js create mode 100644 src/main/resources/webapp/apps/jenkinsApp/build.html create mode 100644 src/main/resources/webapp/apps/jenkinsApp/jenkinsApp.js create mode 100755 src/main/resources/webapp/apps/jenkinsApp/job.html create mode 100644 src/main/resources/webapp/apps/jenkinsApp/server-list.html create mode 100644 src/main/resources/webapp/apps/jenkinsApp/server.html (limited to 'src/main/resources/webapp/apps') diff --git a/src/main/resources/webapp/apps/app.css b/src/main/resources/webapp/apps/app.css new file mode 100755 index 0000000..3088282 --- /dev/null +++ b/src/main/resources/webapp/apps/app.css @@ -0,0 +1,58 @@ +/* + * Badges + */ +/* + bronze = #8c7853 + bronze ii = #a67d3d + */ + +.badge-level-1 { background-color: #a67d3d; color: #000000 } +.badge-level-2 { background-color: silver; color: #000000 } +.badge-level-3 { background-color: #ffd700; color: #000000 } + +/* + * Avatar + */ + +/* This has to match the Gravatar image */ +.avatar80 { + width: 80px; + height: 80px; +} + +/* + * + */ + +#content { + background-color: #ffffff; + padding-bottom: 60px; +} + +#footer { + background-color: #f5f5f5; + border-top: 1px solid #ccc; + color: #000000; +} + +#footer .container { + padding: 60px 0; +} + +#footer abbr[title] { + border-bottom: 1px dotted #000; +} + +#footer p { + margin-bottom: 0; + color: #777; +} + +#footer-links { + margin: 10px 0; +} + +#footer-links li { + display: inline; + margin-right: 10px; +} diff --git a/src/main/resources/webapp/apps/app.js b/src/main/resources/webapp/apps/app.js new file mode 100755 index 0000000..068f454 --- /dev/null +++ b/src/main/resources/webapp/apps/app.js @@ -0,0 +1,97 @@ +var directives = angular.module('core.directives', []); + +directives.filter('countBadgeByLevel', function () { + return function (badges) { + // 5 levels + var levels = [0, 0, 0, 0, 0]; + angular.forEach(badges, function (value, key) { + levels[value.level - 1]++; + }); + return levels; + } +}); + +directives.filter('isodate', function () { + return function (date) { + return date.toISOString(); + } +}); + +directives.filter('gz', function () { + return function (num) { + if (angular.isArray(num)) { + var out = []; + angular.forEach(num, function (x) { + if (x > 0) { + out.push(x); + } + }); + + return out; + } + else if (angular.isNumber(num)) { + return num > 0; + } + console.log("fail"); + return undefined; + } +}); + +directives.directive('navbar', function () { + return { + restrict: 'E', + templateUrl: '/apps/core/navbar.html?noCache=' + noCache + }; +}); + +directives.directive('badge', function () { + return { + restrict: 'E', + scope: { + badgeDetail: '=badgeDetail' + }, + template: '' + + ' {{badgeDetail.badge.name}}' + + ' ' + + '' + + ' awarded to ' + + '{{badgeDetail.person.name}}. ' + + 'More' + } +}); + +directives.directive('badgeSpan', function () { + var template = + '' + + ' {{badge.name}}' + + ' ' + + ''; + + return { + restrict: 'E', + scope: { + badge: '=badge' + }, + template: template + } +}); + +directives.directive('personLink', function () { + return { + restrict: 'E', + scope: { + person: '=person' + }, + template: '{{person.name}}' + } +}); + +directives.directive('personAvatar', function () { + return { + restrict: 'E', + scope: { + person: '=person' + }, + template: '' + } +}); diff --git a/src/main/resources/webapp/apps/buildApp/build.html b/src/main/resources/webapp/apps/buildApp/build.html new file mode 100755 index 0000000..fec38d2 --- /dev/null +++ b/src/main/resources/webapp/apps/buildApp/build.html @@ -0,0 +1,30 @@ +
+ + + +
+

Participants

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

Participants

+ +

+ {{participant.name}} +

+ +
+ +
diff --git a/src/main/resources/webapp/apps/buildApp/buildApp.js b/src/main/resources/webapp/apps/buildApp/buildApp.js new file mode 100755 index 0000000..170af16 --- /dev/null +++ b/src/main/resources/webapp/apps/buildApp/buildApp.js @@ -0,0 +1,12 @@ +'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) { + $scope.build = build; + }); +} diff --git a/src/main/resources/webapp/apps/core/CoreResources.js b/src/main/resources/webapp/apps/core/CoreResources.js new file mode 100644 index 0000000..b258c85 --- /dev/null +++ b/src/main/resources/webapp/apps/core/CoreResources.js @@ -0,0 +1,25 @@ +'use strict'; + +function Person($resource) { + return $resource('/resource/core/person/:uuid', {uuid: '@uuid'}); +} + +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); + +function BuildParticipant($resource) { + return $resource('/resource/core/build-participant/:uuid', {uuid: '@uuid'}); +} + +angular.module('buildParticipant', ['ngResource']).factory('BuildParticipant', BuildParticipant); + +function Badge($resource) { + return $resource('/resource/core/badge/:uuid', {uuid: '@uuid'}); +} + +angular.module('badge', ['ngResource']).factory('Badge', Badge); diff --git a/src/main/resources/webapp/apps/core/PagingTableService.js b/src/main/resources/webapp/apps/core/PagingTableService.js new file mode 100755 index 0000000..af593df --- /dev/null +++ b/src/main/resources/webapp/apps/core/PagingTableService.js @@ -0,0 +1,72 @@ +function PagingTableService() { + var create = function ($scope, fetchCallback, options) { + options = options || {}; + var watcher = options.watcher || function(){}; + var self = { + rows: [], + startIndex: options.startIndex || 0, + count: options.count || 10 + }; + + var update = function(){ + fetchCallback(self.startIndex, self.count, function(data) { + self.rows = data.rows; + watcher(); + }); + }; + + self.first = function () { + self.startIndex = 0; + update(); + }; + + self.next = function () { + self.startIndex += self.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) { + args = args || {}; + return function(startIndex, count, cb) { + if(startIndex) { + args.startIndex = startIndex; + } + if(count) { + args.count = count; + } + console.log("fetching", args); + Resource.query(args, function(data, headers) { + var totalResults = headers("total-results"); + console.log("totalResults", totalResults); + console.log("got data", data); + cb({ + totalResults: totalResults, + rows: data + }); + }); + }; + }; + + return { + create: create, + defaultCallback: defaultCallback + } +} + +angular. + module('pagingTableService', ['ngResource']). + factory('PagingTableService', PagingTableService); diff --git a/src/main/resources/webapp/apps/core/navbar.html b/src/main/resources/webapp/apps/core/navbar.html new file mode 100755 index 0000000..914258e --- /dev/null +++ b/src/main/resources/webapp/apps/core/navbar.html @@ -0,0 +1,17 @@ + diff --git a/src/main/resources/webapp/apps/frontPageApp/badge.html b/src/main/resources/webapp/apps/frontPageApp/badge.html new file mode 100755 index 0000000..92fc7ae --- /dev/null +++ b/src/main/resources/webapp/apps/frontPageApp/badge.html @@ -0,0 +1,30 @@ +
+ + + + + +
+
+ The badge was awarded to at + {{badge.badge.createdDate | date:'medium'}}. +
+
+ +
+
+

Details

+

+ The badge was awarded for having {{badge.personalBadge.builds.length}} successful builds in a row: +

+ +
+
+ +
diff --git a/src/main/resources/webapp/apps/frontPageApp/badgeList.html b/src/main/resources/webapp/apps/frontPageApp/badgeList.html new file mode 100755 index 0000000..7671a55 --- /dev/null +++ b/src/main/resources/webapp/apps/frontPageApp/badgeList.html @@ -0,0 +1,46 @@ +
+ + + + + + + +
+
+
+
+

{{date | date:'mediumDate'}}

+
+
+
+
+ +
+ +
+
+
+ +
+
+
diff --git a/src/main/resources/webapp/apps/frontPageApp/buildList.html b/src/main/resources/webapp/apps/frontPageApp/buildList.html new file mode 100755 index 0000000..13a1dc3 --- /dev/null +++ b/src/main/resources/webapp/apps/frontPageApp/buildList.html @@ -0,0 +1,50 @@ +
+ + + + + + + +
+
+ + + + + + + + + + + +
{{build.build.timestamp | date:'medium'}} + SUCCESS + FAILURE +
+ + + +
+ +
+
+
diff --git a/src/main/resources/webapp/apps/frontPageApp/frontPage.html b/src/main/resources/webapp/apps/frontPageApp/frontPage.html new file mode 100755 index 0000000..c3db55c --- /dev/null +++ b/src/main/resources/webapp/apps/frontPageApp/frontPage.html @@ -0,0 +1,31 @@ +
+ + + + +
+
+

Badges

+ +
+
    +
  • + +
  • +
+
+
+ +
+

Newcomers

+ + +
+
+
diff --git a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js new file mode 100755 index 0000000..6f80d0f --- /dev/null +++ b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js @@ -0,0 +1,110 @@ +'use strict'; + +var frontPageApp = angular.module('frontPageApp', ['ngGrid', 'person', 'badge', 'build', 'pagingTableService', 'core.directives']).config(function ($routeProvider) { + $routeProvider. + when('/', {controller: FrontPageCtrl, templateUrl: '/apps/frontPageApp/frontPage.html?noCache=' + noCache}). + when('/badge/', {controller: BadgeListCtrl, templateUrl: '/apps/frontPageApp/badgeList.html?noCache=' + noCache}). + when('/badge/:badgeUuid', {controller: BadgeCtrl, templateUrl: '/apps/frontPageApp/badge.html?noCache=' + noCache}). + when('/person/', {controller: PersonListCtrl, templateUrl: '/apps/frontPageApp/personList.html?noCache=' + noCache}). + when('/person/:personUuid', {controller: PersonCtrl, templateUrl: '/apps/frontPageApp/person.html?noCache=' + noCache}). + when('/build/', {controller: BuildListCtrl, templateUrl: '/apps/frontPageApp/buildList.html?noCache=' + noCache}); +}); + +function FrontPageCtrl($scope, Person, Badge) { + $scope.persons = Person.query(); + $scope.recentBadges = Badge.query(); +} + +function groupBy(array, size) { + var group = []; + var groups = []; + angular.forEach(array, function (element) { + group.push(element); + if (group.length == size) { + groups.push(group); + group = []; + } + }); + + if (group.length != 0) { + groups.push(group); + } + return groups; +} + +function BadgeListCtrl($scope, Badge, PagingTableService) { + var groupSize = 6; + + var personsWatcher = function () { + var withDay = _.map($scope.badges.rows, function(badge) { + badge.day = new Date(badge.badge.createdDate).clearTime().getTime(); +// badge.day.clearTime(); + return badge; + }); + + var byDay = _.groupBy(withDay, 'day'); + console.log("byDay", byDay); +// var dateGroups = _.map(byDay, function(group, date) { +// return {date: groupBy(group, groupSize)} +// }); + + $scope.badgeGroups = byDay; + }; + + $scope.badges = PagingTableService.create($scope, PagingTableService.defaultCallback(Badge), + {count: groupSize * 6, watcher: personsWatcher}); + + $scope.badgeGroups = []; +} + +function BadgeCtrl($scope, $routeParams, Badge) { + var badgeUuid = $routeParams.badgeUuid; + Badge.get({uuid: badgeUuid}, function (badge) { + $scope.badge = badge; + }); +} + +function PersonListCtrl($scope, Person, PagingTableService) { + var groupSize = 4; + var personsWatcher = function () { + $scope.personGroups = groupBy($scope.persons.rows, groupSize); + }; + + $scope.persons = PagingTableService.create($scope, PagingTableService.defaultCallback(Person, {orderBy: "name"}), + {count: groupSize * 6, watcher: personsWatcher}); + + $scope.personGroups = []; +} + +function PersonCtrl($scope, $routeParams, Person, Build, PagingTableService) { + var personUuid = $routeParams.personUuid; + + $scope.mode = 'overview'; + $scope.builds = PagingTableService.create($scope, PagingTableService.defaultCallback(Build, {person: personUuid})); + + $scope.setMode = function(mode) { + $scope.mode = mode; + switch(mode) { + case 'builds': + var builds = $scope.builds; + + console.log("$scope.builds.length=" + builds.rows.length); + if (builds.rows.length == 0) { + $scope.builds.first(); + } + break; + } + }; + + Person.get({uuid: personUuid}, function (person) { + $scope.person = person; + }); + + Build.query({person: personUuid}, function (builds) { + $scope.recentBuilds = builds; + }); +} + +function BuildListCtrl($scope, Build, PagingTableService) { + $scope.builds = PagingTableService.create($scope, PagingTableService.defaultCallback(Build, {fields: "detailed"})); +} diff --git a/src/main/resources/webapp/apps/frontPageApp/person.html b/src/main/resources/webapp/apps/frontPageApp/person.html new file mode 100755 index 0000000..ba5c18d --- /dev/null +++ b/src/main/resources/webapp/apps/frontPageApp/person.html @@ -0,0 +1,100 @@ +
+ + + + + + + +
+
+

Upcoming

+ + + + + +
{{badge.name}} +
+
+
+
+ +

Badges

+
    +
  • + + {{badge.name}} + + + + + + {{badge.createdDate | date:'medium'}} +
  • +
+
+
+

Recent builds

+ + + + + + + + + + + +
{{build.timestamp | date:'medium'}}{{{true: 'Success', false: 'Failure'}[build.success]}}Details
+
+
+ +
+

Builds

+ + + + + + + + + + + + + + + + + + +
DateSuccess
{{build.timestamp | date:'medium'}}{{build.success}}
+ +
+
+
diff --git a/src/main/resources/webapp/apps/frontPageApp/personList.html b/src/main/resources/webapp/apps/frontPageApp/personList.html new file mode 100755 index 0000000..5d7d8c6 --- /dev/null +++ b/src/main/resources/webapp/apps/frontPageApp/personList.html @@ -0,0 +1,47 @@ +
+ + + + + + + +
+
+
+
+
+ + {{person.person.name}} +
+ + x {{level}} + +
+
+
+ +
+
+
diff --git a/src/main/resources/webapp/apps/jenkinsApp/JenkinsResources.js b/src/main/resources/webapp/apps/jenkinsApp/JenkinsResources.js new file mode 100644 index 0000000..89f3139 --- /dev/null +++ b/src/main/resources/webapp/apps/jenkinsApp/JenkinsResources.js @@ -0,0 +1,25 @@ +'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); + +function JenkinsBuild($resource) { + return $resource('/resource/jenkins/build/:uuid', {uuid: '@uuid'}); +} + +angular. + module('jenkinsBuild', ['ngResource']). + factory('JenkinsBuild', JenkinsBuild); diff --git a/src/main/resources/webapp/apps/jenkinsApp/build.html b/src/main/resources/webapp/apps/jenkinsApp/build.html new file mode 100644 index 0000000..7239c90 --- /dev/null +++ b/src/main/resources/webapp/apps/jenkinsApp/build.html @@ -0,0 +1,43 @@ +
+ + + + + + + +

Overview

+ + + + + + + + + + + + + + + +
Timestamp{{details.build.timestamp | date:'medium'}}
Number{{details.build.number}}
Duration{{details.build.duration / 1000 | number:0}}s
+ +

Users

+ + + + + + +
{{user.uuid}}
+ +
diff --git a/src/main/resources/webapp/apps/jenkinsApp/jenkinsApp.js b/src/main/resources/webapp/apps/jenkinsApp/jenkinsApp.js new file mode 100644 index 0000000..e42c67b --- /dev/null +++ b/src/main/resources/webapp/apps/jenkinsApp/jenkinsApp.js @@ -0,0 +1,57 @@ +'use strict'; + +var jenkinsApp = angular.module('jenkinsApp', ['jenkinsServer', 'jenkinsJob', 'jenkinsBuild', 'core.directives', 'pagingTableService']).config(function ($routeProvider) { + $routeProvider. + when('/', {controller: ServerListCtrl, templateUrl: '/apps/jenkinsApp/server-list.html?noCache=' + noCache}). + when('/server/:uuid', {controller: ServerCtrl, templateUrl: '/apps/jenkinsApp/server.html?noCache=' + noCache}). + when('/job/:uuid', {controller: JobCtrl, templateUrl: '/apps/jenkinsApp/job.html?noCache=' + noCache}). + when('/build/:uuid', {controller: BuildCtrl, templateUrl: '/apps/jenkinsApp/build.html?noCache=' + noCache}); +}); + +function ServerListCtrl($scope, $location, JenkinsServer) { + JenkinsServer.query(function (servers) { + $scope.servers = servers; + }); + + $scope.showServers = function () { $location.path('/'); }; + $scope.showServer = function (uuid) { $location.path('/server/' + uuid); }; +} + +function ServerCtrl($scope, $location, $routeParams, JenkinsServer, JenkinsJob, PagingTableService) { + var serverUuid = $routeParams.uuid; + + JenkinsServer.get({uuid: serverUuid}, function (server) { + $scope.server = server; + }); + + $scope.jobs = PagingTableService.create($scope, PagingTableService.defaultCallback(JenkinsJob, {server: serverUuid})); + + $scope.showServers = function () { $location.path('/'); }; + $scope.showJob = function (uuid) { $location.path('/job/' + uuid); }; +} + +function JobCtrl($scope, $location, $routeParams, JenkinsJob, JenkinsBuild, PagingTableService) { + var jobUuid = $routeParams.uuid; + + JenkinsJob.get({uuid: jobUuid}, function (details) { + $scope.details = details; + }); + + $scope.builds = PagingTableService.create($scope, PagingTableService.defaultCallback(JenkinsBuild, {job: jobUuid})); + + $scope.showServers = function () { $location.path('/'); }; + $scope.showServer = function () { $location.path('/server/' + $scope.job.server); }; + $scope.showBuild = function (uuid) { $location.path('/build/' + uuid); }; +} + +function BuildCtrl($scope, $location, $routeParams, JenkinsBuild) { + var buildUuid = $routeParams.uuid; + + JenkinsBuild.get({uuid: buildUuid}, function (details) { + $scope.details = details; + }); + + $scope.showServers = function () { $location.path('/'); }; + $scope.showServer = function (uuid) { $location.path('/server/' + $scope.server.uuid); }; + $scope.showJob = function (uuid) { $location.path('/job/' + $scope.build.job); }; +} diff --git a/src/main/resources/webapp/apps/jenkinsApp/job.html b/src/main/resources/webapp/apps/jenkinsApp/job.html new file mode 100755 index 0000000..8942ab7 --- /dev/null +++ b/src/main/resources/webapp/apps/jenkinsApp/job.html @@ -0,0 +1,61 @@ +
+ + + + + + + +

Overview

+ + + + + + + + + + + + +
URL{{details.job.displayName}}
Build count{{details.buildCount}}
+ +

Recent Builds

+ + + + + + + + + + + + + + + + + + + + +
BuildResult
{{build.timestamp | date:'medium'}}{{build.result}}
+ +
+
diff --git a/src/main/resources/webapp/apps/jenkinsApp/server-list.html b/src/main/resources/webapp/apps/jenkinsApp/server-list.html new file mode 100644 index 0000000..9e297e6 --- /dev/null +++ b/src/main/resources/webapp/apps/jenkinsApp/server-list.html @@ -0,0 +1,32 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
URLEnabled
{{server.url}}{{server.enabled}}Visit +
+
diff --git a/src/main/resources/webapp/apps/jenkinsApp/server.html b/src/main/resources/webapp/apps/jenkinsApp/server.html new file mode 100644 index 0000000..7fbd9f5 --- /dev/null +++ b/src/main/resources/webapp/apps/jenkinsApp/server.html @@ -0,0 +1,64 @@ +
+ + + + + + + + +

Overview

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

Recent Jobs

+ + + + + + + + + + + + + + + + + + + +
Job
{{job.createdDate | date:'medium'}}{{job.displayName}}{{job.uuid}}
+ +
+ +
-- cgit v1.2.3