Commit 00b87bac by Kálmán Viktor

dashboard: add/remove disk operation buttons on state change

parent 9cc124e8
...@@ -43,10 +43,10 @@ $(function() { ...@@ -43,10 +43,10 @@ $(function() {
success: function(data, textStatus, xhr) { success: function(data, textStatus, xhr) {
$('#confirmation-modal').modal("hide"); $('#confirmation-modal').modal("hide");
if(data.redirect) { if(data.success) {
$('a[href="#activity"]').trigger("click"); $('a[href="#activity"]').trigger("click");
if(data.messages.length > 0) { if(data.messages && data.messages.length > 0) {
addMessage(data.messages.join("<br />"), "danger"); addMessage(data.messages.join("<br />"), "danger");
} }
} }
......
...@@ -341,6 +341,7 @@ function checkNewActivity(only_status, runs) { ...@@ -341,6 +341,7 @@ function checkNewActivity(only_status, runs) {
if(!only_status) { if(!only_status) {
$("#activity-timeline").html(data['activities']); $("#activity-timeline").html(data['activities']);
$("#ops").html(data['ops']); $("#ops").html(data['ops']);
$("#disk-ops").html(data['disk_ops']);
$("[title]").tooltip(); $("[title]").tooltip();
} }
......
{% load i18n %}
{% for op in ops %}
{% if op.is_disk_operation %}
<a href="{{op.get_url}}" class="btn btn-success btn-xs
operation operation-{{op.op}} btn btn-default">
<i class="icon-{{op.icon}}"></i>
{{op.name}} </a>
{% endif %}
{% endfor %}
...@@ -47,18 +47,9 @@ ...@@ -47,18 +47,9 @@
<h3> <h3>
{% trans "Disks" %} {% trans "Disks" %}
<div class="pull-right"> <div class="pull-right">
{% if op.download_disk %} <div id="disk-ops">
<a href="{{op.download_disk.get_url}}" class="btn btn-success btn-xs {% include "dashboard/vm-detail/_disk-operations.html" %}
operation operation-{{op.download_disk.op}} btn btn-default"> </div>
<i class="icon-{{op.download_disk.icon}}"></i>
{{op.download_disk.name}} </a>
{% endif %}
{% if op.create_disk %}
<a href="{{op.create_disk.get_url}}" class="btn btn-success btn-xs
operation operation-{{op.create_disk.op}} btn btn-default">
<i class="icon-{{op.create_disk.icon}}"></i>
{{op.create_disk.name}} </a>
{% endif %}
</div> </div>
</h3> </h3>
......
...@@ -579,7 +579,7 @@ class VmOperationView(OperationView): ...@@ -579,7 +579,7 @@ class VmOperationView(OperationView):
store = messages.get_messages(request) store = messages.get_messages(request)
store.used = True store.used = True
return HttpResponse( return HttpResponse(
json.dumps({'redirect': resp.url, json.dumps({'success': True,
'messages': [unicode(m) for m in store]}), 'messages': [unicode(m) for m in store]}),
content_type="application=json" content_type="application=json"
) )
...@@ -609,7 +609,7 @@ class FormOperationMixin(object): ...@@ -609,7 +609,7 @@ class FormOperationMixin(object):
request, extra, *args, **kwargs) request, extra, *args, **kwargs)
if request.is_ajax(): if request.is_ajax():
return HttpResponse( return HttpResponse(
json.dumps({'redirect': resp.url}), json.dumps({'success': True}),
content_type="application=json" content_type="application=json"
) )
else: else:
...@@ -624,6 +624,7 @@ class VmCreateDiskView(FormOperationMixin, VmOperationView): ...@@ -624,6 +624,7 @@ class VmCreateDiskView(FormOperationMixin, VmOperationView):
form_class = VmCreateDiskForm form_class = VmCreateDiskForm
show_in_toolbar = False show_in_toolbar = False
icon = 'hdd' icon = 'hdd'
is_disk_operation = True
class VmDownloadDiskView(FormOperationMixin, VmOperationView): class VmDownloadDiskView(FormOperationMixin, VmOperationView):
...@@ -632,6 +633,7 @@ class VmDownloadDiskView(FormOperationMixin, VmOperationView): ...@@ -632,6 +633,7 @@ class VmDownloadDiskView(FormOperationMixin, VmOperationView):
form_class = VmDownloadDiskForm form_class = VmDownloadDiskForm
show_in_toolbar = False show_in_toolbar = False
icon = 'download' icon = 'download'
is_disk_operation = True
class VmMigrateView(VmOperationView): class VmMigrateView(VmOperationView):
...@@ -2135,6 +2137,10 @@ def vm_activity(request, pk): ...@@ -2135,6 +2137,10 @@ def vm_activity(request, pk):
"dashboard/vm-detail/_operations.html", "dashboard/vm-detail/_operations.html",
RequestContext(request, context), RequestContext(request, context),
) )
response['disk_ops'] = render_to_string(
"dashboard/vm-detail/_disk-operations.html",
RequestContext(request, context),
)
return HttpResponse( return HttpResponse(
json.dumps(response), json.dumps(response),
......
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