{% extends "base.html" %}

{% block pagebanner %}
  <div class="header">
      <h2>{{ host.hostname }}</h2>
  </div>
  <br/>
{% endblock %}

{% block sidebar %}
{% include "navbar.tmpl" %}
<ul class="sidebar">
<li><a href="/hostbase/{{ host.id }}/" class="sidebar">host info</a></li>
<li><a href="/hostbase/{{ host.id }}/dns/" class="sidebar">detailed dns info</a></li>
<li><a href="/hostbase/{{ host.id }}/dns/edit/" class="sidebar">edit dns info</a></li>
<li><a href="/hostbase/{{ host.id }}/logs/" class="sidebar">change logs</a></li>
</ul>
{% include "logout.tmpl" %}
{% endblock %}

{% block content %}

<script language="JavaScript" type="text/Javascript">
function toggleAddr(interface_id){
   if(document.getElementById){
      var style = document.getElementById('ipaddr'+interface_id).style;
      style.display = style.display? "":"block";
   }
}
function toggleInter(){
   if(document.getElementById){
      var style = document.getElementById('interface').style;
      style.display = style.display? "":"block";
   }
}
</script>

<style type=text/css>
{% for interface in interfaces %}
div#ipaddr{{ interface.0.id }}{
   display: none;
}
{% endfor %}
div#interface{
   display: none;
}
</style>

<form name="hostdata" action="" method="post">
<fieldset class="module aligned ()">
<input type="hidden" name="host" value="{{ host.id }}">
   <label for="id_hostname">hostname:</label>
   <input name="hostname" value="{{ host.hostname }}"><br>
   <label for="id_whatami">whatami:</label>
   <select name="whatami">
   {% for choice in host.WHATAMI_CHOICES %}
       {% ifequal host.whatami choice.0 %}
           <option value="{{ choice.0 }}" selected="selected">{{ choice.1 }}
       {% else %}
           <option value="{{ choice.0 }}">{{ choice.1 }}
       {% endifequal %}
   {% endfor %}
   </select><br>
   <label for="id_netgroup">netgroup:</label>
   <select name="netgroup">
   {% for choice in host.NETGROUP_CHOICES %}
       {% ifequal host.netgroup choice.0 %}
           <option value="{{ choice.0 }}" selected="selected">{{ choice.1 }}
       {% else %}
           <option value="{{ choice.0 }}">{{ choice.1 }}
       {% endifequal %}
   {% endfor %}
   </select><br>
   <label for="id_security_class">class:</label>
   <select name="security_class">
   {% for choice in host.CLASS_CHOICES %}
       {% ifequal host.security_class choice.0 %}
           <option value="{{ choice.0 }}" selected="selected">{{ choice.1 }}
       {% else %}
           <option value="{{ choice.0 }}">{{ choice.1 }}
       {% endifequal %}
   {% endfor %}
   </select><br>
   <label for="id_support">support:</label>
   <select name="support">
   {% for choice in host.SUPPORT_CHOICES %}
       {% ifequal host.support choice.0 %}
           <option value="{{ choice.0 }}" selected="selected">{{ choice.1 }}
       {% else %}
           <option value="{{ choice.0 }}">{{ choice.1 }}
       {% endifequal %}
   {% endfor %}
   </select><br>
   <label for="id_csi">csi:</label>
   <input name="csi" type="text" value="{{ host.csi }}"><br>
   <label for="id_printq">printq:</label>
   <input name="printq" type="text" value="{{ host.printq }}"><br>
   <label for="id_outbound_smtp">outbound_smtp:</label>
   {% if host.outbound_smtp %}
       <input type="checkbox" checked="checked" name="outbound_smtp">
   {% else %}
       <input type="checkbox" name="outbound_smtp">
   {% endif %}<br>
   <label for="id_primary_user">primary_user:</label>
   <input name="primary_user" type="text" size="32" value="{{ host.primary_user }}"><br>
   <label for="id_administrator">administrator:</label>
   <input name="administrator" type="text" size="32" value="{{ host.administrator }}"><br>
   <label for="id_location">location:</label>
   <input name="location" type="text" value="{{ host.location }}"><br>
   <label for="id_expiration_date">expiration_date:</label>
   <input name="expiration_date" type="text" value="{{ host.expiration_date }}"> YYYY-MM-DD<br>
   {% for interface in interfaces %}
      <label for="id_interface">Interface:</label>
      <select name="hdwr_type{{ interface.0.id }}">
      {% for choice in interface.0.TYPE_CHOICES %}
          {% ifequal interface.0.hdwr_type choice.0 %}
	      <option value="{{ choice.0 }}" selected="selected">{{ choice.1 }}
	  {% else %}
	      <option value="{{ choice.0 }}">{{ choice.1 }}
	  {% endifequal %}
      {% endfor %}
      </select><br>
      <label for="id_dhcp">dhcp:</label>
       {% if interface.0.dhcp %}
           <input type="checkbox" checked="checked" name="dhcp{{ interface.0.id }}">
       {% else %}
           <input type="checkbox" name="dhcp{{ interface.0.id }}">
       {% endif %}<br>
      <label for="id_mac_addr">mac_addr:</label>
      <input name="mac_addr{{ interface.0.id }}" type="text" value="{{ interface.0.mac_addr }}">
       <a style="font-size:75%" href="/hostbase/{{ host.id }}/interface/{{ interface.0.id }}/confirm">remove</a><br>
       {% for ip in interface.1 %}
           <label for="id_ip_addr">ip_addr:</label>
           <input name="ip_addr{{ ip.id }}" type="text" value="{{ ip.ip_addr }}">
	   <a style="font-size:75%" href="/hostbase/{{ host.id }}/ip/{{ ip.id }}/confirm">remove</a><br>
       {% endfor %}

<!-- Section for adding a new IP address to an existing interface -->
<!-- By default, section is hidden -->
       <div id=ipaddr{{ interface.0.id }}>
           <label for="id_ip_addr">ip_addr:</label>
           <input name="{{ interface.0.id }}ip_addr" type="text"><br>
       </div>
       <a style="font-size:75%" href=# onclick="toggleAddr({{ interface.0.id }})">Add a New IP Address</a><br>
   {% endfor %}
<!--  End section for new IP address -->

<!-- Section for add an entirely new interface to a host -->
<!-- By default, section is hidden -->
   <div id=interface>
   <label for="id_interface">Interface:</label>
   <select name="hdwr_type_new">
   {% for choice in TYPE_CHOICES %}
       <option value="{{ choice.0 }}">{{ choice.1 }}
   {% endfor %}
   </select><br>
   <label for="id_dhcp">dhcp:</label>
   {% if host.dhcp %}
       <input type="checkbox" checked="checked" name="dhcp_new">
   {% else %}
       <input type="checkbox" name="dhcp_new">
   {% endif %}<br>
   <label for="id_mac_addr">mac_addr:</label>
   <td> <input name="mac_addr_new" type="text"><br>
   <label for="id_ip_addr">ip_addr:</label>
   <td> <input name="ip_addr_new" type="text"><br>
</div>
<a style="font-size:75%" href=# onclick="toggleInter()">Add a New Interface</a><br>
<!-- End new interface section -->


<label for="id_comments">comments:</label>
<textarea rows="10" cols="50" name="comments">{{ host.comments }}</textarea><br>
<a style="font-size:75%" href="/hostbase/{{ host.id }}/dns/edit">edit detailed DNS information for this host</a>
<br>
this host is
<select name="status">
{% for choice in host.STATUS_CHOICES %}
{% ifequal host.status choice.0 %}
<option value="{{ choice.0 }}" selected="selected">{{ choice.1 }}
{% else %}
<option value="{{ choice.0 }}">{{ choice.1 }}
{% endifequal %}
{% endfor %}
</select><br>
last update on {{ host.last }}<br>
<input type="submit" value="submit">
<input type="reset" value="cancel" onclick="history.back()">
</form>

{% endblock %}
