Commit 6dbc55fb by Kálmán Viktor

dashboard: handle managed networks in vm create

parent 210e6c32
......@@ -86,24 +86,39 @@ function vmCreateLoaded() {
vmCreateTemplateChange(this);
});
/* add network */
$('#vm-create-network-add-button').click(function() {
var option = $('#vm-create-network-add-select :selected');
if(option.val() > 0) {
var o = option.val().split('|');
var vlan_pk = o[0];
var managed = o[1];
if ($('#vm-create-network-list').children('span').length < 1) {
$('#vm-create-network-list').html('');
}
$('#vm-create-network-list').append(
vmCreateNetworkLabel(option.val(), option.text(), true)
vmCreateNetworkLabel(option.val(), option.text(), managed > 0 ? true : false)
);
$('option:selected', $('#vm-create-network-add-select')).remove();
/* add dummy text if no more networks are available */
if($('#vm-create-network-add-select option').length < 1) {
$('#vm-create-network-add-button').attr('disabled', true);
$('#vm-create-network-add-select').html('<option value="-1">We are out of &lt;options&gt; hehe</option>');
}
return false;
});
/* remove network */
// event for network remove button (icon, X)
// TODO still not the right place
$('body').on('click', '.vm-create-remove-network', function() {
console.log($('#vm-create-network-add-select option').length);
if($('#vm-create-network-add-select option')[0].value == -1) {
$('#vm-create-network-add-button').attr('disabled', false);
$('#vm-create-network-add-select').html('');
}
var vlan_pk = ($(this).parent('span').prop('id')).replace('vlan-', '');
$(this).parent('span').fadeOut(500, function() {
$(this).remove();
......
......@@ -78,9 +78,9 @@
<h3 id="vm-create-network-add">
<div class="input-group" style="max-width: 300px;">
<select class="form-control" id="vm-create-network-add-select">
<option value="1">vmnet2</option>
<option value="2">PUB</option>
<option value="3">OFF</option>
<option value="1|1">vmnet2</option>
<option value="2|0">PUB</option>
<option value="3|0">OFF</option>
</select>
<div class="input-group-btn">
<!--<input type="submit" value="Add to network" class="btn btn-success"/>-->
......
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