{% extends "base.html" %}

{% block main_content %}
<div class="container">
	<h3>{{page_title}}</h3>
	<div class="row col-lg-12">
		<label class="form-control-plaintext col-lg-2">Job #:</label>
		<label class="form-control-plaintext col-lg-10">{{job.id}}</label>
	</div>
	<div class="row col-lg-12">
		<label class="form-control-plaintext col-lg-2">Name:</label>
		<label class="form-control-plaintext col-lg-10">{{job.name}}</label>
	</div>
	<div class="row col-lg-12">
		<label class="form-control-plaintext col-lg-2">Start Time:</label>
		<label class="form-control-plaintext col-lg-10">{{job.start_time|vicdate}}</label>
	</div>
	<div class="row col-lg-12">
		<label class="form-control-plaintext col-lg-2">Duration:</label>
		<label class="form-control-plaintext col-lg-10">{{duration}}</label>
	</div>
	<div class="row col-lg-12">
		<label class="form-control-plaintext col-lg-2">Last Update:</label>
		<label class="form-control-plaintext col-lg-10">{{job.last_update|vicdate}}</label>
	</div>
	<div class="row col-lg-12">
		<label class="form-control-plaintext col-lg-2">Current state:</label>
		<label class="form-control-plaintext col-lg-10">{{job.state}}</label>
	</div>
    {% if job.wait_for != None %}
        <div class="row col-lg-12">
            <label class="form-control-plaintext col-lg-2">Waiting on Job:</label>
            <label class="form-control-plaintext col-lg-10"><a href="{{url_for('joblog', id=job.wait_for)}}">Job (id={{job.wait_for}})</a></label>
        </div>
    {% endif %}
	<div class="row col-lg-12">
		<label class="form-control-plaintext col-lg-2">Current File:</label>
		<label class="form-control-plaintext col-lg-10">{{job.current_file}}</label>
	</div>
    <div class="row col-lg-12">
         <label class="form-control-plaintext col-lg-2">Files in pass:</label>
    {% if job.num_files and job.num_files > 0 %}
         <div class="col-lg-10 px-0">
            {% set prog=(job.current_file_num/job.num_files*100)|round|int %}
            <div class="progress" style="height:80%">
                <div class="progress-bar bg-info" role="progressbar" style="width: {{prog}}%;" aria-valuenow="{{prog}}" aria-valuemin="0" aria-valuemax="100">{{job.current_file_num}} of {{job.num_files}} - {{prog}}%</div>
            </div>
    {% elif job.num_files == 0 and job.current_file_num > 0 %}
        <label class="form-control-plaintext
        col-lg-10">{{job.current_file_num}} of Unknown Total</label>
    {% else %}
        <label class="form-control-plaintext col-lg-10">N/A</label>
    {% endif %}
	</div>
	</div>
    <div class="row col-lg-12">
        <table id="jobort_tbl" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true">
            <thead><tr class="thead-light"><th>When</th><th>Details</th></tr></thead>
            <tbody>
            {% for log in logs %}
                <tr><td>{{log.log_date|vicdate}}</td><td>{{log.log|safe}}</td></tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div class="containter">
{% endblock main_content %}
{% block script_content %}
<script>
    {% if job.pa_job_state != "Completed" %}
        setTimeout(function(){ window.location.reload(1); }, 3000 )
    {% endif %}
</script>
{% endblock script_content %}
