Merge "Show popups on node boxes everywhere"

This commit is contained in:
Jenkins 2015-01-09 09:41:44 +00:00 committed by Gerrit Code Review
commit c0daa7faaa
7 changed files with 62 additions and 36 deletions

View File

@ -17,6 +17,7 @@ import operator
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
import django.utils.text import django.utils.text
from django.utils.translation import ugettext_lazy as _
from openstack_dashboard.api import base as api_base from openstack_dashboard.api import base as api_base
from tuskar_ui import api from tuskar_ui import api
@ -78,6 +79,8 @@ def _node_data(request, nodes):
'uuid': node.uuid, 'uuid': node.uuid,
'role_name': role.name if role else '', 'role_name': role.name if role else '',
'role_slug': django.utils.text.slugify(role.name) if role else '', 'role_slug': django.utils.text.slugify(role.name) if role else '',
'node_title': unicode(_("{0} node").format(role.name.title())
if role else _("Free node")),
'state': node.state, 'state': node.state,
'state_slug': django.utils.text.slugify(unicode(node.state)), 'state_slug': django.utils.text.slugify(unicode(node.state)),
'state_icon': NODE_STATE_ICON.get(node.state, 'state_icon': NODE_STATE_ICON.get(node.state,
@ -115,6 +118,13 @@ class IndexView(views.IndexView):
def get_data(self, request, context, *args, **kwargs): def get_data(self, request, context, *args, **kwargs):
data = super(IndexView, self).get_data(request, context, data = super(IndexView, self).get_data(request, context,
*args, **kwargs) *args, **kwargs)
nodes = list(_node_data(
request, api.node.Node.list(request, maintenance=False),
))
nodes.sort(key=lambda node: node.get('role_name'))
nodes.reverse()
data['nodes'] = nodes
if not data['stack']: if not data['stack']:
flavors = api.flavor.Flavor.list(self.request) flavors = api.flavor.Flavor.list(self.request)
if not MATCHING_DEPLOYMENT_MODE: if not MATCHING_DEPLOYMENT_MODE:
@ -126,6 +136,7 @@ class IndexView(views.IndexView):
free_roles = [] free_roles = []
flavor_roles = {} flavor_roles = {}
for role in roles: for role in roles:
if 'form' in data:
role['flavor_field'] = data['form'][role['id'] + '-flavor'] role['flavor_field'] = data['form'][role['id'] + '-flavor']
flavor = role['role'].flavor(data['plan']) flavor = role['role'].flavor(data['plan'])
if flavor in flavors: if flavor in flavors:
@ -138,13 +149,6 @@ class IndexView(views.IndexView):
data['flavors'] = list( data['flavors'] = list(
_flavor_data(self.request, flavors, flavor_roles)) _flavor_data(self.request, flavors, flavor_roles))
else: else:
nodes = list(_node_data(
request, api.node.Node.list(request, maintenance=False),
))
nodes.sort(key=lambda node: node.get('role_name'))
nodes.reverse()
data['nodes'] = nodes
distribution = collections.Counter() distribution = collections.Counter()
for node in nodes: for node in nodes:

View File

@ -7,7 +7,14 @@ tuskar.boxes_progress = function () {
}; };
module.update_progress = function (data) { module.update_progress = function (data) {
$('div.boxes-nodes').html(module.nodes_template.render(data)); var $nodes = $('div.boxes-nodes');
$nodes.html(module.nodes_template.render(data));
$nodes.find('div.boxes-node').popover({
'trigger': 'hover',
'placement': 'auto',
'delay': 500,
'html': true
});
}; };
// Attach to the original update procedure. // Attach to the original update procedure.

View File

@ -1,8 +1,18 @@
{% load i18n %} {% load i18n %}
<div <div
class="boxes-node boxes-role-none" class="boxes-nodes
{% if nodes|length >= 100 %}
boxes-nodes-small
{% elif nodes|length >= 25 %}
boxes-nodes-medium
{% endif %}
{{ classes }}"
>
{% for node in nodes %}{% spaceless %}
<div
class="boxes-node boxes-role-{{ node.role_slug }}"
data-toggle="popover" data-toggle="popover"
title="{{ node.role_name|title|default:_('Free') }} {% trans 'node' %}" title="{{ node.node_title }}"
data-content="<dl> data-content="<dl>
<dt>{% trans "Node UUID" %}</dt> <dt>{% trans "Node UUID" %}</dt>
<dd>{{ node.uuid }}</dd> <dd>{{ node.uuid }}</dd>
@ -15,4 +25,6 @@
<dt>{% trans "HDD (GB)" %}</dt> <dt>{% trans "HDD (GB)" %}</dt>
<dd>{{ node.local_gb }}</dd> <dd>{{ node.local_gb }}</dd>
</dl>" </dl>"
>free</div> ><i class="fa fa-lg {{ node.state_icon }}"></i></div>
{% endspaceless %}{% endfor %}
</div>

View File

@ -0,0 +1,23 @@
{% load i18n %}
{% load horizon %}
<script type="text/html" id="nodes-template">{% spaceless %}{% jstemplate %}
[[#nodes]]
<div
class="boxes-node boxes-role-[[ role_slug ]] status-[[ state_slug ]]"
data-toggle="popover"
title="[[ node_title ]]"
data-content="<dl>
<dt>{% trans "Node UUID" %}</dt>
<dd>[[ uuid ]]</dd>
<dt>{% trans "Architecture" %}</dt>
<dd>[[ cpu_arch ]]</dd>
<dt>{% trans "CPUs" %}</dt>
<dd>[[ cpus ]]</dt>
<dt>{% trans "RAM (MB)" %}</dt>
<dd>[[ memory_mb ]]</dd>
<dt>{% trans "HDD (GB)" %}</dt>
<dd>[[ local_gb ]]</dd>
</dl>"
><i class="fa fa-lg [[ state_icon ]]"></i></div>
[[/nodes]]
{% endjstemplate %}{% endspaceless %}</script>

View File

@ -67,11 +67,7 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div> </div>
<div class="boxes-nodes {% if nodes|length >= 100 %}boxes-nodes-small{% elif nodes|length >= 25 %}boxes-nodes-medium{% endif %}"> {% include "tuskar_boxes/overview/_node_info.html" with nodes=nodes %}
{% for node in nodes %}{% spaceless %}
<div class="boxes-node boxes-role-{{ node.role_slug }}"></div>
{% endspaceless %}{% endfor %}
</div>
{% endif %} {% endif %}
</div> </div>
</div> </div>

View File

@ -58,11 +58,7 @@
</ul> </ul>
</div> </div>
</div> </div>
<div class="col-xs-7 boxes-nodes {% if flavor.nodes|length >= 100 %}boxes-nodes-small{% elif flavor.nodes|length >= 25 %}boxes-nodes-medium{% endif %}"> {% include "tuskar_boxes/overview/_node_info.html" with nodes=flavor.nodes classes="col-xs-7" %}
{% for node in flavor.nodes %}{% spaceless %}
{% include "tuskar_boxes/overview/_node_info.html" with node=node %}
{% endspaceless %}{% endfor %}
</div>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}

View File

@ -20,13 +20,7 @@
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
<div class="col-xs-7 boxes-nodes {% if nodes|length >= 100 %}boxes-nodes-small{% elif nodes|length >= 25 %}boxes-nodes-medium{% endif %}"> {% include "tuskar_boxes/overview/_node_info.html" with nodes=nodes classes="col-xs-7" %}
{% for node in nodes %}{% spaceless %}
<div class="boxes-node boxes-role-{{ node.role_slug }} status-{{ node.state_slug }}" title="{{ node.uuid }}">
<i class="fa fa-lg {{ node.state_icon }}"></i>
</div>
{% endspaceless %}{% endfor %}
</div>
</div> </div>
<script type="text/html" id="roles-template">{% spaceless %}{% jstemplate %} <script type="text/html" id="roles-template">{% spaceless %}{% jstemplate %}
@ -46,10 +40,4 @@
</div> </div>
[[/roles]] [[/roles]]
{% endjstemplate %}{% endspaceless %}</script> {% endjstemplate %}{% endspaceless %}</script>
<script type="text/html" id="nodes-template">{% spaceless %}{% jstemplate %} {% include "tuskar_boxes/overview/_node_info_js.html" %}
[[#nodes]]
<div class="boxes-node boxes-role-[[ role_slug ]] status-[[ state_slug ]]" title="[[ uuid ]]">
<i class="fa fa-lg [[ state_icon ]]"></i>
</div>
[[/nodes]]
{% endjstemplate %}{% endspaceless %}</script>