Skip to content

Commit

Permalink
Fix #457 and make style consistent between firefox and chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Aug 6, 2013
1 parent 0c4938d commit 5b85862
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 62 deletions.
37 changes: 37 additions & 0 deletions hawtio-web/src/main/webapp/app/camel/js/pageTitle.ts
@@ -0,0 +1,37 @@
module Core {

export class PageTitle {

private titleElements: { (): string } [] = [];

public addTitleElement(element:() => string):void {
this.titleElements.push(element);
}

public getTitle():string {
return this.getTitleExcluding([], ' ');
}

public getTitleWithSeparator(separator:string):string {
return this.getTitleExcluding([], separator);
}

public getTitleExcluding(excludes:string[], separator:string):string {
return this.getTitleArrayExcluding(excludes).join(separator);
}

public getTitleArrayExcluding(excludes:string[]):string[] {
return <string[]>this.titleElements.map((element):string => {
var answer:string = '';
if (element) {
answer = element();
if (answer === null) {
return '';
}
}
return answer;
}).exclude(excludes);
}
}

}
10 changes: 5 additions & 5 deletions hawtio-web/src/main/webapp/app/core/js/app.ts
@@ -1,6 +1,6 @@
module Core {

export function AppController($scope, $location, workspace, $document, pageTitle, localStorage, userDetails, lastLocation, jolokiaUrl) {
export function AppController($scope, $location, workspace, $document, pageTitle:Core.PageTitle, localStorage, userDetails, lastLocation, jolokiaUrl) {

if (userDetails.username === null) {
// sigh, hack
Expand All @@ -9,15 +9,15 @@ module Core {

$scope.collapse = '';
$scope.match = null;
$scope.pageTitle = pageTitle.exclude('hawtio');
$scope.pageTitle = [];
$scope.userDetails = userDetails;
$scope.confirmLogout = false;

$scope.setPageTitle = () => {
$scope.pageTitle = pageTitle.getTitleArrayExcluding(['hawtio']);
var tab = workspace.getActiveTab();
if (tab && tab.content) {
var foo:any = Array;
setPageTitle($document, foo.create(pageTitle, tab.content));
setPageTitleWithTab($document, pageTitle, tab.content);
} else {
setPageTitle($document, pageTitle);
}
Expand Down Expand Up @@ -87,7 +87,7 @@ module Core {
if (userDetails.username === null) {
lastLocation.url = $location.url('/login');
}
console.log("userDetails: ", userDetails);
//console.log("userDetails: ", userDetails);
}, true);

$scope.$on('$routeChangeStart', function() {
Expand Down
4 changes: 3 additions & 1 deletion hawtio-web/src/main/webapp/app/core/js/corePlugin.ts
Expand Up @@ -103,7 +103,9 @@ angular.module('hawtioCore', ['bootstrap', 'ngResource', 'ui', 'ui.bootstrap.dia
}).

factory('pageTitle', function () {
return ['hawtio'];
var answer = new Core.PageTitle();
answer.addTitleElement(() => { return 'hawtio'; });
return answer;
}).

factory('viewRegistry',function () {
Expand Down
8 changes: 6 additions & 2 deletions hawtio-web/src/main/webapp/app/core/js/helpers.ts
Expand Up @@ -795,8 +795,12 @@ module Core {
return entries;
}

export function setPageTitle($document, title) {
document.title = title.join(' : ');
export function setPageTitle($document, title:Core.PageTitle) {
$document.attr('title', title.getTitleWithSeparator(' : '));
}

export function setPageTitleWithTab($document, title:Core.PageTitle, tab:string) {
$document.attr('title', title.getTitleWithSeparator(' : ') + ' : ' + tab);
}

/**
Expand Down
41 changes: 12 additions & 29 deletions hawtio-web/src/main/webapp/app/fabric/js/fabricPlugin.ts
Expand Up @@ -27,43 +27,26 @@ module Fabric {
return new Fabric.ProfileSelector();
}).

run(($location: ng.ILocationService, workspace: Workspace, jolokia, viewRegistry, pageTitle) => {
run(($location: ng.ILocationService, workspace: Workspace, jolokia, viewRegistry, pageTitle:Core.PageTitle) => {

Fabric.schemaConfigure();
Fabric.schemaConfigure();

viewRegistry['fabric'] = templatePath + 'layoutFabric.html';
viewRegistry['fabric'] = templatePath + 'layoutFabric.html';

try {
var id = jolokia.getAttribute(Fabric.managerMBean, 'CurrentContainerName', {timeout: 1});
if (id) {
pageTitle.push(id);
pageTitle.addTitleElement( ():string => {
var id = '';
try {
id = jolokia.getAttribute(Fabric.managerMBean, 'CurrentContainerName', {timeout: 1});
} catch (e) {
// ignore
}
} catch (e) {
// ignore
}

var isValid = (workspace) => {
if (workspace.treeContainsDomainAndProperties(jmxDomain, {type: 'Fabric'})) {
/*
try {
var status = workspace.jolokia.getAttribute(managerMBean, 'FabricServiceStatus', {timeout: 1});
if (status) {
return status.clientValid && status.clientConnected;
}
} catch (e) {
// ignore this
}
*/
return true;
}
return false;
};

return id;
});

workspace.topLevelTabs.push( {
content: "Fabric",
title: "Manage your containers and middleware in a fabric",
isValid: isValid,
isValid: workspace.treeContainsDomainAndProperties(jmxDomain, {type: 'Fabric'}),
href: () => "#/fabric/view",
isActive: (workspace: Workspace) => workspace.isLinkActive("fabric")
});
Expand Down
18 changes: 10 additions & 8 deletions hawtio-web/src/main/webapp/app/jmx/js/jmxPlugin.ts
Expand Up @@ -13,19 +13,21 @@ module Jmx {
return Jmx.lazyLoaders;
}).

run(($location: ng.ILocationService, workspace:Workspace, viewRegistry, layoutTree, jolokia, pageTitle) => {
run(($location: ng.ILocationService, workspace:Workspace, viewRegistry, layoutTree, jolokia, pageTitle:Core.PageTitle) => {

viewRegistry['jmx'] = layoutTree;


try {
var id = jolokia.getAttribute('java.lang:type=Runtime', 'Name');
if (id) {
pageTitle.push(id);
pageTitle.addTitleElement(():string => {
var id = ''
try {
id = jolokia.getAttribute('java.lang:type=Runtime', 'Name');
} catch (e) {
// ignore
}
} catch (e) {
// ignore
}
return id;
});


workspace.topLevelTabs.push( {
content: "JMX",
Expand Down
11 changes: 11 additions & 0 deletions hawtio-web/src/main/webapp/css/site-base.less
Expand Up @@ -1304,6 +1304,17 @@ li.stacktrace {
opacity: .8;
border-top-left-radius: 4px;
box-shadow: 0 1px 13px rgba(0, 0, 0, 0.12);
line-height: 16px !important;
}

.instance-name .collapse-target ul {
margin: 0;
}

.instance-name .collapse-target ul li {
padding-left: 4px;
padding-right: 4px;
line-height: 16px !important;
}

.collapse-target {
Expand Down
34 changes: 17 additions & 17 deletions hawtio-web/src/main/webapp/index.html
Expand Up @@ -50,23 +50,6 @@
}
</style>

<div class="ng-cloak">
<div modal="confirmLogout">

<form class="form-horizontal no-bottom-margin" ng-submit="doLogout()">
<div class="modal-header"></div>
<div class="modal-body">
<p>Are you sure you want to log out?</p>
</div>
<div class="modal-footer">
<input class="btn btn-success" type="submit" value="Yes">
<input class="btn btn-primary" ng-click="confirmLogout = false" value="No">
</div>
</form>

</div>
</div>

<!-- navbar-inverse -->
<div id="main-nav" class="navbar navbar-fixed-top" ng-show="!fullScreen()" ng-controller="Core.NavBarController">
<div class="navbar-inner" ng-cloak class="ng-cloak">
Expand Down Expand Up @@ -134,6 +117,23 @@
</div>
</div>

<div class="ng-cloak">
<div modal="confirmLogout">

<form class="form-horizontal no-bottom-margin" ng-submit="doLogout()">
<div class="modal-header"></div>
<div class="modal-body">
<p>Are you sure you want to log out?</p>
</div>
<div class="modal-footer">
<input class="btn btn-success" type="submit" value="Yes">
<input class="btn btn-primary" ng-click="confirmLogout = false" value="No">
</div>
</form>

</div>
</div>

<!-- charts and jolokia for jmx -->
<script type="text/javascript" src="lib/d3.v3.min.js"></script>

Expand Down

0 comments on commit 5b85862

Please sign in to comment.