Commit 399b45f6 by Oláh István Gergely

dashboard: list groups, make group table

parent fca3ac78
from django.contrib.auth.models import Group
from django_tables2 import Table, A from django_tables2 import Table, A
from django_tables2.columns import (TemplateColumn, Column, BooleanColumn, from django_tables2.columns import (TemplateColumn, Column, BooleanColumn,
LinkColumn) LinkColumn)
...@@ -101,6 +102,14 @@ class NodeListTable(Table): ...@@ -101,6 +102,14 @@ class NodeListTable(Table):
'number_of_VMs', ) 'number_of_VMs', )
class GroupListTable(Table):
class Meta:
model = Group
attrs = {'class': ('table table-bordered table-striped table-hover '
'group-list-table')}
fields = ('id', 'name', )
class NodeVmListTable(Table): class NodeVmListTable(Table):
pk = TemplateColumn( pk = TemplateColumn(
template_name='dashboard/vm-list/column-id.html', template_name='dashboard/vm-list/column-id.html',
......
{% extends "dashboard/base.html" %}
{% load i18n %}
{% load render_table from django_tables2 %}
{% block content %}
<div class="alert alert-info">
Tip #1: you can select multiple vm instances while holding down the <strong>CTRL</strong> key!
</div>
<div class="alert alert-info">
Tip #2: if you want to select multiple instances by one click select an instance then hold down <strong>SHIFT</strong> key and select another one!
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="no-margin"><i class="icon-desktop"></i> Your nodes</h3>
</div>
<div class="panel-body node-list-group-control">
<p>
<strong>Group actions</strong>
<button id="node-list-group-select-all" class="btn btn-info btn-xs">Select all</button>
<a class="btn btn-default btn-xs" id="node-list-group-migrate" disabled><i class="icon-truck"></i> Migrate</a>
<a disabled href="#" class="btn btn-default btn-xs"><i class="icon-refresh"></i> Reboot</a>
<a disabled href="#" class="btn btn-default btn-xs"><i class="icon-off"></i> Shutdown</a>
<a id="node-list-group-delete" disabled href="#" class="btn btn-danger btn-xs"><i class="icon-remove"></i> Discard</a>
</p>
</div>
<div id="table_container">
<div id="rendered_table" class="panel-body">
{% render_table table %}
</div>
</div>
</div>
</div>
</div>
<style>
.popover {
max-width: 600px;
}
.node-list-selected, .node-list-selected td {
background-color: #e8e8e8 !important;
}
.node-list-selected:hover, .node-list-selected:hover td {
background-color: #d0d0d0 !important;
}
.node-list-selected td:first-child {
font-weight: bold;
}
.node-list-table-thin {
width: 10px;
}
.node-list-table-admin {
width: 130px;
}
</style>
{% endblock %}
{% block extra_js %}
<script src="{{ STATIC_URL}}dashboard/node-list.js"></script>
{% endblock %}
...@@ -8,26 +8,28 @@ ...@@ -8,26 +8,28 @@
</h3> </h3>
</div> </div>
<div class="list-group" id="vm-list-view"> <div class="list-group" id="vm-list-view">
{% for i in groups %}
<a href="#" class="list-group-item"> <a href="#" class="list-group-item">
<i class="icon-file"></i> ALMA <div class="pull-right"><i class="icon-download-alt "></i></div> <i class="icon-file"></i> {{ i.name }}<div class="pull-right"><i class="icon-download-alt "></i></div>
</a>
<a href="#" class="list-group-item">
<i class="icon-file-text"></i> ALMA.docx <div class="pull-right"><i class="icon-download-alt "></i></div>
</a>
<a href="#" class="list-group-item">
<i class="icon-file-text"></i> ALMA.docx <div class="pull-right"><i class="icon-download-alt "></i></div>
</a>
<a href="#" class="list-group-item">
<i class="icon-file-text"></i> ALMA.docx <div class="pull-right"><i class="icon-download-alt "></i></div>
</a>
<a href="#" class="list-group-item">
<i class="icon-file-text"></i> ALMA.docx <div class="pull-right"><i class="icon-download-alt "></i></div>
</a> </a>
{% endfor %}
<div href="#" class="list-group-item list-group-footer text-right"> <div href="#" class="list-group-item list-group-footer text-right">
<p> <div class="row">
<a class="btn btn-primary btn-xs"><i class="icon-chevron-sign-right"></i> show more </a> <div class="col-sm-6 col-xs-6 input-group input-group-sm">
<a class="btn btn-success btn-xs"><i class="icon-upload-alt"></i> upload </a> <input type="text" class="form-control" placeholder="Search..." />
</p> <div class="input-group-btn">
<button type="submit" class="form-control btn btn-primary" title="search"><i class="icon-search"></i></button>
</div>
</div>
<div class="col-sm-6 text-right">
{% if more_groups >= 0 %}
<a class="btn btn-primary btn-xs" href="{% url "dashboard.views.group-list" %}">
<i class="icon-chevron-sign-right"></i> <strong>{{ more_groups }}</strong> more
</a>
{% endif %}
<a class="btn btn-success btn-xs group-create" href="#"><i class="icon-upload-alt"></i> upload </a>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -6,7 +6,7 @@ from .views import ( ...@@ -6,7 +6,7 @@ from .views import (
VmDelete, VmMassDelete, vm_activity, NodeList, NodeDetailView, PortDelete, VmDelete, VmMassDelete, vm_activity, NodeList, NodeDetailView, PortDelete,
TransferOwnershipView, TransferOwnershipConfirmView, NodeDelete, TransferOwnershipView, TransferOwnershipConfirmView, NodeDelete,
TemplateList, LeaseDetail, NodeCreate, LeaseCreate, TemplateCreate, TemplateList, LeaseDetail, NodeCreate, LeaseCreate, TemplateCreate,
FavouriteView, NodeStatus, FavouriteView, NodeStatus, GroupList,
) )
urlpatterns = patterns( urlpatterns = patterns(
...@@ -51,4 +51,6 @@ urlpatterns = patterns( ...@@ -51,4 +51,6 @@ urlpatterns = patterns(
name='dashboard.views.node-create'), name='dashboard.views.node-create'),
url(r'^favourite/$', FavouriteView.as_view(), url(r'^favourite/$', FavouriteView.as_view(),
name='dashboard.views.favourite'), name='dashboard.views.favourite'),
url(r'^group/list/$', GroupList.as_view(),
name='dashboard.views.group-list'),
) )
...@@ -25,7 +25,7 @@ from braces.views import LoginRequiredMixin, SuperuserRequiredMixin ...@@ -25,7 +25,7 @@ from braces.views import LoginRequiredMixin, SuperuserRequiredMixin
from .forms import VmCreateForm, TemplateForm, LeaseForm, NodeForm, HostForm from .forms import VmCreateForm, TemplateForm, LeaseForm, NodeForm, HostForm
from .tables import (VmListTable, NodeListTable, NodeVmListTable, from .tables import (VmListTable, NodeListTable, NodeVmListTable,
TemplateListTable, LeaseListTable) TemplateListTable, LeaseListTable, GroupListTable)
from vm.models import (Instance, InstanceTemplate, InterfaceTemplate, from vm.models import (Instance, InstanceTemplate, InterfaceTemplate,
InstanceActivity, Node, instance_activity, Lease, InstanceActivity, Node, instance_activity, Lease,
Interface) Interface)
...@@ -76,9 +76,12 @@ class IndexView(LoginRequiredMixin, TemplateView): ...@@ -76,9 +76,12 @@ class IndexView(LoginRequiredMixin, TemplateView):
}) })
nodes = Node.objects.all() nodes = Node.objects.all()
groups = Group.objects.all()
context.update({ context.update({
'nodes': nodes[:10], 'nodes': nodes[:10],
'more_nodes': nodes.count() - len(nodes[:10]), 'more_nodes': nodes.count() - len(nodes[:10]),
'groups': groups[:10],
'more_groups': groups.count() - len(groups[:10]),
'sum_node_num': nodes.count(), 'sum_node_num': nodes.count(),
'node_num': { 'node_num': {
'running': Node.get_state_count(True, True), 'running': Node.get_state_count(True, True),
...@@ -567,6 +570,13 @@ class NodeList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView): ...@@ -567,6 +570,13 @@ class NodeList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
table_pagination = False table_pagination = False
class GroupList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
template_name = "dashboard/group-list.html"
model = Group
table_class = GroupListTable
table_pagination = False
class VmCreate(LoginRequiredMixin, TemplateView): class VmCreate(LoginRequiredMixin, TemplateView):
form_class = VmCreateForm form_class = VmCreateForm
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment