Skip to content

Commit

Permalink
Merge pull request #2455 from tardyp/windowTitle
Browse files Browse the repository at this point in the history
base-ui: setup windows title according to the page
  • Loading branch information
tardyp committed Oct 21, 2016
2 parents 1cf22f4 + d46871c commit 4387bb1
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 9 deletions.
4 changes: 3 additions & 1 deletion www/base/src/app/builders/builder/builder.controller.coffee
@@ -1,6 +1,6 @@
class Builder extends Controller
constructor: ($rootScope, $scope, dataService, $stateParams, resultsService, recentStorage,
glBreadcrumbService, $state, glTopbarContextualActionsService, $q) ->
glBreadcrumbService, $state, glTopbarContextualActionsService, $q, $window) ->
# make resultsService utilities available in the template
_.mixin($scope, resultsService)
data = dataService.open().closeOnDestroy($scope)
Expand All @@ -9,6 +9,8 @@ class Builder extends Controller
$scope.is_cancelling = false

data.getBuilders(builderid).onNew = (builder) ->
$window.document.title = $state.current.data.pageTitle
builder: builder['name']
$scope.builder = builder
breadcrumb = [
caption: "Builders"
Expand Down
3 changes: 2 additions & 1 deletion www/base/src/app/builders/builder/builder.route.coffee
Expand Up @@ -7,6 +7,7 @@ class State extends Config
# Configuration
cfg =
tabid: 'builders'
pageTitle: _.template("Buildbot: builder <%= builder %>")

# Register new state
state =
Expand All @@ -16,4 +17,4 @@ class State extends Config
url: '/builders/:builder'
data: cfg

$stateProvider.state(state)
$stateProvider.state(state)
5 changes: 4 additions & 1 deletion www/base/src/app/builders/builds/build.controller.coffee
@@ -1,7 +1,7 @@
class Build extends Controller
constructor: ($rootScope, $scope, $location, $stateParams, $state,
dataService, dataUtilsService, recentStorage, publicFieldsFilter,
glBreadcrumbService, glTopbarContextualActionsService, resultsService) ->
glBreadcrumbService, glTopbarContextualActionsService, resultsService, $window) ->
_.mixin($scope, resultsService)

builderid = _.parseInt($stateParams.builder)
Expand Down Expand Up @@ -72,6 +72,9 @@ class Build extends Controller
data = dataService.open().closeOnDestroy($scope)
data.getBuilders(builderid).onChange = (builders) ->
$scope.builder = builder = builders[0]
$window.document.title = $state.current.data.pageTitle
builder: builder['name'], build: buildnumber

# get the build plus the previous and next
# note that this registers to the updates for all the builds for that builder
# need to see how that scales
Expand Down
3 changes: 2 additions & 1 deletion www/base/src/app/builders/builds/build.route.coffee
Expand Up @@ -10,6 +10,7 @@ class State extends Config
templateUrl: "views/#{name}.html"
name: name
url: '/builders/:builder/builds/:build'
data: {}
data:
pageTitle: _.template("Buildbot: builder <%= builder %> build <%= build %>")

$stateProvider.state(state)
1 change: 0 additions & 1 deletion www/base/src/app/builders/log/log.controller.coffee
Expand Up @@ -24,7 +24,6 @@ class Log extends Controller
sref: "build({builder:#{builder.builderid}, build:#{build.number}})"
,
caption: step.name
sref: "step({builder:#{builder.builderid}, build:#{build.number}, step:#{step.number}})"
,
caption: log.name
sref: "log({builder:#{builder.builderid}, build:#{build.number}, step:#{step.number}, log:'#{log.slug}'})"
Expand Down
1 change: 1 addition & 0 deletions www/base/src/app/builders/log/log.route.coffee
Expand Up @@ -7,6 +7,7 @@ class State extends Config
# Configuration
cfg =
tabid: 'builders'
pageTitle: _.template("Buildbot: log: <%= log %>")

# Register new state
state =
Expand Down
1 change: 1 addition & 0 deletions www/base/src/app/builders/step/step.route.coffee
Expand Up @@ -7,6 +7,7 @@ class State extends Config
# Configuration
cfg =
tabid: 'builders'
pageTitle: _.template("Buildbot: build <%= build %> step: <%= step %>")

# Register new state
$stateProvider.state
Expand Down
@@ -0,0 +1,19 @@
class WindowTitle extends Directive('common')
constructor: ($rootScope, $timeout, $stateParams, $window) -> return {
restrict: 'A'
link: ->
listener = (event, toState) ->
$timeout ->
if toState.data and toState.data.pageTitle
if typeof(toState.data.pageTitle) == "function"
$window.document.title = toState.data.pageTitle($stateParams)
else
$window.document.title = toState.data.pageTitle
else if toState.data and toState.data.caption
$window.document.title = 'Buildbot: ' + toState.data.caption
else
$window.document.title = 'Buildbot'

$rootScope.$on '$stateChangeSuccess', listener
return
}
Expand Up @@ -8,7 +8,8 @@ describe 'recent storage service', ->
$window = $injector.get('$window')
$rootScope = $injector.get('$rootScope')
recentStorage = $injector.get('recentStorage')

if navigator.userAgent.indexOf("PhantomJS") > 0
pending()
beforeEach (inject(injected))

it 'should store recent builds', (done) ->
Expand Down
6 changes: 3 additions & 3 deletions www/base/src/app/layout.jade
@@ -1,15 +1,15 @@
doctype html
html.no-js(xmlns:ng='http://angularjs.org', xmlns:app='ignored')
html.no-js(xmlns:ng='http://angularjs.org', xmlns:app='ignored', ng-app="app")
head
meta(charset='utf-8')
meta(http-equiv='X-UA-Compatible', content='IE=edge,chrome=1')
title Buildbot
title(window-title) Buildbot
meta(name='description', content='Buildbot web UI')
meta(name='viewport', content='initial-scale=1, minimum-scale=1, user-scalable=no, maximum-scale=1, width=device-width')
link(rel='stylesheet', href='styles.css')
link(rel='icon', href='img/favicon.ico')

body(ng-cloak, ng-app="app")
body(ng-cloak)
block content
block footer

Expand Down

0 comments on commit 4387bb1

Please sign in to comment.