diff --git a/public/app/controllers/search.js b/public/app/controllers/search.js index 9083ef74705..1a88b25ef3f 100644 --- a/public/app/controllers/search.js +++ b/public/app/controllers/search.js @@ -123,32 +123,4 @@ function (angular, _, config) { }); - module.directive('tagColorFromName', function() { - - function djb2(str) { - var hash = 5381; - for (var i = 0; i < str.length; i++) { - hash = ((hash << 5) + hash) + str.charCodeAt(i); /* hash * 33 + c */ - } - return hash; - } - - return { - scope: { tag: "=" }, - link: function (scope, element) { - var name = scope.tag; - var hash = djb2(name.toLowerCase()); - var colors = [ - "#E24D42","#1F78C1","#BA43A9","#705DA0","#466803", - "#508642","#447EBC","#C15C17","#890F02","#757575", - "#0A437C","#6D1F62","#584477","#629E51","#2F4F4F", - "#BF1B00","#806EB7","#8a2eb8", "#699e00","#000000", - "#3F6833","#2F575E","#99440A","#E0752D","#0E4AB4", - "#58140C","#052B51","#511749","#3F2B5B", - ]; - var color = colors[Math.abs(hash % colors.length)]; - element.css("background-color", color); - } - }; - }); }); diff --git a/public/app/directives/tip.js b/public/app/directives/tip.js index 8553faad279..a58adce981d 100644 --- a/public/app/directives/tip.js +++ b/public/app/directives/tip.js @@ -78,4 +78,43 @@ function (angular, kbn) { }; }); -}); + angular + .module('grafana.directives') + .directive('tagColorFromName', function() { + + function djb2(str) { + var hash = 5381; + for (var i = 0; i < str.length; i++) { + hash = ((hash << 5) + hash) + str.charCodeAt(i); /* hash * 33 + c */ + } + return hash; + } + + return { + scope: { tagColorFromName: "=" }, + link: function (scope, element) { + var hash = djb2(scope.tagColorFromName.toLowerCase()); + var colors = [ + "#E24D42","#1F78C1","#BA43A9","#705DA0","#466803", + "#508642","#447EBC","#C15C17","#890F02","#757575", + "#0A437C","#6D1F62","#584477","#629E51","#2F4F4F", + "#BF1B00","#806EB7","#8a2eb8", "#699e00","#000000", + "#3F6833","#2F575E","#99440A","#E0752D","#0E4AB4", + "#58140C","#052B51","#511749","#3F2B5B", + ]; + var borderColors = [ + "#FF7368","#459EE7","#E069CF","#9683C6","#6C8E29", + "#76AC68","#6AA4E2","#E7823D","#AF3528","#9B9B9B", + "#3069A2","#934588","#7E6A9D","#88C477","#557575", + "#E54126","#A694DD","#B054DE", "#8FC426","#262626", + "#658E59","#557D84","#BF6A30","#FF9B53","#3470DA", + "#7E3A32","#2B5177","#773D6F","#655181", + ]; + var color = colors[Math.abs(hash % colors.length)]; + var borderColor = borderColors[Math.abs(hash % borderColors.length)]; + + element.css("background-color", color); + element.css("border-color", borderColor); + } + }; + });}); diff --git a/public/app/features/dashboard/partials/variableValueSelect.html b/public/app/features/dashboard/partials/variableValueSelect.html index 30a61072626..c055c1151ae 100644 --- a/public/app/features/dashboard/partials/variableValueSelect.html +++ b/public/app/features/dashboard/partials/variableValueSelect.html @@ -15,12 +15,21 @@ -
diff --git a/public/app/features/templating/editorCtrl.js b/public/app/features/templating/editorCtrl.js index f48452e4569..1363a774ef5 100644 --- a/public/app/features/templating/editorCtrl.js +++ b/public/app/features/templating/editorCtrl.js @@ -82,6 +82,14 @@ function (angular, _) { }; $scope.update = function() { + $scope.current.tags = { + "Europe": ["backend_03", "backend_04"], + "USA": ["backend_01", "backend_02"], + "Asia": ["backend_01"], + "South America": ["backend_02"], + "Africa": ["backend_03"], + }; + if ($scope.isValid()) { $scope.runQuery().then(function() { $scope.reset(); diff --git a/public/app/partials/search.html b/public/app/partials/search.html index 66e5fd3b7f4..18754010f0d 100644 --- a/public/app/partials/search.html +++ b/public/app/partials/search.html @@ -46,7 +46,7 @@ ng-class="{'selected': $index == selectedIndex}" ng-href="{{row.url}}">