Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
5c0d1355
Commit
5c0d1355
authored
Aug 18, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Second take on dashboard tags search result colors
parent
a64604de
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
2 deletions
+34
-2
src/app/controllers/search.js
+26
-0
src/app/partials/search.html
+2
-2
src/css/less/grafana.less
+3
-0
src/css/less/overrides.less
+3
-0
No files found.
src/app/controllers/search.js
View file @
5c0d1355
...
@@ -9,6 +9,32 @@ function (angular, _, config, $) {
...
@@ -9,6 +9,32 @@ function (angular, _, config, $) {
var
module
=
angular
.
module
(
'grafana.controllers'
);
var
module
=
angular
.
module
(
'grafana.controllers'
);
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
;
}
module
.
directive
(
'tagColorFromName'
,
function
()
{
return
function
(
scope
,
element
)
{
var
name
=
_
.
isString
(
scope
.
tag
)
?
scope
.
tag
:
scope
.
tag
.
term
;
var
hash
=
djb2
(
name
.
toLowerCase
());
var
colors
=
[
"#E24D42"
,
"#1F78C1"
,
"#BA43A9"
,
"#705DA0"
,
"#508642"
,
"#447EBC"
,
"#C15C17"
,
"#890F02"
,
"#0A437C"
,
"#6D1F62"
,
"#584477"
,
"#629E51"
,
"#BF1B00"
,
"#EA6460"
,
"#D683CE"
,
"#806EB7"
,
"#3F6833"
,
"#2F575E"
,
"#99440A"
,
"#E0752D"
,
"#58140C"
,
"#052B51"
,
"#511749"
,
"#3F2B5B"
,
];
var
color
=
colors
[
Math
.
abs
(
hash
%
colors
.
length
)];
console
.
log
(
"namei "
+
name
+
" color: "
+
color
,
hash
%
4
);
element
.
css
(
"background-color"
,
color
);
};
});
module
.
controller
(
'SearchCtrl'
,
function
(
$scope
,
$rootScope
,
$element
,
$location
,
datasourceSrv
)
{
module
.
controller
(
'SearchCtrl'
,
function
(
$scope
,
$rootScope
,
$element
,
$location
,
datasourceSrv
)
{
$scope
.
init
=
function
()
{
$scope
.
init
=
function
()
{
...
...
src/app/partials/search.html
View file @
5c0d1355
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
ng-click=
"filterByTag(tag.term, $event)"
>
ng-click=
"filterByTag(tag.term, $event)"
>
<a
class=
"search-result-link"
>
<a
class=
"search-result-link"
>
<i
class=
"icon icon-tag"
></i>
<i
class=
"icon icon-tag"
></i>
<span
class=
"label label-tag"
>
{{tag.term}}
({{tag.count}})
</span>
<span
class=
"label label-tag"
tag-color-from-name
>
{{tag.term}}
({{tag.count}})
</span>
</a>
</a>
</div>
</div>
</div>
</div>
...
@@ -79,7 +79,7 @@
...
@@ -79,7 +79,7 @@
</div>
</div>
<div
class=
"search-result-tags"
>
<div
class=
"search-result-tags"
>
<a
ng-click=
"filterByTag(tag, $event)"
ng-repeat=
"tag in row.tags"
style=
"margin-right: 5px;"
class=
"label label-tag"
>
<a
ng-click=
"filterByTag(tag, $event)"
ng-repeat=
"tag in row.tags"
tag-color-from-name
class=
"label label-tag"
>
{{tag}}
{{tag}}
</a>
</a>
</div>
</div>
...
...
src/css/less/grafana.less
View file @
5c0d1355
...
@@ -86,6 +86,9 @@
...
@@ -86,6 +86,9 @@
.search-result-tags {
.search-result-tags {
float: right;
float: right;
.label {
margin-left: 6px;
}
}
}
.search-result-actions {
.search-result-actions {
...
...
src/css/less/overrides.less
View file @
5c0d1355
...
@@ -589,6 +589,9 @@ div.flot-text {
...
@@ -589,6 +589,9 @@ div.flot-text {
.label-tag {
.label-tag {
background-color: @purple;
background-color: @purple;
color: darken(@white, 5%);
color: darken(@white, 5%);
text-shadow: none;
font-size: 13px;
padding: 3px 6px;
}
}
.label-tag:hover {
.label-tag:hover {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment