{% extends "base.html" %}
{% block content %}
<center>
	<h3>Choose server</h3>
	<p>
		<form action="{{ action }}" method="get">
			<select autofocus required name="serv" id="{{ select_id }}">
				<option disabled>Choose server</option>
					{% for select in selects %}
						{% if select.2 == serv %}
							<option value="{{ select.2 }}" selected>{{ select.1 }}</option>
						{% else %}
							<option value="{{ select.2 }}">{{ select.1 }}</option>
						{% endif %}
					{% endfor %}
			</select>
			<button type="submit" value="open" name="open" class="btn btn-default">Open</button>
		</form>
	</p>
	{% if not aftersave %}
		{% if stderr or error %}
			<div class="alert alert-danger" style="margin-bottom: 10px;">
				Some errors:
				<br> 
				<br> 
				{{stderr}} 
				{{error}} 
			</div>
		{% endif %}
	{% endif %}
	{% if note %}
		<div class="alert alert-info"><b>Note:</b> If you reconfigure Master server, Slave will reconfigured automatically</div>
	{% endif %}
	{% if open %}
		<center>
			<h3>Choose old version</h3>
			<form action="configver.py#conf" method="get">
				<p>
					<select autofocus required name="configver" id="configver">
						<option disabled selected>Choose version</option>
							{% for file in return_files %}
								{% if file == configver %}
									<option {{file}} selected>{{file}}</option>
								{% else %}
									<option {{file}}>{{file}}</option>
								{% endif %}
							{% endfor %}
					</select>
					<input type="hidden" value="{{serv}}" name="serv">
					<input type="hidden" value="open" name="open">
					<input type="hidden" value="{{ view }}" id="view">
					<a class="ui-button ui-widget ui-corner-all" id="show" title="Enter" onclick="{{ onclick }}">Select</a>
				</p>
			</form> 
		</center>
	{% endif %}
	{% if aftersave %}
		<div class="alert alert-info">Uploaded old config ver: {{ configver }} </div>
		{% if stderr or error %}
			<div class="alert alert-danger">
				Some errors:
				<br> 
				<br> 
					{{stderr}} 
					{{error}} 
			</div>
			
		{% else %}
			<div class="alert alert-success">Config ok</div>
			<a href="viewsttats.py?serv={{ serv }}" target="_blank" title="View stats">Go to view stats</a>
			<script>window.history.pushState("Map", "Map", cur_url[0])</script>
		{% endif %}
	{% endif %}
</center>
{% if view %}
	<script> 
		showUploadConfig()
	</script> 
{% endif %}
{% endblock %}