{% load lookup %}
{% load split %}

{% if jobs %}
	<br>
	<table class="table table-sm">
		<thead>
	    <tr>
	        <th></th>
	        <th style="text-align: center;">&#9733;</th>
	        <th style="text-align: center;">&#8470;</th>
	        <th>Имя</th>
	        <th>Описание</th>
	        <th>Параметры</th>
	        <th style="text-align: center;">От..До</th>
	        <th>Тестировщик</th>
	        <th>Танк</th>
	        <th title="Мишень и порт">Мишень</th>
	        <th>Дата и время</th>
	        <th style="padding: 0 0 0 0.3em; text-align: center;" title="Код завершения стрельбы">RC</th>
	    </tr>
		</thead>
		<tbody>
	    {% for job in jobs %}
	    <tr class="job_table_row_{{ job_quit_status_dict|lookup:job.n }}">
	        <td>
	            <a href="/{{ job.id }}">
	            <div id="job_{{ job.id }}_preview" style="border: 1px solid #c5c8d0; width:50px; height:36px; margin-bottom: 0.2em;"></div>
                              <script nonce='{{ common.CSP_SCRIPT_NONCE }}'>
	                              $.getJSON("/preview?job={{ job.id }}").done(function(data){
	                            	  var cfg={
												chart: {
										            renderTo: $("div#job_{{ job.id }}_preview")[0],
										            height: 36,
										            width: 50,
										            borderRadius: 0,
										            margin: [1, 1, 1, 1],
										            animation: false,
										            style: {
										                fontFamily: 'Yandex Sans Text Web'
										            },
										        },
										        title: {
										   			text: "",
										        },
										        subtitle: {
										        	text: "",
										        },
										        navigator: {
										            enabled: false,
										        },
										        rangeSelector: {
										        	enabled: false,
										        },
										        scrollbar: {
										        	enabled: false,
										        },
										        exporting: {
										            enabled: false,
										        },
										        credits: {
										        	enabled: false,
										        },
										        tooltip: {
													enabled: false,										        	
										        },
										        xAxis: {
										        	labels: {enabled: false},
										        	tickLength: 0,
										        	lineWidth: 0,
										        },
										        yAxis: [{
											        	labels: {enabled: false},
											        	tickAmount: 0,
											        	tickLength: 0,
											        	lineWidth: 0,
											        	min: 0,
											        	title: {
											        		text: ''
											        	},
											        	showFirstLabel: false,
											        	showLastLabel: false,
											        	endOnTick: false,
											        	startOnTick: false,
											        	gridLineWidth: 0,
										        	},
										        	{
											        	labels: {enabled: false},
											        	tickAmount: 0,
											        	tickLength: 0,
											        	lineWidth: 0,
											        	min: 0,
											        	title: {
											        		text: ''
											        	},
											        	showFirstLabel: false,
											        	showLastLabel: false,
											        	endOnTick: false,
											        	startOnTick: false,
											        	gridLineWidth: 0,
										        	}],
										        legend: {
										        	enabled: false
										        },
										        plotOptions: {
										        	series: {
		                  				        		cropThreshold: 125,
		                  				        		shadow: false,
		                  				        		connectNulls: true,	
		                  				        		animation: false,
		                  				        		marker: {enabled: false},
		                  				        		states: {hover: {enabled: false}},
		                  				        	},
										        },
										        series: data,
											};
										
								  		new Highcharts.Chart(cfg);
	                              	}
	                              )
                              </script>
	            </a>
	        </td>
	        <td style="text-align: center;">
	        	{% if job.flag %}
	        	<a class="job_star_on" id="job_star_on__{{ job.id }}" href="#"><i class="fa fa-star" style="color:orange" alt="Важность стрельбы" title="Важность стрельбы"></i></a>
	        	<a class="job_star_off" style="display: none"  id="job_star_off__{{ job.id }}" href="#"><i class="fa fa-star text-muted" alt="Важность стрельбы" title="Важность стрельбы"></i></a>
	        	{% else %}
	        	<a class="job_star_on" style="display: none"  id="job_star_on__{{ job.id }}" href="#"><i class="fa fa-star" style="color:orange" alt="Важность стрельбы" title="Важность стрельбы"></i></a>
	        	<a class="job_star_off" id="job_star_off__{{ job.id }}" href="#"><i class="fa fa-star text-muted" alt="Важность стрельбы" title="Важность стрельбы"></i></a>
	        	{% endif %}
			</td>
	        <td style="text-align: center;"><a href="/{{ job.id }}">{{ job.id }}</a></td>
	        <td>
		        <a href="/{{ job.id }}">{{ job.name }}</a>
	        </td>
	        <td class="jobs_table_column_dsc">
        		{% if job.dsc %}
		        {{ job.dsc }}
		        {% endif %}
	        </td>
	        <td class="job_table_column_params" id="job_table_column_params__{{ job.n }}">
	       		{% if job.ver %}
		        	<p>версия&#58;{{ job.ver }}</p>
		        {% endif %}
		        {% if job.imbalance %}
		        	<p style="font-size: 1.3em">разладка&#58;{{ job.imbalance }}</p>
		        {% endif %}
	        </td>
	        <td style="text-align: center;">
	        	{{ job_start_rps_dict|lookup:job.n }}..{{ job_finish_rps_dict|lookup:job.n }}
	        </td>
	        <td><a class="person">{{ job.person }}</a></td>
	        <td title="{{ job.tank.name }}">{{ job.tank_reduced }}</td>
	        <td title="{{ job.srv.name }}:{{ job.srv_port }}">{{ job.srv_reduced }}&#58;{{ job.srv_port }}</td>
	        <td class="jobs_table_column_date">
	        	<span style="font-size: 1.3em" >Длит.&#58;&nbsp;{{ job.duration }}</span>
	        	<br>
	        	{{ job.fd|date:'Y-m-d H:i' }}
	        	<br>
	        </td>
	        <td style="padding: 0 0 0 0.3em; text-align: center;">
	        	{% with job_quit_status_dict|lookup:job.n|split:"_" as qs %}
	        		{% if qs.0 == "completed" %}
						<i class="quit_status-icon fa fa-check text-success" title="{{ job_quit_status_dict|lookup:job.n }}"></i>
					{% elif qs.0 == "interrupted" %}
						<i class="quit_status-icon fa fa-hand-paper-o text-danger" title="{{ job_quit_status_dict|lookup:job.n }}"></i>
					{% elif qs.0 == "autostop" %}
						<i class="quit_status-icon fa fa-exclamation-circle text-danger" title="{{ job_quit_status_dict|lookup:job.n }}"></i>
					{% else %}
						<i class="quit_status-icon fa fa-question text-muted" title="{{ job_quit_status_dict|lookup:job.n }}"></i>
					{% endif %}
		       	{% endwith %}
	        </td>
	    </tr>
	    {% endfor %}
		</tbody>
	</table>
	<br>
	    {% if not_all_jobs %}
    	<p style="font-weight: bold; padding:0 0 0 50px">Полный перечень стрельб по этой задаче&nbsp;<a style="font-weight: bold;" href="/{{ task }}">тут</a></p>
    	{% endif %}
	<br>
{% else %}
    <p style="margin-left: 50px; padding-bottom:4px; padding-right:18px; font-weight: bold;">В этой задаче нет стрельб</p>
    <br>
{% endif %}
