Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions accounts/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,27 @@
{% endblock style %}

{% block content %}
<div class="page-header">
<a class="" href="/"><h1>WebVirtCloud</h1></a>
</div>
<div class="col-12" role="main">
{% if form.errors %}
<div class="alert alert-danger">
<button type="button" class="btn-close" data-dismiss="alert" aria-label="Close"></button>
{% trans "Incorrect username or password." %}
</div>
{% endif %}
<form class="form-signin" method="post" role="form" aria-label="Login form">{% csrf_token %}
<h2 class="form-signin-heading">{% trans "Sign In" %}</h2>
<input type="text" class="form-control" name="username" placeholder="{% trans "User" %}" autocapitalize="none" autocorrect="off" autofocus>
<input type="password" class="form-control" name="password" placeholder="{% trans "Password" %}">
<input type="hidden" name="next" value="{{ next }}">
<div class="d-grid">
<button class="btn btn-lg btn-success" type="submit">{% trans "Sign In" %}</button>
</div>
</form>
<div class="login-box">
<div class="page-header">
<a class="" href="/"><h1>WebVirtCloud</h1></a>
</div>
<div class="col-12" role="main">
{% if form.errors %}
<div class="alert alert-danger">
<button type="button" class="btn-close" data-dismiss="alert" aria-label="Close"></button>
{% trans "Incorrect username or password." %}
</div>
{% endif %}
<form class="form-signin" method="post" role="form" aria-label="Login form">{% csrf_token %}
<h2 class="form-signin-heading">{% trans "Sign In" %}</h2>
<input type="text" class="form-control" name="username" placeholder="{% trans "User" %}" autocapitalize="none" autocorrect="off" autofocus>
<input type="password" class="form-control" name="password" placeholder="{% trans "Password" %}">
<input type="hidden" name="next" value="{{ next }}">
<div class="d-grid">
<button class="btn btn-lg btn-success" type="submit">{% trans "Sign In" %}</button>
</div>
</form>
</div>
</div>

{% endblock %}
2 changes: 1 addition & 1 deletion appsettings/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext_noop as _
from logs.views import addlogmsg

from appsettings.models import AppSettings
Expand Down
4 changes: 4 additions & 0 deletions computes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def proxy(self):
@cached_property
def cpu_count(self):
return self.proxy.get_node_info()[3]

@cached_property
def cpu_usage(self):
return round(self.proxy.get_cpu_usage().get('usage'))

@cached_property
def ram_size(self):
Expand Down
4 changes: 2 additions & 2 deletions instances/templates/allinstances.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
<script src="{% static 'js/filter-table.js' %}"></script>
{% if request.user.is_superuser %}
<script>
function goto_compute() {
let compute = $("#compute_select").val();
function goto_compute(compute) {
//let compute = $("#compute_select").val();
window.location.href = "{% url 'instances:create_instance_select_type' 1 %}".replace(1, compute);
}
</script>
Expand Down
67 changes: 42 additions & 25 deletions instances/templates/create_inst_block.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<!-- Modal pool -->
<div class="modal fade" id="AddInstance" tabindex="-1" role="dialog" aria-labelledby="AddInstanceModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-dialog modal-dialog-scrollable modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{% trans "Choose a compute for new instance" %}</h5>
Expand All @@ -15,33 +15,50 @@ <h5 class="modal-title">{% trans "Choose a compute for new instance" %}</h5>
<form method="post" aria-label="Select compute for instance create form">
{% csrf_token %}
<div class="row">
<label class="col-sm-4 col-form-label">{% trans "Compute" %}</label>
<div class="col-sm-6">
<select class="form-select" id="compute_select">
<option>{% trans "Please select" %}</option>
<table class="table">
<thead>
<tr style="cursor:default;pointer-events:none">
<th>{% trans "Name" %}</th>
<th>{% trans "VCPU" %}
<th>{% trans "Cpu Usage" %}</th>
<th>{% trans "Memory" %}</th>
<th>{% trans "Mem Usage" %}</th>
<th>{% trans "Action" %}</th>
</tr>
</thead>
<tbody>
{% for compute in computes %}
<option {% if compute.status is not True %} class="font-italic text-muted" {% else %} value="{{ compute.id }}" {% endif %}>{{ compute.name }}</option>
{% empty %}
<option value="None">{% trans "None" %}</option>
{% if compute.status is True %}
<tr style="text-decoration: none">
<td>{{ compute.name }}</td>
<td>{{ compute.cpu_count }}</td>
<td>
<div class="progress">
<div class="progress-bar bg-success" role="progressbar" style="width: {{ compute.cpu_usage }}%"
aria-valuenow="{{ compute.cpu_usage }}" aria-valuemin="0" aria-valuemax="100">{{ compute.cpu_usage }}%
</div>
</div>
</td>
<td>{{ compute.ram_size|filesizeformat }}</td>
<td>
<div class="progress">
<div class="progress-bar bg-success" role="progressbar" style="width: {{ compute.ram_usage }}%"
aria-valuenow="{{ compute.ram_usage }}" aria-valuemin="0" aria-valuemax="100">{{ compute.ram_usage }}%
</div>
</div>
</td>
<td class="col-1">
<button class="btn btn-success btn-sm" type="button" onclick="goto_compute('{{ compute.id }}');">
{% trans "Choose" %}
</button>
</td>
</tr>
{% endif %}
{% endfor %}
</select>
</div>
</tbody>
</table>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
{% trans "Close" %}
</button>
{% if computes %}
<button type="submit" class="btn btn-primary" name="choose" onclick='goto_compute()'>
{% trans "Choose" %}
</button>
{% else %}
<button class="btn btn-primary disabled">
{% trans "Choose" %}
</button>
{% endif %}
</form>
</div>
</div> <!-- /.modal-content -->
</div> <!-- /.modal-dialog -->
Expand Down
5 changes: 2 additions & 3 deletions instances/templates/instances/snapshots_tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="takeextsnapshot">
{% if instance.status != 5 %}
<p>{% trans "You can get external snapshots within this tab." %}</p>
<p class="text-primary">{% trans "External snapshots are experimental in this stage, use it if you know what you are doing. It may require manual intervention." %}</p>
{% else %}
<p>{% trans "Create an external snapshot" %}</p>
{% endif %}
<p class="text-danger">{% trans "Give your External Snapshot a <b>distinctive description</b> so it wouldn't get mixed with other snapshots." %}</p>
<p class="fst-italic">{% trans "External snapshots are experimental in this stage, use it if you know what you are doing. 'Revert Snapshot' may require manual operation with CLI." %}</p>
<form action="{% url 'instances:create_external_snapshot' instance.id %}" method="post" role="form" aria-label="Create snapshot form">
{% csrf_token %}
<div class="input-group mb-3">
Expand All @@ -63,7 +62,7 @@
<input type="submit" class="btn btn-lg btn-success float-end" name="snapshot" value="{% trans "Take Snapshot" %}" onclick="showPleaseWaitDialog();">
{% endif %}
</div>
<p class="text-danger">{% trans "WebVirtCloud supports only one external snapshot at the moment." %}</p>
<p class="text-danger font-monospace small">{% trans "WebVirtCloud supports only one external snapshot at the moment." %}</p>
</form>
<div class="clearfix"></div>
</div> <!--tab pane takeextsnapshot-->
Expand Down
2 changes: 1 addition & 1 deletion instances/templates/instances/stats_tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#logs" type="button" role="tab" aria-controls="logs" aria-selected="false">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#logs" type="button" role="tab" aria-controls="logs" aria-selected="false" onclick="update_logs_table(vname);">
{% trans "Logs" %}
</button>
</li>
Expand Down
2 changes: 1 addition & 1 deletion instances/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from django.http import Http404, HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext_noop as _
from libvirt import (VIR_DOMAIN_UNDEFINE_KEEP_NVRAM,
VIR_DOMAIN_UNDEFINE_NVRAM,
VIR_DOMAIN_START_PAUSED,
Expand Down
Loading