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

Commit bc2e772

Browse files
Merge pull request #254 from corentinaltepe/issue-219-repeat-text-panel
Added repeat functionality to "text" panel
2 parents 31d707f + 159b167 commit bc2e772

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

grafonnet/text.libsonnet

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
{
22
/**
3+
* Creates a [text panel](https://grafana.com/docs/grafana/latest/panels/visualizations/text-panel/).
4+
*
35
* @name text.new
6+
*
7+
* @param title (default `''`) Panel title.
8+
* @param description (optional) Panel description.
9+
* @param datasource (optional) Panel datasource.
10+
* @param span (optional)
11+
* @param content (default `''`)
12+
* @param mode (default `'markdown'`)
13+
* @param transparent (optional)
14+
* @param repeat (optional) Name of variable that should be used to repeat this panel.
15+
* @param repeatDirection (default `'h'`) 'h' for horizontal or 'v' for vertical.
16+
* @param repeatMaxPerRow (optional) Maximum panels per row in repeat mode.
417
*/
518
new(
619
title='',
@@ -10,6 +23,9 @@
1023
transparent=null,
1124
description=null,
1225
datasource=null,
26+
repeat=null,
27+
repeatDirection=null,
28+
repeatMaxPerRow=null,
1329
)::
1430
{
1531
[if transparent != null then 'transparent']: transparent,
@@ -20,5 +36,8 @@
2036
content: content,
2137
[if description != null then 'description']: description,
2238
datasource: datasource,
39+
[if repeat != null then 'repeat']: repeat,
40+
[if repeat != null then 'repeatDirection']: repeatDirection,
41+
[if repeat != null then 'maxPerRow']: repeatMaxPerRow,
2342
},
2443
}

tests/text/test.jsonnet

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ local text = grafana.text;
1111
mode='html',
1212
content='coocoo',
1313
transparent=true,
14+
repeat='my-variable',
15+
repeatDirection='v',
16+
repeatMaxPerRow=12,
1417
),
18+
repeat: text.new(span=12, repeat='my-variable'),
1519
}

tests/text/test_compiled.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
"content": "coocoo",
44
"datasource": "$PROMETHEUS",
55
"description": "description",
6+
"maxPerRow": 12,
67
"mode": "html",
8+
"repeat": "my-variable",
9+
"repeatDirection": "v",
710
"span": 5,
811
"title": "foo",
912
"transparent": true,
@@ -16,5 +19,16 @@
1619
"span": 12,
1720
"title": "",
1821
"type": "text"
22+
},
23+
"repeat": {
24+
"content": "",
25+
"datasource": null,
26+
"maxPerRow": null,
27+
"mode": "markdown",
28+
"repeat": "my-variable",
29+
"repeatDirection": null,
30+
"span": 12,
31+
"title": "",
32+
"type": "text"
1933
}
2034
}

0 commit comments

Comments
 (0)