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.columns import (TemplateColumn, Column, BooleanColumn,
LinkColumn)
......@@ -101,6 +102,14 @@ class NodeListTable(Table):
'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):
pk = TemplateColumn(
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 @@
</h3>
</div>
<div class="list-group" id="vm-list-view">
{% for i in groups %}
<a href="#" class="list-group-item">
<i class="icon-file"></i> ALMA <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>
<i class="icon-file"></i> {{ i.name }}<div class="pull-right"><i class="icon-download-alt "></i></div>
</a>
{% endfor %}
<div href="#" class="list-group-item list-group-footer text-right">
<p>
<a class="btn btn-primary btn-xs"><i class="icon-chevron-sign-right"></i> show more </a>
<a class="btn btn-success btn-xs"><i class="icon-upload-alt"></i> upload </a>
</p>
<div class="row">
<div class="col-sm-6 col-xs-6 input-group input-group-sm">
<input type="text" class="form-control" placeholder="Search..." />
<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>
......@@ -6,7 +6,7 @@ from .views import (
VmDelete, VmMassDelete, vm_activity, NodeList, NodeDetailView, PortDelete,
TransferOwnershipView, TransferOwnershipConfirmView, NodeDelete,
TemplateList, LeaseDetail, NodeCreate, LeaseCreate, TemplateCreate,
FavouriteView, NodeStatus,
FavouriteView, NodeStatus, GroupList,
)
urlpatterns = patterns(
......@@ -51,4 +51,6 @@ urlpatterns = patterns(
name='dashboard.views.node-create'),
url(r'^favourite/$', FavouriteView.as_view(),
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
from .forms import VmCreateForm, TemplateForm, LeaseForm, NodeForm, HostForm
from .tables import (VmListTable, NodeListTable, NodeVmListTable,
TemplateListTable, LeaseListTable)
TemplateListTable, LeaseListTable, GroupListTable)
from vm.models import (Instance, InstanceTemplate, InterfaceTemplate,
InstanceActivity, Node, instance_activity, Lease,
Interface)
......@@ -76,9 +76,12 @@ class IndexView(LoginRequiredMixin, TemplateView):
})
nodes = Node.objects.all()
groups = Group.objects.all()
context.update({
'nodes': nodes[:10],
'more_nodes': nodes.count() - len(nodes[:10]),
'groups': groups[:10],
'more_groups': groups.count() - len(groups[:10]),
'sum_node_num': nodes.count(),
'node_num': {
'running': Node.get_state_count(True, True),
......@@ -567,6 +570,13 @@ class NodeList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
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):
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