{% extends "sentry/index.html" %}

{% load sentry_helpers %}

{% block title %}{{ group.error }} | Django Sentry{% endblock %}

{% block heading %}Message Details{% endblock %}

{% block content %}
	<div id="sidebar">
		<a href="{% url sentry %}">&laquo; back to list</a>
		{% if group|can_chart %}
			<h2>Last 24 Hours</h2>

			<img src="{{ group|chart_url }}" class="chart" alt="chart"/>
		{% endif %}
	
		<h2>Meta</h2>

		<dl class="flat">
			<dt>First Seen:</dt>
			<dd>{{ group.first_seen }}</dd>
			<dt>Last Seen:</dt>
			<dd>{{ group.last_seen }}</dd>
			<dt>Status:</dt>
			<dd>{{ group.get_status_display|title }}</dd>
		</dl>

		{% with group.unique_servers|slice:"10" as unique_servers %}
			{% if unique_servers %}
				<h2>Servers <a href="{% url sentry-group-servers group.pk %}" class="morelink">&raquo;</a></h2>

				<ul class="server-list">
					{% for server, priority in unique_servers|with_priority:"times_seen" %}
						<li class="priority-{{ priority }}"><span class="count">{{ server.times_seen }}</span> {{ server.server_name }}</li>
					{% endfor %}
				</ul>
			{% endif %}
		{% endwith %}

		{% with group.unique_urls|slice:"10" as unique_urls %}
			{% if unique_urls %}
				<h2>URLs <a href="{% url sentry-group-urls group.pk %}" class="morelink">&raquo;</a></h2>

				<ul class="url-list">
					{% for link, priority in unique_urls|with_priority:"times_seen" %}
						<li class="priority-{{ priority }}"><span class="count">{{ link.times_seen }}</span> <a href="{{ link.url }}">{{ link.url }}</a></li>
					{% endfor %}
				</ul>
			{% endif %}
		{% endwith %}
	</div>

	<div id="body" class="with-sidebar">
		<ul class="messages" id="message_list">
			<li class="{% cycle 'row1' 'row2' %} level-{{ group.level }} active" id="group_{{ group.pk }}" data-sentry-count="{{ group.times_seen }}">
				<span class="count count-digits-{{ group.times_seen|num_digits }}">{{ group.times_seen }}</span>
				<h3>{% if group.view %}{{ group.view }}{% else %}{{ group.message }}{% endif %}</h3>
				<span class="last_seen">{{ group.last_seen|timesince }} ago</span>
				<span class="status status-{{ group.status }}">{{ group.get_status_display }}</span>
				<p class="message"><span class="tag tag-level">{{ group.get_level_display }}</span> {{ group.error }}</p>
				{% if group.status == 0 %}
					<a href="{% url sentry-ajax %}?op=resolve&amp;gid={{ group.pk }}" class="hidden button button_resolve">&#10003;</a>
				{% endif %}
			</li>
		</ul>

		<ul class="nav" id="group_nav">
			<li{% if not page %} class="active"{% endif %}><a href="{% url sentry-group group.pk %}">Details</a></li>
			<li{% ifequal page 'messages' %} class="active"{% endifequal %}><a href="{% url sentry-group-messages group.pk %}">Messages</a></li>
			<li{% ifequal page 'urls' %} class="active"{% endifequal %}><a href="{% url sentry-group-urls group.pk %}">URLs</a></li>
			<li{% ifequal page 'servers' %} class="active"{% endifequal %}><a href="{% url sentry-group-servers group.pk %}">Servers</a></li>
		</ul>
		
		{% block inner %}
			<div id="details">
				{% if traceback %}

					<h2>Sample Traceback</h2>

					{{ traceback }}

				{% endif %}
	
				<div id="requestinfo">
					<h2>More Information</h2>
	  
					{% for k, v in json_data %}
						<h3 id="get-info">{{ k }}</h3>
						{% if v %}
							{% if v|is_dict %}
								<table class="req">
									<thead>
										<tr>
											<th>Variable</th>
											<th>Value</th>
										</tr>
									</thead>
									<tbody>
										{% for k_, v_ in v.iteritems %}
										<tr>
											<td>{{ k_ }}</td>
											<td class="code"><div>{{ v_|pprint }}</div></td>
										</tr>
										{% endfor %}
									</tbody>
								</table>
							{% else %}
								{{ v|pprint }}
							{% endif %}
						{% else %}
							<p>No data for {{ k }}</p>
						{% endif %}
					{% endfor %}
				</div>
			</div>
		{% endblock %}
	</div>
{% endblock %}