Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

Commit fc29041

Browse files
Merge pull request #224 from DifferentialOrange/update-inputs
Add constant input option
2 parents 24ead6a + 685bce4 commit fc29041

File tree

3 files changed

+151
-4
lines changed

3 files changed

+151
-4
lines changed

grafonnet/dashboard.libsonnet

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,18 @@ local timepickerlib = import 'timepicker.libsonnet';
133133
name,
134134
label,
135135
type,
136-
pluginId,
137-
pluginName,
136+
pluginId=null,
137+
pluginName=null,
138138
description='',
139+
value=null,
139140
):: self {
140141
inputs+: [{
141142
name: name,
142143
label: label,
143144
type: type,
144-
pluginId: pluginId,
145-
pluginName: pluginName,
145+
[if pluginId != null then 'pluginId']: pluginId,
146+
[if pluginName != null then 'pluginName']: pluginName,
147+
[if value != null then 'value']: value,
146148
description: description,
147149
}],
148150
},

tests/dashboards/inputs.jsonnet

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
local grafana = import 'grafonnet/grafana.libsonnet';
2+
local dashboard = grafana.dashboard;
3+
4+
{
5+
constant: dashboard.new('constant').addInput(
6+
name='var',
7+
label='variable',
8+
type='constant',
9+
value='default_value',
10+
),
11+
datasource: dashboard.new('datasource').addInput(
12+
name='datasource',
13+
label='InfluxDB',
14+
type='datasource',
15+
description='InfluxDB datasource',
16+
pluginId='influxdb',
17+
pluginName='InfluxDB',
18+
),
19+
20+
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{
2+
"constant": {
3+
"__inputs": [
4+
{
5+
"description": "",
6+
"label": "variable",
7+
"name": "var",
8+
"type": "constant",
9+
"value": "default_value"
10+
}
11+
],
12+
"__requires": [ ],
13+
"annotations": {
14+
"list": [ ]
15+
},
16+
"editable": false,
17+
"gnetId": null,
18+
"graphTooltip": 0,
19+
"hideControls": false,
20+
"id": null,
21+
"links": [ ],
22+
"refresh": "",
23+
"rows": [ ],
24+
"schemaVersion": 14,
25+
"style": "dark",
26+
"tags": [ ],
27+
"templating": {
28+
"list": [ ]
29+
},
30+
"time": {
31+
"from": "now-6h",
32+
"to": "now"
33+
},
34+
"timepicker": {
35+
"refresh_intervals": [
36+
"5s",
37+
"10s",
38+
"30s",
39+
"1m",
40+
"5m",
41+
"15m",
42+
"30m",
43+
"1h",
44+
"2h",
45+
"1d"
46+
],
47+
"time_options": [
48+
"5m",
49+
"15m",
50+
"1h",
51+
"6h",
52+
"12h",
53+
"24h",
54+
"2d",
55+
"7d",
56+
"30d"
57+
]
58+
},
59+
"timezone": "browser",
60+
"title": "constant",
61+
"version": 0
62+
},
63+
"datasource": {
64+
"__inputs": [
65+
{
66+
"description": "InfluxDB datasource",
67+
"label": "InfluxDB",
68+
"name": "datasource",
69+
"pluginId": "influxdb",
70+
"pluginName": "InfluxDB",
71+
"type": "datasource"
72+
}
73+
],
74+
"__requires": [ ],
75+
"annotations": {
76+
"list": [ ]
77+
},
78+
"editable": false,
79+
"gnetId": null,
80+
"graphTooltip": 0,
81+
"hideControls": false,
82+
"id": null,
83+
"links": [ ],
84+
"refresh": "",
85+
"rows": [ ],
86+
"schemaVersion": 14,
87+
"style": "dark",
88+
"tags": [ ],
89+
"templating": {
90+
"list": [ ]
91+
},
92+
"time": {
93+
"from": "now-6h",
94+
"to": "now"
95+
},
96+
"timepicker": {
97+
"refresh_intervals": [
98+
"5s",
99+
"10s",
100+
"30s",
101+
"1m",
102+
"5m",
103+
"15m",
104+
"30m",
105+
"1h",
106+
"2h",
107+
"1d"
108+
],
109+
"time_options": [
110+
"5m",
111+
"15m",
112+
"1h",
113+
"6h",
114+
"12h",
115+
"24h",
116+
"2d",
117+
"7d",
118+
"30d"
119+
]
120+
},
121+
"timezone": "browser",
122+
"title": "datasource",
123+
"version": 0
124+
}
125+
}

0 commit comments

Comments
 (0)