Skip to content

Commit 62ed91d

Browse files
szhen11acrnsi
authored andcommitted
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>
1 parent c442f3f commit 62ed91d

File tree

2 files changed

+54
-17
lines changed

2 files changed

+54
-17
lines changed

misc/acrn-config/config_app/static/main.js

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,26 @@ $().ready(function(){
299299
show_com_target(id, value);
300300
})
301301

302+
$(document).on('click', "button:contains('+')", function() {
303+
var add_vcpu_id = $(this).attr('id');
304+
var id = add_vcpu_id.replace('add_vcpu_', '');
305+
var config_item = $(this).parent().parent();
306+
var config_item_added = config_item.clone();
307+
var id_added = (parseInt(id)+1).toString();
308+
config_item_added.find("button:contains('+')").attr('id', 'add_vcpu_'+id_added);
309+
config_item_added.find("button:contains('-')").attr('id', 'remove_vcpu_'+id_added);
310+
config_item_added.find("button:contains('-')").prop("disabled", false);
311+
config_item_added.find("label:first").text("");
312+
config_item_added.find('.bootstrap-select').replaceWith(function() { return $('select', this); });
313+
config_item_added.find('.selectpicker').selectpicker('render');
314+
config_item_added.insertAfter(config_item);
315+
});
316+
317+
$(document).on('click', "button:contains('-')", function() {
318+
var config_item = $(this).parent().parent();
319+
config_item.remove();
320+
});
321+
302322
})
303323

304324

@@ -330,7 +350,7 @@ function show_com_target(id, value) {
330350

331351

332352
function save_scenario(generator=null){
333-
var board_info = $("select#board_info").val();
353+
var board_info = $("text#board_type").text();
334354
if (board_info==null || board_info=='') {
335355
alert("Please select one board info before this operation.");
336356
return;
@@ -346,7 +366,7 @@ function save_scenario(generator=null){
346366
var value = $(this).val();
347367
if(id!='new_scenario_name' && id!='board_info_file'
348368
&& id!='board_info_upload' && id!="scenario_file") {
349-
scenario_config[id] = $(this).val();
369+
scenario_config[id] = value;
350370
}
351371
})
352372

@@ -355,16 +375,22 @@ function save_scenario(generator=null){
355375
var value = $(this).val();
356376
if(id!='new_scenario_name' && id!='board_info_file'
357377
&& id!='board_info_upload' && id!="scenario_file") {
358-
scenario_config[id] = $(this).val();
378+
scenario_config[id] = value;
359379
}
360380
})
361381

362382
$("select").each(function(){
363383
var id = $(this).attr('id');
364-
var value = $(this).val();
365-
if(id!='board_info') {
366-
scenario_config[$(this).attr('id')] = $(this).val();
367-
}
384+
var value = $(this).val();
385+
if(id.indexOf('pcpu_id')>=0) {
386+
if(id in scenario_config) {
387+
scenario_config[id].push(value);
388+
} else {
389+
scenario_config[id] = [value];
390+
}
391+
} else if(id!='board_info') {
392+
scenario_config[id] = value;
393+
}
368394
})
369395

370396
$.ajax({
@@ -442,7 +468,7 @@ function save_scenario(generator=null){
442468
}
443469

444470
function save_launch(generator=null) {
445-
var board_info = $("select#board_info").val();
471+
var board_info = $("text#board_type").text();
446472
var scenario_name = $("select#scenario_name").val();
447473
if (board_info==null || board_info=='' || scenario_name==null || scenario_name=='') {
448474
alert("Please select one board and scenario before this operation.");
@@ -461,15 +487,15 @@ function save_launch(generator=null) {
461487
if(id!='new_launch_name' && id!='board_info_file'
462488
&& id!='board_info_upload' && id!='scenario_name'
463489
&& id!="launch_file") {
464-
launch_config[id] = $(this).val();
490+
launch_config[id] = value;
465491
}
466492
})
467493

468494
$("select").each(function(){
469495
var id = $(this).attr('id');
470496
var value = $(this).val();
471497
if(id!='board_info') {
472-
launch_config[$(this).attr('id')] = $(this).val();
498+
launch_config[id] = value;
473499
}
474500
})
475501

@@ -478,7 +504,7 @@ function save_launch(generator=null) {
478504
var value = $(this).val();
479505
if(id!='new_scenario_name' && id!='board_info_file'
480506
&& id!='board_info_upload' && id!="scenario_file") {
481-
launch_config[id] = $(this).val();
507+
launch_config[id] = value;
482508
}
483509
})
484510

misc/acrn-config/config_app/templates/scenario.html

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,19 @@ <h4 class="modal-title" id="myModalLabel">Save as</h4>
147147
<div class="form-group">
148148
{% if 'id' not in elem.attrib %}
149149
{% if not first_child %}
150-
{% do first_child.append(1) %}
151150
<label class="col-sm-1 control-label" data-toggle="tooltip"
152-
title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}">
151+
title="{{elem.attrib['desc'] if 'desc' in elem.attrib else elem.tag}}">
153152
{{elem.tag}}</label>
154153
{% else %}
155154
<label class="col-sm-1 control-label" data-toggle="tooltip"
156-
title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}">
155+
title="{{elem.attrib['desc'] if 'desc' in elem.attrib else elem.tag}}">
157156
</label>
158157
{% endif %}
159-
160158
<label class="col-sm-2 control-label" data-toggle="tooltip"
161159
title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}">
162160
{{sub_elem.tag}}</label>
163-
{% if ','.join(['vm', elem.tag, sub_elem.tag]) not in scenario_item_values %}
161+
162+
{% if ','.join(['vm', elem.tag, sub_elem.tag]) not in scenario_item_values and elem.tag != 'vcpu_affinity' %}
164163
{% if sub_elem.tag in ['bootargs', 'kern_args'] %}
165164
<div class="col-sm-6">
166165
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
@@ -186,6 +185,8 @@ <h4 class="modal-title" id="myModalLabel">Save as</h4>
186185
</div>
187186
{% endif %}
188187
{% else %}
188+
{% set item_key = ','.join(['vm', elem.tag, sub_elem.tag]) if elem.tag != 'vcpu_affinity' else
189+
','.join(['vm', elem.tag])%}
189190
<div class="dropdown col-sm-6">
190191
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
191192
<select class="selectpicker" data-width="auto"
@@ -194,16 +195,26 @@ <h4 class="modal-title" id="myModalLabel">Save as</h4>
194195
<select class="selectpicker" data-width="auto"
195196
id="{{'vm:id='+vm.attrib['id']+','+elem.tag+','+sub_elem.tag}}">
196197
{% endif %}
197-
{% for item_value in scenario_item_values[','.join(['vm', elem.tag, sub_elem.tag])] %}
198+
{% for item_value in scenario_item_values[item_key] %}
198199
{% if item_value == sub_elem_text %}
199200
<option value="{{item_value}}" selected="selected">{{item_value}}</option>
200201
{% else %}
201202
<option value="{{item_value}}">{{item_value}}</option>
202203
{% endif %}
203204
{% endfor %}
204205
</select>
206+
207+
{% if elem.tag == 'vcpu_affinity' %}
208+
<button type="button" class="btn" id="add_vcpu_{{first_child|length}}">+</button>
209+
{% if not first_child %}
210+
<button type="button" disabled class="btn" id="remove_vcpu_{{first_child|length}}">-</button>
211+
{% else %}
212+
<button type="button" class="btn" id="remove_vcpu_{{first_child|length}}">-</button>
213+
{% endif %}
214+
{% endif%}
205215
</div>
206216
{% endif %}
217+
{% do first_child.append(1) %}
207218
<p id="{{'vm:id='+vm.attrib['id']+','+elem.tag+','+sub_elem.tag}}_err" class="col-sm-3"></p>
208219
{% else %}
209220
{% if not first_child %}

0 commit comments

Comments
 (0)