{% extends "../base.html" %}
{% block content %}
<div class="row">
	<div class="col-md-9">
		<h2><span translate>Plates</span> <a class="btn btn-default" href="/plate/add" role="button"><span class="glyphicon glyphicon-plus"></span></a>
			<a class="btn btn-success" href="/static/?width={{width}}&height={{height}}&dst=/plate/add-support&exit=/plates"
			 role="button"><span class="glyphicon glyphicon-plus"></span> <translate>3D Editor</translate></a>
			{% if os == "linux" %}
			<a class="btn btn-default" href="/plate/add-usb" role="button"><span class="glyphicon glyphicon-plus"></span> <translate>USB</translate></a>
			{% endif %}
		</h2>
	</div>
	<div class="col-md-3">
		<input id="search" placeholder="Search Plates" class="form-control compact-input">
		<translate class="hide">Search Plates</translate>
	</div>
</div>
<div class="row">
	<div class="col-md-12">
		{% if freeSpace < 1000 && freeSpace>0 %}
			<div class="alert alert-danger" translate>Free space available on your disk is low. Please remove some plates.</div>
			{% endif %}
	</div>
</div>
<translate class="hide" id="delete-confirm">Are you sure you want to delete this plate?</translate>
<translate class="hide" id="regenerate-confirm">Are you sure you want to regenerate the layers of this plate?</translate>
<translate class="hide" id="stop-confirm">Are you sure you want to stop printing?</translate>
<translate class="hide" id="start-confirm">Are you sure you want to print plate from the start?</translate>
<translate class="hide" id="calibrate-confirm">Are you sure you want to print the calibration plate?</translate>
<table class="table table-striped table-bordered model-list" id="plates">
	<thead>
		<tr>
			<th translate>Plate</th>
			<th translate>Preview</th>
			<th translate>Details</th>
			<th translate>Action</th>
			<th translate>Printing</th>
		</tr>
	</thead>
	{% if plates %}
	{% for row in plates %}{% if row.PlateID != 0 %}
	<tr class="{% if row.Processed %}plate-processed{% endif %}">
		<td>
			<b>{{row.Path}}</b>
			<br><br>
			{% if !row.profileError %}
			<span class="glyphicon glyphicon-tint"></span> 
			<a href="/profile/edit/{{row.profileID}}">{{row.ProfileName}}</a><br>
			<span class="glyphicon glyphicon-resize-small"></span> 
			X: {{row.XRes}}μm Y: {{row.YRes}}μm Z: {{row.ZRes}}μm<br>
			<span class="glyphicon glyphicon-time"></span> 
			<translate>Cure Time</translate>: {{row.cureTime}}s<br>
			{% if row.ProfileUpdate>row.Updated %}			
				<div class="notice"><span class="glyphicon glyphicon-alert"></span> <translate>Plate generated using old profile data.</translate></div>
			{% endif %}
			{% else %}
			<div class="alert alert-warning"><span class="glyphicon glyphicon-alert"></span> <translate>Profile not found.</translate></div>
			{% endif %}
			{% if row.Risky %}			
				<div class="notice"><span class="glyphicon glyphicon-alert"></span> <a href="/plate/preview/{{ row.PlateID }}" translate>Plate contains overhang areas.</a></div>
			{% endif %}
		</td>
		<td>
			{% if row.Preview %}<img src="static/plates/{{row.PlateID}}/3d.png">{% endif %}
		</td>
		<td>
			<dl class="small">
				<dt><span class="glyphicon glyphicon-time"></span>
					<translate>Print Time</translate>
				</dt>
				<dd>{{row.PrintTime}}</dd>
				<dt><span class="glyphicon glyphicon-tint"></span>
					<translate>Resin Usage</translate>
				</dt>
				<dd>{{row.TotalSolidArea}}ml</dd>
				<dt><span class="glyphicon glyphicon-usd"></span>
					<translate>Resin Cost</translate>
				</dt>
				<dd>{{row.Price}}</dd>
				{% if row.StopLayers %}
				<dt><span class="glyphicon glyphicon-stop"></span>
					<translate>Stop Layers</translate>
				</dt>
				<dd>{{row.StopLayers}}</dd>
				{% endif %}
			</dl>
		</td>
		<td>
			{% if row.Corrupted==true %}
			<div class="alert alert-danger"><span class="glyphicon glyphicon-alert"></span>
				<translate>This plate is corrupt.</translate>
			</div><br>
			{% endif %}
			<div class="alert alert-danger req-not-processed"><span class="glyphicon glyphicon-exclamation-sign"></span>
				<transplate>The plate is not sliced yet.</transplate></div>
			<div class="req-not-processed"><br></div>
			<a class="btn btn-primary" href="/plate/edit/{{ row.PlateID }}"><span class="glyphicon glyphicon-pencil"></span>
			</a>

			{% if row.PlateID != status.PlateID or status.Printing == false %}
			<a class="btn btn-danger ask" href="/plate/delete/{{ row.PlateID }}" data-ask="delete-confirm"><span class="glyphicon glyphicon-trash"></span>
			</a>
			{% endif %}

			{% if row.Type=="stl" %}
			<a href="/static/?src=/static/plates/{{ row.PlateID }}/plate.stl&dst=/plate/add-support&width={{width}}&height={{height}}"
			 class="btn btn-success"><span class="glyphicon glyphicon-pencil"></span>
				<translate>3D</translate>
			</a>
			{% endif %}
			<a class="btn btn-success" href="/plate/preview/{{ row.PlateID }}"><span class="glyphicon glyphicon-eye-open"></span></a>

			<a class="btn btn-success req-processed" href="/plate/download/{{ row.PlateID }}/nanodlp"><span class="glyphicon glyphicon-download-alt"></span></a>

			<br>
			{% if (row.Processed==true && row.Type!="" && (( row.PlateID != status.PlateID or status.Printing == false))) or (row.Type!="" && !autoSlice) %}
			<a class="btn btn-success ask req-no-slicing" href="/plate/regenerate/{{ row.PlateID }}" data-ask="regenerate-confirm"><span
				 class="glyphicon glyphicon-refresh"></span> <translate>Regenerate</translate></a>
			{% endif %}

			<a class="btn btn-warning req-processed" href="/plate/cover/{{ row.PlateID }}"><span class="glyphicon glyphicon-plus"></span>
				<translate>Blackout</translate>
			</a>
			<div class="plate" data-plate="{{row.PlateID}}" data-total="{{row.LayersCount}}">
				<div class="details hide">
					<div class="alert alert-danger"><span class="glyphicon glyphicon-refresh"></span> <translate>Slicing...</translate>
						<div class="progress progress-striped active">
							<div style="width: 0%" class="progress-bar progress-bar-success"></div>
						</div>
					</div>
				</div>
			</div>
		</td>
		<td>
			{% if status.Printing == false %}
			<form action="/printer/start/{{ row.PlateID }}" method="POST">
				<div class="input-append">
					<input id="appendedtext" name="LayerID" class="form-control compact-input" value="{% if row.PlateID == status.PlateID %}{{status.ResumeID}}{% endif %}" type="number" min="0" size="3">
					<translate class="hide">Layer ID</translate>
					<span class="add-on"> <span translate>of</span> {{row.LayersCount}} <span translate>Layers</span></span>
					<button type="submit" class="btn btn-warning resume req-processed" data-confirm='Are you sure you want to resume plate {{row.Path}} from layer [LayerID]?' value="Submit"><span class="glyphicon glyphicon-play"></span> <translate>Resume</translate></button>
				</div>
			</form>
			<a class="btn btn-success ask req-processed" href="/printer/start/{{ row.PlateID }}" data-ask="start-confirm"><span class="glyphicon glyphicon-play"></span> <translate>Start Print</translate></a>
			{% else %}
			{% if row.PlateID == status.PlateID %}
			<div class="input-append">
				<a class="btn btn-danger ask" href="/printer/stop" title="stop" data-ask="stop-confirm"><span class="glyphicon glyphicon-stop"></span></a>
				<br>
				<br>
				<span class="add-on"><span translate>Layer</span> {{ status.ResumeID }} <span translate>of</span>
					{{row.LayersCount}}</span>
			</div>
			{% endif %}
			{% endif %}
		</td>
	</tr>
	{% endif %}{% endfor %}
	{% else %}
	<tr>
		<td colspan="999">
			<div class="text-center" translate>
				No Plates
			</div>
		</td>
	</tr>
	{% endif %}

	<tr>
		<td translate>Plate Generator</td>
		<td colspan="2" translate>Create 3D shapes by repeating an image frame</td>
		<td>
			<a class="btn btn-info" href="/plate/layer-generator" translate>Upload Image</a>
			<br>
			<a class="btn btn-info" href="/plate/paint" translate>Paint</a>
		</td>
		<td></td>
	</tr>

	<tr>
		<td><span translate>Calibration Plate</span>{{helpModal("calibration-plate")}}</td>
		<td><span translate>Rect:</span> {{generator.BlockWidth}}*{{generator.BlockHeight}}*{{generator.Depth}}
			<br>
			<span translate>Pillars:</span> {{generator.PillarSize}}*{{generator.Depth}}
		</td>
		<td>-</td>
		<td>
			<a class="btn btn-primary" href="/plate/generator" title="Generate Calibration Plate" translate>Generate</a>
			<br>
			<a class="btn btn-success" href="/plate/preview/0"><span class="glyphicon glyphicon-eye-open"></span></a>
		</td>
		<td>
			{% if 0 != status.PlateID or status.Printing == false %}
			<a class="btn btn-success ask" href="/printer/start/0" data-ask="calibrate-confirm"><span class="glyphicon glyphicon-play"></span></a>
			{% else %}
			<div class="input-append">
				<a class="btn btn-danger ask" href="/printer/stop" title="stop" data-ask="stop-confirm"><span class="glyphicon glyphicon-stop"></span></a>
			</div>
			{% endif %}
		</td>
	</tr>

</table>
{% if freeSpace > 0 %}
<sub><span class="glyphicon glyphicon-hdd"></span>
	<translate>Free Disk Space</translate> {{freeSpace}}MB
</sub>
<br>
<br>
{% endif %}
{% endblock %}