acrn-config: update vcpu affinity in web UI

According to the new vcpu affinity configuration method, update vcpu
configuration in Web UI from multi-select box to seperated select box
which can dynamically add or delete vcpus with mapped pcpus.

Tracked-On: #3798
Signed-off-by: Shuang Zheng <shuang.zheng@intel.com>
Reviewed-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
Shuang Zheng 2019-10-12 10:23:07 +08:00 committed by ACRN System Integration
parent c442f3f4d1
commit 62ed91d303
2 changed files with 54 additions and 17 deletions

View File

@ -299,6 +299,26 @@ $().ready(function(){
show_com_target(id, value);
})
$(document).on('click', "button:contains('+')", function() {
var add_vcpu_id = $(this).attr('id');
var id = add_vcpu_id.replace('add_vcpu_', '');
var config_item = $(this).parent().parent();
var config_item_added = config_item.clone();
var id_added = (parseInt(id)+1).toString();
config_item_added.find("button:contains('+')").attr('id', 'add_vcpu_'+id_added);
config_item_added.find("button:contains('-')").attr('id', 'remove_vcpu_'+id_added);
config_item_added.find("button:contains('-')").prop("disabled", false);
config_item_added.find("label:first").text("");
config_item_added.find('.bootstrap-select').replaceWith(function() { return $('select', this); });
config_item_added.find('.selectpicker').selectpicker('render');
config_item_added.insertAfter(config_item);
});
$(document).on('click', "button:contains('-')", function() {
var config_item = $(this).parent().parent();
config_item.remove();
});
})
@ -330,7 +350,7 @@ function show_com_target(id, value) {
function save_scenario(generator=null){
var board_info = $("select#board_info").val();
var board_info = $("text#board_type").text();
if (board_info==null || board_info=='') {
alert("Please select one board info before this operation.");
return;
@ -346,7 +366,7 @@ function save_scenario(generator=null){
var value = $(this).val();
if(id!='new_scenario_name' && id!='board_info_file'
&& id!='board_info_upload' && id!="scenario_file") {
scenario_config[id] = $(this).val();
scenario_config[id] = value;
}
})
@ -355,16 +375,22 @@ function save_scenario(generator=null){
var value = $(this).val();
if(id!='new_scenario_name' && id!='board_info_file'
&& id!='board_info_upload' && id!="scenario_file") {
scenario_config[id] = $(this).val();
scenario_config[id] = value;
}
})
$("select").each(function(){
var id = $(this).attr('id');
var value = $(this).val();
if(id!='board_info') {
scenario_config[$(this).attr('id')] = $(this).val();
}
var value = $(this).val();
if(id.indexOf('pcpu_id')>=0) {
if(id in scenario_config) {
scenario_config[id].push(value);
} else {
scenario_config[id] = [value];
}
} else if(id!='board_info') {
scenario_config[id] = value;
}
})
$.ajax({
@ -442,7 +468,7 @@ function save_scenario(generator=null){
}
function save_launch(generator=null) {
var board_info = $("select#board_info").val();
var board_info = $("text#board_type").text();
var scenario_name = $("select#scenario_name").val();
if (board_info==null || board_info=='' || scenario_name==null || scenario_name=='') {
alert("Please select one board and scenario before this operation.");
@ -461,7 +487,7 @@ function save_launch(generator=null) {
if(id!='new_launch_name' && id!='board_info_file'
&& id!='board_info_upload' && id!='scenario_name'
&& id!="launch_file") {
launch_config[id] = $(this).val();
launch_config[id] = value;
}
})
@ -469,7 +495,7 @@ function save_launch(generator=null) {
var id = $(this).attr('id');
var value = $(this).val();
if(id!='board_info') {
launch_config[$(this).attr('id')] = $(this).val();
launch_config[id] = value;
}
})
@ -478,7 +504,7 @@ function save_launch(generator=null) {
var value = $(this).val();
if(id!='new_scenario_name' && id!='board_info_file'
&& id!='board_info_upload' && id!="scenario_file") {
launch_config[id] = $(this).val();
launch_config[id] = value;
}
})

View File

@ -147,20 +147,19 @@
<div class="form-group">
{% if 'id' not in elem.attrib %}
{% if not first_child %}
{% do first_child.append(1) %}
<label class="col-sm-1 control-label" data-toggle="tooltip"
title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}">
title="{{elem.attrib['desc'] if 'desc' in elem.attrib else elem.tag}}">
{{elem.tag}}</label>
{% else %}
<label class="col-sm-1 control-label" data-toggle="tooltip"
title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}">
title="{{elem.attrib['desc'] if 'desc' in elem.attrib else elem.tag}}">
</label>
{% endif %}
<label class="col-sm-2 control-label" data-toggle="tooltip"
title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}">
{{sub_elem.tag}}</label>
{% if ','.join(['vm', elem.tag, sub_elem.tag]) not in scenario_item_values %}
{% if ','.join(['vm', elem.tag, sub_elem.tag]) not in scenario_item_values and elem.tag != 'vcpu_affinity' %}
{% if sub_elem.tag in ['bootargs', 'kern_args'] %}
<div class="col-sm-6">
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
@ -186,6 +185,8 @@
</div>
{% endif %}
{% else %}
{% set item_key = ','.join(['vm', elem.tag, sub_elem.tag]) if elem.tag != 'vcpu_affinity' else
','.join(['vm', elem.tag])%}
<div class="dropdown col-sm-6">
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
<select class="selectpicker" data-width="auto"
@ -194,7 +195,7 @@
<select class="selectpicker" data-width="auto"
id="{{'vm:id='+vm.attrib['id']+','+elem.tag+','+sub_elem.tag}}">
{% endif %}
{% for item_value in scenario_item_values[','.join(['vm', elem.tag, sub_elem.tag])] %}
{% for item_value in scenario_item_values[item_key] %}
{% if item_value == sub_elem_text %}
<option value="{{item_value}}" selected="selected">{{item_value}}</option>
{% else %}
@ -202,8 +203,18 @@
{% endif %}
{% endfor %}
</select>
{% if elem.tag == 'vcpu_affinity' %}
<button type="button" class="btn" id="add_vcpu_{{first_child|length}}">+</button>
{% if not first_child %}
<button type="button" disabled class="btn" id="remove_vcpu_{{first_child|length}}">-</button>
{% else %}
<button type="button" class="btn" id="remove_vcpu_{{first_child|length}}">-</button>
{% endif %}
{% endif%}
</div>
{% endif %}
{% do first_child.append(1) %}
<p id="{{'vm:id='+vm.attrib['id']+','+elem.tag+','+sub_elem.tag}}_err" class="col-sm-3"></p>
{% else %}
{% if not first_child %}