Skip to content
2 changes: 1 addition & 1 deletion adagios/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def resolve_urlname(request):
request is within the template"""
from django.core.urlresolvers import resolve
try:
res = resolve(request.path)
res = resolve(request.path_info)
if res:
return {'urlname': res.url_name}
except Exception:
Expand Down
14 changes: 7 additions & 7 deletions adagios/objectbrowser/templates/copy_object.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
<div class="alert alert-success">
<button class="close" data-dismiss="alert">×</button>
<strong>{% trans "Success!" %}</strong>
{% url edit_object i.id as the_url %}
{% blocktrans with type=i.object_type desc=u.description file=i.filename %}
{{ type }} <a href="{{ the_url }}">"{{ desc }}"</a> was successfully saved to {{ file }}.
{% endblocktrans %}
{% url edit_object object.id as the_url %}
{% blocktrans with type=object.object_type desc=object.description file=object.filename %}
{{ type }} <a href="{{ the_url }}">"{{ desc }}"</a> was successfully saved to {{ file }}.
{% endblocktrans %}
</div>
{% endfor %}
{% else %}
<div class="alert alert-info">
{% blocktrans with type=i.object_type desc=u.description %}
You are about to copy {{ type }} "{{ desc }}".
{% endblocktrans %}
{% blocktrans with type=object.object_type desc=object.description %}
You are about to copy {{ type }} "{{ desc }}".
{% endblocktrans %}
</div>
<p></p>
<form action="#" method="POST" class="form-horizontal">{% csrf_token %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,4 @@
{% else %}
{% endif %}

<script>
// Enable the multiselect checkbox in all status tables
adagios.status.initilize_multiselect_checkboxes();
</script>
<!-- snippet status_hostgrouplist_snippet.html ends -->
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,4 @@
</tbody>
</table>

<script>
// Enable the multiselect checkbox in all status tables
adagios.status.initilize_multiselect_checkboxes();
</script>
<!-- snippet status_hostlist_snippet.html ends -->
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,4 @@
</table>
{% blocktrans with length=services|length %}{{ length }} objects found.{% endblocktrans %}

<script>
// Enable the multiselect checkbox in all status tables
adagios.status.initilize_multiselect_checkboxes();
</script>

<!-- snippet status_servicelist_snippet.html ends -->
8 changes: 4 additions & 4 deletions adagios/status/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ def get_services(request=None, tags=None, fields=None, *args, **kwargs):

# If q was added, it is a fuzzy filter on services
for i in q:
arguments.append('Filter: host_name ~~ %s' % i)
arguments.append('Filter: description ~~ %s' % i)
arguments.append('Filter: plugin_output ~~ %s' % i)
arguments.append('Filter: host_address ~~ %s' % i)
arguments.append('Filter: host_name ~~ %s' % i.encode('utf-8'))
arguments.append('Filter: description ~~ %s' % i.encode('utf-8'))
arguments.append('Filter: plugin_output ~~ %s' % i.encode('utf-8'))
arguments.append('Filter: host_address ~~ %s' % i.encode('utf-8'))
arguments.append('Or: 4')

if fields is None:
Expand Down
52 changes: 31 additions & 21 deletions adagios/status/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,26 @@
@adagios_decorator
def detail(request):
""" Return status detail view for a single given host, hostgroup,service, contact, etc """
host_name = request.GET.get('host_name')
service_description = request.GET.get('service_description')
contact_name = request.GET.get('contact_name')
hostgroup_name = request.GET.get('hostgroup_name')
contactgroup_name = request.GET.get('contactgroup_name')
servicegroup_name = request.GET.get('servicegroup_name')
if service_description:
return service_detail(request, host_name=host_name, service_description=service_description)
elif host_name:
return host_detail(request, host_name=host_name)
elif contact_name:
return contact_detail(request, contact_name=contact_name)
elif contactgroup_name:
return contactgroup_detail(request, contactgroup_name=contactgroup_name)
elif hostgroup_name:
return hostgroup_detail(request, hostgroup_name=hostgroup_name)
elif servicegroup_name:
return servicegroup_detail(request, servicegroup_name=servicegroup_name)
args = {}
for query_parm in ['host_name', 'service_description', 'contact_name',
'hostgroup_name', 'contactgroup_name', 'servicegroup_name']:
value = request.GET.get(query_parm)
if value:
args[query_parm] = value.encode('utf-8')

if 'service_description' in args:
return service_detail(request, host_name=args['host_name'],
service_description=args['service_description'])
elif 'host_name' in args:
return host_detail(request, host_name=args['host_name'])
elif 'contact_name' in args:
return contact_detail(request, contact_name=args['contact_name'])
elif 'contactgroup_name' in args:
return contactgroup_detail(request, contactgroup_name=args['contactgroup_name'])
elif 'hostgroup_name' in args:
return hostgroup_detail(request, hostgroup_name=args['hostgroup_name'])
elif 'servicegroup_name' in args:
return servicegroup_detail(request, servicegroup_name=args['servicegroup_name'])

raise Exception(_("You have to provide an item via querystring so we know what to give you details for"))

Expand Down Expand Up @@ -1223,6 +1225,10 @@ def backends(request):

@adagios_decorator
def custom_view(request, viewname):
c = {}
c['messages'] = []
c['errors'] = []

def data_to_query(data):
"""
Transforms a view dict into a Livestatus query.
Expand All @@ -1244,9 +1250,10 @@ def data_to_query(data):
'%(columns)s'
'%(filters)s'
'%(stats)s') % d
# Remove uneeded linebreaks at the end:
query = query.strip()
return query

c = {}
# View management
user = userdata.User(request)
c['viewname'] = viewname
Expand All @@ -1267,8 +1274,11 @@ def data_to_query(data):
# the split is a workaround for pynag and the 'Stats:' clause
c['data'] = livestatus.query(*livestatus_query.split('\n'))
except Exception as e:
c['data'] = []
c['errors'] = [_('Error in LiveStatus query'), e.message]
# Any exception in livestatus query here is a critical error
error = _('Error in LiveStatus query')
c['errors'].append(error)
c['errors'].append(e.message)
return error_page(request, c)

# Data post-processing
# sorting
Expand Down
3 changes: 2 additions & 1 deletion adagios/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<script>
var BASE_URL = "{% url home %}";
</script>
<script type="text/javascript"src="{% url django.views.i18n.javascript_catalog %}"></script>
<script type="text/javascript" src="{% url django.views.i18n.javascript_catalog %}"></script>

</head>

Expand Down Expand Up @@ -117,6 +117,7 @@
<li{% if urlname == 'adagios.status.views.perfdata2' %} class="active"{% endif %}><a href="{% url status.views.perfdata2 %}">{% trans "Performance Data 2" %}</a></li>
<li{% if urlname == 'adagios.bi.views.index' %} class="active"{% endif %}><a href="{% url bi.views.index %}">{% trans "Business Intelligence" %}</a></li>
<li{% if urlname == 'adagios.status.views.dashboard' %} class="active"{% endif %}><a href="{% url status.views.dashboard %}">{% trans "Dashboard" %}</a></li>
</ul>
</div>
{% endblock left_sidebar %}
<!-- block left_sidebar ends -->
Expand Down