From 45720d3bcf84e017395091a61c9d6d28e1878962 Mon Sep 17 00:00:00 2001 From: catborise Date: Fri, 16 Nov 2018 16:08:35 +0300 Subject: [PATCH] convert HDD selection of new instance creation to user request. Before that, instance creation gets all images of all pools. If there is a problem with some pools other than default. It causes problem and sometimes it takes too long to opeen create instance page. With that extension getting volumes is up to request. Firs you must select pool then select volume. For now the create page opens instantly. --- create/templates/create_instance.html | 120 ++++++++++++++++++++------ create/views.py | 3 +- 2 files changed, 95 insertions(+), 28 deletions(-) diff --git a/create/templates/create_instance.html b/create/templates/create_instance.html index 024405d..aab1228 100644 --- a/create/templates/create_instance.html +++ b/create/templates/create_instance.html @@ -16,6 +16,22 @@ {% include 'errors_block.html' %} {% include 'pleasewaitdialog.html' %} + + {% if form.errors %} + {% for field in form %} + {% for error in field.errors %} +
+ {{ error|escape }} +
+ {% endfor %} + {% endfor %} + {% for error in form.non_field_errors %} +
+ {{ error|escape }} +
+ {% endfor %} +{% endif %} +
@@ -223,9 +239,9 @@
- {% endif %} -
-
+ {% endif %} +
+
@@ -239,7 +255,7 @@
- +
@@ -256,24 +272,36 @@
+
-
-
    - -
- - +
+
+
+ +
+
@@ -354,7 +382,7 @@
{% if storages %} - {% else %} @@ -379,7 +407,7 @@
- +
@@ -396,19 +424,27 @@
+
-
- +
+
+
+ +
@@ -487,7 +523,7 @@
{% if storages %} - {% else %} @@ -539,12 +575,14 @@ } $(document).ready(function () { - $('#image-control').multiselect({ + + $('#image-control').multiselect({ + disableIfEmpty: true, enableCaseInsensitiveFiltering: true, maxHeight: 400, inheritClass: true, buttonText: function (options, select) { - return 'Add image'; + return 'Add image...'; }, buttonTitle: function (options, select) { return ''; @@ -552,21 +590,27 @@ onChange: function (element, checked) { var input_value = toggleValue($('#images').val(), element.val(), checked); $('#images').val(input_value); + var selected_list_html = ''; var counter = 0; if (input_value != '') { - $.each(input_value.split(','), function (index, value) { + $('#disk_list_div').show(); + $.each(input_value.split(','), function (index, value) { var li = '
  • hdd' + counter + ' -> ' + value + ' ' + - 'x
  • '; + 'x'; selected_list_html += li; counter++; }); + }else { + $('#disk_list_div').hide(); } $('#img-list').html(selected_list_html); + } }); + $('#network-control').multiselect({ inheritClass: true, buttonText: function (options, select) { @@ -584,7 +628,7 @@ $.each(input_value.split(','), function (index, value) { var li = '
  • eth' + counter + ' -> ' + value + ' ' + - 'x
  • '; + 'x'; selected_list_html += li; counter++; }); @@ -593,7 +637,31 @@ } }); }); + + function get_cust_vols(compute_id, pool) { + get_vol_url = "/computes/" + compute_id + "/storage/" + pool + "/volumes"; + $.getJSON(get_vol_url, function (data) { + $("#image-control").find('option').remove(); + $.each(data['vols'], function(i, item) { + $("#image-control").append(''); + + }); + $('#image-control').multiselect('rebuild'); + }); + } + + function get_template_vols(compute_id, pool) { + get_vol_url = "/computes/" + compute_id + "/storage/" + pool + "/volumes"; + $.getJSON(get_vol_url, function (data) { + $("#template").find('option').remove(); + $.each(data['vols'], function(i, item) { + $("#template").append(''); + }); + }); + $("#template").removeAttr("disabled"); + } +