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
9818f81c
Commit
9818f81c
authored
Feb 07, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Completed search makover
parent
8f4e4401
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
33 deletions
+37
-33
pkg/api/search.go
+7
-11
src/app/controllers/search.js
+9
-9
src/app/partials/search.html
+18
-6
src/css/less/search.less
+3
-7
No files found.
pkg/api/search.go
View file @
9818f81c
package
api
package
api
import
(
import
(
"regexp"
"strings"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/middleware"
"github.com/grafana/grafana/pkg/middleware"
m
"github.com/grafana/grafana/pkg/models"
m
"github.com/grafana/grafana/pkg/models"
...
@@ -31,7 +28,9 @@ func setIsStarredFlagOnSearchResults(c *middleware.Context, hits []*m.DashboardS
...
@@ -31,7 +28,9 @@ func setIsStarredFlagOnSearchResults(c *middleware.Context, hits []*m.DashboardS
}
}
func
Search
(
c
*
middleware
.
Context
)
{
func
Search
(
c
*
middleware
.
Context
)
{
queryText
:=
c
.
Query
(
"q"
)
query
:=
c
.
Query
(
"query"
)
tag
:=
c
.
Query
(
"tag"
)
tagcloud
:=
c
.
Query
(
"tagcloud"
)
starred
:=
c
.
Query
(
"starred"
)
starred
:=
c
.
Query
(
"starred"
)
limit
:=
c
.
QueryInt
(
"limit"
)
limit
:=
c
.
QueryInt
(
"limit"
)
...
@@ -44,7 +43,7 @@ func Search(c *middleware.Context) {
...
@@ -44,7 +43,7 @@ func Search(c *middleware.Context) {
Tags
:
[]
*
m
.
DashboardTagCloudItem
{},
Tags
:
[]
*
m
.
DashboardTagCloudItem
{},
}
}
if
strings
.
HasPrefix
(
queryText
,
"tags!:"
)
{
if
tagcloud
==
"true"
{
query
:=
m
.
GetDashboardTagsQuery
{
AccountId
:
c
.
AccountId
}
query
:=
m
.
GetDashboardTagsQuery
{
AccountId
:
c
.
AccountId
}
err
:=
bus
.
Dispatch
(
&
query
)
err
:=
bus
.
Dispatch
(
&
query
)
...
@@ -56,15 +55,12 @@ func Search(c *middleware.Context) {
...
@@ -56,15 +55,12 @@ func Search(c *middleware.Context) {
result
.
TagsOnly
=
true
result
.
TagsOnly
=
true
}
else
{
}
else
{
searchQueryRegEx
,
_
:=
regexp
.
Compile
(
`(tags:(\w*)\sAND\s)?(?:title:)?(.*)?`
)
matches
:=
searchQueryRegEx
.
FindStringSubmatch
(
queryText
)
query
:=
m
.
SearchDashboardsQuery
{
query
:=
m
.
SearchDashboardsQuery
{
Title
:
matches
[
3
]
,
Title
:
query
,
Tag
:
matches
[
2
]
,
Tag
:
tag
,
UserId
:
c
.
UserId
,
UserId
:
c
.
UserId
,
Limit
:
limit
,
Limit
:
limit
,
IsStarred
:
starred
==
"
1
"
,
IsStarred
:
starred
==
"
true
"
,
AccountId
:
c
.
AccountId
,
AccountId
:
c
.
AccountId
,
}
}
...
...
src/app/controllers/search.js
View file @
9818f81c
...
@@ -41,7 +41,7 @@ function (angular, _, config, $) {
...
@@ -41,7 +41,7 @@ function (angular, _, config, $) {
$scope
.
moveSelection
(
-
1
);
$scope
.
moveSelection
(
-
1
);
}
}
if
(
evt
.
keyCode
===
13
)
{
if
(
evt
.
keyCode
===
13
)
{
if
(
$scope
.
tagsOnly
)
{
if
(
$scope
.
query
.
tagcloud
)
{
var
tag
=
$scope
.
results
.
tags
[
$scope
.
selectedIndex
];
var
tag
=
$scope
.
results
.
tags
[
$scope
.
selectedIndex
];
if
(
tag
)
{
if
(
tag
)
{
$scope
.
filterByTag
(
tag
.
term
);
$scope
.
filterByTag
(
tag
.
term
);
...
@@ -77,7 +77,6 @@ function (angular, _, config, $) {
...
@@ -77,7 +77,6 @@ function (angular, _, config, $) {
.
then
(
function
(
results
)
{
.
then
(
function
(
results
)
{
if
(
localSearchId
<
$scope
.
currentSearchId
)
{
return
;
}
if
(
localSearchId
<
$scope
.
currentSearchId
)
{
return
;
}
$scope
.
tagsOnly
=
results
.
tagsOnly
;
$scope
.
results
.
dashboards
=
results
.
dashboards
;
$scope
.
results
.
dashboards
=
results
.
dashboards
;
$scope
.
results
.
tags
=
results
.
tags
;
$scope
.
results
.
tags
=
results
.
tags
;
$scope
.
resultCount
=
results
.
tagsOnly
?
results
.
tags
.
length
:
results
.
dashboards
.
length
;
$scope
.
resultCount
=
results
.
tagsOnly
?
results
.
tags
.
length
:
results
.
dashboards
.
length
;
...
@@ -85,7 +84,8 @@ function (angular, _, config, $) {
...
@@ -85,7 +84,8 @@ function (angular, _, config, $) {
};
};
$scope
.
filterByTag
=
function
(
tag
,
evt
)
{
$scope
.
filterByTag
=
function
(
tag
,
evt
)
{
$scope
.
query
.
query
=
"tags:"
+
tag
+
" AND title:"
;
$scope
.
query
.
tag
=
tag
;
$scope
.
query
.
tagcloud
=
false
;
$scope
.
search
();
$scope
.
search
();
$scope
.
giveSearchFocus
=
$scope
.
giveSearchFocus
+
1
;
$scope
.
giveSearchFocus
=
$scope
.
giveSearchFocus
+
1
;
if
(
evt
)
{
if
(
evt
)
{
...
@@ -95,8 +95,7 @@ function (angular, _, config, $) {
...
@@ -95,8 +95,7 @@ function (angular, _, config, $) {
};
};
$scope
.
showTags
=
function
()
{
$scope
.
showTags
=
function
()
{
$scope
.
tagsOnly
=
!
$scope
.
tagsOnly
;
$scope
.
query
.
tagcloud
=
!
$scope
.
query
.
tagcloud
;
$scope
.
query
.
query
=
$scope
.
tagsOnly
?
"tags!:"
:
""
;
$scope
.
giveSearchFocus
=
$scope
.
giveSearchFocus
+
1
;
$scope
.
giveSearchFocus
=
$scope
.
giveSearchFocus
+
1
;
$scope
.
search
();
$scope
.
search
();
};
};
...
@@ -178,8 +177,10 @@ function (angular, _, config, $) {
...
@@ -178,8 +177,10 @@ function (angular, _, config, $) {
return
hash
;
return
hash
;
}
}
return
function
(
scope
,
element
)
{
return
{
var
name
=
_
.
isString
(
scope
.
tag
)
?
scope
.
tag
:
scope
.
tag
.
term
;
scope
:
{
tag
:
"="
},
link
:
function
(
scope
,
element
)
{
var
name
=
scope
.
tag
;
var
hash
=
djb2
(
name
.
toLowerCase
());
var
hash
=
djb2
(
name
.
toLowerCase
());
var
colors
=
[
var
colors
=
[
"#E24D42"
,
"#1F78C1"
,
"#BA43A9"
,
"#705DA0"
,
"#466803"
,
"#E24D42"
,
"#1F78C1"
,
"#BA43A9"
,
"#705DA0"
,
"#466803"
,
...
@@ -191,8 +192,7 @@ function (angular, _, config, $) {
...
@@ -191,8 +192,7 @@ function (angular, _, config, $) {
];
];
var
color
=
colors
[
Math
.
abs
(
hash
%
colors
.
length
)];
var
color
=
colors
[
Math
.
abs
(
hash
%
colors
.
length
)];
element
.
css
(
"background-color"
,
color
);
element
.
css
(
"background-color"
,
color
);
}
};
};
});
});
});
});
src/app/partials/search.html
View file @
9818f81c
...
@@ -7,19 +7,31 @@
...
@@ -7,19 +7,31 @@
</span>
</span>
<div
class=
"search-switches"
>
<div
class=
"search-switches"
>
<i
class=
"fa fa-filter"
></i>
<i
class=
"fa fa-filter"
></i>
<a
href=
"javascript:void(0);"
ng-class=
"{'active': tagsOnly}"
ng-click=
"showStarred()"
tabindex=
"2"
>
starred
</a>
|
<a
class=
"pointer"
ng-click=
"showStarred()"
tabindex=
"2"
>
<a
href=
"javascript:void(0);"
ng-class=
"{'active': tagsOnly}"
ng-click=
"showTags()"
tabindex=
"3"
>
tags
</a>
<i
class=
"fa fa-remove"
ng-show=
"query.starred"
></i>
starred
</a>
|
<a
class=
"pointer"
ng-click=
"showTags()"
tabindex=
"3"
>
<i
class=
"fa fa-remove"
ng-show=
"query.tagcloud"
></i>
tags
</a>
<span
ng-show=
"query.tag"
>
|
<a
ng-click=
"filterByTag('')"
tag-color-from-name
tag=
"query.tag"
class=
"label label-tag"
ng-if=
"query.tag"
>
<i
class=
"fa fa-remove"
></i>
{{query.tag}}
</a>
</span>
</div>
</div>
</div>
</div>
<div
ng-if=
"!showImport"
>
<div
ng-if=
"!showImport"
>
<div
class=
"search-results-container"
ng-if=
"
tagsOnly
"
>
<div
class=
"search-results-container"
ng-if=
"
query.tagcloud
"
>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"span6 offset1"
>
<div
class=
"span6 offset1"
>
<div
ng-repeat=
"tag in results.tags"
class=
"pointer"
style=
"width: 180px; float: left;"
<div
ng-repeat=
"tag in results.tags"
class=
"pointer"
style=
"width: 180px; float: left;"
ng-class=
"{'selected': $index === selectedIndex }"
ng-class=
"{'selected': $index === selectedIndex }"
ng-click=
"filterByTag(tag.term, $event)"
>
ng-click=
"filterByTag(tag.term, $event)"
>
<a
class=
"search-result-tag label label-tag"
tag-color-from-name
>
<a
class=
"search-result-tag label label-tag"
tag-color-from-name
tag=
"tag.term"
>
<i
class=
"fa fa-tag"
></i>
<i
class=
"fa fa-tag"
></i>
<span>
{{tag.term}}
({{tag.count}})
</span>
<span>
{{tag.term}}
({{tag.count}})
</span>
</a>
</a>
...
@@ -28,7 +40,7 @@
...
@@ -28,7 +40,7 @@
</div>
</div>
</div>
</div>
<div
class=
"search-results-container"
ng-if=
"!
tagsOnly
"
>
<div
class=
"search-results-container"
ng-if=
"!
query.tagcloud
"
>
<h6
ng-hide=
"results.dashboards.length"
>
No dashboards matching your query were found.
</h6>
<h6
ng-hide=
"results.dashboards.length"
>
No dashboards matching your query were found.
</h6>
<div
class=
"search-result-item pointer"
bindonce
ng-repeat=
"row in results.dashboards"
<div
class=
"search-result-item pointer"
bindonce
ng-repeat=
"row in results.dashboards"
...
@@ -41,7 +53,7 @@
...
@@ -41,7 +53,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"
tag-color-from-name
class=
"label label-tag"
>
<a
ng-click=
"filterByTag(tag, $event)"
ng-repeat=
"tag in row.tags"
tag-color-from-name
tag=
"tag"
class=
"label label-tag"
>
{{tag}}
{{tag}}
</a>
</a>
<i
class=
"fa"
ng-class=
"{'fa-star': row.isStarred, 'fa-star-o': !row.isStarred}"
></i>
<i
class=
"fa"
ng-class=
"{'fa-star': row.isStarred, 'fa-star-o': !row.isStarred}"
></i>
...
...
src/css/less/search.less
View file @
9818f81c
...
@@ -91,17 +91,13 @@
...
@@ -91,17 +91,13 @@
.search-switches {
.search-switches {
position: absolute;
position: absolute;
top: 19px;
top: 19px;
color: @textColor;
right: 21px;
right: 21px;
a {
color: @textColor;
&.active {
color: @linkColor;
}
}
}
}
.search-button-row {
.search-button-row {
padding-top: 20px;
padding-top: 20px;
button {
margin-right: 10px;
}
}
}
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