template-edit.html 7.04 KB
Newer Older
1
{% extends "dashboard/base.html" %}
2
{% load staticfiles %}
3
{% load i18n %}
4
{% load sizefieldtags %}
5
{% load crispy_forms_tags %}
6

7
{% block title-page %}{{ form.name.value }} | {% trans "template" %}{% endblock %}
8

9 10 11
{% block content %}

<div class="row">
12
  <div class="col-md-7">
13 14
    <div class="panel panel-default">
      <div class="panel-heading">
15 16 17
        <a class="pull-right btn btn-default btn-xs" href="{% url "dashboard.views.template-list" %}">
          {% trans "Back" %}
        </a>
18
        <h3 class="no-margin"><i class="fa fa-puzzle-piece"></i> {% trans "Edit template" %}</h3>
19 20
      </div>
      <div class="panel-body">
21
        <form action="" method="POST">
22 23 24
        {% with form=form %}
          {% include "display-form-errors.html" %}
        {% endwith %}
25 26 27 28

        {% csrf_token %}

        {{ form.name|as_crispy_field }}
29 30 31 32 33 34 35 36 37

        <strong>{% trans "Parent template" %}:</strong>
        {% if parent %}
        <a href="{% url "dashboard.views.template-detail" pk=parent.pk %}">
          {{ parent.name }}
        </a>
        {% else %}
          -
        {% endif %}
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

        <fieldset class="resources-sliders">
          <legend>{% trans "Resource configuration" %}</legend>
          {% include "dashboard/_resources-sliders.html" with field_priority=form.priority field_num_cores=form.num_cores field_ram_size=form.ram_size %}
          {{ form.max_ram_size|as_crispy_field }}
        </fieldset>

        <fieldset>
          <legend>{% trans "Virtual machine settings" %}</legend>
        {{ form.arch|as_crispy_field }}
        {{ form.access_method|as_crispy_field }}
        {{ form.boot_menu|as_crispy_field }}
        {{ form.raw_data|as_crispy_field }}
        {{ form.req_traits|as_crispy_field }}
        {{ form.description|as_crispy_field }}
        {{ form.system|as_crispy_field }}
54
        {{ form.has_agent|as_crispy_field }}
55 56 57 58 59 60 61 62 63 64 65
        </fieldset>
        <fieldset>
          <legend>{% trans "External resources" %}</legend>
        {{ form.networks|as_crispy_field }}
        {{ form.lease|as_crispy_field }}

        {{ form.tags|as_crispy_field }}
        </fieldset>

        <input type="submit" value="{% trans "Save changes" %}" class="btn btn-primary">
        </form>
66 67 68
      </div>
    </div>
  </div>
69

70
  <div class="col-md-5">
71 72 73
    {% if is_owner %}
    <div class="panel panel-default">
      <div class="panel-heading">
Kálmán Viktor committed
74
        <a href="{% url "dashboard.views.template-delete" pk=object.pk %}"
75
         class="btn btn-xs btn-danger pull-right template-delete">
76 77 78 79 80 81 82
          {% trans "Delete" %}
        </a>
        <h4 class="no-margin"><i class="fa fa-times"></i> {% trans "Delete template"  %}</h4>
      </div>
    </div>
    {% endif %}

83 84
    <div class="panel panel-default">
      <div class="panel-heading">
85 86 87 88 89 90
        <h4 class="no-margin"><i class="fa fa-user"></i> {% trans "Owner"  %}</h4>
      </div>
      <div class="panel-body">
        {% if user == object.owner %}
        {% blocktrans %}You are the current owner of this template.{% endblocktrans %}
        {% else %}
91
        {% url "dashboard.views.profile" username=object.owner.username as url %}
92
        {% blocktrans with owner=object.owner name=object.owner.get_full_name%}
93
          The current owner of this template is <a href="{{url}}">{{name}} ({{owner}})</a>.
94 95 96 97 98 99 100 101 102 103 104
        {% endblocktrans %}
        {% endif %}
        {% if user == object.owner or user.is_superuser %}
        <a href="{% url "dashboard.views.template-transfer-ownership" object.pk %}"
           class="btn btn-link tx-tpl-ownership">{% trans "Transfer ownership..." %}</a>
        {% endif %}
      </div>
    </div>

    <div class="panel panel-default">
      <div class="panel-heading">
105
        <h4 class="no-margin"><i class="fa fa-group"></i> {% trans "Manage access"  %}</h4>
106 107
      </div>
      <div class="panel-body">
108
        {% include "dashboard/_manage_access.html" with table_id="template-access-table" %}
109 110
      </div>
    </div>
111

Kálmán Viktor committed
112 113 114 115 116 117 118 119 120 121 122 123
    <div class="panel panel-default">
      <div class="panel-heading">
        <h4 class="no-margin">
          <i class="fa fa-question-circle"></i>
          {% trans "Access level rights" %}
        </h4>
      </div>
      <div class="panel-body">
        <dl>
          <dt>{% trans "User" %}</dt>
          <dd>
            {% blocktrans %}
124
            User can deploy instances from this template.
Kálmán Viktor committed
125 126 127 128 129
            {% endblocktrans %}
          </dd>
          <dt>{% trans "Operator" %}</dt>
          <dd>
            {% blocktrans %}
130
            Operators are able to deploy and grant/revoke User level access to this template.
Kálmán Viktor committed
131 132 133 134 135
            {% endblocktrans %}
          </dd>
          <dt>{% trans "Owner" %}</dt>
          <dd>
            {% blocktrans %}
136 137 138 139
            Owners can edit attributes or delete the template.
            Owners are able to grant/revoke User, Operator and Owner level access to the template.
            The accountable owner (the one who created the template) can not be demoted.
            The accountable ownership can be transferred to other User via the "Transfer onwership" button.
Kálmán Viktor committed
140 141 142 143 144
            {% endblocktrans %}
          </dd>
        </dl>
      </div>
    </div>
145

146 147
    <div class="panel panel-default">
      <div class="panel-heading">
148
        <h4 class="no-margin"><i class="fa fa-file"></i> {% trans "Disk list" %}</h4>
149 150
      </div>
      <div class="panel-body">
151 152 153 154
        <ul class="template-disk-list">
        {% if not disks %}
          {% trans "No disks are added!" %}
        {% endif %}
155 156
        {% for d in disks %}
          <li>
157
            <i class="fa fa-file"></i>
158
            {{ d.name }} (#{{ d.id }})
159 160 161 162 163
            <a href="{% url "dashboard.views.disk-remove" pk=d.pk %}?next={{ request.path }}"
              data-disk-pk="{{ d.pk }}" class="btn btn-xs btn-danger pull-right disk-remove"
              {% if not long_remove %}title="{% trans "Remove" %}"{% endif %}>
              <i class="fa fa-times"></i>{% if long_remove %} {% trans "Remove" %}{% endif %}
            </a>
164 165 166 167 168
          </li>
        {% endfor %}
        </ul>
      </div>
    </div>
169 170 171 172 173 174

    {% if show_graph %}
      <div class="panel panel-default">
        <div class="panel-heading">
          <h3 class="no-margin"><i class="fa fa-area-chart"></i> {% trans "Graphs" %}</h3>
        </div>
175 176 177 178 179 180 181 182 183 184 185 186 187
        <div class="text-center panel-body">
          <div class="graph-buttons">
            {% include "dashboard/_graph-time-buttons.html" %}
          </div>
          <div class="text-center graph-images">
            <img src="{% url "dashboard.views.template-graph" object.pk "instances" graph_time %}"/>
          </div>

          {% if request.user.is_superuser %}
            <a  href="{% url "dashboard.views.vm-list" %}?s=template:{{object.pk}}&stype=all">
              {% trans "List all template instances" %}
            </a>
          {% endif %}
188 189 190
        </div>
      </div>
    {% endif %}
191 192
  </div><!-- .col-md-4 -->
</div><!-- .row -->
193

194

195 196 197 198 199 200 201 202
<style>
  fieldset {
    margin-top: 40px;
  }
  fieldset legend {
    font-weight: bold;
  }
</style>
203 204 205 206 207 208 209 210
{% endblock %}

{% block extra_js %}
  <script>
    $(function() {
      $("#hint_id_num_cores, #hint_id_priority, #hint_id_ram_size").hide();
    });
  </script>
211
{% endblock %}