Skip to content

Commit

Permalink
add cluster status text to navbar and tab title
Browse files Browse the repository at this point in the history
  • Loading branch information
lmenezes committed Apr 14, 2018
1 parent a820e1c commit 6e3aa2e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 41 deletions.
32 changes: 12 additions & 20 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3008,9 +3008,6 @@ angular.module('cerebro').factory('ModalService', ['$sce', function($sce) {
angular.module('cerebro').factory('PageService', ['DataService', '$rootScope',
'$document', function(DataService, $rootScope, $document) {

var clusterName;
var clusterStatus;

var link = $document[0].querySelector('link[rel~=\'icon\']');

var colors = {
Expand All @@ -3020,35 +3017,30 @@ angular.module('cerebro').factory('PageService', ['DataService', '$rootScope',
black: 'img/black-favicon.png'
};

this.setup = function(newName, newStatus) {
setPageTitle(newName);
setFavIconColor(newStatus);
this.setup = function(name, status) {
setPageTitle(name, status);
setFavIconColor(status);
};

var setPageTitle = function(newClusterName) {
if (clusterName !== newClusterName) {
if (newClusterName) {
clusterName = newClusterName;
$rootScope.title = 'cerebro[' + clusterName + ']';
} else {
clusterName = undefined;
$rootScope.title = 'cerebro - no connection';
}
var setPageTitle = function(name, status) {
if (name) {
$rootScope.title = name + '[' + status + ']';
} else {
$rootScope.title = 'cerebro - no connection';
}
};

var setFavIconColor = function(newClusterStatus) {
var setFavIconColor = function(status) {
if (link) {
clusterStatus = newClusterStatus;
var url = clusterStatus ? colors[clusterStatus] : colors.black;
link.type = 'image/png';
link.href = url;
link.href = colors[status] || colors.black;
}
};

return this;

}]);
}
]);

angular.module('cerebro').factory('RefreshService',
function($rootScope, $timeout) {
Expand Down
2 changes: 1 addition & 1 deletion public/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
</li>
<li class="hidden-xs">
<a class="nav-item nav-link">
<span ng-show="host">{{host}}</span>
<span ng-show="host">{{host}} [{{status}}]</span>
</a>
</li>
<li>
Expand Down
32 changes: 12 additions & 20 deletions src/app/shared/services/page.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
angular.module('cerebro').factory('PageService', ['DataService', '$rootScope',
'$document', function(DataService, $rootScope, $document) {

var clusterName;
var clusterStatus;

var link = $document[0].querySelector('link[rel~=\'icon\']');

var colors = {
Expand All @@ -13,32 +10,27 @@ angular.module('cerebro').factory('PageService', ['DataService', '$rootScope',
black: 'img/black-favicon.png'
};

this.setup = function(newName, newStatus) {
setPageTitle(newName);
setFavIconColor(newStatus);
this.setup = function(name, status) {
setPageTitle(name, status);
setFavIconColor(status);
};

var setPageTitle = function(newClusterName) {
if (clusterName !== newClusterName) {
if (newClusterName) {
clusterName = newClusterName;
$rootScope.title = 'cerebro[' + clusterName + ']';
} else {
clusterName = undefined;
$rootScope.title = 'cerebro - no connection';
}
var setPageTitle = function(name, status) {
if (name) {
$rootScope.title = name + '[' + status + ']';
} else {
$rootScope.title = 'cerebro - no connection';
}
};

var setFavIconColor = function(newClusterStatus) {
var setFavIconColor = function(status) {
if (link) {
clusterStatus = newClusterStatus;
var url = clusterStatus ? colors[clusterStatus] : colors.black;
link.type = 'image/png';
link.href = url;
link.href = colors[status] || colors.black;
}
};

return this;

}]);
}
]);

0 comments on commit 6e3aa2e

Please sign in to comment.