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
4a71a79c
Commit
4a71a79c
authored
May 27, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slight refactoring in annotationSrv
parent
99556057
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
20 deletions
+14
-20
public/app/features/annotations/annotationsSrv.js
+14
-20
No files found.
public/app/features/annotations/annotationsSrv.js
View file @
4a71a79c
define
([
'angular'
,
'lodash'
,
'moment'
,
'./editorCtrl'
],
function
(
angular
,
_
,
moment
)
{
],
function
(
angular
,
_
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.services'
);
...
...
@@ -11,7 +10,6 @@ define([
module
.
service
(
'annotationsSrv'
,
function
(
datasourceSrv
,
$q
,
alertSrv
,
$rootScope
,
$sanitize
)
{
var
promiseCached
;
var
list
=
[];
var
timezone
;
var
self
=
this
;
this
.
init
=
function
()
{
...
...
@@ -33,7 +31,7 @@ define([
return
promiseCached
;
}
timezone
=
dashboard
.
timezone
;
self
.
dashboard
=
dashboard
;
var
annotations
=
_
.
where
(
dashboard
.
annotations
.
list
,
{
enable
:
true
});
var
promises
=
_
.
map
(
annotations
,
function
(
annotation
)
{
...
...
@@ -54,31 +52,21 @@ define([
this
.
receiveAnnotationResults
=
function
(
results
)
{
for
(
var
i
=
0
;
i
<
results
.
length
;
i
++
)
{
addAnnotation
(
results
[
i
]);
self
.
addAnnotation
(
results
[
i
]);
}
};
function
errorHandler
(
err
)
{
console
.
log
(
'Annotation error: '
,
err
);
var
message
=
err
.
message
||
"Annotation query failed"
;
alertSrv
.
set
(
'Annotations error'
,
message
,
'error'
);
}
function
addAnnotation
(
options
)
{
this
.
addAnnotation
=
function
(
options
)
{
var
title
=
$sanitize
(
options
.
title
);
var
tooltip
=
"<small><b>"
+
title
+
"</b><br/>"
;
var
time
=
'<i>'
+
self
.
dashboard
.
formatDate
(
options
.
time
)
+
'</i>'
;
var
tooltip
=
'<div class="graph-tooltip small"><div class="graph-tooltip-time">'
+
title
+
' '
+
time
+
'</div> '
;
if
(
options
.
tags
)
{
var
tags
=
$sanitize
(
options
.
tags
);
tooltip
+=
'<span class="tag label label-tag">'
+
(
tags
||
''
)
+
'</span><br/>'
;
}
if
(
timezone
===
'browser'
)
{
tooltip
+=
'<i>'
+
moment
(
options
.
time
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
+
'</i><br/>'
;
}
else
{
tooltip
+=
'<i>'
+
moment
.
utc
(
options
.
time
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
+
'</i><br/>'
;
}
if
(
options
.
text
)
{
var
text
=
$sanitize
(
options
.
text
);
tooltip
+=
text
.
replace
(
/
\n
/g
,
'<br/>'
);
...
...
@@ -95,6 +83,12 @@ define([
description
:
tooltip
,
score
:
1
});
};
function
errorHandler
(
err
)
{
console
.
log
(
'Annotation error: '
,
err
);
var
message
=
err
.
message
||
"Annotation query failed"
;
alertSrv
.
set
(
'Annotations error'
,
message
,
'error'
);
}
// Now init
...
...
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