
{% extends "base.html" %}
{% block pagename %}mobilefirestarter{% endblock %}
{% block title %}Запустить стрельбу{% endblock %}
{% load lookup %}

{% block body %}


<div class="header-bottom-padding"></div>
<div class="container-fluid" style="padding-bottom: 15px;">

{% include "apk_upload_form.html" %}
{% include "tests_upload_form.html" %}

<form method="POST" action="/mobilefirestarter/fire" id="mobileFireForm">
	{% block waiter %}
	<div class="waiter_body alert alert-warning" id="waiter_body" style="display: none;">
		<span>Ждём запуска онлайн-стрельбы с танка <span id="tank" style="font-weight: bold;"></span>:<span id="port" style="font-weight: bold;"></span></span>
		<br>
		<label style="font-weight: bold;">Статус:&emsp;</label><span id="status" data-status=""></span>
		<span style="margin-left: 0.4em;"><i class="krutilka fa fa-circle-o-notch fa-spin" aria-hidden="true"></i></span>
		<span style="display: none;" id="link" data-link=""></span>
	</div>
	{% endblock %}

	{% block error %}
		{% if error %}
            <div class="error_block alert alert-danger" id="error_block" role="alert">
                <span id="error_text">{{ error }}</span>
            </div>
		{% else %}
            <div class="error_block alert alert-danger" id="error_block" style="display: none" role="alert">
                <span id="error_text"></span>
            </div>
		{% endif %}
	{% endblock %}

	<div class="row">
		<div class="col-md-10">
			<div class="input-group mobilefirestarter-input">
				<span class="input-group-addon mobilefirestarter-input__title" id="input-group-addon__apk">APK&emsp;<i style="display: none; margin-top:-1px" class="krutilka fa fa-circle-o-notch fa-spin" aria-hidden="true"></i></span>
				<select class="form-control mobilefirestarter-input__apk selectpicker" style="margin-left: 0px;" data-type="apk" data-live-search="true" data-style="btn-secondary" id="apk_select"  size="1" name="apk_select">
					<option value="">--</option>
					{% if apk_files %}
						<option value="" disabled='disabled' style="font-weight: bold;">APK</option>
					{% endif %}
					{% for apk in apk_files %}
                        <option value="{{ apk.path }}">{{ apk.dsc }}</option>
					{% endfor %}
				</select>
			</div>
		</div>
		<div class="col-md-2" style="float: right; padding-left: 0;">
	    	<button class="btn btn-secondary mobilefirestarter-input" id="upload_apk_button" type="button" data-toggle="collapse" data-target="#apkUploadForm" aria-expanded="false" aria-controls="apkUploadForm">Залить файл <span class="caret"></span></button>
		</div>
	</div>



    <div class="input-group mobilefirestarter-input">
		<span class="input-group-addon mobilefirestarter-input__title" >Package</span>
		<input class="form-control mobilefirestarter-input" placeholder="package" data-type="job_name" size=120 maxlength=120 value="{{ conf|lookup:'meta'|lookup:'job_name' }}" id="package_input" name="package_input"/>
	</div>

    <div class="row">
		<div class="col-md-10">
			<div class="input-group mobilefirestarter-input">
				<span class="input-group-addon mobilefirestarter-input__title" id="input-group-addon__apk">APK с тестами&emsp;<i style="display: none; margin-top:-1px" class="krutilka fa fa-circle-o-notch fa-spin" aria-hidden="true"></i></span>
				<select class="form-control mobilefirestarter-input__tests selectpicker" style="margin-left: 0px;" data-type="tests" data-live-search="true" data-style="btn-secondary" id="tests_select"  size="1" name="tests_select">
					<option value="">--</option>
					{% if tests_files %}
						<option value="" disabled='disabled' style="font-weight: bold;">APK с тестами</option>
					{% endif %}
					{% for tests in tests_files %}
                        <option value="{{ tests.path }}">{{ tests.dsc }}</option>
					{% endfor %}
				</select>
			</div>
		</div>
		<div class="col-md-2" style="float: right; padding-left: 0;">
	    	<button class="btn btn-secondary mobilefirestarter-input" id="upload_tests_button" type="button" data-toggle="collapse" data-target="#testsUploadForm" aria-expanded="false" aria-controls="testsUploadForm">Залить файл <span class="caret"></span></button>
		</div>
	</div>



    <div class="input-group mobilefirestarter-input">
		<span class="input-group-addon mobilefirestarter-input__title" >Test package</span>
		<input class="form-control mobilefirestarter-input" placeholder="test_package" data-type="test_package" size=120 maxlength=120 id="test_package_input" name="test_package_input"/>
	</div>
    <div class="input-group mobilefirestarter-input">
		<span class="input-group-addon mobilefirestarter-input__title" >Test classes</span>
		<input class="form-control mobilefirestarter-input" placeholder="test_classes через запятую" data-type="test_classes" size=120 maxlength=120 id="test_classes_input" name="test_classes_input"/>
	</div>
    <div class="input-group mobilefirestarter-input">
		<span class="input-group-addon mobilefirestarter-input__title" >Test runner</span>
		<input class="form-control mobilefirestarter-input" value="android.support.test.runner.AndroidJUnitRunner" placeholder="test_runner" data-type="test_runner" size=120 maxlength=120 id="test_runner_input" name="test_runner_input"/>
	</div>
    <div class="input-group mobilefirestarter-input">
		<span class="input-group-addon mobilefirestarter-input__title" >Таск</span>
		<input class="form-control mobilefirestarter-input" value="LOAD-640" placeholder="startrek task" data-type="task" size=120 maxlength=120 id="task_input" name="task_input"/>
	    {% if recent_user_tasks %}
		<span class="input-group-addon mobilefirestarter-suggest__container">
			Недавние:
			{% for task in recent_user_tasks %}
				<span class="mobilefirestarter-suggest mobilefirestarter-suggest__task link-dotted clickable">{{ task }}</span>
			{% endfor %}
		</span>
		{% endif %}
    </div>
    <div class="input-group mobilefirestarter-input">
		<span class="input-group-addon mobilefirestarter-input__title" >Танк</span>
		<input class="form-control mobilefirestarter-input" value="213" placeholder="зомбик или вольта сервер" data-type="tank" size=120 maxlength=256 id="tank_input" name="tank_input"/>
	    {% if recent_user_tanks %}
		<span class="input-group-addon mobilefirestarter-suggest__container">
			Недавние:
			{% for tank in recent_user_tanks %}
				<span class="mobilefirestarter-suggest mobilefirestarter-suggest__tank link-dotted clickable">{{ tank }}</span>
			{% endfor %}
		</span>
		{% endif %}
    </div>
	<div class="input-group mobilefirestarter-input">
		<span class="input-group-addon mobilefirestarter-input__title" >Комментарий</span>
		<input class="form-control" placeholder="необязательно" data-type="job_dsc" size=120 maxlength=120 id="job_dsc_input" name="job_dsc_input"/>
	</div>
<br style="font-size: 6pt;">
<button class="btn btn-brand" name="submitMobileFire" id="submitMobileFire">Огонь!</button>
<br>
<br>
</form>

<!-- Modal config-->
<div class="modal fade" id="configModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title"><span class="person">{{ person }}</span></h4>
      </div>
      <div class="modal-body">
          <div id="jobsList">
          </div>
      </div>
    </div>
  </div>
</div>

<!-- <script nonce='{{ common.CSP_SCRIPT_NONCE }}' src="/media/ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script nonce='{{ common.CSP_SCRIPT_NONCE }}'>
    var editor = ace.edit("editor");
    document.getElementById('editor').style.fontSize='12pt';
    editor.getSession().setMode("ace/mode/yaml");
    editor.setShowPrintMargin(false);
    editor.commands.addCommand({
    	  name: 'submit_form.',
    	  bindKey: {win: 'Ctrl-Enter', mac: 'Command-Enter'},
    	  exec: function(editor) {
    		  	$("#mobilefirestarter-submit").click()
    		  }
    	  });
    editor.setOptions({
	    maxLines: Infinity
	});
</script>-->

<script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript">
    $(document).ready(function(){
        $('#apk_select').selectpicker();
        $('#tests_select').selectpicker();
        $('button.btn.dropdown-toggle.btn-secondary[data-id="apk_select"]').css('margin-left', '0px');
        $('button.btn.dropdown-toggle.btn-secondary[data-id="tests_select"]').css('margin-left', '0px');
    });
</script>

</div>

<link href="/media/css/mobilefirestarter.css?version=43.4" type="text/css" rel="stylesheet" />
<script nonce='{{ common.CSP_SCRIPT_NONCE }}' type='text/javascript' src='/media/js/vendor/jquerymd5.js'></script>
<script nonce='{{ common.CSP_SCRIPT_NONCE }}' type='text/javascript' src='/media/js/mobilefirestarter.js?version=43.4'></script>
{% endblock %}
