File tree 3 files changed +37
-0
lines changed
3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ x.x.x (TBD)
12
12
* Added StateTimeline panel which was added in Grafana v8
13
13
* Added support for timeseries panel added in Grafana v8
14
14
* Added MinMetricAgg and PercentilesMetricAgg to Elasticsearch
15
+ * Added support for News panel
15
16
* Added support for Pie Chart v2 from Grafana v8
16
17
17
18
Changes
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ def to_json_data(self):
95
95
PIE_CHART_V2_TYPE = 'piechart'
96
96
TIMESERIES_TYPE = 'timeseries'
97
97
WORLD_MAP_TYPE = 'grafana-worldmap-panel'
98
+ NEWS_TYPE = 'news'
98
99
99
100
DEFAULT_FILL = 1
100
101
DEFAULT_REFRESH = '10s'
@@ -3397,3 +3398,29 @@ def to_json_data(self):
3397
3398
'type' : STATE_TIMELINE_TYPE ,
3398
3399
}
3399
3400
)
3401
+
3402
+
3403
+ @attr .s
3404
+ class News (Panel ):
3405
+ """Generates News panel json structure
3406
+ Grafana docs on State Timeline panel: https://grafana.com/docs/grafana/next/visualizations/news-panel/
3407
+
3408
+ :param feedUrl: URL to query, only RSS feed formats are supported (not Atom).
3409
+ :param showImage: Controls if the news item social (og:image) image is shown above text content
3410
+ :param useProxy: If the feed is unable to connect, consider a CORS proxy
3411
+ """
3412
+ feedUrl = attr .ib (default = '' , validator = instance_of (str ))
3413
+ showImage = attr .ib (default = True , validator = instance_of (bool ))
3414
+ useProxy = attr .ib (default = False , validator = instance_of (bool ))
3415
+
3416
+ def to_json_data (self ):
3417
+ return self .panel_json (
3418
+ {
3419
+ 'options' : {
3420
+ 'feedUrl' : self .feedUrl ,
3421
+ 'showImage' : self .showImage ,
3422
+ 'useProxy' : self .useProxy
3423
+ },
3424
+ 'type' : NEWS_TYPE ,
3425
+ }
3426
+ )
Original file line number Diff line number Diff line change @@ -504,6 +504,15 @@ def test_timeseries():
504
504
assert data ['title' ] == title
505
505
506
506
507
+ def test_news ():
508
+ title = 'dummy title'
509
+ feedUrl = "www.example.com"
510
+ news = G .News (title = title , feedUrl = feedUrl )
511
+ data = news .to_json_data ()
512
+ assert data ['options' ]['feedUrl' ] == feedUrl
513
+ assert data ['title' ] == title
514
+
515
+
507
516
def test_pieChartv2 ():
508
517
data_source = 'dummy data source'
509
518
targets = ['dummy_prom_query' ]
You can’t perform that action at this time.
0 commit comments