Commit 2a333e50 by Kálmán Viktor

dashboard: working template list on index view

parent 8fb63c4f
$(function () {
$('.vm-create').click(function(e) {
var template = $(this).data("template");
$.ajax({
type: 'GET',
url: '/dashboard/vm/create/',
......@@ -11,6 +12,9 @@ $(function () {
$('#create-modal').on('hidden.bs.modal', function() {
$('#create-modal').remove();
});
if(template) {
$('#vm-create-template-select option[value="' + template + '"]').prop("selected", true).trigger("change");
}
}
});
return false;
......
{% load i18n %}
<div class="panel panel-default">
<div class="panel-heading">
<span class="btn btn-default btn-xs infobtn pull-right" title="Halp">
......@@ -7,21 +8,12 @@
</h3>
</div>
<div class="list-group" id="vm-list-view">
<a href="#" class="list-group-item">
<i class="icon-linux"></i> ALMA <small class="text-muted">CentOS 6</small><div class="pull-right"><i class="icon-play "></i></div>
</a>
<a href="#" class="list-group-item">
<i class="icon-windows"></i> ALMA <small class="text-muted">Windows 7</small><div class="pull-right"><i class="icon-play "></i></div>
</a>
<a href="#" class="list-group-item">
<i class="icon-linux"></i> ALMA <small class="text-muted">Gentoo</small><div class="pull-right"><i class="icon-play "></i></div>
</a>
<a href="#" class="list-group-item">
<i class="icon-linux"></i> ALMA <small class="text-muted">Ubuntu 12.04 LTS</small><div class="pull-right"><i class="icon-play "></i></div>
</a>
<a href="#" class="list-group-item">
<i class="icon-windows"></i> ALMA <small class="text-muted">Windows 7</small><div class="pull-right"><i class="icon-play "></i></div>
{% for t in templates %}
<a href="{% url "dashboard.views.template-detail" pk=t.pk %}" class="list-group-item">
<i class="icon-{{ t.os_type }}"></i> {{ t.name }} <small class="text-muted">{{ t.system }}</small>
<div class="pull-right vm-create" data-template="{{ t.pk }}"><i title="{% trans "Start vm instance" %}" class="icon-play"></i></div>
</a>
{% endfor %}
<div href="#" class="list-group-item list-group-footer text-right">
<p>
<a href="{% url "dashboard.views.template-list" %}" class="btn btn-primary btn-xs"><i class="icon-chevron-sign-right"></i> show all </a>
......
......@@ -94,6 +94,8 @@ class IndexView(LoginRequiredMixin, TemplateView):
'stopped_vm_num': instances.exclude(
state__in=['RUNNING', 'NOSTATE']).count()
})
context['templates'] = InstanceTemplate.objects.all()[:5]
return context
......
......@@ -142,7 +142,7 @@ class InstanceTemplate(AclBase, VirtualMachineDescModel, TimeStampedModel):
"""Get the type of the template's operating system.
"""
if self.access_method == 'rdp':
return 'win'
return 'windows'
else:
return 'linux'
......
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