<template name="showLog">
	{{#unless privileged}}
		<h1>PLZ login as admin!</h1>
	{{else}}
	<div class="page-component">
		<div class="js-search-field">
			<div class="input-group">
				<span class="input-group-addon">ID</span>
				<input class="js-rel-input js-update-url form-control"
					type="text"
					value="{{relFilter}}"
					placeholder="Pw8HSnHtjErhPfCaa, f59a1e7855"/>
			</div>
			<div class="input-group">
				<span class="input-group-addon">Track</span>
				<input class="js-tr-input js-update-url form-control"
					type="text"
					value="{{trFilter}}"
					placeholder="Profile.Region"/>
			</div>
			<div class="input-group">
				<span class="input-group-addon">Date</span>
				<input class="js-date-input js-update-url form-control"
					type="text"
					value="{{date}}"
					placeholder="YYYY-MM-DD hh:mm:ss"/>
			</div>
		</div>
	</div>
	<div class="page-component log-pane">
	{{#if loading}}
		<div class="loading">
			<h1><marquee>&nbsp;&nbsp;&nbsp;LOADING! BE PATIENT! ENJOY THE SUN!</marquee></h1>
		</div>
	{{/if}}
		<table class="table">
			<tr><th>ID</th><th>Track</th><th>Timestamp</th><th>Rel</th><th>Body</th></tr>
		{{#each results}}
			{{> showLogEntry}}
		{{else}}
			{{#unless loading}}
			<tr><td>Nothing found.</td></tr>
			{{/unless}}
		{{/each}}
		</table>

	{{#if hasMore}}
		<div class="show-more-courses">
			<button type="button" class="btn btn-success js-more">
				<span class="fa fa-plus fa-fw" aria-hidden="true"></span>
				Show more
			</button>
		</div>
	{{/if}}
	</div>
	{{/unless}}
</template>

<template name="showLogEntry">
	<tr>
	{{#if interval}}
		<td></td><td></td><td colspan="3" style="color: gray">{{interval}}</td>
	{{else}}
		<td>{{#with _id}}<a class="js-rel-id id clickable" title={{this}}>{{shortId this}}</a>{{/with}}</td>
		<td>{{#with tr}}<a class="js-tr id clickable">{{this}}</a>{{/with}}</td>
		<td>{{#with ts}}<a class="js-date clickable nowrap">{{isodate this}}</a>{{/with}}</td>
		<td class="nowrap">
			{{#each rel}}
				<a class="js-rel-id id clickable nowrap" title="{{this}}">{{shortId this}}</a>
			{{/each}}
		</td>
		<td>
			{{#if expanded}}
				<pre class="js-collapse">{{jsonBody}}</pre>
			{{else}}
				<div class="js-expand nowrap">{{jsonBody}}</div>
			{{/if}}
		</td>
	{{/if}}
	</tr>
</template>
