Add support for time range

This commit adds the ability to configure the options in Time Range panel: time override, time shift and hide time override info.

Change-Id: I1d8c527ef1a377de6e34b94621f3060706356008
This commit is contained in:
Ye Na Rhee 2016-04-20 21:18:54 +02:00
parent a38798a292
commit 3b01b4df7d
6 changed files with 123 additions and 0 deletions

View File

@ -116,6 +116,7 @@ class Graph(Base):
graph = {
v.Required('bars', default=False): v.All(bool),
v.Required('fill', default=1): v.All(int),
v.Optional('hideTimeOverride'): v.All(bool),
v.Optional('leftYAxisLabel'): v.All(str, v.Length(min=1)),
v.Required('lines', default=True): v.All(bool),
v.Required('linewidth', default=2): v.All(int),
@ -129,6 +130,8 @@ class Graph(Base):
v.Required('stack', default=False): v.All(bool),
v.Required('steppedLine', default=False): v.All(bool),
v.Required('targets', default=[]): v.All(list),
v.Optional('timeFrom'): v.All(v.Match(r'[1-9]+[0-9]*[smhdw]')),
v.Optional('timeShift'): v.All(v.Match(r'[1-9]+[0-9]*[smhdw]')),
v.Optional('tooltip'): v.All(tooltip),
v.Required('x-axis', default=True): v.All(bool),
v.Required('y-axis', default=True): v.All(bool),

View File

@ -63,6 +63,9 @@ class Singlestat(Base):
v.Required('valueName', default='avg'): v.Any(
'avg', 'current', 'max', 'min', 'total'),
v.Optional('decimals'): v.All(int, v.Range(min=0, max=12)),
v.Optional('hideTimeOverride'): v.All(bool),
v.Optional('timeFrom'): v.All(v.Match(r'[1-9]+[0-9]*[smhdw]')),
v.Optional('timeShift'): v.All(v.Match(r'[1-9]+[0-9]*[smhdw]')),
}
singlestat.update(self.base)
return v.Schema(singlestat)

View File

@ -0,0 +1,50 @@
{
"dashboard": {
"new-dashboard": {
"rows": [
{
"collapse": false,
"editable": true,
"height": "250px",
"panels": [
{
"colorBackground": false,
"colorValue": false,
"editable": true,
"error": false,
"hideTimeOverride": true,
"maxDataPoints": 100,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"span": 12,
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false
},
"targets": [],
"thresholds": "",
"timeFrom": "10d",
"timeShift": "1h",
"title": "no title (click here)",
"type": "singlestat",
"valueFontSize": "80%",
"valueName": "avg"
}
],
"showTitle": false,
"title": "New row"
}
],
"templating": {
"enabled": false,
"list": []
},
"timezone": "utc",
"title": "New dashboard"
}
}
}

View File

@ -0,0 +1,11 @@
dashboard:
title: New dashboard
rows:
- title: New row
height: 250px
panels:
- title: no title (click here)
type: singlestat
timeFrom: 10d
timeShift: 1h
hideTimeOverride: true

View File

@ -0,0 +1,45 @@
{
"dashboard": {
"new-dashboard": {
"rows": [
{
"collapse": false,
"editable": true,
"height": "250px",
"panels": [
{
"bars": false,
"editable": true,
"error": false,
"fill": 1,
"hideTimeOverride": true,
"lines": true,
"linewidth": 2,
"percentage": false,
"pointradius": 5,
"points": false,
"span": 12,
"stack": false,
"steppedLine": false,
"targets": [],
"timeFrom": "10d",
"timeShift": "1h",
"title": "no title (click here)",
"type": "graph",
"x-axis": true,
"y-axis": true
}
],
"showTitle": false,
"title": "New row"
}
],
"templating": {
"enabled": false,
"list": []
},
"timezone": "utc",
"title": "New dashboard"
}
}
}

View File

@ -0,0 +1,11 @@
dashboard:
title: New dashboard
rows:
- title: New row
height: 250px
panels:
- title: no title (click here)
type: graph
timeFrom: 10d
timeShift: 1h
hideTimeOverride: true