Commit 93b78ecd by Kálmán Viktor

dashboard: js fixes for vm create network add

parent dd0f3dc2
...@@ -99,10 +99,11 @@ function vmCreateLoaded() { ...@@ -99,10 +99,11 @@ function vmCreateLoaded() {
/* build up network list */ /* build up network list */
$('#vm-create-network-add-select option').each(function() { $('#vm-create-network-add-vlan option').each(function() {
vlans.push({ vlans.push({
'name': $(this).text(), 'name': $(this).text().replace("unmanaged -", "").replace("managed -", ""),
'pk': parseInt($(this).val()) 'pk': parseInt($(this).val()),
'managed': $(this).text().indexOf("mana") == 0,
}); });
}); });
...@@ -236,8 +237,11 @@ function vmCreateTemplateChange(new_this) { ...@@ -236,8 +237,11 @@ function vmCreateTemplateChange(new_this) {
$("#vm-create-network-add-vlan").find('option').prop('selected', false); $("#vm-create-network-add-vlan").find('option').prop('selected', false);
$('#vm-create-disk-add-form').find('option').prop('selected', false); $('#vm-create-disk-add-form').find('option').prop('selected', false);
/* clear the network select */
$("#vm-create-network-add-select").html('');
/* append vlans from InterfaceTemplates */ /* append vlans from InterfaceTemplates */
$('#vm-create-network-list').html(''); $('#vm-create-network-list').html("");
var added_vlans = [] var added_vlans = []
for(var n = 0; n<data['network'].length; n++) { for(var n = 0; n<data['network'].length; n++) {
nn = data['network'][n] nn = data['network'][n]
...@@ -253,11 +257,10 @@ function vmCreateTemplateChange(new_this) { ...@@ -253,11 +257,10 @@ function vmCreateTemplateChange(new_this) {
$('#vm-create-network-add-select').html(''); $('#vm-create-network-add-select').html('');
// this is working because the vlans array already has the icon's hex code // this is working because the vlans array already has the icon's hex code
for(var i=0; i < vlans.length; i++) for(var i=0; i < vlans.length; i++)
if(added_vlans.indexOf(vlans[i].pk) == -1) if(added_vlans.indexOf(vlans[i].pk) == -1) {
$('#vm-create-network-add-select').append($('<option>', { var html = '<option data-managed="' + (vlans[i].managed ? 1 : 0) + '" value="' + vlans[i].pk + '">' + vlans[i].name + '</option>';
value: vlans[i].pk, $('#vm-create-network-add-select').append(html);
text: vlans[i].name }
}));
/* enable the network add button if there are not added vlans */ /* enable the network add button if there are not added vlans */
if(added_vlans.length != vlans.length) { if(added_vlans.length != vlans.length) {
...@@ -267,6 +270,10 @@ function vmCreateTemplateChange(new_this) { ...@@ -267,6 +270,10 @@ function vmCreateTemplateChange(new_this) {
$('#vm-create-network-add-button').attr('disabled', true); $('#vm-create-network-add-button').attr('disabled', true);
} }
/* if there are no added vlans print it out */
if(added_vlans.length < 1) {
$('#vm-create-network-list').html("Not added to any network!");
}
/* append disks */ /* append disks */
$('#vm-create-disk-list').html(''); $('#vm-create-disk-list').html('');
......
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