{% extends "freeadmin/generic_form.html" %}
{% load freeadmin %}
{% block form %}
    {% csrf_token %}
  <tr>
        <th>{% trans "Plugin Name:" %}</th>
        <td>{{ form.vcp_name }}</td>
  </tr>
  <tr>
        <th>{% trans "Available Plugin Version:" %}</th>
           {% if 'Not available' in form.vcp_available_version%}
        <td><font color="RED">{{ form.vcp_available_version}}</font></td>
            {% else %}
        <td>{{ form.vcp_available_version}}</td>
        {% endif %}

  </tr>
 
  <tr>
        <th>{% trans "Installed Plugin Version:" %}</th>
        <td>{{ form.vcp_version }}</td>
  </tr>

{% admin_form form %}
    {% if  form.is_https %}
      <tr>
            <th>{% trans "Enable vCenter Plugin over https:" %}</th>
            <td>
              {{ aux_enable_https }}
              &nbsp&nbsp
              <button 
                id="btn_vcenterauxsettings"
                data-dojo-type="dijit.form.Button"
                type="button">
                  {% trans "Edit" %}
                  <script
                    type="dojo/method"
                    data-dojo-event="onClick"
                    data-dojo-args="evt">
                      editObject('{% trans "Edit vCenter Auxiliary Settings"|force_escape|force_escape %}',
                        '{% url "vcp_vcenterauxsettings" %}', [this,]);
                  </script>
              </button>
            </td>
      </tr>
      {% endif %}
{% endblock %}
  
{% block buttons %}
<button id="btn_vcenterconfiguration_Ok" data-dojo-type="dijit.form.Button" type="submit" data-dojo-props="type:'submit'"  class="submitform">
    {% block oklabel %}{% trans "Install" %}{% endblock %}
</button>
{% if not inline %}
<button id="btn_vcenterconfiguration_Cancel" data-dojo-type="dijit.form.Button">
    {% block cancellabel %}{% trans "Uninstall" %}{% endblock %}
    <script type="dojo/method" data-dojo-event="onClick" data-dojo-args="e">
        
        form = getForm(this);
        doSubmit({
            form: form,
            event: e,
            url: '{% url "vcp_uninstall" %}',
        });
    </script>
</button>
{% endif %}
{% with form.advanced_fields as advfields %}
{% include "freeadmin/advanced_btn.html" %}
{% endwith %}

    {% block extra_buttons %}
         <button id="btn_vcenterconfiguration_Update" data-dojo-type="dijit.form.Button">{% trans "Upgrade" %}
            <script type="dojo/method" data-dojo-event="onClick" data-dojo-args="e">
               
              form = getForm(this);
                doSubmit({
                    form: form,
                    event: e,
                    url: '{% url "vcp_upgrade" %}',
                    });               
             
                </script>
        </button>
	<button id="btn_vcenterconfiguration_Repair" data-dojo-type="dijit.form.Button">{% trans "Repair" %}
            <script type="dojo/method" data-dojo-event="onClick" data-dojo-args="e">
               
              form = getForm(this);
                doSubmit({
                    form: form,
                    event: e,
                    url: '{% url "vcp_repair" %}',
                    });               
             
                </script>
        </button>

    {% endblock %}       
         
       {% if not form.vcp_is_update_available %}
       <script type="dojo/method"> 
          document.getElementById("btn_vcenterconfiguration_Update").disabled = true;
       </script>
       {% endif %}
       {% if  form.vcp_is_installed %}
       <script type="dojo/method">
          document.getElementById("btn_vcenterconfiguration_Ok").disabled = true;
          document.getElementById("btn_vcenterconfiguration_Cancel").disabled = false;
          document.getElementById("btn_vcenterconfiguration_Repair").disabled = false;      
       </script>
        {% else %}
       <script type="dojo/method">           
          document.getElementById("btn_vcenterconfiguration_Ok").disabled = false;      
          document.getElementById("btn_vcenterconfiguration_Cancel").disabled = true;
          document.getElementById("btn_vcenterconfiguration_Repair").disabled = true;
       </script>
       {% endif %}       
       {% if 'Not available' in form.vcp_available_version%}
         <script type="dojo/method">
         document.getElementById("btn_vcenterconfiguration_Ok").disabled = true;
         document.getElementById("btn_vcenterconfiguration_Update").disabled = true;
       </script>
       {% endif %}
{% endblock %}
