Source

HackersEdge / he_one / templates / he_one / host_detail.html

Full commit
Kevin Veroneau 8d6c3a4 



































































































































































































{% extends "base.html" %}
{% load hackers_edge %}
{% load url from future %}

{% block title %}Host: {{dns}}{% endblock %}

{% block css %}.jtable tr .ui-state-hover { font-weight: normal; }{% endblock %}

{% block jquery %}
{{block.super}}
{% if object.is_booted %}
{% if user == object.owner or user in object.users.all %}
  $(".jtable th").each(function(){ $(this).addClass("ui-state-default"); });
  $(".jtable td").each(function(){ $(this).addClass("ui-widget-content"); });
  $(".jtable tr").hover(function(){
   $(this).children("td").addClass("ui-state-hover");
  }, function(){
   $(this).children("td").removeClass("ui-state-hover");
  });
  {% if user == object.owner or user in object.users.all %}
  $("#dialog-users").dialog({autoOpen:false,modal:true,width:620,buttons:
    {"Okay": function(){
     addUser();
     $(this).dialog("close");
    }, Cancel: function() {
     $(this).dialog("close");
    }}});
  {% if object.supports_mail %}
  $("#dialog-mailboxes").dialog({autoOpen:false,modal:true,width:620,buttons:
    {"Okay": function(){
     addMailbox();
     $(this).dialog("close");
    }, Cancel: function() {
     $(this).dialog("close");
    }}});
  {% endif %}
  $("#dialog-files").dialog({autoOpen:false,modal:true,width:620,buttons:
    {"Okay": function(){
     $(this).dialog("close");
    }, Cancel: function() {
     $(this).dialog("close");
    }}});
  $("#dialog-logs").dialog({autoOpen:false,modal:true,width:620,buttons:
    {"Delete All": function(){
     Dajaxice.host.rm_log(Dajax.process, {'log_id':'ALL', 'host_ip':'{{object.ip}}'});
     $(this).dialog("close");
    }, Cancel: function() {
     $(this).dialog("close");
    }}});
  {% if object.is_router %}
  $("#dialog-hosts").dialog({autoOpen:false,modal:true,width:620,buttons:
    {"Okay": function(){
     $(this).dialog("close");
    }, Cancel: function() {
     $(this).dialog("close");
    }}});
  {% endif %}
  {% endif %}
{% endif %}
{% endif %}
{% endblock %}

{% block javascript %}
{% if object.is_booted %}
{% if user == object.owner or user in object.users.all %}
addUser = function(){
  perm_set = {'host_ip':'{{object.ip}}', 'is_staff':$("#is_staff").is(":checked"), 'is_superuser':$("#is_superuser").is(":checked")};
  Dajaxice.host.user_perms(Dajax.process, {'username':$("#username").val(), 'perm_set':perm_set});
  return false;
}
rmFile = function(file_id){
  Dajaxice.host.rm_file(Dajax.process, {'file_id':file_id});
  return false;
}
rmLog = function(log_id){
  Dajaxice.host.rm_log(Dajax.process, {'log_id':log_id, 'host_ip':'{{object.ip}}'});
  return false;
}
{% if object.supports_mail %}
addMailbox = function(){
  Dajaxice.host.add_mailbox(Dajax.process, {'username':$("#mailbox").val(), 'host_ip':'{{object.ip}}'});
  return false;
}
rmMailbox = function(mbx_id){
  Dajaxice.host.rm_mailbox(Dajax.process, {'mbx_id':mbx_id, 'host_ip':'{{object.ip}}'});
  return false;
}
{% endif %}
{% endif %}
{% endif %}
{% endblock %}

{% block tools %}
      {{block.super}}
      {% if object.is_booted %}
      {% if user == object.owner or user in object.users.all %}
      <a href="#" onclick="$('#dialog-users').dialog('open'); return false;">{% showicon "person" %}Manage Users</a><br/>
      {% if object.is_router %}<a href="#" onclick="$('#dialog-hosts').dialog('open'); return false;">{% showicon "signal-diag" %}Connected Hosts</a><br/>{% endif %}
      {% if object.supports_mail %}<a href="#" onclick="$('#dialog-mailboxes').dialog('open'); return false;">{% showicon "mail-closed" %}Manage Mailboxes</a><br/>{% endif %}
      <a href="#" onclick="$('#dialog-files').dialog('open'); return false;">{% showicon "folder-collapsed" %}Manage Files</a><br/>
      <a href="#" onclick="$('#dialog-logs').dialog('open'); return false;">{% showicon "note" %}Manage Logs</a><br/>
      {% if object.supports_web %}
      {% if object.supports_store %}<a href="#">{% showicon "cart" %}Manage eStore</a><br/>{% endif %}
      {% if object.supports_download %}<a href="#">{% showicon "folder-collapsed" %}Manage Downloads</a><br/>{% endif %}
      {% if object.provides_missions %}<a href="#">{% showicon "script" %}Mission List</a><br/>{% endif %}
      {% endif %}
      {% endif %}
      {% endif %}
      {% if user.is_superuser %}<a href="{% url 'admin:he_one_host_change' object.pk %}">{% showicon "pencil" %}Edit Host</a><br/>{% endif %}
{% endblock %}

{% block content %}
<h2>{{dns}}</h2>
<b>Booted</b> {{object.is_booted|yesnoicon}}<br/>
{% if not object.is_booted %}<a href="{% url 'host-boot' object.ip %}">Attempt to boot system</a><br/>{% endif %}
{% if user == object.owner or user in object.users.all %}
<h3>Host names</h3>
<ul>
 {% for hostname in object.namesystem_set.all %}
 <li>{{hostname}}</li>
 {% endfor %}
</ul>
{% if object.gateway %}<b>Gateway:</b> {{object.gateway|link}}<br/>{% endif %}
<b>Owner:</b> {{object.owner}}<br/>
<b>Router</b> {{object.is_router|yesnoicon}}<br/>
<b>Supports Mail</b> {{object.supports_mail|yesnoicon}}<br/>
<b>Web Server</b> {{object.supports_web|yesnoicon}}<br/>
{% endif %}
{% endblock %}

{% block footer %}
{% if object.is_booted %}
{% if user == object.owner or user in object.users.all %}
 <div id="dialog-users" title="Manage Users">
   <table class="jtable" width="600">
     <thead><tr><th>Username</th><th>Staff access</th><th>Superuser</th><th>Options</th></tr></thead>
     <tbody>
     {% get_user_permissions object as user_list %}
     {% for user in user_list %}
       <tr><td>{{user.user}}</td><td>{{user.is_staff|yesnoicon}}</td><td>{{user.is_superuser|yesnoicon}}</td><td>{% showicon "trash" %}</td></tr>
     {% endfor %}
       <tr><td><input type="text" id="username" /></td>
       <td><input type="checkbox" id="is_staff" /></td><td><input type="checkbox" id="is_superuser" /></td>
       <td>&nbsp;</td></tr>
     </tbody>
   </table>
 </div>
{% if object.supports_mail %}
 <div id="dialog-mailboxes" title="Manage Mailboxes">
   <table class="jtable" width="600">
     <thead><tr><th>Username</th><th>Messages</th><th>Options</th></tr></thead>
     <tbody>
     {% for mbx in object.mailboxes.all %}
       <tr><td><a href="{% url 'mailbox-detail' host.ip mbx.pk %}">{{mbx}}</a></td><td>{{mbx.messages.count}}</td><td><a href="#" onclick="return rmMailbox({{mbx.pk}});">{% showicon "trash" %}</a></td></tr>
     {% endfor %}
       <tr><td><input type="text" id="mailbox" /></td><td>&nbsp;</td>
       <td>&nbsp;</td></tr>
     </tbody>
   </table>
 </div>
{% endif %}
 <div id="dialog-files" title="Manage Files">
   <table class="jtable" width="600">
     <thead><tr><th>Filename</th><th>Creator</th><th>Create Date</th><th>Patch level</th><th>Public</th><th>Options</th></tr></thead>
     <tbody>
     {% get_file_permissions object as file_list %}
     {% for file in file_list %}
       <tr><td><a href="{% url 'pcfile-detail' host.ip file.pcfile.filename file.pcfile.file_type %}">{{file.pcfile}}</a></td><td>{{file.creator}}</td><td>{{file.create_date}}</td><td>{{file.patch}}</td><td>{{file.is_public|yesnoicon}}</td><td><a href="#" onclick="return rmFile({{file.pk}});">{% showicon "trash" %}</a></td></tr>
     {% endfor %}
     </tbody>
   </table>
 </div>
 <div id="dialog-logs" title="Manage Logs">
   <table class="jtable" width="600">
     <thead><tr><th>By Who</th><th>Message</th><th>Logged at</th><th>Options</th></tr></thead>
     <tbody>
     {% for log in object.logs.all %}
       <tr><td>{{log.by_who}}</td><td>{{log.message}}</td><td>{{log.logged_at}}</td><td><a href="#" onclick="return rmLog({{log.pk}});">{% showicon "trash" %}</a></td></tr>
     {% endfor %}
     </tbody>
   </table>
 </div>
{% if object.is_router %}
 <div id="dialog-hosts" title="Connected hosts">
   <table class="jtable" width="600">
     <thead><tr><th>IP Address</th><th>Owner</th><th>Booted</th><th>Options</th></tr></thead>
     <tbody>
     {% for host in object.host_set.all %}
       <tr><td>{{host|link}}</td><td>{{host.owner}}</td><td>{{host.is_booted|yesnoicon}}</td><td>{% showicon "trash" %}</td></tr>
     {% endfor %}
     </tbody>
   </table>
 </div>
{% endif %}
{% endif %}
{% endif %}
{% endblock %}