Commit 26a04c48 by Dányi Bence

webui: implement vm-rename feature (ajax)

parent 18c6833f
......@@ -80,6 +80,9 @@ urlpatterns = patterns('',
url(r'^ajax/vm/status/(?P<iid>\d+)$',
'one.views.vm_ajax_instance_status',
name='vm_ajax_instance_status'),
url(r'^ajax/vm/rename/(?P<iid>\d+)/$',
'one.views.vm_ajax_rename',
name='vm_ajax_rename'),
url(r'^language/(?P<lang>[-A-Za-z]+)/$', 'school.views.language',
name='language'),
url(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
......
......@@ -56,7 +56,17 @@ $(function() {
$('#vm-' + id + '-name').find('input[type=submit]').click(function(f) {
f.preventDefault();
f.stopPropagation();
alert($(this).prev().val());
var newName = $(this).prev().val();
$.ajax({
type: 'POST',
data: 'name=' + newName,
dataType: 'json',
url: '/ajax/vm/rename/' + id + '/',
success: function(data) {
$('#vm-' + id + '-name-details').show();
$('#vm-' + id + '-name').html(data.name);
}
});
})
});
$('.try-template-button').click(function(e) {
......
......@@ -295,6 +295,13 @@ def vm_ajax_instance_status(request, iid):
inst.update_state()
return HttpResponse(json.dumps({'booting': not inst.active_since, 'state': inst.state}))
@login_required
def vm_ajax_rename(request, iid):
inst = get_object_or_404(Instance, id=iid, owner=request.user)
inst.name = request.POST['name']
inst.save()
return HttpResponse(json.dumps({'name': inst.name}))
def boot_token(request, token):
try:
id = signing.loads(token, salt='activate')
......
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