From 7e05c42378c79752c5f9b5bc4c0c8d59da97b47c Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 22 Jan 2013 17:07:45 +0100 Subject: o Creating a little component to create and maintain a Bootstrap navbar. --- .../webapp/apps/frontPageApp/frontPageApp.js | 10 +- .../resources/webapp/apps/jenkinsApp/jenkinsApp.js | 43 ++++++- .../resources/webapp/apps/jenkinsApp/server.html | 125 +++++++++++++-------- 3 files changed, 122 insertions(+), 56 deletions(-) diff --git a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js index 4633892..6a3e6a6 100755 --- a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js +++ b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js @@ -11,11 +11,6 @@ var frontPageApp = angular.module('frontPageApp', ['ngGrid', 'person', 'badge', when('/build/:buildUuid', {controller: BuildCtrl, templateUrl: '/apps/frontPageApp/build.html?noCache=' + noCache}); }); -function FrontPageCtrl($scope, Person, Badge) { - $scope.persons = Person.query(); - $scope.recentBadges = Badge.query(); -} - function groupBy(array, size) { var group = []; var groups = []; @@ -50,6 +45,11 @@ function groupByDay(array, accessor) { return byDay; } +function FrontPageCtrl($scope, Person, Badge) { + $scope.persons = Person.query(); + $scope.recentBadges = Badge.query(); +} + function BadgeListCtrl($scope, Badge, PagingTableService) { var personsWatcher = function () { $scope.badgeGroups = groupByDay($scope.badges.rows, function (badge) { return badge.badge.createdDate }); diff --git a/src/main/resources/webapp/apps/jenkinsApp/jenkinsApp.js b/src/main/resources/webapp/apps/jenkinsApp/jenkinsApp.js index 7d0a90c..d632aaf 100755 --- a/src/main/resources/webapp/apps/jenkinsApp/jenkinsApp.js +++ b/src/main/resources/webapp/apps/jenkinsApp/jenkinsApp.js @@ -1,6 +1,43 @@ 'use strict'; -var jenkinsApp = angular.module('jenkinsApp', ['jenkinsServer', 'jenkinsJob', 'jenkinsBuild', 'core.directives', 'pagingTableService']).config(function ($routeProvider) { +function NavbarService() { + var create = function(tabs) { + console.log("create", tabs); + var currentIndex = 0; + var currentTab = tabs[currentIndex]; + + var onClick = function(tab) { + console.log("onClick", arguments); + currentTab = tab; + currentIndex = _.indexOf(tabs, tab); + }; + + var selected = function() { + return currentTab; + }; + + var selectedIndex = function() { + return currentIndex; + }; + + return { + onClick: onClick, + selected: selected, + selectedIndex: selectedIndex, + tabs: tabs + } + }; + + return { + create: create + } +} + +angular. + module('navbarService', ['ngResource']). + factory('NavbarService', NavbarService); + +var jenkinsApp = angular.module('jenkinsApp', ['jenkinsServer', 'jenkinsJob', 'jenkinsBuild', 'core.directives', 'navbarService', 'pagingTableService']).config(function ($routeProvider) { $routeProvider. when('/', {controller: ServerListCtrl, templateUrl: '/apps/jenkinsApp/server-list.html?noCache=' + noCache}). when('/server/:serverUuid', {controller: ServerCtrl, templateUrl: '/apps/jenkinsApp/server.html?noCache=' + noCache}). @@ -14,7 +51,7 @@ function ServerListCtrl($scope, $location, JenkinsServer) { }); } -function ServerCtrl($scope, $location, $routeParams, JenkinsServer, JenkinsJob, PagingTableService) { +function ServerCtrl($scope, $routeParams, JenkinsServer, JenkinsJob, PagingTableService, NavbarService) { $scope.serverUuid = $routeParams.serverUuid; JenkinsServer.get({uuid: $scope.serverUuid}, function (server) { @@ -22,6 +59,8 @@ function ServerCtrl($scope, $location, $routeParams, JenkinsServer, JenkinsJob, }); $scope.jobs = PagingTableService.create($scope, PagingTableService.defaultCallback(JenkinsJob, {server: $scope.serverUuid})); + + $scope.navbar = NavbarService.create(["Overview", "Jobs", "Recent Builds"]); } function JobCtrl($scope, $location, $routeParams, JenkinsJob, JenkinsBuild, PagingTableService) { diff --git a/src/main/resources/webapp/apps/jenkinsApp/server.html b/src/main/resources/webapp/apps/jenkinsApp/server.html index 88948b5..2a220db 100755 --- a/src/main/resources/webapp/apps/jenkinsApp/server.html +++ b/src/main/resources/webapp/apps/jenkinsApp/server.html @@ -12,55 +12,82 @@
  • Server
  • -

    Overview

    - - - - - - - - - - - - - - - - - - - - - - - -
    URL{{server.url}}
    Enabled{{server.enabled}}
    Number of jobs{{server.jobCount}}
    Number of builds{{server.buildCount}}
    Most recent build{{server.lastBuildTimestamp | date:'medium'}}
    + + + +
    +
    +

    Overview

    + + + + + + + + + + + + + + + + + + + + + + + +
    URL{{server.url}}
    Enabled{{server.enabled}}
    Number of jobs{{server.jobCount}}
    Number of builds{{server.buildCount}}
    Most recent build{{server.lastBuildTimestamp | date:'medium'}}
    +
    +
    -

    Recent Jobs

    - - - - - - - - - - - - - -
    {{job.displayName}}{{job.createdDate | date:'medium'}}
    - -
    +
    +
    +

    Jobs

    + + + + + + + + + + + + + +
    {{job.displayName}}{{job.createdDate | date:'medium'}}
    + +
    +
    +
    + +
    +
    +

    Recent builds

    +
    +
    -- cgit v1.2.3