Commit a3138b02 by Kálmán Viktor

dashboard: enhance template list table

Closes #239
parent aef328d4
...@@ -184,9 +184,8 @@ class UserListTablex(Table): ...@@ -184,9 +184,8 @@ class UserListTablex(Table):
class TemplateListTable(Table): class TemplateListTable(Table):
name = LinkColumn( name = TemplateColumn(
'dashboard.views.template-detail', template_name="dashboard/template-list/column-template-name.html",
args=[A('pk')],
attrs={'th': {'data-sort': "string"}} attrs={'th': {'data-sort': "string"}}
) )
num_cores = Column( num_cores = Column(
...@@ -194,23 +193,31 @@ class TemplateListTable(Table): ...@@ -194,23 +193,31 @@ class TemplateListTable(Table):
attrs={'th': {'data-sort': "int"}} attrs={'th': {'data-sort': "int"}}
) )
ram_size = TemplateColumn( ram_size = TemplateColumn(
"{{ record.ram_size }} Mb", "{{ record.ram_size }} MiB",
attrs={'th': {'data-sort': "string"}} attrs={'th': {'data-sort': "int"}},
) )
lease = TemplateColumn( lease = TemplateColumn(
"{{ record.lease.name }}", "{{ record.lease.name }}",
verbose_name=_("Lease"), verbose_name=_("Lease"),
attrs={'th': {'data-sort': "string"}} attrs={'th': {'data-sort': "string"}}
) )
arch = Column(
attrs={'th': {'data-sort': "string"}}
)
system = Column( system = Column(
attrs={'th': {'data-sort': "string"}} attrs={'th': {'data-sort': "string"}}
) )
access_method = Column( access_method = Column(
attrs={'th': {'data-sort': "string"}} attrs={'th': {'data-sort': "string"}}
) )
owner = TemplateColumn(
template_name="dashboard/template-list/column-template-owner.html",
verbose_name=_("Owner"),
attrs={'th': {'data-sort': "string"}}
)
running = TemplateColumn(
template_name="dashboard/template-list/column-template-running.html",
verbose_name=_("Running"),
attrs={'th': {'data-sort': "int"}},
orderable=False,
)
actions = TemplateColumn( actions = TemplateColumn(
verbose_name=_("Actions"), verbose_name=_("Actions"),
template_name="dashboard/template-list/column-template-actions.html", template_name="dashboard/template-list/column-template-actions.html",
...@@ -222,8 +229,8 @@ class TemplateListTable(Table): ...@@ -222,8 +229,8 @@ class TemplateListTable(Table):
model = InstanceTemplate model = InstanceTemplate
attrs = {'class': ('table table-bordered table-striped table-hover' attrs = {'class': ('table table-bordered table-striped table-hover'
' template-list-table')} ' template-list-table')}
fields = ('name', 'num_cores', 'ram_size', 'arch', fields = ('name', 'num_cores', 'ram_size', 'system',
'system', 'access_method', 'lease', 'actions', ) 'access_method', 'lease', 'owner', 'running', 'actions', )
prefix = "template-" prefix = "template-"
......
<a href="{% url "dashboard.views.template-detail" pk=record.pk %}" title="{{ record.description }}">
{{ record.name }}
</a>
{% include "dashboard/_display-name.html" with user=record.owner show_org=True %}
<a href="{% url "dashboard.views.vm-list" %}?s=template:{{ record.pk }} status:running">
{{ record.get_running_instances.count }}
</a>
...@@ -1555,6 +1555,7 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView): ...@@ -1555,6 +1555,7 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
'tags[]': "tags__name__in", 'tags[]': "tags__name__in",
'tags': "tags__name__in", # for search string 'tags': "tags__name__in", # for search string
'owner': "owner__username", 'owner': "owner__username",
'template': "template__pk",
} }
def get(self, *args, **kwargs): def get(self, *args, **kwargs):
......
...@@ -203,6 +203,9 @@ class InstanceTemplate(AclBase, VirtualMachineDescModel, TimeStampedModel): ...@@ -203,6 +203,9 @@ class InstanceTemplate(AclBase, VirtualMachineDescModel, TimeStampedModel):
for disk in self.disks.all(): for disk in self.disks.all():
disk.destroy() disk.destroy()
def get_running_instances(self):
return Instance.active.filter(template=self, status="RUNNING")
class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin, class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
TimeStampedModel): TimeStampedModel):
......
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