Skip to content

Commit

Permalink
AJAX modal for associate floating IP. Fixes bug 884495.
Browse files Browse the repository at this point in the history
Change-Id: I4f7bdf9a3f22c2b9efeaee1b9de84a51347d847e
  • Loading branch information
gabrielhurley committed Nov 24, 2011
1 parent 72927d2 commit 0ac50ad
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
14 changes: 10 additions & 4 deletions horizon/horizon/dashboards/nova/floating_ips/views.py
Expand Up @@ -74,10 +74,16 @@ def associate(request, ip_id):
if handled:
return handled

return shortcuts.render(request,
'nova/floating_ips/associate.html', {
'floating_ip_id': ip_id,
'associate_form': form})
context = {'floating_ip_id': ip_id,
'form': form}

if request.is_ajax():
template = 'nova/floating_ips/_associate.html'
context['hide'] = True
else:
template = 'nova/floating_ips/associate.html'

return shortcuts.render(request, template, context)


@login_required
Expand Down
Expand Up @@ -11,8 +11,8 @@
<td>
{% if ip.fixed_ip %}
<ul>
<li><span>{%trans "Instance ID:"%}</span> {{ip.instance_id}}</li>
<li><span>{%trans "Fixed IP:"%}</span> {{ip.fixed_ip}}</li>
<li><span>{% trans "Instance ID:" %}</span> {{ ip.instance_id }}</li>
<li><span>{% trans "Fixed IP:" %}</span> {{ ip.fixed_ip }}</li>
</ul>
{% else %}
None
Expand All @@ -25,7 +25,7 @@
{% if ip.fixed_ip %}
<li class="form">{% include "nova/floating_ips/_disassociate.html" with form=disassociate_form %}</li>
{% else %}
<li class="form"><a class="btn small" href="{% url horizon:nova:floating_ips:associate ip.id %}">{%trans "Associate to instance"%}</a></li>
<li class="form"><a class="btn small ajax-modal" href="{% url horizon:nova:floating_ips:associate ip.id %}">{%trans "Associate to instance"%}</a></li>
{% endif %}
</ul>
</td>
Expand Down
Expand Up @@ -7,5 +7,5 @@
{% endblock page_header %}

{% block dash_main %}
{% include 'nova/floating_ips/_associate.html' with form=associate_form %}
{% include 'nova/floating_ips/_associate.html' %}
{% endblock %}
18 changes: 14 additions & 4 deletions openstack-dashboard/dashboard/static/dashboard/js/application.js
@@ -1,5 +1,5 @@
(function($, window, document, undefined) {
$.fn.columnar = function (target, opt) {
$.fn.columnar = function (target, opt) {
var options = $.extend({
trigger: 'change',
retrieve: 'name',
Expand All @@ -16,9 +16,20 @@


$(function(){
$('.cancel').click(function(){
$('.modal:not(.static_page) .cancel').live('click', function (evt) {
$(this).closest('.modal').remove();
});

})
$('.ajax-modal').click(function (evt) {
var $this = $(this);
$.ajax($this.attr('href'), {
complete: function (jqXHR, status) {
$('body').append(jqXHR.responseText);
$('body .modal:last').modal({'show':true, 'backdrop': true, 'keyboard': true});
}
});
return false;
});

$('.table_search input').quicksearch('tr.odd, tr.even', {
'delay': 300,
Expand All @@ -43,7 +54,6 @@ $(function(){
$('#keypair_filter form input[type=checkbox]').columnar({});



// show+hide image details
$(".details").hide()
$("#images td:not(#actions)").click(function(e){
Expand Down

0 comments on commit 0ac50ad

Please sign in to comment.