');
//add the conditions into fieldset
if ('' == globalCondition){
@@ -835,6 +834,7 @@ function mkCondRespDia(){
success : function(data){
var tempHash = new Object();
+ var oldSelectedResp = '';
var showStr = '';
if (data.rsp[0]){
var names = data.rsp[0].split(';');
@@ -848,6 +848,7 @@ function mkCondRespDia(){
for(var name in globalResponse){
if(tempHash[name]){
showStr += '' + name;
+ oldSelectedResp += ';' + name;
}
else{
showStr += '' + name;
@@ -855,6 +856,7 @@ function mkCondRespDia(){
}
diaDiv.find('#mkAssResp').empty().append('').append(showStr);
+ diaDiv.find('#selectedResp').empty().append(oldSelectedResp);
}
});
});
@@ -870,6 +872,69 @@ function mkCondRespDia(){
$(this).dialog('close');
},
ok : function(){
+ var newResp = new Object();
+ var oldResp = new Object();
+ var oldString = '';
+ var newString = '';
+ //get the old seelected responses
+ var conditionName = $(this).find('#mkAssCond :checked').attr('value');
+ if (!conditionName){
+ return;
+ }
+ var temp = $(this).find('#selectedResp').html();
+ if('' == temp){
+ return;
+ }
+ var tempArray = temp.substr(1).split(';');
+ for (var i in tempArray){
+ oldResp[tempArray[i]] = 1;
+ }
+ //get the new selected responses
+ $(this).find('#mkAssResp input:checked').each(function(){
+ var respName = $(this).attr('value');
+ newResp[respName] = 1;
+ });
+
+ for (var i in newResp){
+ if(oldResp[i]){
+ delete oldResp[i];
+ delete newResp[i];
+ }
+ }
+
+ //add the response which are delete.
+ for (var i in oldResp){
+ oldString += ',"' + i + '"';
+ }
+ if('' != oldString){
+ oldString = oldString.substr(1);
+ }
+
+ //add the response which are new add
+ for (var i in newResp){
+ newString += ',"' + i +'"';
+ }
+ if ('' != newString){
+ newString = newString.substr(1);
+ }
+
+ if(('' != oldString) || ('' != newString)){
+ $('#rmcEventStatus').empty().append('Create/Remove associations').append(createLoader());
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : 'mkcondresp;"' + conditionName + '";+' + newString + ':-' + oldString,
+ msg : ''
+ },
+
+ success : function(data){
+ $('#rmcEventStatus').empty().append(data.rsp[0]);;
+ }
+ });
+ }
$(this).dialog('close');
}
}
diff --git a/xCAT-server/lib/xcat/plugins/web.pm b/xCAT-server/lib/xcat/plugins/web.pm
index d48fb328d..1977aef1a 100644
--- a/xCAT-server/lib/xcat/plugins/web.pm
+++ b/xCAT-server/lib/xcat/plugins/web.pm
@@ -154,15 +154,28 @@ sub web_lsrsrc {
sub web_mkcondresp {
my ( $request, $callback, $sub_req ) = @_;
- print Dumper( $request->{arg}->[0] ); #debug
- my $ret = system( $request->{arg}->[0] );
+ my $conditionName = $request->{arg}->[1];
+ my $temp = $request->{arg}->[2];
+ my $cmd = '';
- #there's no output for "mkcondresp"
- #TODO
- if ($ret) {
-
- #failed
+ my @resp = split(':', $temp);
+ #create new associations
+ if (1 < length(@resp[0])){
+ $cmd = substr(@resp[0], 1);
+ $cmd =~ s/,/ /;
+ $cmd = 'mkcondresp ' . $conditionName . ' ' . $cmd;
+ my $retInfo = xCAT::Utils->runcmd($cmd, -1, 1);
}
+
+ #delete old associations
+ if (1 < length(@resp[1])){
+ $cmd = substr(@resp[1], 1);
+ $cmd =~ s/,/ /;
+ $cmd = 'rmcondresp ' . $conditionName . ' ' . $cmd;
+ my $retInfo = xCAT::Utils->runcmd($cmd, -1, 1);
+ }
+ #there's no output for "mkcondresp"
+ $callback->({ data => "Success." });
}
sub web_startcondresp {