Commit 2a333e50 by Kálmán Viktor

dashboard: working template list on index view

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