/******************************************************************************************************************************** * Licensed Materials - Property of IBM * * * * IBM Cognos Products: AGS * * * * (C) Copyright IBM Corp. 2005, 2008 * * * * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. * *********************************************************************************************************************************/ var ACTION_MARKER = "ACTION_XX_MARKER"; var ACTION_COUNT_NAME = "ACTION_COUNT"; var ACTION_NAME_NAME = "name"; var ACTION_ID_NAME = "id"; var ACTION_TYPE_NAME = "type"; var ACTION_PATH_NAME = "path"; var ACTION_TASK_LEVEL_FILTER = "taskLevelFilter"; var ACTION_RUN_CONDITION = "runCondition"; var ACTION_NAME = "ACTION"; var AGENT_PARAM = "AGENT_PARAM"; var Filter_ongoing_changed = "Filter_changed"; var Changed = "changed"; var Filter_ongoing_unchanged = "Filter_unchanged"; var Unchanged = "unchanged"; var Filter_ongoing_group = "Filter_ongoing_group"; var Filter_new = "Filter_new"; var Filter_no_events = "Filter_nil"; var Nu = "new"; var Filter_stopped = "Filter_deleted"; var Stopped = "deleted"; var Action_topic_filter = "Action_topic_filter"; var last_selected_action; var MAX_TASK_NAME_LENGTH = 50; // called only when we finish - this does the stack-down-save into // suppressionFinish - and writes out variables that that needs too function doFinish() { if (window.validate && window.validate()) { // we've passed validation - so do the do writeAgents(); // now do the redirect and submit document.forms.pform.m.value='/ags/suppressionFinish.xts'; document.forms.pform.ps_nav_op.value='stack-down-save'; //reset the undo history now that the form has been submitted var redoUndoMgr = parent.getConfigFrame().getRedoUndoManager(); redoUndoMgr.resetTreeAction(); cf.changeMenu(cf.TAB_SOURCE); document.forms.pform.submit(); } } function writeAgents(){ var the_div = document.getElementById("hidden_div"); the_div.innerHTML = ""; writeActions(parent.getAgentDefinition(), "hidden_div"); }; function loadAgentsToPage() { var count = parent.getAgentDefinition().getActionCount(); //set them to the screen for(var load_count = 0; load_count < count; load_count++){ addActionToPage(parent.getAgentDefinition().getActionAt(load_count)); } if(count > 0){ document.pform.ad_select_display.selectedIndex = 0; onSelectAction(parent.getAgentDefinition().getActionAt(0)); } } function setSelectedActionDisplay(name_id){ for(var i=0; i < document.pform.ad_select_display.length ; i++){ if(document.pform.ad_select_display.options[i].value == name_id){ document.pform.ad_select_display.selectedIndex = i; break; } } } function onSelectAction() { var success = true; if(last_selected_action && !validateAgentAction(last_selected_action)){ success = false; //stay on the old action... validate method diplays messages setSelectedActionDisplay(last_selected_action.name_id); } else { //Reset the action last_selected_action = getSelectedAction(); doSelectAction(last_selected_action); } return success; } function doSelectAction(action){ if(!action){ window.alert("selected action is undefined "); return; } //register the form object as the listener target parent.getAgentItemsListener().registerField(Action_topic_filter, action.id, action.getParams().getParamValue(Action_topic_filter), window.name); var unchanged_param = action.getParams().getParamValue(Filter_ongoing_unchanged)!= undefined; var changed_param = action.getParams().getParamValue(Filter_ongoing_changed)!= undefined; var allOngoing = changed_param && unchanged_param; var selIndex = 0; if (changed_param && !allOngoing) { selIndex = 1; } else if (unchanged_param && !allOngoing) { selIndex = 2; } document.pform.Filter_ongoing_specified_value.selectedIndex = selIndex; if (selIndex == 0) { droppy.setDropZoneValue('','Action_topic_filter'); action.getParams().setParam(Action_topic_filter, null); //Should be clear by now, but clear anyway action.nonDuplication.clear(); } else { var topics = action.getParams().getParamValue(Action_topic_filter); action.nonDuplication.clear(); action.nonDuplication.parseFromString(topics); } //new and stopped document.pform.Filter_new.checked = action.getParams().getParamValue(Filter_new) != undefined; document.pform.Filter_nil.checked = action.getParams().getParamValue(Filter_no_events) != undefined; document.pform.Filter_deleted.checked = action.getParams().getParamValue(Filter_stopped) != undefined; document.pform.Filter_ongoing_group.checked = allOngoing || changed_param || unchanged_param; document.pform.main_radio_group[0].checked = action.runCondition != "runOnFailure"; document.pform.main_radio_group[1].checked = action.runCondition == "runOnFailure"; document.getElementById('event_rules_table').disabled = action.runCondition == "runOnFailure"; updateTaskLevelFilter(action.taskLevelFilter); changeTaskLevelFilterState(); changeOngoingActionDetails(document.pform.Filter_ongoing_group.checked, selIndex); } function checkTheBox(box){ var box_value = box.checked ? box.value : null; if (box.name == Filter_ongoing_group && box.checked) { document.pform.Filter_ongoing_specified_value.selectedIndex = 0; } else { getSelectedAction().setParam(box.name, box_value); } var cf = window.parent.getConfigFrame(); if ( cf != null ) { // set agent state cf.agentHasChanged(true); } } function displayState(){ if (!window.event.altKey){ return; } var an_action = document.pform.ad_select_display.selectedIndex == -1 ? parent.getAgentDefinition().getActionAt(0) : parent.getAgentDefinition().getActionAt(document.pform.ad_select_display.selectedIndex); var buffer = "agent filter state for "+ an_action.name +"\n"; buffer += "Summary_Event_Key = " + parent.getAgentDefinition().summaryEventKey.toString()+"\n"; buffer += "Filter_ongoing_changed = " + an_action.getParams().getParamValue(Filter_ongoing_changed)+"\n"; buffer += "Filter_ongoing_unchanged = " + an_action.getParams().getParamValue(Filter_ongoing_unchanged)+"\n"; buffer += "Filter_new = " + an_action.getParams().getParamValue(Filter_new)+"\n"; buffer += "Filter_no_events = " + an_action.getParams().getParamValue(Filter_no_events)+"\n"; buffer += "Filter_stopped = " + an_action.getParams().getParamValue(Filter_stopped)+"\n"; buffer += "Action_topic_filter = " + an_action.getParams().getParamValue(Action_topic_filter)+"\n"; alert(buffer); } function changeOngoingActionDetails(checked, selIndex) { document.pform.Filter_ongoing_specified_value.disabled = !checked; if (selIndex == 0) { disableActionTopics(); } else { enableActionTopics(); } } function storeOngoingActionDetails() { var allOngoing = document.pform.Filter_ongoing_specified_value.selectedIndex == 0; var changed = document.pform.Filter_ongoing_specified_value.selectedIndex == 1; var unchanged = document.pform.Filter_ongoing_specified_value.selectedIndex == 2; if(allOngoing){ getSelectedAction().getParams().setParam(Action_topic_filter, null); getSelectedAction().nonDuplication.clear(); //Droppy should be available in the suppression Wizard.xts scripts. droppy.setDropZoneValue('','Action_topic_filter'); parent.getAgentItemsListener().updateField(Action_topic_filter, ""); } //all is selected set to ongoing changed or unchanged topic filter getSelectedAction().setParam(Filter_ongoing_changed,allOngoing || changed?Changed:null); getSelectedAction().setParam(Filter_ongoing_unchanged,allOngoing || unchanged?Unchanged:null); var cf = window.parent.getConfigFrame(); if ( cf != null ) { // set agent state cf.agentHasChanged(true); } } function getSelectedAction(){ var sel = document.pform.ad_select_display; var selected_id = sel.options[sel.selectedIndex].value; return parent.getAgentDefinition().getActionById(selected_id); } function selectActionImage(action){ document.images.action_img.src = action.img_src; } function addActionToPage(action){ var display = pad(action.name, action.type, 40); document.pform.ad_select_display.options[document.pform.ad_select_display.length] = new Option(display, action.name_id); //document.pform.Action_topic_filter.value = action.getParams().getParamValue(Action_topic_filter); var sTopics = action.getParams().getParamValue(Action_topic_filter); action.nonDuplication = new parent.NonDuplicationItems(sTopics); } function pad(sName, sType, length){ var display_name = sName.length > MAX_TASK_NAME_LENGTH ? sName.substring(0, MAX_TASK_NAME_LENGTH) + "..." : sName; var l = length < MAX_TASK_NAME_LENGTH ? length : MAX_TASK_NAME_LENGTH; for(var v = sName.length; v < l; v++){ sName = sName + " "; } display_name = display_name + " (" + sType +")" return display_name; } function onAddAction(){ var action = getActionFromPage(); if(!action){ return; } if(parent.getAgentDefinition().addAction(action)){ addActionToPage(action); }else{ alert("must have unique name"); } } function onRemoveAction(){ parent.getAgentDefinition().removeActionAt(document.pform.ad_select_display.selectedIndex); removeActionFromPage(); } /* write out our definitions to form fields */ function writeActions (agent, div){ //get the summary event key and make sure its valid var converted_key = agent.getSummaryEventKeyValueWithPortalStyleTopics(); // always write out the information for the summary_event_key setHiddenField(AGENT_PARAM + "_" + "Summary_event_key", converted_key , div); // only do the others if we have actions. if (agent.getActionCount() > 0) { //write out stuff for each action for(var i = 1; i <= agent.getActionCount(); i++){ var an_action = agent.getActionAt(i - 1); //first write in the marker for the action setHiddenField(ACTION_MARKER, ACTION_NAME + "_" + i , div); setHiddenField(makeActionName(ACTION_NAME_NAME, i), an_action.name, div); setHiddenField(makeActionName(ACTION_ID_NAME, i), an_action.id, div); setHiddenField(makeActionName(ACTION_TASK_LEVEL_FILTER, i), an_action.taskLevelFilter, div); setHiddenField(makeActionName(ACTION_RUN_CONDITION, i), an_action.runCondition, div); var action_params = an_action.getParams(); for(var param_index = 0; param_index < action_params.getParamCount(); param_index++){ var param = action_params.getParamAt(param_index); //if this has topics in it they are converted to portal style var converted_param_value = param.getPortalStyleValue(); setHiddenField(makeActionName("PARAM_" + param.param_name, i), converted_param_value, div); } } } } function makeActionName(name, index){ return ACTION_NAME + "_" + index + "_" + name; } /** * private function to write out a hidden form field value */ function setHiddenField(field_name, value, div){ var hidden_input = ""; var divObject = document.getElementById(div); //write hidden form fields to the supplied div... this may be browser specific divObject.innerHTML = divObject.innerHTML + hidden_input; }