Add panel type 'row'
Change-Id: I47ea73eab779fa311d22a930acdc33ac2a9230f8
This commit is contained in:
parent
2ff186cae7
commit
2ffded73e9
@ -17,6 +17,7 @@ import voluptuous as v
|
||||
from grafana_dashboards.schema.panel.base import Base
|
||||
from grafana_dashboards.schema.panel.dashlist import Dashlist
|
||||
from grafana_dashboards.schema.panel.graph import Graph
|
||||
from grafana_dashboards.schema.panel.row import Row
|
||||
from grafana_dashboards.schema.panel.singlestat import Singlestat
|
||||
from grafana_dashboards.schema.panel.text import Text
|
||||
|
||||
@ -42,6 +43,8 @@ class Panel(object):
|
||||
schema = Singlestat().get_schema()
|
||||
elif panel['type'] == 'text':
|
||||
schema = Text().get_schema()
|
||||
elif panel['type'] == 'row':
|
||||
schema = Row().get_schema()
|
||||
|
||||
res.append(schema(panel))
|
||||
|
||||
|
@ -41,7 +41,7 @@ class Base(object):
|
||||
v.Required('span', default=12): v.All(int, v.Range(min=0, max=12)),
|
||||
v.Required('title'): v.All(str, v.Length(min=1)),
|
||||
v.Required('type'): v.Any(
|
||||
'dashlist', 'graph', 'singlestat', 'text'),
|
||||
'dashlist', 'graph', 'singlestat', 'text', 'row'),
|
||||
v.Optional('id'): int,
|
||||
v.Optional('format'): v.Any(self.formats, v.Length(min=1)),
|
||||
v.Optional('transparent'): v.All(bool),
|
||||
|
28
grafana_dashboards/schema/panel/row.py
Normal file
28
grafana_dashboards/schema/panel/row.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Copyright 2018 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import voluptuous as v
|
||||
|
||||
from grafana_dashboards.schema.panel.base import Base
|
||||
|
||||
|
||||
class Row(Base):
|
||||
|
||||
def get_schema(self):
|
||||
row = {
|
||||
v.Required('collapsed'): v.All(bool),
|
||||
v.Optional('panels', default=[]): v.All([str])
|
||||
}
|
||||
row.update(self.base)
|
||||
return v.Schema(row)
|
36
tests/schema/fixtures/dashboard-0033.json
Normal file
36
tests/schema/fixtures/dashboard-0033.json
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"dashboard": {
|
||||
"new-dashboard": {
|
||||
"rows": [
|
||||
{
|
||||
"collapse": false,
|
||||
"editable": true,
|
||||
"height": "250px",
|
||||
"panels": [
|
||||
{
|
||||
"collapsed": false,
|
||||
"editable": true,
|
||||
"error": false,
|
||||
"panels": [],
|
||||
"span": 12,
|
||||
"title": "Main",
|
||||
"type": "row"
|
||||
}
|
||||
],
|
||||
"showTitle": false,
|
||||
"title": "New row"
|
||||
}
|
||||
],
|
||||
"templating": {
|
||||
"enabled": false,
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "2018-02-07T08:42:27.000Z",
|
||||
"to": "2018-02-07T13:48:32.000Z"
|
||||
},
|
||||
"timezone": "utc",
|
||||
"title": "New dashboard"
|
||||
}
|
||||
}
|
||||
}
|
12
tests/schema/fixtures/dashboard-0033.yaml
Normal file
12
tests/schema/fixtures/dashboard-0033.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
dashboard:
|
||||
time:
|
||||
from: "2018-02-07T08:42:27.000Z"
|
||||
to: "2018-02-07T13:48:32.000Z"
|
||||
title: New dashboard
|
||||
rows:
|
||||
- title: New row
|
||||
height: 250px
|
||||
panels:
|
||||
- collapsed: false
|
||||
title: Main
|
||||
type: row
|
Loading…
x
Reference in New Issue
Block a user