1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2025-07-31 12:41:08 +00:00

Add users and users VMs

;
This commit is contained in:
Retspen 2015-03-02 17:31:25 +02:00
parent 29b05745ad
commit 55e93a9087
11 changed files with 213 additions and 21 deletions

22
templates/instance.html Normal file
View file

@ -0,0 +1,22 @@
{% extends "base.html" %}
{% load i18n %}
{% block title %}{% trans "Instance" %} - {{ vname }}{% endblock %}
{% block content %}
<div class="container-fluid">
<div class="row">
{% include 'sidebar.html' %}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
{% if request.user.is_superuser %}
<button type="button" class="btn btn-success pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
{% endif %}
<h1 class="page-header">{{ vname }}</h1>
{% include 'errors.html' %}
</div>
</div>
</div>
{% endblock %}

View file

@ -13,12 +13,16 @@
{% include 'errors.html' %}
<div class="table-responsive">
{% if request.user.is_superuser %}
<table class="table">
<thead>
<tr class="active">
<th>Name</th>
<th>Host</th>
<th>VCPU</th>
<th>Memory</th>
<th>Status</th>
<th style="width:164px;">Actions</th>
</tr>
@ -33,6 +37,8 @@
<td>
<span class="glyphicon glyphicon-tasks" aria-hidden="true"></span> <a href="{% url 'compute' host.0 %}">{{ host.1 }}</a>
</td>
<td>{{ info.vcpu }}</td>
<td>{{ info.memory }}</td>
<td>{% ifequal info.status 1 %}
<span class="label label-success">{% trans "Running" %}</span>
{% endifequal %}
@ -99,6 +105,94 @@
{% endfor %}
</tbody>
</table>
{% else %}
<table class="table">
<thead>
<tr class="active">
<th>Name</th>
<th>VCPU</th>
<th>Memory</th>
<th>Status</th>
<th style="width:164px;">Actions</th>
</tr>
</thead>
<tbody>
{% for host, vm in all_user_vms.items %}
<tr>
<td>
<span class="glyphicon glyphicon-tasks" aria-hidden="true"></span> <a href="{% url 'instance' host.0 vm.name %}">{{ vm.name }}</a>
</td>
<td>{{ vm.vcpu }}</td>
<td>{{ vm.memory }} {% trans "MB" %}</td>
<td>{% ifequal vm.status 1 %}
<span class="label label-success">{% trans "Running" %}</span>
{% endifequal %}
{% ifequal vm.status 5 %}
<span class="label label-danger">{% trans "Shutoff" %}</span>
{% endifequal %}
{% ifequal vm.status 3 %}
<span class="label label-warning">{% trans "Suspend" %}</span>
{% endifequal %}
</td>
<td><form action="" method="post" role="form">{% csrf_token %}
<input type="hidden" name="name" value="{{ vm.name }}"/>
<input type="hidden" name="compute" value="{{ host.0 }}"/>
{% ifequal vm.status 5 %}
<button class="btn btn-sm btn-default" type="submit" name="start" title="Start">
<span class="glyphicon glyphicon-play"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Suspend" %}">
<span class="glyphicon glyphicon-pause"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Destroy" %}">
<span class="glyphicon glyphicon-stop"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Console" %}">
<span class="glyphicon glyphicon-eye-open"></span>
</button>
{% endifequal %}
{% ifequal vm.status 3 %}
<button class="btn btn-sm btn-default" type="submit" name="resume"
title="{% trans "Resume" %}">
<span class="glyphicon glyphicon-play"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Suspend" %}">
<span class="glyphicon glyphicon-pause"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Destroy" %}">
<span class="glyphicon glyphicon-stop"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Console" %}">
<span class="glyphicon glyphicon-eye-open"></span>
</button>
{% endifequal %}
{% ifequal vm.status 1 %}
<button class="btn btn-sm btn-default disabled" title="{% trans "Start" %}">
<span class="glyphicon glyphicon-play"></span>
</button>
<button class="btn btn-sm btn-default" type="submit" name="suspend"
title="{% trans "Suspend" %}">
<span class="glyphicon glyphicon-pause"></span>
</button>
<button class="btn btn-sm btn-default" type="submit" name="destroy"
title="{% trans "Destroy" %}" onclick="return confirm('Are you sure?')">
<span class="glyphicon glyphicon-stop"></span>
</button>
<a href="#" class="btn btn-sm btn-default"
onclick='open_console("{{ host.0 }}-{{ vm.uuid }}")' title="{% trans "Console" %}">
<span class="glyphicon glyphicon-eye-open"></span>
</a>
{% endifequal %}
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
</div>

23
templates/login.html Normal file
View file

@ -0,0 +1,23 @@
{% extends "base.html" %}
{% load i18n %}
{% block title %}{% trans "Sign In" %}{% endblock %}
{% block content %}
<div class="row">
<div class="col-xs-12" role="main">
{% if form.errors %}
<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
{% trans "Incorrect username or password." %}
</div>
{% endif %}
<form class="form-signin" method="post" role="form">{% csrf_token %}
<h2 class="form-signin-heading">{% trans "Sign In" %}</h2>
<input type="text" class="form-control" name="username" placeholder="Login" autocapitalize="none"
autocorrect="off" autofocus>
<input type="password" class="form-control" name="password" placeholder="Password">
<input name="next" id="next" type="hidden" value="{% url 'instances' %}">
<button class="btn btn-lg btn-success btn-block" type="submit">{% trans "Sign In" %}</button>
</form>
</div>
</div>
{% endblock %}

12
templates/logout.html Normal file
View file

@ -0,0 +1,12 @@
{% extends "base.html" %}
{% load i18n %}
{% block title %}{% trans "Sign Out" %}{% endblock %}
{% block content %}
<div class="row">
<div class="col-xs-12" role="main">
<div class="logout">
<h1>{% trans "Successful log out" %}</h1>
</div>
</div>
</div>
{% endblock %}

View file

@ -5,8 +5,10 @@
<hr>
<ul class="nav nav-sidebar">
<li {% active request "^/instance" %}><a href="{% url 'instances' %}"><span class="glyphicon glyphicon-th" aria-hidden="true"></span></a></li>
<li {% active request "^/compute" %}><a href="{% url 'computes' %}"><span class="glyphicon glyphicon-tasks" aria-hidden="true"></span></a></li>
<li {% active request "^/user" %}><a href="{% url 'users' %}"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></a></li>
{% if request.user.is_superuser %}
<li {% active request "^/compute" %}><a href="{% url 'computes' %}"><span class="glyphicon glyphicon-tasks" aria-hidden="true"></span></a></li>
<li {% active request "^/user" %}><a href="{% url 'users' %}"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></a></li>
{% endif %}
<li class="bottom-sticky">
<a href="#"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span></a>
<a href="{% url 'logout' %}"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span></a>