Skip to content

Commit

Permalink
F #1454: Added form when create a new host
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmont committed Feb 1, 2018
1 parent ead9f0e commit f150cdb
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/sunstone/public/app/tabs/hosts-tab/form-panels/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ define(function(require) {
$("#im_mad", context).val(this.value).change();
$(".vcenter_credentials", context).hide();
$(".ec2_extra", context).hide();
$(".one_extra", context).hide();
$(".drivers", context).hide();
$("#name_container", context).show();

Expand All @@ -134,6 +135,9 @@ define(function(require) {
} else if (this.value == "ec2") {
$(".ec2_extra", context).show();
Sunstone.showFormPanelSubmit(TAB_ID);
} else if (this.value == "one") {
$(".one_extra", context).show();
Sunstone.showFormPanelSubmit(TAB_ID);
} else {
Sunstone.showFormPanelSubmit(TAB_ID);
}
Expand All @@ -160,6 +164,27 @@ define(function(require) {
tr.remove();
});

context.off("click", ".add_custom_tag", context);
context.on("click", ".add_custom_tag", context, function(){
$("tbody.capacity_one", context).append(
"<tr class='row_capacity_one'>\
<td style='display: flex; justify-content: flex-start'>\
<input class='capacity_key' type='text' name='key'>\
</td>\
<td>\
<input class='capacity_value' type='number' min='0' name='value'>\
</td>\
<td style='width: 150%; display: flex; justify-content: flex-end'>\
<a href='#'><i class='fa fa-times-circle remove-capacity'></i></a>\
</td>\
</tr>");
});

context.on("click", "tbody.capacity_one i.remove-capacity", function(){
var tr = $(this).closest('tr');
tr.remove();
});

$("#host_type_mad", context).change();

$("form.vcenter_credentials", context)
Expand Down Expand Up @@ -266,6 +291,27 @@ define(function(require) {
host_json["host"]["capacity"] = capacity;
}
}

if(vmm_mad == "one"){
var capacity = {};
var key = "";
var value = "";
var user = $('input[name="ONE_USER"]').val();
var pass = $('input[name="ONE_PASSWORD"]').val();
var endpoint = $('input[name="ONE_ENDPOINT"]').val();
$('tr.row_capacity_one',context).each(function() {
key = $("input[name='key']", this).val();
value = $("input[name='value']", this).val();
capacity[key] = value;
});

host_json["host"]["ONE_USER"] = user;
host_json["host"]["ONE_PASSWORD"] = pass;
host_json["host"]["ONE_ENDPOINT"] = endpoint;
if (capacity["CPU"] && capacity["MEMORY"]){
host_json["host"]["ONE_CAPACITY"] = capacity;
}
}
//Create the OpenNebula.Host.
//If it is successfull we refresh the list.
Sunstone.runAction("Host.create", host_json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,79 @@
</div>
</fieldset>
</div>

<div class="one_extra">
<fieldset>
<legend>{{tr "OpenNebula"}}</legend>
<div class="row">
<div class="large-12 columns">
<label for="ONE_USER">{{tr "Remote username"}}</label>
<input type="text" name="ONE_USER" />
</div>
</div>
<div class="row">
<div class="large-6 columns">
<label for="ONE_PASSWORD">{{tr "Remote password"}}</label>
<input type="text" name="ONE_PASSWORD" />
</div>
<div class="large-6 columns">
<label for="ONE_ENDPOINT">{{tr "Remote endpoint"}}</label>
<input type="text" name="ONE_ENDPOINT" />
</div>
</div>
<div class="row">
<div class="medium-12 columns">
<label>{{tr "Remote capacity"}}</label>
<div class="row">
<div class="large-12 columns">
<table class="dataTable capacity_table">
<thead>
<tr>
<th>{{tr "Key"}}</th>
<th>{{tr "Value"}}</th>
<th></th>
</tr>
</thead>
<tbody class="capacity_one">
<tr class='row_capacity_one'>
<td style='display: flex; justify-content: flex-start'>
<input class='capacity_key' type='text' name='key' value="CPU">
</td>
<td>
<input class='capacity_value' type='number' min='0' name='value'>
</td>
<td style='width: 150%; display: flex; justify-content: flex-end'>
<a href='#'><i class='fa fa-times-circle remove-capacity'></i></a>
</td>
</tr>
<tr class='row_capacity_one'>
<td style='display: flex; justify-content: flex-start'>
<input class='capacity_key' type='text' name='key' value="MEMORY">
</td>
<td>
<input class='capacity_value' type='number' min='0' name='value'>
</td>
<td style='width: 150%; display: flex; justify-content: flex-end'>
<a href='#'><i class='fa fa-times-circle remove-capacity'></i></a>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3">
<a type="button" class="add_custom_tag button small small-12 secondary radius">
<i class="fa fa-lg fa-plus-circle"></i>
</a>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</fieldset>
</div>
</form>
<form data-abide novalidate class="vcenter_credentials" action="">
<fieldset>
Expand Down

0 comments on commit f150cdb

Please sign in to comment.