Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
brian-dashboard-manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
brian
brian-dashboard-manager
Commits
e467753b
Commit
e467753b
authored
6 months ago
by
Bjarke Madsen
Browse files
Options
Downloads
Patches
Plain Diff
refactor render.py to easily show what is reused and what is not
parent
d79bb40d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
brian_dashboard_manager/templating/render.py
+145
-164
145 additions, 164 deletions
brian_dashboard_manager/templating/render.py
with
145 additions
and
164 deletions
brian_dashboard_manager/templating/render.py
+
145
−
164
View file @
e467753b
BASE_DROPDOWN_PANEL
=
{
"
aliasColors
"
:
{},
"
collapsed
"
:
False
,
"
datasource
"
:
None
,
"
fill
"
:
None
,
"
fillGradient
"
:
None
,
"
legend
"
:
None
,
"
lines
"
:
None
,
"
linewidth
"
:
None
,
"
search
"
:
None
,
"
stack
"
:
None
,
"
tags
"
:
None
,
"
targets
"
:
None
,
"
type
"
:
"
row
"
,
"
xaxis
"
:
None
,
"
yaxes
"
:
None
,
"
yaxis
"
:
None
,
}
BASE_YAXES
=
{
"
logBase
"
:
1
,
"
max
"
:
None
,
"
min
"
:
0
,
"
show
"
:
True
,
}
BASE_PANEL
=
{
"
bars
"
:
False
,
"
collapsed
"
:
None
,
"
dashLength
"
:
10
,
"
dashes
"
:
False
,
"
decimals
"
:
2
,
"
fieldConfig
"
:
{
"
defaults
"
:
{
"
custom
"
:
{}},
"
overrides
"
:
[]},
"
fill
"
:
1
,
"
fillGradient
"
:
10
,
"
hiddenSeries
"
:
False
,
"
lines
"
:
True
,
"
nullPointMode
"
:
"
null
"
,
"
options
"
:
{
"
alertThreshold
"
:
True
},
"
percentage
"
:
False
,
"
pointradius
"
:
2
,
"
points
"
:
False
,
"
renderer
"
:
"
flot
"
,
"
search
"
:
None
,
"
seriesOverrides
"
:
[],
"
spaceLength
"
:
10
,
"
steppedLine
"
:
False
,
"
tags
"
:
None
,
"
thresholds
"
:
[],
"
timeFrom
"
:
None
,
"
timeRegions
"
:
[],
"
timeShift
"
:
None
,
"
tooltip
"
:
{
"
shared
"
:
True
,
"
sort
"
:
0
,
"
value_type
"
:
"
individual
"
},
"
type
"
:
"
graph
"
,
"
xaxis
"
:
{
"
buckets
"
:
None
,
"
mode
"
:
"
time
"
,
"
name
"
:
None
,
"
show
"
:
True
,
"
values
"
:
None
,
},
"
yaxis
"
:
{
"
align
"
:
False
,
"
alignLevel
"
:
None
},
"
targets
"
:
[],
}
BASE_LEGEND
=
{
"
alignAsTable
"
:
True
,
"
avg
"
:
True
,
"
current
"
:
True
,
"
max
"
:
True
,
"
min
"
:
False
,
"
rightSide
"
:
None
,
"
show
"
:
True
,
"
total
"
:
False
,
"
values
"
:
True
,
}
BASE_DASHBOARD
=
{
"
id
"
:
None
,
"
uid
"
:
None
,
"
annotations
"
:
{
"
list
"
:
[
{
"
builtIn
"
:
1
,
"
datasource
"
:
"
-- Grafana --
"
,
"
enable
"
:
True
,
"
hide
"
:
True
,
"
iconColor
"
:
"
rgba(0, 211, 255, 1)
"
,
"
name
"
:
"
Annotations & Alerts
"
,
"
type
"
:
"
dashboard
"
,
}
]
},
"
editable
"
:
False
,
"
gnetId
"
:
None
,
"
graphTooltip
"
:
0
,
"
schemaVersion
"
:
27
,
"
style
"
:
"
dark
"
,
"
templating
"
:
{
"
list
"
:
[]},
"
time
"
:
{
"
from
"
:
"
now-24h
"
,
"
to
"
:
"
now
"
},
"
timepicker
"
:
{},
"
timezone
"
:
""
,
"
version
"
:
1
,
"
links
"
:
[],
}
INFOBOX
=
{
"
datasource
"
:
None
,
"
gridPos
"
:
{
"
h
"
:
2
,
"
w
"
:
24
,
"
x
"
:
0
,
"
y
"
:
0
},
"
id
"
:
1
,
"
options
"
:
{
"
content
"
:
"""
<center style=
"
margin-top:5px;
"
>
INFO: The average values displayed are only mean values for timescales of 2 days or less
</center>
"""
,
"
mode
"
:
"
html
"
},
"
pluginVersion
"
:
"
8.2.5
"
,
"
title
"
:
""
,
"
type
"
:
"
text
"
,
}
def
create_dropdown_panel
(
title
,
id
,
y
,
**
kwargs
):
"""
Creates a dropdown panel from the given data.
...
...
@@ -10,25 +133,10 @@ def create_dropdown_panel(title, id, y, **kwargs):
:return: rendered dropdown panel JSON
"""
return
{
"
aliasColors
"
:
{},
"
collapsed
"
:
False
,
"
datasource
"
:
None
,
"
fill
"
:
None
,
"
fillGradient
"
:
None
,
"
gridPos
"
:
{
"
h
"
:
1
,
"
w
"
:
24
,
"
x
"
:
0
,
"
y
"
:
y
},
**
BASE_DROPDOWN_PANEL
,
"
id
"
:
id
,
"
legend
"
:
None
,
"
lines
"
:
None
,
"
linewidth
"
:
None
,
"
search
"
:
None
,
"
stack
"
:
None
,
"
tags
"
:
None
,
"
targets
"
:
None
,
"
gridPos
"
:
{
"
h
"
:
1
,
"
w
"
:
24
,
"
x
"
:
0
,
"
y
"
:
y
},
"
title
"
:
title
,
"
type
"
:
"
row
"
,
"
xaxis
"
:
None
,
"
yaxes
"
:
None
,
"
yaxis
"
:
None
,
}
...
...
@@ -43,41 +151,28 @@ def create_yaxes(type):
if
type
==
"
errors
"
:
return
[
{
**
BASE_YAXES
,
"
format
"
:
"
none
"
,
"
label
"
:
"
errors and discards per second
"
,
"
logBase
"
:
1
,
"
max
"
:
None
,
"
min
"
:
0
,
"
show
"
:
True
,
},
{
**
BASE_YAXES
,
"
format
"
:
"
none
"
,
"
label
"
:
"
errors and discards per second
"
,
"
logBase
"
:
1
,
"
max
"
:
None
,
"
min
"
:
0
,
"
show
"
:
True
,
},
]
else
:
return
[
{
"
format
"
:
"
bps
"
,
"
label
"
:
"
bits per second
"
,
"
logBase
"
:
1
,
"
max
"
:
None
,
"
min
"
:
""
,
"
show
"
:
True
,
},
{
"
format
"
:
"
bps
"
,
"
label
"
:
"
bits per second
"
,
"
logBase
"
:
1
,
"
max
"
:
None
,
"
min
"
:
""
,
"
show
"
:
True
,
},
]
return
[
{
**
BASE_YAXES
,
"
format
"
:
"
bps
"
,
"
label
"
:
"
bits per second
"
,
},
{
**
BASE_YAXES
,
"
format
"
:
"
bps
"
,
"
label
"
:
"
bits per second
"
,
},
]
def
create_panel_target
(
...
...
@@ -197,64 +292,19 @@ def create_panel(
interval
=
5
if
not
is_lambda
else
15
result
=
{
**
BASE_PANEL
,
"
aliasColors
"
:
alias_colors
or
{},
"
bars
"
:
False
,
"
collapsed
"
:
None
,
"
dashLength
"
:
10
,
"
dashes
"
:
False
,
"
datasource
"
:
datasource
,
"
decimals
"
:
2
,
"
fieldConfig
"
:
{
"
defaults
"
:
{
"
custom
"
:
{}},
"
overrides
"
:
[]},
"
fill
"
:
1
,
"
fillGradient
"
:
10
,
"
gridPos
"
:
{
"
h
"
:
height
,
"
w
"
:
width
,
"
x
"
:
x
,
"
y
"
:
y
},
"
hiddenSeries
"
:
False
,
"
id
"
:
id
,
"
interval
"
:
f
"
{
interval
}
m
"
,
"
lines
"
:
True
,
"
linewidth
"
:
linewidth
,
"
nullPointMode
"
:
"
null
"
,
"
options
"
:
{
"
alertThreshold
"
:
True
},
"
percentage
"
:
False
,
"
pointradius
"
:
2
,
"
points
"
:
False
,
"
renderer
"
:
"
flot
"
,
"
search
"
:
None
,
"
seriesOverrides
"
:
[],
"
spaceLength
"
:
10
,
"
stack
"
:
stack
,
"
steppedLine
"
:
False
,
"
tags
"
:
None
,
"
thresholds
"
:
[],
"
timeFrom
"
:
None
,
"
timeRegions
"
:
[],
"
timeShift
"
:
None
,
"
title
"
:
title
,
"
tooltip
"
:
{
"
shared
"
:
True
,
"
sort
"
:
0
,
"
value_type
"
:
"
individual
"
},
"
type
"
:
"
graph
"
,
"
xaxis
"
:
{
"
buckets
"
:
None
,
"
mode
"
:
"
time
"
,
"
name
"
:
None
,
"
show
"
:
True
,
"
values
"
:
None
,
},
"
yaxes
"
:
yaxes
,
"
yaxis
"
:
{
"
align
"
:
False
,
"
alignLevel
"
:
None
},
"
targets
"
:
[],
}
if
not
disable_legend
:
result
[
"
legend
"
]
=
{
"
alignAsTable
"
:
True
,
"
avg
"
:
True
,
"
current
"
:
True
,
"
max
"
:
True
,
"
min
"
:
False
,
"
rightSide
"
:
None
,
"
show
"
:
True
,
"
total
"
:
False
,
"
values
"
:
True
,
}
result
[
"
legend
"
]
=
BASE_LEGEND
targets
=
targets
or
[]
for
target
in
panel_targets
or
[]:
...
...
@@ -263,63 +313,19 @@ def create_panel(
return
result
def
create_infobox
():
return
{
"
datasource
"
:
None
,
"
gridPos
"
:
{
"
h
"
:
2
,
"
w
"
:
24
,
"
x
"
:
0
,
"
y
"
:
0
},
"
id
"
:
1
,
"
options
"
:
{
"
content
"
:
"""
<center style=
"
margin-top:5px;
"
>
INFO: The average values displayed are only mean values for timescales of 2 days or less
</center>
"""
,
"
mode
"
:
"
html
"
},
"
pluginVersion
"
:
"
8.2.5
"
,
"
title
"
:
""
,
"
type
"
:
"
text
"
,
}
def
render_with_aggregate_dashboard
(
nren_name
,
aggregate_panels
,
dropdown_groups
,
tag
=
None
,
tags
=
None
,
**
_
):
assert
tag
or
tags
panels
=
[
create_infobox
()]
panels
.
extend
(
aggregate_panels
)
panels
=
[
INFOBOX
,
*
aggregate_panels
]
for
group
in
dropdown_groups
:
panels
.
append
(
group
[
"
dropdown
"
])
panels
.
extend
(
group
[
"
panels
"
])
return
{
"
id
"
:
None
,
"
uid
"
:
None
,
"
annotations
"
:
{
"
list
"
:
[
{
"
builtIn
"
:
1
,
"
datasource
"
:
"
-- Grafana --
"
,
"
enable
"
:
True
,
"
hide
"
:
True
,
"
iconColor
"
:
"
rgba(0, 211, 255, 1)
"
,
"
name
"
:
"
Annotations & Alerts
"
,
"
type
"
:
"
dashboard
"
,
}
]
},
"
editable
"
:
False
,
"
gnetId
"
:
None
,
"
graphTooltip
"
:
0
,
"
schemaVersion
"
:
27
,
"
style
"
:
"
dark
"
,
**
BASE_DASHBOARD
,
"
tags
"
:
tags
or
[
tag
],
"
templating
"
:
{
"
list
"
:
[]},
"
time
"
:
{
"
from
"
:
"
now-24h
"
,
"
to
"
:
"
now
"
},
"
timepicker
"
:
{},
"
timezone
"
:
""
,
"
title
"
:
nren_name
,
"
version
"
:
1
,
"
links
"
:
[],
"
panels
"
:
panels
,
}
...
...
@@ -327,36 +333,11 @@ def render_with_aggregate_dashboard(
def
render_simple_dashboard
(
title
,
tag
=
None
,
tags
=
None
,
panels
=
None
,
**
_
):
assert
tag
or
tags
return
{
"
id
"
:
None
,
"
uid
"
:
None
,
"
annotations
"
:
{
"
list
"
:
[
{
"
builtIn
"
:
1
,
"
datasource
"
:
"
-- Grafana --
"
,
"
enable
"
:
True
,
"
hide
"
:
True
,
"
iconColor
"
:
"
rgba(0, 211, 255, 1)
"
,
"
name
"
:
"
Annotations & Alerts
"
,
"
type
"
:
"
dashboard
"
,
}
]
},
"
editable
"
:
False
,
"
gnetId
"
:
None
,
"
graphTooltip
"
:
0
,
"
schemaVersion
"
:
27
,
"
style
"
:
"
dark
"
,
**
BASE_DASHBOARD
,
"
tags
"
:
tags
or
[
tag
],
"
templating
"
:
{
"
list
"
:
[]},
"
time
"
:
{
"
from
"
:
"
now-24h
"
,
"
to
"
:
"
now
"
},
"
timepicker
"
:
{},
"
timezone
"
:
""
,
"
title
"
:
title
,
"
version
"
:
1
,
"
links
"
:
[],
"
panels
"
:
[
create_infobox
()
,
INFOBOX
,
*
(
panels
or
[]),
],
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment