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
b67f4dc3
Commit
b67f4dc3
authored
Feb 02, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added stars to search results
parent
1e3970c6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
46 deletions
+45
-46
src/app/controllers/search.js
+17
-28
src/app/features/dashboard/dashboardNavCtrl.js
+4
-4
src/app/features/grafanaDatasource/datasource.js
+1
-7
src/app/partials/search.html
+2
-4
src/app/services/userSrv.js
+11
-1
src/css/less/search.less
+10
-2
No files found.
src/app/controllers/search.js
View file @
b67f4dc3
...
...
@@ -18,6 +18,7 @@ function (angular, _, config, $) {
$scope
.
query
=
{
query
:
'title:'
};
$scope
.
db
=
datasourceSrv
.
getGrafanaDB
();
$scope
.
currentSearchId
=
0
;
$scope
.
starsPromise
=
$scope
.
grafana
.
user
.
getStars
();
// events
$scope
.
onAppEvent
(
'dashboard-deleted'
,
$scope
.
dashboardDeleted
);
...
...
@@ -64,38 +65,26 @@ function (angular, _, config, $) {
$scope
.
selectedIndex
=
Math
.
max
(
Math
.
min
(
$scope
.
selectedIndex
+
direction
,
$scope
.
resultCount
-
1
),
0
);
};
$scope
.
goToDashboard
=
function
(
id
)
{
$scope
.
goToDashboard
=
function
(
slug
)
{
$location
.
search
({});
$location
.
path
(
"/dashboard/db/"
+
id
);
};
$scope
.
shareDashboard
=
function
(
title
,
id
,
$event
)
{
$event
.
stopPropagation
();
var
baseUrl
=
window
.
location
.
href
.
replace
(
window
.
location
.
hash
,
''
);
$scope
.
share
=
{
title
:
title
,
url
:
baseUrl
+
'#dashboard/db/'
+
encodeURIComponent
(
id
)
};
$location
.
path
(
"/dashboard/db/"
+
slug
);
};
$scope
.
searchDashboards
=
function
(
queryString
)
{
// bookeeping for determining stale search requests
var
searchId
=
$scope
.
currentSearchId
+
1
;
$scope
.
currentSearchId
=
searchId
>
$scope
.
currentSearchId
?
searchId
:
$scope
.
currentSearchId
;
$scope
.
currentSearchId
=
$scope
.
currentSearchId
+
1
;
var
localSearchId
=
$scope
.
currentSearchId
;
return
$scope
.
db
.
searchDashboards
(
queryString
)
.
then
(
function
(
results
)
{
// since searches are async, it's possible that these results are not for the latest search. throw
// them away if so
if
(
searchId
<
$scope
.
currentSearchId
)
{
return
;
}
$scope
.
tagsOnly
=
results
.
tagsOnly
;
$scope
.
results
.
dashboards
=
results
.
dashboards
;
$scope
.
results
.
tags
=
results
.
tags
;
$scope
.
resultCount
=
results
.
tagsOnly
?
results
.
tags
.
length
:
results
.
dashboards
.
length
;
if
(
localSearchId
<
$scope
.
currentSearchId
)
{
return
;
}
$scope
.
starsPromise
.
then
(
function
(
stars
)
{
$scope
.
starredIds
=
stars
.
dashboardIds
;
$scope
.
tagsOnly
=
results
.
tagsOnly
;
$scope
.
results
.
dashboards
=
results
.
dashboards
;
$scope
.
results
.
tags
=
results
.
tags
;
$scope
.
resultCount
=
results
.
tagsOnly
?
results
.
tags
.
length
:
results
.
dashboards
.
length
;
});
});
};
...
...
@@ -125,11 +114,11 @@ function (angular, _, config, $) {
$scope
.
deleteDashboard
=
function
(
dash
,
evt
)
{
evt
.
stopPropagation
();
$scope
.
appEvent
(
'delete-dashboard'
,
{
id
:
dash
.
id
,
title
:
dash
.
title
});
$scope
.
appEvent
(
'delete-dashboard'
,
{
slug
:
dash
.
slug
,
title
:
dash
.
title
});
};
$scope
.
dashboardDeleted
=
function
(
evt
,
i
d
)
{
var
dash
=
_
.
findWhere
(
$scope
.
results
.
dashboards
,
{
id
:
id
});
$scope
.
dashboardDeleted
=
function
(
evt
,
payloa
d
)
{
var
dash
=
_
.
findWhere
(
$scope
.
results
.
dashboards
,
{
slug
:
payload
.
slug
});
$scope
.
results
.
dashboards
=
_
.
without
(
$scope
.
results
.
dashboards
,
dash
);
};
...
...
src/app/features/dashboard/dashboardNavCtrl.js
View file @
b67f4dc3
...
...
@@ -116,10 +116,10 @@ function (angular, _, moment, config, store) {
};
$scope
.
deleteDashboardConfirmed
=
function
(
options
)
{
var
id
=
options
.
id
;
$scope
.
db
.
deleteDashboard
(
id
).
then
(
function
(
id
)
{
$scope
.
appEvent
(
'dashboard-deleted'
,
id
);
$scope
.
appEvent
(
'alert-success'
,
[
'Dashboard Deleted'
,
id
+
' has been deleted'
]);
var
slug
=
options
.
slug
;
$scope
.
db
.
deleteDashboard
(
slug
).
then
(
function
(
)
{
$scope
.
appEvent
(
'dashboard-deleted'
,
options
);
$scope
.
appEvent
(
'alert-success'
,
[
'Dashboard Deleted'
,
options
.
title
+
' has been deleted'
]);
},
function
(
err
)
{
$scope
.
appEvent
(
'alert-error'
,
[
'Deleted failed'
,
err
]);
});
...
...
src/app/features/grafanaDatasource/datasource.js
View file @
b67f4dc3
...
...
@@ -61,18 +61,12 @@ function (angular, _, kbn) {
};
GrafanaDatasource
.
prototype
.
deleteDashboard
=
function
(
id
)
{
return
backendSrv
.
delete
(
'/api/dashboard/'
+
id
)
.
then
(
function
(
data
)
{
return
data
.
title
;
});
return
backendSrv
.
delete
(
'/api/dashboard/'
+
id
);
};
GrafanaDatasource
.
prototype
.
searchDashboards
=
function
(
query
)
{
return
backendSrv
.
get
(
'/api/search/'
,
{
q
:
query
})
.
then
(
function
(
data
)
{
_
.
each
(
data
.
dashboards
,
function
(
item
)
{
item
.
id
=
item
.
slug
;
});
return
data
;
});
};
...
...
src/app/partials/search.html
View file @
b67f4dc3
...
...
@@ -49,12 +49,9 @@
<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"
ng-class=
"{'selected': $index === selectedIndex }"
ng-click=
"goToDashboard(row.
id
)"
>
ng-class=
"{'selected': $index === selectedIndex }"
ng-click=
"goToDashboard(row.
slug
)"
>
<div
class=
"search-result-actions small"
>
<a
ng-click=
"shareDashboard(row.id, row.id, $event)"
config-modal=
"app/partials/dashLoaderShare.html"
>
<i
class=
"fa fa-share"
></i>
share
</a>
<a
ng-click=
"deleteDashboard(row, $event)"
>
<i
class=
"fa fa-remove"
></i>
delete
</a>
...
...
@@ -64,6 +61,7 @@
<a
ng-click=
"filterByTag(tag, $event)"
ng-repeat=
"tag in row.tags"
tag-color-from-name
class=
"label label-tag"
>
{{tag}}
</a>
<i
class=
"fa"
ng-class=
"{'fa-star': starredIds[row.id], 'fa-star-o': !starredIds[row.id]}"
></i>
</div>
<a
class=
"search-result-link"
>
...
...
src/app/services/userSrv.js
View file @
b67f4dc3
...
...
@@ -7,7 +7,7 @@ function (angular, _) {
var
module
=
angular
.
module
(
'grafana.services'
);
module
.
service
(
'userSrv'
,
function
()
{
module
.
service
(
'userSrv'
,
function
(
backendSrv
,
$q
)
{
function
User
()
{
if
(
window
.
grafanaBootData
.
user
)
{
...
...
@@ -15,6 +15,16 @@ function (angular, _) {
}
}
User
.
prototype
.
getStars
=
function
()
{
if
(
!
this
.
isSignedIn
)
{
return
$q
.
when
([]);
}
return
backendSrv
.
get
(
'/api/user/stars'
).
then
(
function
(
stars
)
{
return
stars
;
});
};
this
.
getSignedInUser
=
function
()
{
return
new
User
();
};
...
...
src/css/less/search.less
View file @
b67f4dc3
...
...
@@ -35,13 +35,21 @@
}
}
.fa-star, .fa-star-o {
padding-left: 13px;
}
.fa-star {
color: @orange;
}
.search-result-link {
color: @grafanaListMainLinkColor;
.fa {
.fa
-th-large
{
padding-right: 10px;
color: @grafanaListHighlightContrast;
}
}
}
.search-result-item:nth-child(odd) {
background-color: @grafanaListAccent;
...
...
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