{% extends "base.html" %}
{% comment %}
#
# This file is part of Plinth.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
{% endcomment %}

{% load bootstrap %}

{% block main_block %}

{% if pagekite_status = 'not_installed' %}

  <p>PageKite is not installed, please install it. PageKite comes
  pre-installed with {{ cfg.box_name }}. On any Debian based system
  (such as {{ cfg.box_name }}) you may install it using the command
  'aptitude install pagekite'</p>

{% else %}

  <form class="form" method="post">
    {% csrf_token %}

    {% include 'bootstrapform/field.html' with field=form.enabled %}

    <div id='pagekite-post-enabled-form'
         style='display: {{ form.enabled.value|yesno:'block,none' }};'>
      <h3>PageKite Account</h3>
      {% include 'bootstrapform/field.html' with field=form.server %}
      {% include 'bootstrapform/field.html' with field=form.kite_name %}
      {% include 'bootstrapform/field.html' with field=form.kite_secret %}

      <h3>Services</h3>
      {% include 'bootstrapform/field.html' with field=form.http_enabled %}
      {% include 'bootstrapform/field.html' with field=form.ssh_enabled %}
    </div>

    <input type="submit" class="btn-primary" value="Update setup"/>

  </form>

{% endif %}

{% endblock %}

{% block js_block %}
  {{ js|safe }}

  <script type="text/javascript">
    (function($) {

    $('#id_pagekite-enabled').change(function() {
      if ($('#id_pagekite-enabled').prop('checked')) {
        $('#pagekite-post-enabled-form').show('slow');
      } else {
        $('#pagekite-post-enabled-form').hide('slow');
      }
    });

    })(jQuery);
  </script>
{% endblock %}
