_vm-create-1.html 4.61 KB
Newer Older
1
{% load sizefieldtags %}
2
{% load i18n %}
3 4 5 6 7 8 9 10 11 12 13

<div class="vm-create-template-list">
  {% for t in templates %}
  <div class="vm-create-template">
    <div class="vm-create-template-summary">
      {{ t.name }}
      <span class="pull-right"><i class="icon-{{ t.os_type }}"></i> {{ t.system }}</span>
    </div>
    <div class="vm-create-template-details">
      <ul>
        <li>
14
          <i class="icon-gears"></i> {% trans "CPU" %}
15 16 17 18 19 20 21 22
          <div class="progress pull-right">
            <div class="progress-bar progress-bar-success" role="progressbar" 
              aria-valuenow="{{ t.num_cores }}" aria-valuemin="0" aria-valuemax="8" style="width: 80%">
              <span class="progress-bar-text">{{ t.num_cores }} cores</span>
            </div>
          </div>
        </li>
        <li>
23
          <i class="icon-ticket"></i> {% trans "Memory" %}
24 25 26 27 28 29 30 31 32
          <div class="progress pull-right">
            <div class="progress-bar progress-bar-info" role="progressbar" 
              aria-valuenow="{{ t.ram_size }}" aria-valuemin="0" aria-valuemax="4096" 
              style="width: 80%">
              <span class="progress-bar-text">{{ t.ram_size }} MB</span>
            </div>
          </div>
        </li>
        <li>
33 34
          <i class="icon-file"></i> {% trans "Disks" %} 
          <span style="float: right; text-align: right;">
35
            {% for d in t.disks.all %}{{ d.name }} ({% if d.size %}{{ d.size|filesize }}{% endif %}){% if not forloop.last %}, {% endif %}{% endfor %}
36
          </span>
37
          <div style="clear: both;"></div>
38 39
        </li>
        <li>
40
          <i class="icon-globe"></i> {% trans "Network" %}
41 42 43 44 45
          <span style="float: right;">
            {% for i in t.interface_set.all %}{{ i.vlan.name }}{% if not forloop.last %}, {% endif %}{% endfor %}
          </span>
        </li>
        <li>
46
          <i class="icon-tag"></i> {% trans "Type" %}: {{ t.lease.name }}
47 48 49 50 51 52
          <span style="float: right;">
            <i class="icon-pause"></i> {{ t.lease.get_readable_suspend_time }}
            <i class="icon-remove"></i> {{ t.lease.get_readable_delete_time }}
          </span>
        </li>
        <li>
53
          <i class="icon-hand-right"></i> {% trans "Description" %}:
54 55 56 57 58 59 60
          <span style="float: right; max-width: 350px;">
            {{ t.description }}
          </span>
          <div class="clearfix"></div>
        </li>
      </ul>
      <div style="margin-top: 20px; padding: 0 15px; width: 100%">
61
        {% if perms.vm_set_resources %}
62 63
        <a class="btn btn-primary btn-xs customize-vm" data-template-pk="{{ t.pk }}" href="{% url "dashboard.views.vm-create" %}?template={{ t.pk }}"><i class="icon-wrench"></i> {% trans "Customize" %}</a>
        {% endif %}
64 65 66
        <form class="pull-right text-right" method="POST" action="{% url "dashboard.views.vm-create" %}">
          {% csrf_token %}
          <input type="hidden" name="template" value="{{ t.pk }}"/>
67 68 69
          <button class="btn btn-success btn-xs vm-create-start" data-template-pk="{{ t.pk }}" type="submit">
            <i class="icon-play"></i> {% trans "Start" %}
          </button>
70
        </form>
71
        <div style="clear: both;"></div>
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
      </div>
    </div>
  </div>
  {% endfor %}
</div>

<style>
  .row {
    margin-bottom: 15px;
  }

  .vm-create-template {
    max-width: 800px;
    border: 1px solid black;
    border-bottom: none;
  }

  .vm-create-template-list .vm-create-template:last-child {
    border-bottom: 1px solid black;
  }

  .vm-create-template-summary {
    padding: 15px;
    cursor: pointer;
  }

  .vm-create-template:nth-child(odd) .vm-create-template-summary {
    background: #F5F5F5;
  }

  .vm-create-template-list .vm-create-template-summary:hover {
    background: #D2D2D2;
  }

  .vm-create-template-details {
    border-top: 1px dashed #D3D3D3;
    padding: 15px;
  }

  .vm-create-template-details ul {
    list-style: none;
    padding: 0 15px;
  }

  .vm-create-template-details li {
    border-bottom: 1px dotted #aaa;
    padding: 5px 0px;
  }

  .progress {
    position: relative;
    width: 200px;
    height: 12px;
    margin-bottom: 0px;
    margin-top: 5px;
  }
  .progress-bar-text {
    position: absolute;
    display: block;
    width: 100%;
    color: white;
    /* outline */
    text-shadow:  
      -1px -1px 0 #000,
      1px -1px 0 #000,
      -1px 1px 0 #000,
      1px 1px 0 #000;  
    font-size: 10px;
  }
</style>

{% block "extra-js" %}
<script>
$('.progress-bar').each(function() {
  var min = $(this).attr('aria-valuemin');
  var max = $(this).attr('aria-valuemax');
  var now = $(this).attr('aria-valuenow');
  var siz = (now-min)*100/(max-min);
  $(this).css('width', siz+'%');
});
</script>
{% endblock %}