Skip to content

Commit

Permalink
fix favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
tonykoval committed Nov 17, 2016
1 parent d0c2fda commit 5f28095
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 46 deletions.
Binary file added public/img/black-favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/green-favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/red-favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/yellow-favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 11 additions & 23 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2071,15 +2071,17 @@ angular.module('cerebro').factory('ModalService', ['$sce', function($sce) {
angular.module('cerebro').factory('PageService', ['DataService', '$rootScope',
'$document', function(DataService, $rootScope, $document) {

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

if (link) {
var faviconUrl = link.href;
var img = $document[0].createElement('img');
img.src = faviconUrl;
}
var link = $document[0].querySelector('link[rel~=\'icon\']');

var colors = {
green: 'img/green-favicon.png',
yellow: 'img/yellow-favicon.png',
red: 'img/red-favicon.png',
black: 'img/black-favicon.png'
};

this.setup = function(newName, newStatus) {
setPageTitle(newName);
Expand All @@ -2101,23 +2103,9 @@ angular.module('cerebro').factory('PageService', ['DataService', '$rootScope',
var setFavIconColor = function(newClusterStatus) {
if (link) {
clusterStatus = newClusterStatus;
try {
var colors = {green: '#1AC98E', yellow: '#E4D836', red: '#E64759'};
var color = clusterStatus ? colors[clusterStatus] : '#222426';
var canvas = $document[0].createElement('canvas');
canvas.width = 32;
canvas.height = 34;
var context = canvas.getContext('2d');
context.drawImage(img, 0, 0);
context.globalCompositeOperation = 'source-in';
context.fillStyle = color;
context.fillRect(0, 0, 32, 34);
context.fill();
link.type = 'image/png';
link.href = canvas.toDataURL();
} catch (exception) {
//
}
var url = clusterStatus ? colors[clusterStatus] : colors.black;
link.type = 'image/png';
link.href = url;
}
};

Expand Down
34 changes: 11 additions & 23 deletions src/app/shared/services/page.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
angular.module('cerebro').factory('PageService', ['DataService', '$rootScope',
'$document', function(DataService, $rootScope, $document) {

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

if (link) {
var faviconUrl = link.href;
var img = $document[0].createElement('img');
img.src = faviconUrl;
}
var link = $document[0].querySelector('link[rel~=\'icon\']');

var colors = {
green: 'img/green-favicon.png',
yellow: 'img/yellow-favicon.png',
red: 'img/red-favicon.png',
black: 'img/black-favicon.png'
};

this.setup = function(newName, newStatus) {
setPageTitle(newName);
Expand All @@ -31,23 +33,9 @@ angular.module('cerebro').factory('PageService', ['DataService', '$rootScope',
var setFavIconColor = function(newClusterStatus) {
if (link) {
clusterStatus = newClusterStatus;
try {
var colors = {green: '#1AC98E', yellow: '#E4D836', red: '#E64759'};
var color = clusterStatus ? colors[clusterStatus] : '#222426';
var canvas = $document[0].createElement('canvas');
canvas.width = 32;
canvas.height = 34;
var context = canvas.getContext('2d');
context.drawImage(img, 0, 0);
context.globalCompositeOperation = 'source-in';
context.fillStyle = color;
context.fillRect(0, 0, 32, 34);
context.fill();
link.type = 'image/png';
link.href = canvas.toDataURL();
} catch (exception) {
//
}
var url = clusterStatus ? colors[clusterStatus] : colors.black;
link.type = 'image/png';
link.href = url;
}
};

Expand Down

0 comments on commit 5f28095

Please sign in to comment.