Display flavor details in instance listing in a popover

This patch moves the flavor details in the instance listing into
a popover to reduce the amount of displayed details in the listing.

Change-Id: Ibd8cd228bae41e0f2870a8a14b6ce21338d61a8f
Closes-Bug: #1314177
This commit is contained in:
Christian Berendt 2014-05-05 15:15:49 +02:00
parent d370764055
commit 233b4345c4
4 changed files with 35 additions and 8 deletions

View File

@ -163,7 +163,9 @@ class InstanceViewTest(test.BaseAdminViewTests):
# two instances of name, other name comes from row data-display
self.assertContains(res, "server_1", 2, 200)
self.assertContains(res, "10.0.0.1", 1, 200)
self.assertContains(res, "512MB RAM | 1 VCPU | 0Bytes Disk", 1, 200)
self.assertContains(res, "RAM</th><td>512MB", 1, 200)
self.assertContains(res, "VCPUs</th><td>1", 1, 200)
self.assertContains(res, "Size</th><td>0 GB", 1, 200)
self.assertContains(res, "Active", 1, 200)
self.assertContains(res, "Running", 1, 200)

View File

@ -663,13 +663,20 @@ def get_ips(instance):
def get_size(instance):
if hasattr(instance, "full_flavor"):
size_string = _("%(name)s | %(RAM)s RAM | %(VCPU)s VCPU "
"| %(disk)s Disk")
vals = {'name': instance.full_flavor.name,
'RAM': sizeformat.mbformat(instance.full_flavor.ram),
'VCPU': instance.full_flavor.vcpus,
'disk': sizeformat.diskgbformat(instance.full_flavor.disk)}
return size_string % vals
template_name = 'project/instances/_instance_flavor.html'
size_ram = sizeformat.mb_float_format(instance.full_flavor.ram)
if instance.full_flavor.disk > 0:
size_disk = sizeformat.diskgbformat(instance.full_flavor.disk)
else:
size_disk = _("%s GB") % "0"
context = {
"name": instance.full_flavor.name,
"flavor_id": instance.full_flavor.id,
"size_disk": size_disk,
"size_ram": size_ram,
"vcpus": instance.full_flavor.vcpus
}
return template.loader.render_to_string(template_name, context)
return _("Not available")

View File

@ -0,0 +1,13 @@
{% load i18n %}
<a href="#" id="flavor_details_{{ flavor_id }}" class="link-popover" rel="popover" data-content="
<table class='table table-bordered'>
<tr><th>{% trans 'VCPUs' %}</th><td>{{ vcpus }}</td></tr>
<tr><th>{% trans 'RAM' %}</th><td>{{ size_ram }}</td></tr>
<tr><th>{% trans 'Size' %}</th><td>{{ size_disk }}</td></tr>
</table>
" data-original-title="{% trans "Flavor Details" %}: {{ name }}">{{ name }}</a>
<script type="text/javascript" charset="utf-8">
$(function ()
{ $("#flavor_details_{{ flavor_id }}").popover();
});
</script>

View File

@ -2560,3 +2560,8 @@ $contentTableWidth: $browserWrapperWidth - $navigationTableWidth;
background-image: url(/static/dashboard/img/drop_arrow.png);
}
}
/**** Popover ****/
a.link-popover { cursor: default; }
a:hover.link-popover { text-decoration: none; }