Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
b087edc2
Unverified
Commit
b087edc2
authored
Jan 19, 2020
by
Torkel Ödegaard
Committed by
GitHub
Jan 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Typescript: null check fixes, and news panel fix (#21595)
parent
e7621906
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
30 deletions
+35
-30
public/app/plugins/panel/news/rss.ts
+12
-4
public/app/plugins/panel/news/utils.ts
+3
-6
public/app/plugins/panel/singlestat/specs/singlestat.test.ts
+19
-19
public/dashboards/home.json
+1
-1
No files found.
public/app/plugins/panel/news/rss.ts
View file @
b087edc2
...
@@ -9,12 +9,20 @@ export async function loadRSSFeed(url: string): Promise<RssFeed> {
...
@@ -9,12 +9,20 @@ export async function loadRSSFeed(url: string): Promise<RssFeed> {
items
:
[],
items
:
[],
};
};
const
getProperty
=
(
node
:
Element
,
property
:
string
)
=>
{
const
propNode
=
node
.
querySelector
(
property
);
if
(
propNode
)
{
return
propNode
.
textContent
??
''
;
}
return
''
;
};
doc
.
querySelectorAll
(
'item'
).
forEach
(
node
=>
{
doc
.
querySelectorAll
(
'item'
).
forEach
(
node
=>
{
const
item
:
RssItem
=
{
const
item
:
RssItem
=
{
title
:
node
.
querySelector
(
'title'
).
textContent
,
title
:
getProperty
(
node
,
'title'
)
,
link
:
node
.
querySelector
(
'link'
).
textContent
,
link
:
getProperty
(
node
,
'link'
)
,
content
:
node
.
querySelector
(
'description'
).
textContent
,
content
:
getProperty
(
node
,
'description'
)
,
pubDate
:
node
.
querySelector
(
'pubDate'
).
textContent
,
pubDate
:
getProperty
(
node
,
'pubDate'
)
,
};
};
feed
.
items
.
push
(
item
);
feed
.
items
.
push
(
item
);
...
...
public/app/plugins/panel/news/utils.ts
View file @
b087edc2
...
@@ -15,13 +15,10 @@ export function feedToDataFrame(feed: RssFeed): DataFrame {
...
@@ -15,13 +15,10 @@ export function feedToDataFrame(feed: RssFeed): DataFrame {
title
.
buffer
.
push
(
item
.
title
);
title
.
buffer
.
push
(
item
.
title
);
link
.
buffer
.
push
(
item
.
link
);
link
.
buffer
.
push
(
item
.
link
);
let
body
=
item
.
content
.
replace
(
/<
\/?[^
>
]
+
(
>|$
)
/g
,
''
);
if
(
item
.
content
)
{
const
body
=
item
.
content
.
replace
(
/<
\/?[^
>
]
+
(
>|$
)
/g
,
''
);
if
(
body
&&
body
.
length
>
300
)
{
content
.
buffer
.
push
(
body
);
body
=
body
.
substr
(
0
,
300
);
}
}
content
.
buffer
.
push
(
body
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
warn
(
'Error reading news item:'
,
err
,
item
);
console
.
warn
(
'Error reading news item:'
,
err
,
item
);
}
}
...
...
public/app/plugins/panel/singlestat/specs/singlestat.test.ts
View file @
b087edc2
...
@@ -73,7 +73,7 @@ describe('SingleStatCtrl', () => {
...
@@ -73,7 +73,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'should set formatted falue'
,
()
=>
{
it
(
'should set formatted falue'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'15'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'15'
);
});
});
});
});
...
@@ -96,7 +96,7 @@ describe('SingleStatCtrl', () => {
...
@@ -96,7 +96,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'should set formatted value'
,
()
=>
{
it
(
'should set formatted value'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'test.cpu1'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'test.cpu1'
);
});
});
});
});
...
@@ -121,7 +121,7 @@ describe('SingleStatCtrl', () => {
...
@@ -121,7 +121,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'should set formatted value'
,
()
=>
{
it
(
'should set formatted value'
,
()
=>
{
expect
(
dateTime
(
ctx
.
data
.
display
.
text
).
valueOf
()).
toBe
(
1505634997000
);
expect
(
dateTime
(
ctx
.
data
.
display
!
.
text
).
valueOf
()).
toBe
(
1505634997000
);
});
});
});
});
...
@@ -142,7 +142,7 @@ describe('SingleStatCtrl', () => {
...
@@ -142,7 +142,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'should set value'
,
()
=>
{
it
(
'should set value'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'1970-01-01 00:00:05'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'1970-01-01 00:00:05'
);
});
});
});
});
...
@@ -167,7 +167,7 @@ describe('SingleStatCtrl', () => {
...
@@ -167,7 +167,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'should set formatted value'
,
()
=>
{
it
(
'should set formatted value'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
dateTime
(
1505634997920
).
format
(
'MM/DD/YYYY h:mm:ss a'
));
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
dateTime
(
1505634997920
).
format
(
'MM/DD/YYYY h:mm:ss a'
));
});
});
});
});
...
@@ -188,7 +188,7 @@ describe('SingleStatCtrl', () => {
...
@@ -188,7 +188,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'should set formatted value'
,
()
=>
{
it
(
'should set formatted value'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'01/01/1970 12:00:05 am'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'01/01/1970 12:00:05 am'
);
});
});
});
});
...
@@ -212,7 +212,7 @@ describe('SingleStatCtrl', () => {
...
@@ -212,7 +212,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'should set formatted value'
,
()
=>
{
it
(
'should set formatted value'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'2 days ago'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'2 days ago'
);
});
});
});
});
...
@@ -232,7 +232,7 @@ describe('SingleStatCtrl', () => {
...
@@ -232,7 +232,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'should set formatted value'
,
()
=>
{
it
(
'should set formatted value'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'2 days ago'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'2 days ago'
);
});
});
});
});
...
@@ -258,7 +258,7 @@ describe('SingleStatCtrl', () => {
...
@@ -258,7 +258,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'should set formatted value'
,
()
=>
{
it
(
'should set formatted value'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'100'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'100'
);
});
});
}
}
);
);
...
@@ -274,7 +274,7 @@ describe('SingleStatCtrl', () => {
...
@@ -274,7 +274,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'Should replace value with text'
,
()
=>
{
it
(
'Should replace value with text'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'OK'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'OK'
);
});
});
});
});
...
@@ -289,7 +289,7 @@ describe('SingleStatCtrl', () => {
...
@@ -289,7 +289,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'Should replace value with text'
,
()
=>
{
it
(
'Should replace value with text'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'XYZ'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'XYZ'
);
});
});
});
});
...
@@ -304,7 +304,7 @@ describe('SingleStatCtrl', () => {
...
@@ -304,7 +304,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'Should replace value with text OK'
,
()
=>
{
it
(
'Should replace value with text OK'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'OK'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'OK'
);
});
});
});
});
...
@@ -319,7 +319,7 @@ describe('SingleStatCtrl', () => {
...
@@ -319,7 +319,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'Should replace value with text NOT OK'
,
()
=>
{
it
(
'Should replace value with text NOT OK'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'NOT OK'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'NOT OK'
);
});
});
});
});
...
@@ -347,7 +347,7 @@ describe('SingleStatCtrl', () => {
...
@@ -347,7 +347,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'should set formatted value'
,
()
=>
{
it
(
'should set formatted value'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'15'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'15'
);
});
});
});
});
...
@@ -377,7 +377,7 @@ describe('SingleStatCtrl', () => {
...
@@ -377,7 +377,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'should set formatted falue'
,
()
=>
{
it
(
'should set formatted falue'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'100'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'100'
);
});
});
}
}
);
);
...
@@ -396,7 +396,7 @@ describe('SingleStatCtrl', () => {
...
@@ -396,7 +396,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'Should replace value with text'
,
()
=>
{
it
(
'Should replace value with text'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'OK'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'OK'
);
});
});
});
});
...
@@ -413,7 +413,7 @@ describe('SingleStatCtrl', () => {
...
@@ -413,7 +413,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'Should replace value with text OK'
,
()
=>
{
it
(
'Should replace value with text OK'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'OK'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'OK'
);
});
});
});
});
...
@@ -430,7 +430,7 @@ describe('SingleStatCtrl', () => {
...
@@ -430,7 +430,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'Should replace value with text NOT OK'
,
()
=>
{
it
(
'Should replace value with text NOT OK'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'NOT OK'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'NOT OK'
);
});
});
});
});
...
@@ -443,7 +443,7 @@ describe('SingleStatCtrl', () => {
...
@@ -443,7 +443,7 @@ describe('SingleStatCtrl', () => {
});
});
it
(
'Should replace value with text NOT OK'
,
()
=>
{
it
(
'Should replace value with text NOT OK'
,
()
=>
{
expect
(
ctx
.
data
.
display
.
text
).
toBe
(
'ignore1'
);
expect
(
ctx
.
data
.
display
!
.
text
).
toBe
(
'ignore1'
);
});
});
});
});
...
...
public/dashboards/home.json
View file @
b087edc2
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
"id"
:
4
,
"id"
:
4
,
"links"
:
[],
"links"
:
[],
"options"
:
{
"options"
:
{
"feedUrl"
:
"https://grafana.com/blog/
index
.xml"
"feedUrl"
:
"https://grafana.com/blog/
news
.xml"
},
},
"title"
:
"Latest from the blog"
,
"title"
:
"Latest from the blog"
,
"type"
:
"news"
"type"
:
"news"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment