{% extends "base.html" %}
{% block content %}	
{% from 'include/input_macros.html' import input, checkbox %}
<script src="/inc/users.js"></script>
<input type="hidden" id="service" value="{{service}}" />
<table class="overview">
	<tr class="overviewHead">
		<td class="padding10 first-collumn" style="width: 10%;">
			{% if select_id == 'viewlogs' %}
				Log
			{% else %}
				Server
			{% endif %}
		</td>
		{% if select_id != 'viewlogs' and service != 'nginx' %}
		<td style="width: 5%;">WAF logs</td>
		{% endif %}
		<td>Number rows</td>
		<td class="padding10"><span title="Find in log file(supports regular expressions)">Find (?)<span></td>
		<td class="padding10"><span title="Exclude from search in log file(supports regular expressions)">Exclude (?)<span></td>
		<td style="width: 10%;">
			<label for="time_range_out_hour" style="padding: 0">Time range:</label>
			{{ input('time_range_out_hour', value=hour, class='time-range', readonly='readonly') }}:{{ input('time_range_out_minut', value=minut, class='time-range', readonly='readonly') }}
			{{ input('time_range_out_hour1', value=hour1, class='time-range', readonly='readonly') }}:{{ input('time_range_out_minut1', value=minut1, class='time-range', readonly='readonly') }}	
		</td>
		<td></td>
	</tr>
	<tr>
		<td class="padding10 first-collumn" style="width: 10%;">
			<form action="" method="post" id="show_log_form">
				{% if select_id == 'viewlogs' %}
					<select autofocus required name="serv" id="{{ select_id }}">
						<option disabled selected>Choose log</option>
						{% for select in selects %}
							{% if page == 'for_editor' %}
								{% if select.1.startswith('haproxy-wi') or select.1.startswith('config_edit') %}
									{% if select.0|int() == serv|int() %}
										<option value="{{ select.0 }}" selected>{{ select.1 }}</option>
									{% else %}
										<option value="{{ select.0 }}">{{ select.1 }}</option>
									{% endif %}
								{% endif %}
							{% else %}
								{% if select.0|int() == serv|int() %}
									<option value="{{ select.0 }}" selected>{{ select.1 }}</option>
								{% else %}
									<option value="{{ select.0 }}">{{ select.1 }}</option>
								{% endif %}
							{% endif %}
						{% endfor %}
					</select>
					{% else %}
						{% include 'include/select.html' %}
					{% endif %}			
		</td>
		{% if select_id != 'viewlogs' and service != 'nginx' %}
		<td>
			{{ checkbox('waf') }}
		</td>
		{% endif %}
		<td class="padding10" style="width: 10%;">
			{{ input('rows', type='number', value=rows, required='required', size='5') }}
		</td> 
		<td class="padding10" style="width: 10%;">
			{{ input('grep', value=grep) }}
		</td>
		<td class="padding10" style="width: 10%;">
			{{ input('exgrep', value=exgrep) }}
		</td>
		<td class="padding10" style="width: 10%;">
			<div id="time-range"></div>			
		</td>			
		<td class="padding10 first-collumn" style="width: 10%;">
			<button type="submit" name="Show log" value="Show" id="show_log_button">Show</button>
			</form>
		</td>
	</tr>
</table>
<div id="ajax">
</div>
{% if select_id == 'viewlogs' and serv != '' and viewlogs != '' and viewlogs != 'haproxy-wi.error.log' and viewlogs != 'haproxy-wi.access.log' %}
	<script>
		viewLogs()
		if (window.matchMedia('(max-width: 786px)').matches || window.matchMedia('(max-width: 1024px)').matches || window.matchMedia('(max-width: 667px)').matches) {
			$( "#viewlogs" ).selectmenu({
				  width: 150
			});
		}
	</script>
	<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
			You can read the descriptions about all logs <a href="https://haproxy-wi.org/description.py?description=logs" title="Servers description" target="_blank">here</a>
		</div>
{% elif serv == 'haproxy-wi.error.log' or serv == 'haproxy-wi.access.log' %}
	<script>
		showApacheLog('{{serv}}');
	</script>
	<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
			You can read the description about all logs file <a href="https://haproxy-wi.org/description.py?description=logs" title="Servers description" target="_blank">here</a>
		</div>
{% else %}
	<script>
		{% if waf == '1' %}
			$('#waf').prop('checked', true);
		{% endif %}
		showLog()
		if (window.matchMedia('(max-width: 786px)').matches || window.matchMedia('(max-width: 1024px)').matches || window.matchMedia('(max-width: 667px)').matches) {
			$( "#serv" ).selectmenu({
				  width: 150
			});
		}
	</script>
{% endif %}
{% endblock %}