diff --git a/instances/templates/instances.html b/instances/templates/instances.html index bd9d65e..e9c2306 100644 --- a/instances/templates/instances.html +++ b/instances/templates/instances.html @@ -31,127 +31,17 @@ {% if not all_host_vms %}
- + {% trans "Warning:" %} {% trans "You don't have any Instance" %}
{% else %} - - - - - - - - - - - - - - {% for host, inst in all_host_vms.items %} - - - - - - - - - - - {% for vm, info in inst.items %} - - - - - - - - - - {% endfor %} - {% endfor %} - -
#Name
Description
UserStatusVCPUMemoryActions & Mem Usage
{{ forloop.counter }}{{ host.1 }}{% ifequal host.2 1 %}{% trans "Active" %} - {% endifequal %} - {% ifequal host.2 2 %}{% trans "Not Active" %} - {% endifequal %} - {% ifequal host.2 3 %}{% trans "Connection Failed" %} - {% endifequal %} - {{ host.3 }}{{ host.4|filesizeformat }} -
{{ host.5 }}%
-
{{ forloop.counter }} {{ vm }}
{{ info.title }}
{% if info.userinstances.count > 0 %}{{ info.userinstances.first_user.user.username }}{% if info.userinstances.count > 1 %} (+{{ info.userinstances.count|add:"-1" }}){% endif %}{% endif %}{% ifequal info.status 1 %} - {% trans "Active" %} - {% endifequal %} - {% ifequal info.status 5 %} - {% trans "Off" %} - {% endifequal %} - {% ifequal info.status 3 %} - {% trans "Suspend" %} - {% endifequal %} - {{ info.vcpu }}{{ info.memory |filesizeformat }}
{% csrf_token %} - - - {% ifequal info.status 5 %} - {% if info.is_template %} - - {% else %} - - {% endif %} - - - - - {% endifequal %} - {% ifequal info.status 3 %} - - - - - - {% endifequal %} - {% ifequal info.status 1 %} - - - - - - - - {% endifequal %} -
-
+ {% ifequal view_style "nongrouped" %} + {% include 'instances_nongrouped.html' %} + {% endifequal %} + {% ifequal view_style 'instances_grouped.html' %} + {% include 'instances_grouped.html' %} + {% endifequal %} {% endif %} {% else %} {% if not all_user_vms %} diff --git a/instances/templates/instances_grouped.html b/instances/templates/instances_grouped.html new file mode 100644 index 0000000..6aeec17 --- /dev/null +++ b/instances/templates/instances_grouped.html @@ -0,0 +1,122 @@ +{% load i18n %} + + + + + + + + + + + + + + {% for host, inst in all_host_vms.items %} + + + + + + + + + + + {% for vm, info in inst.items %} + + + + + + + + + + {% endfor %} + {% endfor %} + +
#Name
Description
UserStatusVCPUMemoryActions & Mem Usage
{{ forloop.counter }}{{ host.1 }} + {% ifequal host.2 1 %}{% trans "Active" %}{% endifequal %} + {% ifequal host.2 2 %}{% trans "Not Active" %}{% endifequal %} + {% ifequal host.2 3 %}{% trans "Connection Failed" %}{% endifequal %} + {{ host.3 }}{{ host.4|filesizeformat }} +
{{ host.5 }}% +
+
{{ forloop.counter }} {{ vm }}
+ {{ info.title }} +
+ + {% if info.userinstances.count > 0 %} {{ info.userinstances.first_user.user.username }} + {% if info.userinstances.count > 1 %} (+{{ info.userinstances.count|add:"-1" }}){% endif %} + {% endif %} + + + + {% ifequal info.status 1 %}{% trans "Active" %}{% endifequal %} + {% ifequal info.status 5 %}{% trans "Off" %}{% endifequal %} + {% ifequal info.status 3 %}{% trans "Suspend" %}{% endifequal %} + {{ info.vcpu }}{{ info.memory |filesizeformat }} +
{% csrf_token %} + + + {% ifequal info.status 5 %} + {% if info.is_template %} + + {% else %} + + {% endif %} + + + + + {% endifequal %} + {% ifequal info.status 3 %} + + + + + + {% endifequal %} + {% ifequal info.status 1 %} + + + + + + + + {% endifequal %} +
+
\ No newline at end of file diff --git a/instances/templates/instances_nongrouped.html b/instances/templates/instances_nongrouped.html new file mode 100644 index 0000000..6112414 --- /dev/null +++ b/instances/templates/instances_nongrouped.html @@ -0,0 +1,92 @@ +{% load i18n %} + + + + + + + + + + + + + {% for host, inst in all_host_vms.items %} + {% for vm, info in inst.items %} + + + + + + + + + {% endfor %} + {% endfor %} + +
Name
Description
Host
User
StatusVCPUMemoryActions
{{ vm }}
{{ info.title }}
{{ host.1 }}
{% if info.userinstances.count > 0 %}{{ info.userinstances.first_user.user.username }}{% if info.userinstances.count > 1 %} (+{{ info.userinstances.count|add:"-1" }}){% endif %}{% endif %}
+ {% ifequal info.status 1 %}{% trans "Active" %}{% endifequal %} + {% ifequal info.status 5 %}{% trans "Off" %}{% endifequal %} + {% ifequal info.status 3 %}{% trans "Suspend" %}{% endifequal %} + {{ info.vcpu }}{{ info.memory|filesizeformat }}
{% csrf_token %} + + + {% ifequal info.status 5 %} + {% if info.is_template %} + + {% else %} + + {% endif %} + + + + + {% endifequal %} + {% ifequal info.status 3 %} + + + + + + {% endifequal %} + {% ifequal info.status 1 %} + + + + + + + + {% endifequal %} +
+
diff --git a/instances/views.py b/instances/views.py index 5189ace..6d8454c 100644 --- a/instances/views.py +++ b/instances/views.py @@ -193,6 +193,9 @@ def instances(request): error_messages.append(lib_err) addlogmsg(request.user.username, instance.name, lib_err.message) + instances_template_file = 'instances.html' + view_style = settings.VIEW_INSTANCES_LIST_STYLE + return render(request, 'instances.html', locals()) @@ -976,6 +979,7 @@ def check_instance(request, vname): data['exists'] = True return HttpResponse(json.dumps(data)) + def sshkeys(request, vname): """ :param request: @@ -997,6 +1001,7 @@ def sshkeys(request, vname): response = json.dumps(instance_keys) return HttpResponse(response) + def delete_instance(instance, delete_disk=False): compute = instance.compute instance_name = instance.name diff --git a/webvirtcloud/settings.py.template b/webvirtcloud/settings.py.template index ffee758..f357bba 100644 --- a/webvirtcloud/settings.py.template +++ b/webvirtcloud/settings.py.template @@ -143,6 +143,9 @@ SHOW_PROFILE_EDIT_PASSWORD = False # available: default (grid), list VIEW_ACCOUNTS_STYLE = 'grid' +# available: default (grouped), nongrouped +VIEW_INSTANCES_LIST_STYLE = 'grouped' + INSTANCE_VOLUME_DEFAULT_FORMAT = 'qcow2' INSTANCE_VOLUME_DEFAULT_BUS = 'virtio' INSTANCE_VOLUME_DEFAULT_CACHE = 'directsync'