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
9e72588c
Commit
9e72588c
authored
Oct 02, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip: began work on support for testdata tables & annotations support
parent
19354978
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
13 deletions
+72
-13
pkg/tsdb/testdata/scenarios.go
+27
-0
public/app/plugins/datasource/testdata/datasource.ts
+44
-12
public/app/plugins/datasource/testdata/module.ts
+1
-1
No files found.
pkg/tsdb/testdata/scenarios.go
View file @
9e72588c
...
@@ -221,6 +221,33 @@ func init() {
...
@@ -221,6 +221,33 @@ func init() {
return
queryRes
return
queryRes
},
},
})
})
registerScenario
(
&
Scenario
{
Id
:
"annotations"
,
Name
:
"Annotations"
,
Handler
:
func
(
query
*
tsdb
.
Query
,
tsdbQuery
*
tsdb
.
TsdbQuery
)
*
tsdb
.
QueryResult
{
timeWalkerMs
:=
tsdbQuery
.
TimeRange
.
GetFromAsMsEpoch
()
to
:=
tsdbQuery
.
TimeRange
.
GetToAsMsEpoch
()
table
:=
tsdb
.
Table
{
Columns
:
[]
tsdb
.
TableColumn
{
{
Text
:
"time"
},
{
Text
:
"message"
},
},
Rows
:
[]
tsdb
.
RowValues
{},
}
for
i
:=
int64
(
0
);
i
<
10
&&
timeWalkerMs
<
to
;
i
++
{
table
.
Rows
=
append
(
table
.
Rows
,
tsdb
.
RowValues
{
float64
(
timeWalkerMs
),
"hello"
})
timeWalkerMs
+=
query
.
IntervalMs
}
queryRes
:=
tsdb
.
NewQueryResult
()
queryRes
.
Tables
=
append
(
queryRes
.
Tables
,
&
table
)
return
queryRes
},
})
}
}
func
registerScenario
(
scenario
*
Scenario
)
{
func
registerScenario
(
scenario
*
Scenario
)
{
...
...
public/app/plugins/datasource/testdata/datasource.ts
View file @
9e72588c
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
TableModel
from
'app/core/table_model'
;
class
TestDataDatasource
{
class
TestDataDatasource
{
id
:
any
;
id
:
any
;
...
@@ -29,16 +30,29 @@ class TestDataDatasource {
...
@@ -29,16 +30,29 @@ class TestDataDatasource {
}
}
return
this
.
backendSrv
return
this
.
backendSrv
.
post
(
'/api/tsdb/query'
,
{
.
datasourceRequest
({
from
:
options
.
range
.
from
.
valueOf
().
toString
(),
method
:
'POST'
,
to
:
options
.
range
.
to
.
valueOf
().
toString
(),
url
:
'/api/tsdb/query'
,
queries
:
queries
,
data
:
{
from
:
options
.
range
.
from
.
valueOf
().
toString
(),
to
:
options
.
range
.
to
.
valueOf
().
toString
(),
queries
:
queries
,
},
})
})
.
then
(
res
=>
{
.
then
(
res
=>
{
const
data
=
[];
const
data
=
[];
if
(
res
.
results
)
{
if
(
res
.
data
.
results
)
{
_
.
forEach
(
res
.
results
,
queryRes
=>
{
_
.
forEach
(
res
.
data
.
results
,
queryRes
=>
{
if
(
queryRes
.
tables
)
{
for
(
const
table
of
queryRes
.
tables
)
{
const
model
=
new
TableModel
();
model
.
rows
=
table
.
rows
;
model
.
columns
=
table
.
columns
;
data
.
push
(
model
);
}
}
for
(
const
series
of
queryRes
.
series
)
{
for
(
const
series
of
queryRes
.
series
)
{
data
.
push
({
data
.
push
({
target
:
series
.
name
,
target
:
series
.
name
,
...
@@ -48,17 +62,35 @@ class TestDataDatasource {
...
@@ -48,17 +62,35 @@ class TestDataDatasource {
});
});
}
}
console
.
log
(
res
);
return
{
data
:
data
};
return
{
data
:
data
};
});
});
}
}
annotationQuery
(
options
)
{
annotationQuery
(
options
)
{
return
this
.
backendSrv
.
get
(
'/api/annotations'
,
{
return
this
.
backendSrv
from
:
options
.
range
.
from
.
valueOf
(),
.
datasourceRequest
({
to
:
options
.
range
.
to
.
valueOf
(),
method
:
'POST'
,
limit
:
options
.
limit
,
url
:
'/api/tsdb/query'
,
type
:
options
.
type
,
data
:
{
});
from
:
options
.
range
.
from
.
valueOf
().
toString
(),
to
:
options
.
range
.
to
.
valueOf
().
toString
(),
queries
:
[
{
refId
:
'A'
,
scenarioId
:
'annotations'
,
intervalMs
:
100
,
maxDataPoints
:
100
,
stringInput
:
''
,
datasourceId
:
this
.
id
,
},
],
},
})
.
then
(
resp
=>
{
console
.
log
(
resp
);
return
[];
});
}
}
}
}
...
...
public/app/plugins/datasource/testdata/module.ts
View file @
9e72588c
...
@@ -6,7 +6,7 @@ class TestDataAnnotationsQueryCtrl {
...
@@ -6,7 +6,7 @@ class TestDataAnnotationsQueryCtrl {
constructor
()
{}
constructor
()
{}
static
template
=
'<h2>
test data
</h2>'
;
static
template
=
'<h2>
Annotation scenario
</h2>'
;
}
}
export
{
export
{
...
...
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