+{% extends 'qcg/base.html' %}
+{% load staticfiles bootstrap3 qcg_utils %}
+
+{% block extra_css %}
+ <link href="{% static 'qcg/selectize/selectize.bootstrap3.css' %}" rel="stylesheet">
+ <link href="{% static 'qcg/datetimepicker/bootstrap-datetimepicker.min.css' %}" rel="stylesheet">
+{% endblock %}
+
+{% block extra_js %}
+ <script src="{% static 'qcg/selectize/selectize.min.js' %}"></script>
+ <script src="{% static 'qcg/formset/jquery.formset.js' %}"></script>
+ <script src="{% static 'qcg/moment/moment.min.js' %}"></script>
+ <script src="{% static 'qcg/moment/pl.js' %}"></script>
+ <script src="{% static 'qcg/datetimepicker/bootstrap-datetimepicker.min.js' %}"></script>
+
+ <script>
+ $(function() {
+ $('#id_application, #id_host').selectize();
+ $('#id_arguments,#id_properties,#id_native').selectize({
+ plugins: ['remove_button'],
+ create: true,
+ render: {
+ option_create: function(data, escape) {
+ return '<div class="create">Dodaj <strong>' + escape(data.input) + '</strong>…</div>';
+ }
+ }
+ });
+ $('#id_queue').selectize({
+ create: true,
+ render: {
+ option_create: function(data, escape) {
+ return '<div class="create">Wybierz <strong>' + escape(data.input) + '</strong>…</div>';
+ }
+ }
+ });
+ $('#id_modules').selectize({
+ plugins: ['remove_button']
+ });
+
+ // hide delete checkbox in empty env form
+ $('#env-form-empty').find('div.form-group:last-of-type').hide();
+ $('#env-controls').find('> div').formset({
+ formTemplate: '#env-form-empty',
+ parent: '#env-controls',
+ addLinkParent: '#add-env-form',
+ addText: 'dodaj »',
+ addCssClass: 'add-btn',
+ deleteText: 'Usuń',
+ deleteCssClass: 'delete-btn btn btn-xs btn-danger'
+ });
+
+ $('#id_not_before,#id_not_after').datetimepicker({
+ locale: 'pl',
+ minDate: moment()
+ });
+
+ $('input[name="notify_type"],input[name="watch_output_type"],input[name="preprocess_type"],input[name="postprocess_type"]').on('change', function () {
+ $(this).tab('show');
+ }).each(function() {
+ $(this).parent().toggleClass('active', this.checked);
+
+ if (this.checked)
+ $(this).tab('show');
+ });
+
+ $('#toggle-advanced').click(function(e) {
+ e.preventDefault();
+ $('form .collapse').collapse('toggle');
+ $(this).find('span').text(this.text == "Pokaż zaawansowane" ? "Ukryj zaawansowane" : "Pokaż zaawansowane");
+ });
+
+ $('#new-env').click(function(e) {
+ e.preventDefault();
+ $('#env-modal').modal('show');
+ });
+
+ $('#env-form').submit(function(e) {
+ e.preventDefault();
+ $('#env-modal').modal('hide');
+
+ $('#id_environment')[0].selectize.createItem($('#id_env_name').val() + '=' + $('#id_env_value').val());
+ });
+ });
+ </script>
+{% endblock %}
+
+{% block container %}
+ <h1 class="page-header">{% block title %}Zleć zadanie{% endblock %}</h1>
+
+ <form action="." method="post" class="form-horizontal">
+ {% csrf_token %}
+
+ <!-- Nav tabs -->
+ <ul class="nav nav-tabs" style="margin-bottom: 20px">
+ <li role="presentation" class="active"><a href="#basic" data-toggle="tab">Podstawowe</a></li>
+ <li role="presentation"><a href="#resources" data-toggle="tab">Zasoby</a></li>
+ <li role="presentation"><a href="#files" data-toggle="tab">Pliki</a></li>
+ <li role="presentation"><a href="#environment" data-toggle="tab">Środowisko</a></li>
+ <li role="presentation"><a href="#reservation" data-toggle="tab">Rezerwacja</a></li>
+ <li role="presentation"><a href="#monitoring" data-toggle="tab">Powiadomienia</a></li>
+ <li role="presentation"><a href="#other" data-toggle="tab">Inne</a></li>
+ </ul>
+
+ <div class="tab-content">
+ <fieldset id="basic" class="tab-pane active" role="tabpanel">
+ {% bootstrap_field form.application layout="horizontal" %}
+ <div class="row" style="margin-top: -15px; margin-bottom: 15px">
+ <div class="col-sm-offset-3 col-md-offset-4 col-sm-9 col-md-6">
+ {# TODO grid ftp #}
+ <a id="add-main-file" href="#">wybierz plik główny »</a>
+ </div>
+ </div>
+
+ {% bootstrap_field form.executable layout="horizontal" form_group_class="form-group collapse" %}
+ {% bootstrap_field form.arguments layout="horizontal" %}
+ {% bootstrap_field form.name layout="horizontal" %}
+ {% bootstrap_field form.note layout="horizontal" %}
+ {% bootstrap_field form.grant layout="horizontal" %}
+ </fieldset>
+
+ <fieldset id="resources" class="tab-pane" role="tabpanel">
+ {% bootstrap_field form.host layout="horizontal" %}
+ {% bootstrap_field form.queue layout="horizontal" %}
+ {% bootstrap_field form.procs layout="horizontal" %}
+ {% bootstrap_field form.nodes layout="horizontal" form_group_class="form-group collapse" %}
+ {% bootstrap_field form.wall_time layout="horizontal" %}
+ {% bootstrap_field form.memory layout="horizontal" %}
+ {% bootstrap_field form.memory_per_slot layout="horizontal" %}
+ </fieldset>
+
+ <fieldset id="files" class="tab-pane" role="tabpanel">
+ {% bootstrap_field form.input layout="horizontal" %}
+ {% bootstrap_field form.output layout="horizontal" %}
+ {% bootstrap_field form.error layout="horizontal" %}
+ {% bootstrap_field form.stage_in layout="horizontal" %}
+ {% bootstrap_field form.stage_out layout="horizontal" %}
+ </fieldset>
+
+ <fieldset id="environment" class="tab-pane" role="tabpanel">
+ {% bootstrap_field form.properties layout="horizontal" %}
+ {{ env_formset.management_form }}
+
+ <div class="form-group">
+ <label class="col-sm-3 col-md-4 control-label">Zmienne środowiskowe</label>
+ <div class="col-sm-9 col-md-6">
+ <div id="env-controls">
+ {% for env_form in env_formset %}
+ <div>{% bootstrap_form env_form layout='inline' %}</div>
+ {% endfor %}
+ </div>
+ <div id="add-env-form"></div>
+ <div id="env-form-empty" style="display: none">
+ {% bootstrap_form env_formset.empty_form layout='inline' %}
+ </div>
+ </div>
+ </div>
+
+ {% bootstrap_field form.modules layout="horizontal" %}
+ </fieldset>
+
+ <fieldset id="reservation" class="tab-pane" role="tabpanel">
+ {% bootstrap_field form.not_before layout="horizontal" %}
+ {% bootstrap_field form.not_after layout="horizontal" %}
+ {% bootstrap_field form.deadline layout="horizontal" %}
+ {% bootstrap_field form.reservation layout="horizontal" form_group_class="form-group collapse" %}
+ </fieldset>
+
+ <fieldset id="monitoring" class="tab-pane" role="tabpanel">
+ {% bootstrap_checkbox form.monitoring %}
+
+ <div class="form-group">
+ <label class="col-sm-3 col-md-4 control-label">Monitorowanie stanu</label>
+ <div class="col-sm-9 col-md-6">
+ <div class="btn-group" data-toggle="buttons">
+ {% for option in form.notify_type %}
+ <label class="btn btn-default">
+ <input type="radio" autocomplete="off" name="{{ option.name }}" value="{{ option.choice_value }}"
+ {% if option.is_checked %}checked{% endif %}
+ data-target=".notify-type-{{ option.choice_value }}"> {{ option.choice_label }}
+ </label>
+ {% endfor %}
+ </div>
+ </div>
+ </div>
+
+ <div class="tab-content">
+ <div class="tab-pane notify-type-0"></div>
+
+ <div class="tab-pane notify-type-1 notify-type-2" style="margin-top: 15px">
+ {% bootstrap_field form.notify_address layout="horizontal" %}
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-sm-3 col-md-4 control-label">Monitorowanie wyjścia</label>
+ <div class="col-sm-9 col-md-6">
+ <div class="btn-group" data-toggle="buttons">
+ {% for option in form.watch_output_type %}
+ <label class="btn btn-default">
+ <input type="radio" autocomplete="off" name="{{ option.name }}" value="{{ option.choice_value }}"
+ {% if option.is_checked %}checked{% endif %}
+ data-target=".watch-output-type-{{ option.choice_value }}"> {{ option.choice_label }}
+ </label>
+ {% endfor %}
+ </div>
+ </div>
+ </div>
+
+ <div class="tab-content">
+ <div class="tab-pane watch-output-type-0"></div>
+
+ <div class="tab-pane watch-output-type-1 watch-output-type-2" style="margin-top: 15px">
+ {% bootstrap_field form.watch_output_address layout="horizontal" %}
+ {% bootstrap_field form.watch_output_pattern layout="horizontal" %}
+ </div>
+ </div>
+ </fieldset>
+
+ <fieldset id="other" class="tab-pane" role="tabpanel">
+ <div class="form-group">
+ <label class="col-sm-3 col-md-4 control-label">Preprocessing</label>
+ <div class="col-sm-9 col-md-6">
+ <div class="btn-group" data-toggle="buttons">
+ {% for option in form.preprocess_type %}
+ <label class="btn btn-default">
+ <input type="radio" autocomplete="off" name="{{ option.name }}" value="{{ option.choice_value }}"
+ {% if option.is_checked %}checked{% endif %}
+ data-target=".preprocess-type-{{ option.choice_value }}"> {{ option.choice_label }}
+ </label>
+ {% endfor %}
+ </div>
+ </div>
+ </div>
+
+ <div class="tab-content">
+ <div class="tab-pane preprocess-type-0"></div>
+
+ <div class="tab-pane preprocess-type-1" style="margin-top: 15px">
+ {% bootstrap_field form.preprocess_cmd layout="horizontal" %}
+ </div>
+
+ <div class="tab-pane preprocess-type-2" style="margin-top: 15px">
+ {% bootstrap_field form.preprocess_script layout="horizontal" %}
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-sm-3 col-md-4 control-label">Postprocessing</label>
+ <div class="col-sm-9 col-md-6">
+ <div class="btn-group" data-toggle="buttons">
+ {% for option in form.postprocess_type %}
+ <label class="btn btn-default">
+ <input type="radio" autocomplete="off" name="{{ option.name }}" value="{{ option.choice_value }}"
+ {% if option.is_checked %}checked{% endif %}
+ data-target=".postprocess-type-{{ option.choice_value }}"> {{ option.choice_label }}
+ </label>
+ {% endfor %}
+ </div>
+ </div>
+ </div>
+
+ <div class="tab-content">
+ <div class="tab-pane postprocess-type-0"></div>
+
+ <div class="tab-pane postprocess-type-1" style="margin-top: 15px">
+ {% bootstrap_field form.postprocess_cmd layout="horizontal" %}
+ </div>
+
+ <div class="tab-pane postprocess-type-2" style="margin-top: 15px">
+ {% bootstrap_field form.postprocess_script layout="horizontal" %}
+ </div>
+ </div>
+
+ {% bootstrap_field form.native layout="horizontal" %}
+ {% bootstrap_checkbox form.persistent %}
+ {% bootstrap_checkbox form.use_scratch %}
+ </fieldset>
+ </div>
+
+ <hr>
+
+ <div class="row">
+ <div class="col-sm-offset-3 col-md-offset-4 col-sm-9 col-md-6">
+ <button type="submit" class="btn btn-primary">Zleć zadanie</button>
+ <button type="reset" class="btn btn-warning">Resetuj</button>
+ <a id="toggle-advanced" href="#"><span class="text-muted">Pokaż zaawansowane</span></a>
+ </div>
+ </div>
+ </form>
+
+{% endblock %}