mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
Resoved problem with app template
This commit is contained in:
parent
35da9ad193
commit
b4e8da8671
42 changed files with 37 additions and 32 deletions
73
networks/templates/create_net_block.html
Normal file
73
networks/templates/create_net_block.html
Normal file
|
@ -0,0 +1,73 @@
|
|||
{% load i18n %}
|
||||
{% if request.user.is_superuser %}
|
||||
<a href="#AddNetPool" type="button" class="btn btn-success pull-right" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
|
||||
</a>
|
||||
|
||||
<!-- Modal pool -->
|
||||
<div class="modal fade" id="AddNetPool" tabindex="-1" role="dialog" aria-labelledby="AddNetPoolLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">{% trans "Add New Network" %}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal" method="post" action="" role="form">{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">{% trans "Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" name="name" placeholder="default" required pattern="[a-zA-Z0-9_]+">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group bridge_name_form_group_dhcp">
|
||||
<label class="col-sm-4 control-label">{% trans "Subnet pool" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" name="subnet" value="192.168.100.0/24" required pattern="[0-9\/\.]+">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group bridge_name_form_group_dhcp">
|
||||
<label class="col-sm-4 control-label">{% trans "DHCP" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="checkbox" name="dhcp" value="true" checked>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group bridge_name_form_group_dhcp">
|
||||
<label class="col-sm-4 control-label">{% trans "Fixed Address" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="checkbox" name="fixed" value="true">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">{% trans "Type forwarding" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select id="forward_select" class="form-control" name="forward">
|
||||
<option value="nat">{% trans "NAT" %}</option>
|
||||
<option value="route">{% trans "ROUTE" %}</option>
|
||||
<option value="none">{% trans "ISOLATE" %}</option>
|
||||
<option value="bridge">{% trans "BRIDGE" %}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group bridge_name_form_group">
|
||||
<label class="col-sm-4 control-label">{% trans "Bridge Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" name="bridge_name" placeholder="br0" pattern="[a-z0-9\-_]+">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group bridge_name_form_group">
|
||||
<label class="col-sm-4 control-label">{% trans "Open vSwitch" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="checkbox" name="openvswitch" value="true">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
|
||||
<button type="submit" class="btn btn-primary" name="create">{% trans "Create" %}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div> <!-- /.modal-content -->
|
||||
</div> <!-- /.modal-dialog -->
|
||||
</div> <!-- /.modal -->
|
||||
{% endif %}
|
187
networks/templates/network.html
Normal file
187
networks/templates/network.html
Normal file
|
@ -0,0 +1,187 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Network" %} - {{ pool }}{% endblock %}
|
||||
{% block content %}
|
||||
<!-- Page Heading -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header">{% trans "Network:" %} {{ pool }}</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li class="active">
|
||||
<i class="fa fa-dashboard"></i> <a href="{% url 'overview' compute.id %}">{% trans "Overview" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-hdd-o"></i> <a href="{% url 'storages' compute.id %}">{% trans "Storages" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-sitemap"></i> <a href="{% url 'networks' compute.id %}">{% trans "Networks" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-wifi"></i> <a href="{% url 'interfaces' compute.id %}">{% trans "Interfaces" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-key"></i> <a href="{% url 'secrets' compute.id %}">{% trans "Secrets" %}</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
|
||||
{% include 'errors_block.html' %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-6 col-sm-4">
|
||||
<p>{% trans "Network name:" %}</p>
|
||||
<p>{% trans "Device:" %}</p>
|
||||
<p>{% trans "State" %}</p>
|
||||
<p>{% trans "Autostart" %}</p>
|
||||
</div>
|
||||
<div class="col-xs-6 col-sm-6">
|
||||
<p>{{ pool }}</p>
|
||||
<p>{{ device }}</p>
|
||||
<p>
|
||||
<form action="" method="post" role="form">{% csrf_token %}
|
||||
{% ifequal state 0 %}
|
||||
<input type="submit" class="btn btn-xs btn-default" name="start" value="{% trans "Start" %}">
|
||||
<input type="submit" class="btn btn-xs btn-default" name="delete" value="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
{% else %}
|
||||
<input type="submit" class="btn btn-xs btn-default" name="stop" value="{% trans "Stop" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
{% endifequal %}
|
||||
</form>
|
||||
</p>
|
||||
<p>
|
||||
<form action="" method="post" role="form">{% csrf_token %}
|
||||
{% ifequal autostart 0 %}
|
||||
<input type="submit" class="btn btn-xs btn-default" name="set_autostart" value="{% trans "Enable" %}">
|
||||
{% else %}
|
||||
<input type="submit" class="btn btn-xs btn-default" name="unset_autostart" onclick="return confirm('{% trans "Are you sure?" %}')" value="{% trans "Disable" %}">
|
||||
{% endifequal %}
|
||||
</form>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{% if state %}
|
||||
<div class="row">
|
||||
<h3 class="page-header">{% trans "IPv4 configuration" %}</h3>
|
||||
<div class="col-xs-6 col-sm-4">
|
||||
<p>{% trans "IPv4 Forwarding:" %}</p>
|
||||
<p>{% trans "Network:" %}</p>
|
||||
<p>{% trans "DHCP:" %}</p>
|
||||
{% if ipv4_dhcp_range_start and ipv4_dhcp_range_end %}
|
||||
<p>{% trans "Start:" %}</p>
|
||||
<p>{% trans "End:" %}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-xs-6 col-sm-4">
|
||||
<p>
|
||||
{% ifequal ipv4_forward.0 'nat' %}
|
||||
{% trans "NAT" %}
|
||||
{% endifequal %}
|
||||
{% ifequal ipv4_forward.0 'route' %}
|
||||
{% trans "ROUTE" %}
|
||||
{% endifequal %}
|
||||
{% ifequal ipv4_forward.0 'bridge' %}
|
||||
{% trans "BRIDGE" %}
|
||||
{% endifequal %}
|
||||
{% if not ipv4_forward.0 %}
|
||||
{% trans "ISOLATE" %}
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>{{ ipv4_network }}</p>
|
||||
<p>
|
||||
{% if ipv4_dhcp_range_start and ipv4_dhcp_range_end %}
|
||||
<span class="text-success">{% trans "ON" %}</span>
|
||||
{% else %}
|
||||
<span class="text-danger">{% trans "OFF" %}</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% if ipv4_dhcp_range_start and ipv4_dhcp_range_end %}
|
||||
<p>{{ ipv4_dhcp_range_start }}</p>
|
||||
<p>{{ ipv4_dhcp_range_end }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% if fixed_address %}
|
||||
<div class="row">
|
||||
<h3 class="page-header">{% trans "Fixed Address" %}</h3>
|
||||
<div class="col-xs-12">
|
||||
<div class="panel-group" id="accordion">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
|
||||
Show
|
||||
</a>
|
||||
</div>
|
||||
<div id="collapseOne" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<div class="input-append form-inline pull-right" style="">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" id="filter_input">
|
||||
</div>
|
||||
<input type="button" class="btn btn-default" id="filter_button" value="Filter">
|
||||
<button type="button" class="btn btn-default" id="filter_clear">Clear</button>
|
||||
</div>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: center">{% trans "Address" %}</th>
|
||||
<th style="text-align: center">{% trans "MAC" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody style="text-align: center">
|
||||
{% for fix in fixed_address %}
|
||||
<tr>
|
||||
<td>{{ fix.host }}</td>
|
||||
<td>{{ fix.mac }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block script %}
|
||||
<script>
|
||||
$.expr[':'].Contains = $.expr.createPseudo(function (arg) {
|
||||
return function (elem) {
|
||||
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
|
||||
};
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
// add event button labeled "filter"
|
||||
$('#filter_button').click(function (event) {
|
||||
// get value
|
||||
var filter_val = $('#filter_input').val();
|
||||
if (filter_val == '') {
|
||||
// show all
|
||||
$('tbody tr').show();
|
||||
} else {
|
||||
// show only matches
|
||||
$('tbody tr:Contains(\'' + filter_val + '\')').show();
|
||||
// hide non-matching items
|
||||
$('tbody tr:not(:Contains(\'' + filter_val + '\'))').hide();
|
||||
}
|
||||
});
|
||||
|
||||
// add event button labeled "clear"
|
||||
$('#filter_clear').click(function (event) {
|
||||
$('#filter_input').val('');
|
||||
$('#filter_button').click();
|
||||
});
|
||||
|
||||
// trigger filter when enter key pressed
|
||||
$('#filter_input').keyup(function (event) {
|
||||
if (event.keyCode == 13) {
|
||||
$('#filter_button').click();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
80
networks/templates/networks.html
Normal file
80
networks/templates/networks.html
Normal file
|
@ -0,0 +1,80 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Networks" %} - {{ compute.name }}{% endblock %}
|
||||
{% block content %}
|
||||
<!-- Page Heading -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
{% include 'create_net_block.html' %}
|
||||
<h1 class="page-header">{{ compute.name }}</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li class="active">
|
||||
<i class="fa fa-dashboard"></i> <a href="{% url 'overview' compute.id %}">{% trans "Overview" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-hdd-o"></i> <a href="{% url 'storages' compute.id %}">{% trans "Storages" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-sitemap"></i> {% trans "Networks" %}
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-wifi"></i> <a href="{% url 'interfaces' compute.id %}">{% trans "Interfaces" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-key"></i> <a href="{% url 'secrets' compute.id %}">{% trans "Secrets" %}</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
|
||||
{% include 'errors_block.html' %}
|
||||
|
||||
<div class="row">
|
||||
{% if not networks %}
|
||||
<div class="col-lg-12">
|
||||
<div class="alert alert-warning alert-dismissable">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<i class="fa fa-exclamation-triangle"></i> <strong>{% trans "Warning:" %}</strong> {% trans "Hypervisor doesn't have any Networks" %}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
{% for pool in networks %}
|
||||
<div class="col-xs-12 col-sm-4">
|
||||
<div class="panel {% if pool.status %}panel-success{% else %}panel-danger{% endif %} panel-data">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><a href="{% url 'network' compute.id pool.name %}">{{ pool.name }}</a></h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-xs-4 col-sm-4">
|
||||
<p><strong>{% trans "Device:" %}</strong></p>
|
||||
<p><strong>{% trans "Forward:" %}</strong></p>
|
||||
</div>
|
||||
<div class="col-xs-6 col-sm-7">
|
||||
<p>{{ pool.device }}</p>
|
||||
<p>{{ pool.forward|upper }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block script %}
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#forward_select').change(function (eventObject) {
|
||||
if ($(this).val() == 'bridge') {
|
||||
$('.bridge_name_form_group').show();
|
||||
$('.bridge_name_form_group_dhcp').hide();
|
||||
} else {
|
||||
$('.bridge_name_form_group').hide();
|
||||
$('.bridge_name_form_group_dhcp').show();
|
||||
}
|
||||
}).change();
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -57,7 +57,7 @@ def networks(request, compute_id):
|
|||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err)
|
||||
|
||||
return render(request, 'networks/networks.html', locals())
|
||||
return render(request, 'networks.html', locals())
|
||||
|
||||
|
||||
def network(request, compute_id, pool):
|
||||
|
@ -127,4 +127,4 @@ def network(request, compute_id, pool):
|
|||
|
||||
conn.close()
|
||||
|
||||
return render(request, 'networks/network.html', locals())
|
||||
return render(request, 'network.html', locals())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue