{% load i18n %}
{% load sizefieldtags %}
{% load crispy_forms_tags %}
{% load static %}
{% if is_operator %}
  {% if instance.cloud_init %}
    {% include "dashboard/_ci-data-help.html" %}
    <div class="row">
      <div class="col-sm-12">
        <h3>
          {% trans "Cloud-init" %}
        </h3>
        <script src="{% static 'dashboard/js/ace/ace.js' %}" type="text/javascript" charset="utf-8"></script>
        <form method="POST" action="{{ op.cloudinit_change.get_url }}" id="resource-cidata-form">
          {% csrf_token %}
          {{ ci_data.ci_meta_data|as_crispy_field }}
          <div id="ace-meta-data" style="border: 1px solid #ccc;"></div>
          <div style="height: 160px;"></div>
          {{ ci_data.ci_network_config|as_crispy_field }}
          <div id="ace-network-data" style="border: 1px solid #ccc;"></div>
          <div style="height: 160px;"></div>
          {{ ci_data.ci_user_data|as_crispy_field }}
          <div id="ace-user-data" style="border: 1px solid #ccc;"></div>
          <div style="height: 360px;"></div>
          <button type="submit" class="btn btn-success btn-sm change-resources-button"
            id="vm-details-cidata-save" data-vm="{{ instance.pk }}"
            {% if not save_resources_enabled %}disabled{% endif %}>
            <i class="fa fa-floppy-o"></i> {% trans "Validate & Save" %}
          </button>{% if not save_resources_enabled %}{% trans "Stop your VM to change cloud-init options." %}{% endif %}
        </form>
      </div>
    </div>
  {% else %}
    <div class="alert alert-warning">
      {% trans "Cloud-init is inactive" %}
    </div>
  {% endif %}
{% else %}
<div class="alert alert-warning">
  {% trans "You are not authorized to access the cloud-init options." %}
</div>
{% endif %}