Allow dynamic dashboard links
This change allows users of this python package to set GRAFANA_LINKS to an array of the title/file to link to in the local_settings file, instead of having them hard-coded in html. Change-Id: I32b231b7b51b4570ae606cdd5c94a36df71e6114
This commit is contained in:
parent
53c960843d
commit
6096575e27
@ -7,3 +7,9 @@ MONITORING_SERVICES = [
|
||||
{'name': _('Servers'),
|
||||
'groupBy': 'hostname'}
|
||||
]
|
||||
|
||||
# Grafana button titles/file names
|
||||
GRAFANA_LINKS = [
|
||||
{'title': 'Dashboard', 'fileName': 'openstack.json'},
|
||||
{'title': 'Monasca Health', 'fileName': 'monasca.json'}
|
||||
]
|
||||
|
@ -8,14 +8,12 @@
|
||||
{% load url from future %}
|
||||
{% block main %}
|
||||
<div style="padding: 3px;">
|
||||
<a target="dashboard" href="/static/grafana/index.html#/dashboard/file/openstack.json?&api={{api}}" class="btn btn-default btn-sm">
|
||||
<span class="glyphicon glyphicon-dashboard"></span>
|
||||
{% trans 'Dashboard' %}
|
||||
</a>
|
||||
<a target="dashboard" href="/static/grafana/index.html#/dashboard/file/monasca.json?&api={{api}}" class="btn btn-default btn-sm">
|
||||
<span class="glyphicon glyphicon-dashboard"></span>
|
||||
{% trans 'Monasca Health' %}
|
||||
</a>
|
||||
{% for dashboard in dashboards %}
|
||||
<a target={{ dashboard.title }} href="/static/grafana/index.html#/dashboard/file/{{ dashboard.fileName }}?api={{api}}" class="btn btn-default btn-sm">
|
||||
<span class="glyphicon glyphicon-dashboard"></span>
|
||||
{% trans dashboard.title %}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% include 'monitoring/overview/monitor.html' %}
|
||||
{% endblock %}
|
||||
|
@ -35,7 +35,13 @@ OVERVIEW = [
|
||||
'groupBy': 'hostname'}
|
||||
]
|
||||
|
||||
DEFAULT_LINKS = [
|
||||
{'title': 'Dashboard', 'fileName': 'openstack.json'},
|
||||
{'title': 'Monasca Health', 'fileName': 'monasca.json'}
|
||||
]
|
||||
|
||||
SERVICES = getattr(settings, 'MONITORING_SERVICES', OVERVIEW)
|
||||
DASHBOARDS = getattr(settings, 'GRAFANA_LINKS', DEFAULT_LINKS)
|
||||
|
||||
|
||||
def get_icon(status):
|
||||
@ -127,6 +133,7 @@ class IndexView(TemplateView):
|
||||
proxy_url_path = str(reverse_lazy(constants.URL_PREFIX + 'proxy'))
|
||||
api_root = self.request.build_absolute_uri(proxy_url_path)
|
||||
context["api"] = api_root
|
||||
context["dashboards"] = DASHBOARDS
|
||||
return context
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user