From b83c4eed1a75e9e68279ab6f84cd7b5eb602abec Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 22 Jan 2013 22:52:09 +0100 Subject: NavbarService: o Storing the current tab with $location.search. JenkinsApp: o Implementing job search. --- .../resources/webapp/apps/core/PagingTableService.js | 2 +- .../resources/webapp/apps/jenkinsApp/jenkinsApp.js | 18 +++++++++++------- src/main/resources/webapp/apps/jenkinsApp/server.html | 9 ++++++++- 3 files changed, 20 insertions(+), 9 deletions(-) (limited to 'src/main/resources') diff --git a/src/main/resources/webapp/apps/core/PagingTableService.js b/src/main/resources/webapp/apps/core/PagingTableService.js index 802c0c8..61446a6 100755 --- a/src/main/resources/webapp/apps/core/PagingTableService.js +++ b/src/main/resources/webapp/apps/core/PagingTableService.js @@ -156,7 +156,7 @@ function PagingTableService() { console.log("Fetching page. args =", args); Resource.query(args, function(data, headers) { var totalResults = headers("total-results"); - console.log("Total results =", totalResults, "Data =", data); + console.log("Total results =", totalResults, "data.length =", data.length, "Data =", data); cb({ totalResults: totalResults, rows: data diff --git a/src/main/resources/webapp/apps/jenkinsApp/jenkinsApp.js b/src/main/resources/webapp/apps/jenkinsApp/jenkinsApp.js index d632aaf..d31b81c 100755 --- a/src/main/resources/webapp/apps/jenkinsApp/jenkinsApp.js +++ b/src/main/resources/webapp/apps/jenkinsApp/jenkinsApp.js @@ -1,15 +1,19 @@ 'use strict'; -function NavbarService() { - var create = function(tabs) { - console.log("create", tabs); - var currentIndex = 0; +function NavbarService($location) { + var create = function(name, tabs) { + var keys = _.map(tabs, function(element) { + return element.toLowerCase().replace(' ', '-'); + }); + + var currentKey = $location.search()[name] || ""; + var currentIndex = _.indexOf(keys, currentKey) || 0; var currentTab = tabs[currentIndex]; var onClick = function(tab) { - console.log("onClick", arguments); currentTab = tab; currentIndex = _.indexOf(tabs, tab); + $location.search(name, keys[currentIndex]); }; var selected = function() { @@ -58,9 +62,9 @@ function ServerCtrl($scope, $routeParams, JenkinsServer, JenkinsJob, PagingTable $scope.server = server; }); - $scope.jobs = PagingTableService.create($scope, PagingTableService.defaultCallback(JenkinsJob, {server: $scope.serverUuid})); + $scope.jobs = PagingTableService.create($scope, PagingTableService.defaultCallback(JenkinsJob, {server: $scope.serverUuid, orderBy: "display_name"})); - $scope.navbar = NavbarService.create(["Overview", "Jobs", "Recent Builds"]); + $scope.navbar = NavbarService.create("view", ["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 2a220db..80544b0 100755 --- a/src/main/resources/webapp/apps/jenkinsApp/server.html +++ b/src/main/resources/webapp/apps/jenkinsApp/server.html @@ -57,7 +57,14 @@
-

Jobs

+ +
+
-- cgit v1.2.3