<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>{appname} - Ramona administation console</title>
	<link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
	<link rel="shortcut icon" href="/static/img/favicon.ico" />
	<style type="text/css">
footer iframe
{{
	vertical-align: bottom;
}}
	</style>
</head>
<body>
	<div class="container">
		<h1>{appname}</h1><p class="lead" title="{version}">Ramona web administration console</p>
		{logmsg}
		<p>
		  <a href="/" id="refreshButton" class="btn btn-large btn-primary">Refresh</a>
		  <a href="/?action=start" class="btn btn-large btn-success">Start all</a>
		  <a href="/?action=stop" class="btn btn-large btn-danger">Stop all</a>
		  <a href="/?action=restart" class="btn btn-large btn-warning">Restart all</a>
		  <a href="/?action=start&amp;force=1" class="btn btn-large btn-inverse">Start all (force)</a>
		  <img src="/static/img/ajax-loader.gif" style="display: none" id="loader" alt="Loading..." />
		</p>		
		{statuses}
		<form id="raform" style="display: none">
		  <label class="checkbox">
		    <input type="checkbox" checked="checked" id="refreshAutomatically"> Refresh automatically
		  </label>
		  </form>
	<hr>
	<footer>
		<p>Ramona (version {version}) project:
		<a href="http://ateska.github.com/ramona/">Ramona project page</a> |
		<a href="https://github.com/ateska/ramona">Ramona @ GitHub</a> |
		<a href="http://pypi.python.org/pypi/ramona">Ramona @ PyPi</a> |
		<script data-gittip-username="ateska" data-gittip-widget="button" src="//gttp.co/v1.js"></script>
		</p>
	</footer>
	</div>

	<script src="/static/miniajax/miniajax.js"></script>
	
	<script type="text/javascript">
	function refreshStatuses() {{
		document.getElementById('loader').style.display = "inline";
		ajax.get('/ajax/statusTable', function(data, response) {{
		   if(response.status == 200) {{
			   document.getElementById('statusTable').innerHTML = data;
		   }} else {{
			   document.getElementById('statusTable').innerHTML = '<div class="alert alert-error"><h4>Error loading program statuses!</h4> Please check that Ramona server is running and that the Ramona HTTP frontend is accessible.</div>';
		   }}
		   document.getElementById('loader').style.display = "none";
		}});
	}}
	
	setInterval(function() {{
		if(document.getElementById('refreshAutomatically').checked) {{
			refreshStatuses();
		}}
	}}, 5000);
	
	document.getElementById('refreshButton').onclick = function(event) {{
		event.preventDefault();
		refreshStatuses();
	}}
	document.getElementById('raform').style.display = "inline";
	</script>
	
</body>
</html>