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
cf68725c
Commit
cf68725c
authored
Jul 18, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
influxdb annotation column mapping is working
parent
cf2ef095
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
32 deletions
+77
-32
src/app/partials/influxdb/annotation_editor.html
+24
-2
src/app/services/annotationsSrv.js
+2
-2
src/app/services/influxdb/influxSeries.js
+14
-14
src/test/specs/influxSeries-specs.js
+37
-14
No files found.
src/app/partials/influxdb/annotation_editor.html
View file @
cf68725c
<div
class=
"editor-row"
>
<div
class=
"editor-row"
>
<div
class=
"section"
>
<h5>
InfluxDB Query
<tip>
Example: select text from events where [[timeFilter]]
</tip></h5>
<div
class=
"editor-option"
>
<div
class=
"editor-option"
>
<label
class=
"small"
>
InfluxDB query
</label>
<input
type=
"text"
class=
"span10"
ng-model=
'currentAnnotation.query'
placeholder=
"select text from events where [[timeFilter]]"
></input>
<input
type=
"text"
class=
"span10"
ng-model=
'currentAnnotation.query'
placeholder=
""
></input>
</div>
</div>
</div>
<div
class=
"editor-row"
>
<div
class=
"section"
>
<h5>
Column mappings
<tip>
If your influxdb query returns more than one column you need to specify the column names bellow. An annotation event is composed of a title, tags, and an additional text field.
</tip></h5>
<div
class=
"editor-option"
>
<label
class=
"small"
>
Title
</label>
<input
type=
"text"
class=
"input-small"
ng-model=
'currentAnnotation.titleColumn'
placeholder=
""
></input>
</div>
<div
class=
"editor-option"
>
<label
class=
"small"
>
Tags
</label>
<input
type=
"text"
class=
"input-small"
ng-model=
'currentAnnotation.tagsColumn'
placeholder=
""
></input>
</div>
<div
class=
"editor-option"
>
<label
class=
"small"
>
Text
</label>
<input
type=
"text"
class=
"input-small"
ng-model=
'currentAnnotation.textColumn'
placeholder=
""
></input>
</div>
</div>
</div>
</div>
</div>
src/app/services/annotationsSrv.js
View file @
cf68725c
...
@@ -142,8 +142,8 @@ define([
...
@@ -142,8 +142,8 @@ define([
tooltip
+=
'<i>'
+
moment
(
options
.
time
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
+
'</i><br/>'
;
tooltip
+=
'<i>'
+
moment
(
options
.
time
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
+
'</i><br/>'
;
if
(
options
.
data
)
{
if
(
options
.
text
)
{
tooltip
+=
options
.
data
.
replace
(
/
\n
/g
,
'<br/>'
);
tooltip
+=
options
.
text
.
replace
(
/
\n
/g
,
'<br/>'
);
}
}
tooltip
+=
"</small>"
;
tooltip
+=
"</small>"
;
...
...
src/app/services/influxdb/influxSeries.js
View file @
cf68725c
...
@@ -71,27 +71,27 @@ function (_) {
...
@@ -71,27 +71,27 @@ function (_) {
var
self
=
this
;
var
self
=
this
;
_
.
each
(
this
.
seriesList
,
function
(
series
)
{
_
.
each
(
this
.
seriesList
,
function
(
series
)
{
var
titleCol
=
0
;
var
titleCol
=
null
;
var
tagsCol
=
0
;
var
timeCol
=
null
;
var
tagsCol
=
null
;
var
textCol
=
null
;
_
.
each
(
series
.
columns
,
function
(
column
,
index
)
{
_
.
each
(
series
.
columns
,
function
(
column
,
index
)
{
if
(
column
===
'time'
||
column
===
'sequence_number'
)
{
if
(
column
===
'time'
)
{
timeCol
=
index
;
return
;
}
return
;
if
(
column
===
'sequence_number'
)
{
return
;
}
}
if
(
!
titleCol
)
{
titleCol
=
index
;
}
if
(
column
===
self
.
annotation
.
titleColumn
)
{
titleCol
=
index
;
return
;
}
if
(
!
titleCol
&&
column
!==
'tags'
)
{
if
(
column
===
self
.
annotation
.
tagsColumn
)
{
tagsCol
=
index
;
return
;
}
titleCol
=
index
;
if
(
column
===
self
.
annotation
.
textColumn
)
{
textCol
=
index
;
return
;
}
}
else
{
tagsCol
=
index
;
}
});
});
_
.
each
(
series
.
points
,
function
(
point
)
{
_
.
each
(
series
.
points
,
function
(
point
)
{
var
data
=
{
var
data
=
{
annotation
:
self
.
annotation
,
annotation
:
self
.
annotation
,
time
:
point
[
0
]
*
1000
,
time
:
point
[
timeCol
]
*
1000
,
title
:
point
[
titleCol
]
title
:
point
[
titleCol
],
tags
:
point
[
tagsCol
],
text
:
point
[
textCol
]
};
};
if
(
tagsCol
)
{
if
(
tagsCol
)
{
...
...
src/test/specs/influxSeries-specs.js
View file @
cf68725c
...
@@ -140,33 +140,56 @@ define([
...
@@ -140,33 +140,56 @@ define([
});
});
describe
(
"when creating annotations from influxdb response"
,
function
()
{
describe
(
"when creating annotations from influxdb response"
,
function
()
{
describe
(
'given
two serie
s'
,
function
()
{
describe
(
'given
column mapping for all column
s'
,
function
()
{
var
series
=
new
InfluxSeries
({
var
series
=
new
InfluxSeries
({
seriesList
:
[
seriesList
:
[
{
{
columns
:
[
'time'
,
'text'
,
'sequence_number'
],
columns
:
[
'time'
,
'text'
,
'sequence_number'
,
'title'
,
'tags'
],
name
:
'events1'
,
name
:
'events1'
,
points
:
[[
1402596000
,
'some text'
,
1
],
[
1402596001
,
'asd'
,
2
]]
points
:
[[
1402596000
,
'some text'
,
1
,
'Hello'
,
'B'
],
[
1402596001
,
'asd'
,
2
,
'Hello2'
,
'B'
]]
},
{
columns
:
[
'time'
,
'tags'
,
'text'
],
name
:
'events2'
,
points
:
[[
1402596000
,
'tag1, tag2'
,
'mu'
]]
}
}
],
],
annotation
:
{
query
:
'select'
}
annotation
:
{
query
:
'select'
,
titleColumn
:
'title'
,
tagsColumn
:
'tags'
,
textColumn
:
'text'
,
}
});
});
var
result
=
series
.
getAnnotations
();
var
result
=
series
.
getAnnotations
();
it
(
' should generate
4
annnotations '
,
function
()
{
it
(
' should generate
2
annnotations '
,
function
()
{
expect
(
result
.
length
).
to
.
be
(
3
);
expect
(
result
.
length
).
to
.
be
(
2
);
expect
(
result
[
0
].
annotation
.
query
).
to
.
be
(
'select'
);
expect
(
result
[
0
].
annotation
.
query
).
to
.
be
(
'select'
);
expect
(
result
[
0
].
title
).
to
.
be
(
'Hello'
);
expect
(
result
[
0
].
time
).
to
.
be
(
1402596000000
);
expect
(
result
[
0
].
tags
).
to
.
be
(
'B'
);
expect
(
result
[
0
].
text
).
to
.
be
(
'some text'
);
});
});
describe
(
'given no column mapping'
,
function
()
{
var
series
=
new
InfluxSeries
({
seriesList
:
[
{
columns
:
[
'time'
,
'text'
,
'sequence_number'
],
name
:
'events1'
,
points
:
[[
1402596000
,
'some text'
,
1
]]
}
],
annotation
:
{
query
:
'select'
}
});
var
result
=
series
.
getAnnotations
();
it
(
'should generate 1 annnotation'
,
function
()
{
expect
(
result
.
length
).
to
.
be
(
1
);
expect
(
result
[
0
].
title
).
to
.
be
(
'some text'
);
expect
(
result
[
0
].
title
).
to
.
be
(
'some text'
);
expect
(
result
[
0
].
time
).
to
.
be
(
1402596000000
);
expect
(
result
[
0
].
time
).
to
.
be
(
1402596000000
);
expect
(
result
[
1
].
title
).
to
.
be
(
'asd'
);
expect
(
result
[
0
].
tags
).
to
.
be
(
undefined
);
//expect(result[2].tags).to.be('tag1, tag2');
expect
(
result
[
0
].
text
).
to
.
be
(
undefined
);
//expect(result[2].title).to.be('mu');
});
});
});
});
...
...
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