1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-24 23:25:24 +00:00

intances reformat code. Fix typo error

This commit is contained in:
catborise 2018-07-19 09:39:41 +03:00
parent 5e2144b113
commit 65769eb894

View file

@ -3,7 +3,7 @@
{% load staticfiles %} {% load staticfiles %}
{% block title %}{% trans "Instances" %}{% endblock %} {% block title %}{% trans "Instances" %}{% endblock %}
{% block style %} {% block style %}
<link rel="stylesheet" href="{% static "css/sortable-theme-bootstrap.css" %}"/> <link rel="stylesheet" href="{% static "css/sortable-theme-bootstrap.css" %}" />
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<!-- Page Heading --> <!-- Page Heading -->
@ -32,13 +32,12 @@
<div class="col-lg-12"> <div class="col-lg-12">
<div class="alert alert-warning alert-dismissable"> <div class="alert alert-warning alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<i class="fa fa-exclamation-triangle"></i> <i class="fa fa-exclamation-triangle"></i> <strong>{% trans "Warning:" %}</strong> {% trans "You don't have any Instance" %}
<strong>{% trans "Warning:" %}</strong> {% trans "You don't have any Instace" %}
</div> </div>
</div> </div>
{% else %} {% else %}
<table class="table table-hover table-striped sortable-theme-bootstrap" data-sortable> <table class="table table-hover table-striped sortable-theme-bootstrap" data-sortable>
<thead> <thead >
<tr> <tr>
<th>#</th> <th>#</th>
<th>Name<br>Description</th> <th>Name<br>Description</th>
@ -59,34 +58,21 @@
</span>{% endifequal %} </span>{% endifequal %}
{% ifequal host.2 2 %}<span class="label label-danger">{% trans "Not Active" %} {% ifequal host.2 2 %}<span class="label label-danger">{% trans "Not Active" %}
</span>{% endifequal %} </span>{% endifequal %}
{% ifequal host.2 3 %} {% ifequal host.2 3 %}<span class="label label-danger">{% trans "Connection Failed" %}
<span class="label label-danger">{% trans "Connection Failed" %}
</span>{% endifequal %} </span>{% endifequal %}
</td> </td>
<td style="text-align:center;">{{ host.3 }}</td> <td style="text-align:center;">{{ host.3 }}</td>
<td style="text-align:right;">{{ host.4|filesizeformat }}</td> <td style="text-align:right;">{{ host.4|filesizeformat }}</td>
<td style="text-align:left;"> <td style="text-align:left;">
<div class="progress-bar-success" role="progressbar" <div class="progress-bar-success" role="progressbar" style="width: {{ host.5 }}%" aria-valuenow="{{ host.5 }}" aria-valuemin="0" aria-valuemax="100">{{ host.5 }}%</div>
style="width: {{ host.5 }}%" aria-valuenow="{{ host.5 }}" aria-valuemin="0"
aria-valuemax="100">{{ host.5 }}%
</div>
</td> </td>
</tr> </tr>
{% for vm, info in inst.items %} {% for vm, info in inst.items %}
<tr> <tr>
<td></td> <td></td>
<td>{{ forloop.counter }} &emsp; <a <td>{{ forloop.counter }} &emsp; <a href="{% url 'instance' host.0 vm %}">{{ vm }}</a><br><small><em>{{ info.title }}</em></small></td>
href="{% url 'instance' host.0 vm %}">{{ vm }}</a><br> <td><small><em>{% if info.userinstances.count > 0 %}{{ info.userinstances.first_user.user.username }}{% if info.userinstances.count > 1 %} (+{{ info.userinstances.count|add:"-1" }}){% endif %}{% endif %}</em></small></td>
<small><em>{{ info.title }}</em></small>
</td>
<td>
<small><em>{% if info.userinstances.count > 0 %}
{{ info.userinstances.first_user.user.username }}
{% if info.userinstances.count > 1 %} (+
{{ info.userinstances.count|add:"-1" }}){% endif %}{% endif %}</em>
</small>
</td>
<td>{% ifequal info.status 1 %} <td>{% ifequal info.status 1 %}
<span class="text-success">{% trans "Active" %}</span> <span class="text-success">{% trans "Active" %}</span>
{% endifequal %} {% endifequal %}
@ -99,84 +85,63 @@
</td> </td>
<td style="text-align:center;">{{ info.vcpu }}</td> <td style="text-align:center;">{{ info.vcpu }}</td>
<td style="text-align:right;">{{ info.memory |filesizeformat }}</td> <td style="text-align:right;">{{ info.memory |filesizeformat }}</td>
<td> <td><form action="" method="post" role="form">{% csrf_token %}
<form action="" method="post" role="form">{% csrf_token %}
<input type="hidden" name="name" value="{{ vm }}"/> <input type="hidden" name="name" value="{{ vm }}"/>
<input type="hidden" name="compute_id" value="{{ host.0 }}"/> <input type="hidden" name="compute_id" value="{{ host.0 }}"/>
{% ifequal info.status 5 %} {% ifequal info.status 5 %}
{% if info.is_template %} {% if info.is_template %}
<button class="btn btn-sm btn-default" type="button" <button class="btn btn-sm btn-default" type="button" name="clone" title="{% trans "Clone" %}" onclick="goto_instance_clone({{ host.0 }}, '{{ vm }}');">
name="clone" title="{% trans "Clone" %}"
onclick="goto_instance_clone({{ host.0 }}, '{{ vm }}');">
<span class="glyphicon glyphicon-duplicate"></span> <span class="glyphicon glyphicon-duplicate"></span>
</button> </button>
{% else %} {% else %}
<button class="btn btn-sm btn-default" type="submit" <button class="btn btn-sm btn-default" type="submit" name="poweron" title="{% trans "Power On" %}">
name="poweron" title="{% trans "Power On" %}">
<span class="glyphicon glyphicon-play"></span> <span class="glyphicon glyphicon-play"></span>
</button> </button>
{% endif %} {% endif %}
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "Suspend" %}">
title="{% trans "Suspend" %}">
<span class="glyphicon glyphicon-pause"></span> <span class="glyphicon glyphicon-pause"></span>
</button> </button>
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "Power Off" %}">
title="{% trans "Power Off" %}">
<span class="glyphicon glyphicon-off"></span> <span class="glyphicon glyphicon-off"></span>
</button> </button>
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "Power Cycle" %}">
title="{% trans "Power Cycle" %}">
<span class="glyphicon glyphicon-refresh"></span> <span class="glyphicon glyphicon-refresh"></span>
</button> </button>
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "VNC Console" %}">
title="{% trans "VNC Console" %}">
<span class="glyphicon glyphicon-eye-open"></span> <span class="glyphicon glyphicon-eye-open"></span>
</button> </button>
{% endifequal %} {% endifequal %}
{% ifequal info.status 3 %} {% ifequal info.status 3 %}
<button class="btn btn-sm btn-default" type="submit" name="resume" <button class="btn btn-sm btn-default" type="submit" name="resume" title="{% trans "Resume" %}">
title="{% trans "Resume" %}">
<span class="glyphicon glyphicon-play"></span> <span class="glyphicon glyphicon-play"></span>
</button> </button>
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "Suspend" %}">
title="{% trans "Suspend" %}">
<span class="glyphicon glyphicon-pause"></span> <span class="glyphicon glyphicon-pause"></span>
</button> </button>
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "Power Off" %}">
title="{% trans "Power Off" %}">
<span class="glyphicon glyphicon-off"></span> <span class="glyphicon glyphicon-off"></span>
</button> </button>
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "Power Cycle" %}">
title="{% trans "Power Cycle" %}">
<span class="glyphicon glyphicon-refresh"></span> <span class="glyphicon glyphicon-refresh"></span>
</button> </button>
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "VNC Console" %}">
title="{% trans "VNC Console" %}">
<span class="glyphicon glyphicon-eye-open"></span> <span class="glyphicon glyphicon-eye-open"></span>
</button> </button>
{% endifequal %} {% endifequal %}
{% ifequal info.status 1 %} {% ifequal info.status 1 %}
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "Power On" %}">
title="{% trans "Power On" %}">
<span class="glyphicon glyphicon-play"></span> <span class="glyphicon glyphicon-play"></span>
</button> </button>
<button class="btn btn-sm btn-default" type="submit" name="suspend" <button class="btn btn-sm btn-default" type="submit" name="suspend" title="{% trans "Suspend" %}">
title="{% trans "Suspend" %}">
<span class="glyphicon glyphicon-pause"></span> <span class="glyphicon glyphicon-pause"></span>
</button> </button>
<button class="btn btn-sm btn-default" type="submit" name="poweroff" <button class="btn btn-sm btn-default" type="submit" name="poweroff" title="{% trans "Power Off" %}" onclick="return confirm('Are you sure?')">
title="{% trans "Power Off" %}"
onclick="return confirm('Are you sure?')">
<span class="glyphicon glyphicon-off"></span> <span class="glyphicon glyphicon-off"></span>
</button> </button>
<button class="btn btn-sm btn-default" type="submit" <button class="btn btn-sm btn-default" type="submit" name="powercycle" title="{% trans "Power Cycle" %}" onclick="return confirm('Are you sure?')">
name="powercycle" title="{% trans "Power Cycle" %}"
onclick="return confirm('Are you sure?')">
<span class="glyphicon glyphicon-refresh"></span> <span class="glyphicon glyphicon-refresh"></span>
</button> </button>
<a href="#" class="btn btn-sm btn-default" <a href="#" class="btn btn-sm btn-default" onclick='open_console("{{ host.0 }}-{{ info.uuid }}")' title="{% trans "Console" %}">
onclick='open_console("{{ host.0 }}-{{ info.uuid }}")'
title="{% trans "Console" %}">
<span class="glyphicon glyphicon-eye-open"></span> <span class="glyphicon glyphicon-eye-open"></span>
</a> </a>
{% endifequal %} {% endifequal %}
@ -193,8 +158,7 @@
<div class="col-lg-12"> <div class="col-lg-12">
<div class="alert alert-warning alert-dismissable"> <div class="alert alert-warning alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<i class="fa fa-exclamation-triangle"></i> <i class="fa fa-exclamation-triangle"></i> <strong>{% trans "Warning:" %}</strong> {% trans "You don't have any Instance" %}
<strong>{% trans "Warning:" %}</strong> {% trans "You don't have any Instance" %}
</div> </div>
</div> </div>
{% else %} {% else %}
@ -211,9 +175,7 @@
<tbody class="searchable"> <tbody class="searchable">
{% for inst, vm in all_user_vms.items %} {% for inst, vm in all_user_vms.items %}
<tr> <tr>
<td><a href="{% url 'instance' vm.compute_id vm.name %}">{{ vm.name }}</a><br> <td><a href="{% url 'instance' vm.compute_id vm.name %}">{{ vm.name }}</a><br><small><em>{{ vm.title }}</em></small></td>
<small><em>{{ vm.title }}</em></small>
</td>
<td>{% ifequal vm.status 1 %} <td>{% ifequal vm.status 1 %}
<span class="text-success">{% trans "Active" %}</span> <span class="text-success">{% trans "Active" %}</span>
{% endifequal %} {% endifequal %}
@ -226,71 +188,54 @@
</td> </td>
<td>{{ vm.vcpu }}</td> <td>{{ vm.vcpu }}</td>
<td>{{ vm.memory }} {% trans "MB" %}</td> <td>{{ vm.memory }} {% trans "MB" %}</td>
<td> <td><form action="" method="post" role="form">{% csrf_token %}
<form action="" method="post" role="form">{% csrf_token %}
<input type="hidden" name="name" value="{{ vm.name }}"/> <input type="hidden" name="name" value="{{ vm.name }}"/>
<input type="hidden" name="compute_id" value="{{ vm.compute_id }}"/> <input type="hidden" name="compute_id" value="{{ vm.compute_id }}"/>
{% ifequal vm.status 5 %} {% ifequal vm.status 5 %}
{% if inst.instance.is_template %} {% if inst.instance.is_template %}
<button class="btn btn-sm btn-default" type="button" name="clone" <button class="btn btn-sm btn-default" type="button" name="clone" title="{% trans "Clone" %}" onclick="goto_instance_clone({{ vm.compute_id }}, '{{ vm.name }}');">
title="{% trans "Clone" %}"
onclick="goto_instance_clone({{ vm.compute_id }}, '{{ vm.name }}');">
<span class="glyphicon glyphicon-duplicate"></span> <span class="glyphicon glyphicon-duplicate"></span>
</button> </button>
{% else %} {% else %}
<button class="btn btn-sm btn-default" type="submit" name="poweron" <button class="btn btn-sm btn-default" type="submit" name="poweron" title="{% trans "Power On" %}">
title="{% trans "Power On" %}">
<span class="glyphicon glyphicon-play"></span> <span class="glyphicon glyphicon-play"></span>
</button> </button>
{% endif %} {% endif %}
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "Power Off" %}">
title="{% trans "Power Off" %}">
<span class="glyphicon glyphicon-off"></span> <span class="glyphicon glyphicon-off"></span>
</button> </button>
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "Power Cycle" %}">
title="{% trans "Power Cycle" %}">
<span class="glyphicon glyphicon-refresh"></span> <span class="glyphicon glyphicon-refresh"></span>
</button> </button>
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "VNC Console" %}">
title="{% trans "VNC Console" %}">
<span class="glyphicon glyphicon-eye-open"></span> <span class="glyphicon glyphicon-eye-open"></span>
</button> </button>
{% endifequal %} {% endifequal %}
{% ifequal vm.status 3 %} {% ifequal vm.status 3 %}
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "Power On" %}">
title="{% trans "Power On" %}">
<span class="glyphicon glyphicon-play"></span> <span class="glyphicon glyphicon-play"></span>
</button> </button>
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "Power Off" %}">
title="{% trans "Power Off" %}">
<span class="glyphicon glyphicon-off"></span> <span class="glyphicon glyphicon-off"></span>
</button> </button>
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "Power Cycle" %}">
title="{% trans "Power Cycle" %}">
<span class="glyphicon glyphicon-refresh"></span> <span class="glyphicon glyphicon-refresh"></span>
</button> </button>
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "VNC Console" %}">
title="{% trans "VNC Console" %}">
<span class="glyphicon glyphicon-eye-open"></span> <span class="glyphicon glyphicon-eye-open"></span>
</button> </button>
{% endifequal %} {% endifequal %}
{% ifequal vm.status 1 %} {% ifequal vm.status 1 %}
<button class="btn btn-sm btn-default disabled" <button class="btn btn-sm btn-default disabled" title="{% trans "Power On" %}">
title="{% trans "Power On" %}">
<span class="glyphicon glyphicon-play"></span> <span class="glyphicon glyphicon-play"></span>
</button> </button>
<button class="btn btn-sm btn-default" type="submit" name="poweroff" <button class="btn btn-sm btn-default" type="submit" name="poweroff" title="{% trans "Power Off" %}">
title="{% trans "Power Off" %}">
<span class="glyphicon glyphicon-off"></span> <span class="glyphicon glyphicon-off"></span>
</button> </button>
<button class="btn btn-sm btn-default" type="submit" name="powercycle" <button class="btn btn-sm btn-default" type="submit" name="powercycle" title="{% trans "Power Cycle" %}" onclick="return confirm('Are you sure?')">
title="{% trans "Power Cycle" %}"
onclick="return confirm('Are you sure?')">
<span class="glyphicon glyphicon-refresh"></span> <span class="glyphicon glyphicon-refresh"></span>
</button> </button>
<a href="#" class="btn btn-sm btn-default" <a href="#" class="btn btn-sm btn-default" onclick='open_console("{{ vm.compute_id }}-{{ vm.uuid }}")' title="{% trans "Console" %}">
onclick='open_console("{{ vm.compute_id }}-{{ vm.uuid }}")'
title="{% trans "Console" %}">
<span class="glyphicon glyphicon-eye-open"></span> <span class="glyphicon glyphicon-eye-open"></span>
</a> </a>
{% endifequal %} {% endifequal %}
@ -307,22 +252,21 @@
</div> </div>
{% endblock %} {% endblock %}
{% block script %} {% block script %}
<script src="{% static "js/sortable.min.js" %}"></script> <script src="{% static "js/sortable.min.js" %}"></script>
<script> <script>
function open_console(uuid) { function open_console(uuid) {
window.open("{% url 'console' %}?token=" + uuid, "", "width=850,height=485"); window.open("{% url 'console' %}?token=" + uuid, "", "width=850,height=485");
} }
</script> </script>
<script> <script>
function filter_table() { function filter_table() {
var rex = new RegExp($(this).val(), 'i'); var rex = new RegExp($(this).val(), 'i');
$('.searchable tr').hide(); $('.searchable tr').hide();
$('.searchable tr').filter(function () { $('.searchable tr').filter(function () {
return rex.test($(this).text()); return rex.test($(this).text());
}).show(); }).show();
Cookies.set("instances_filter", $(this).val(), {expires: 1}); Cookies.set("instances_filter", $(this).val(), { expires: 1 });
} }
$(document).ready(function () { $(document).ready(function () {
instances_filter_cookie = Cookies.get("instances_filter"); instances_filter_cookie = Cookies.get("instances_filter");
if (instances_filter_cookie) { if (instances_filter_cookie) {
@ -333,18 +277,18 @@
$('#filter').keyup(filter_table) $('#filter').keyup(filter_table)
}(jQuery)); }(jQuery));
}); });
</script> </script>
<script> <script>
function goto_instance_clone(compute, instance) { function goto_instance_clone(compute, instance) {
window.location = "/instance/" + compute + "/" + instance + "/#clone"; window.location = "/instance/" + compute + "/" + instance + "/#clone";
} }
</script> </script>
{% if request.user.is_superuser %} {% if request.user.is_superuser %}
<script> <script>
function goto_compute() { function goto_compute() {
var compute = $("#compute_select").val(); var compute = $("#compute_select").val();
window.location = "/compute/" + compute + "/create/"; window.location = "/compute/" + compute + "/create/";
} }
</script> </script>
{% endif %} {% endif %}
{% endblock %} {% endblock %}