Rev 7279 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<%@LANGUAGE="VBSCRIPT"%><%'====================================================='| |'| wAddDaemon |'| |'=====================================================%><%Option explicitResponse.Expires = 0%><!--#include file="common/conf.asp"--><!--#include file="common/globals.asp"--><!--#include file="common/formating.asp"--><!--#include file="common/qstr.asp"--><!--#include file="common/common_subs.asp"--><!--#include file="common/_form_window_common.asp"--><%'------------ ACCESS CONTROL ------------------%><!--#include file="_access_control_general.asp"--><!--#include file="_access_control_login.asp"--><%'------------ VARIABLE DEFINITION -------------Dim rsQry, healthTag, cmdInterface, pkgOwner, isInterface, package, procDescDim sMessageDim Query_StringDim RecordCountDim bmcon_idDim daemon_modeDim gbe_buildfilterDim bShowEmptyDim bAdd'------------ CONSTANTS DECLARATION -----------'------------ VARIABLE INIT -------------------sMessage = NULLparRtag_id = Request("rtag_id")bmcon_id = RequestDefault("bmcon_id",Request("base_bmcon_id"))bAdd = (Request("rcon_id") = "")Set objFormCollector = CreateObject("Scripting.Dictionary")'------------ CONDITIONS ----------------------'----------------------------------------------%><%'--------------------------------------------------------------------------------------------------------------------------' Function: GetData' Description: Determine the basic data for the edit sessionSub GetData' Determine if any daemons have been configured in this release' Will be used to determine if a new entry should be a MASTER or a SLAVE'Query_String = "select * " &_" from release_config rc," &_" gbe_machtype gbe " &_" where rc.rtag_id = "& parRtag_id &_" and gbe.gbe_id = rc.gbe_id"Set rsQry = OraDatabase.DbCreateDynaset( Query_String, cint(0))RecordCount = rsQry.RecordCountIf RecordCount = 0 Thendaemon_mode = "M"elsedaemon_mode = "S"End IfrsQry.Close()Set rsQry = Nothing' Edit an existing entry' May have a link into the build_machine_config - or it may not' Check firstbShowEmpty = TRUEIf NOT bAdd ThenQuery_String = "SELECT * " &_" FROM RELEASE_CONFIG rc," &_" gbe_machtype gb" &_" WHERE rc.rcon_id = "& Request("rcon_id") &_" AND rc.gbe_id = gb.gbe_id"Set rsQry = OraDatabase.DbCreateDynaset( Query_String, cint(0))If rsQry.RecordCount > 0 Thenbmcon_id = rsQry("bmcon_id")daemon_mode = rsQry("daemon_mode")gbe_buildfilter = NiceCStr(rsQry("gbe_buildfilter"),"")End IfrsQry.Close()Set rsQry = NothingEnd IfIf NOT isNULL(bmcon_id) AND bmcon_id <> "" Then' Extract information from the machine configQuery_String = "SELECT * " &_" FROM build_machine_config bc, " &_" gbe_machtype gb " &_"WHERE bc.bmcon_id = " & bmcon_id &_" AND bc.gbe_id = gb.gbe_id"Set rsQry = OraDatabase.DbCreateDynaset( Query_String, cint(0))If rsQry.RecordCount > 0 Thenbmcon_id = rsQry("bmcon_id")bShowEmpty = FALSEEnd IfrsQry.Close()Set rsQry = NothingEnd If' Cleanup gbe_buildfilterDim regExSet regEx = New RegExpregEx.Global = trueregEx.IgnoreCase = TrueregEx.Pattern = "\s{2,}"gbe_buildfilter = Replace(gbe_buildfilter,","," ")gbe_buildfilter = Trim(regEx.Replace(gbe_buildfilter, " "))End SubSub InsertXrefData'' Create a data structure (javascript) to map build machine (bmcon_id) to available platforms'Query_String = "SELECT bp.bp_name, bp.bp_id, bc2.bmcon_id" &_" FROM release_manager.build_platforms bp, release_manager.build_platforms_config2 bc2 " &_" WHERE bp.bp_id = bc2.bp_id " &_" ORDER BY upper(bp.bp_name)"Set rsQry = OraDatabase.DbCreateDynaset( Query_String, ORADYN_DEFAULT )While (NOT rsQry.BOF) AND (NOT rsQry.EOF)Response.Write "AddXrefEntry('" & rsQry("bp_name") &"',"& rsQry("bmcon_id") & ");" & vbCrLfrsQry.MoveNextWendrsQry.Close()Set rsQry = NothingEnd Sub'-------------------------------------------------' Gnerate a table of build machine informationSub DisplayBuildMachinesDim rsQry, queryResponse.Write "<table id='daemonHost' class='comboBox' width='100%'>"OraDatabase.Parameters.Add "bmcon_id", bmcon_id, ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.Parameters.Add "rtag_id", parRtag_id, ORAPARM_INPUT, ORATYPE_NUMBERquery = ReadFile( rootPath & "queries\available_build_machines.sql" )Set rsQry = OraDatabase.DbCreateDynaset( query, ORADYN_DEFAULT )While (NOT rsQry.BOF) AND (NOT rsQry.EOF)Response.Write "<tr class='"& rsQry("state") & "' data-bmconid="& rsQry("bmcon_id") &">"Response.Write "<td>" & rsQry("display_name") & "</td>"Response.Write "<td>" & rsQry("gbe_value") & "</td>"Response.Write "<td style='max-width:300px'>" & rsQry("description") & "</td>"Response.Write "</tr>"rsQry.MoveNextWendrsQry.Close()Set rsQry = NothingOraDatabase.Parameters.Remove "bmcon_id"OraDatabase.Parameters.Remove "rtag_id"Response.Write "</table>"End Sub'--------------------------------------------------------------------------------------------------------------------------'------------ RUN BEFORE PAGE RENDER ----------If CBool(Request("action")) ThenIf bmcon_id = "" ThensMessage = "Select a Build Machine before updating the entry"Else' Add or Update after the users edit sessionIf Request("rcon_id") <> "" ThenOraDatabase.Parameters.Add "RCON_ID", Request("rcon_id"), ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.Parameters.Add "BMCON_ID", bmcon_id, ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.Parameters.Add "DAEMON_MODE", Request("daemon_mode"), ORAPARM_INPUT, ORATYPE_VARCHAR2OraDatabase.Parameters.Add "GBE_BUILDFILTER", Request("gbe_buildfilter"), ORAPARM_INPUT, ORATYPE_VARCHAR2objEH.ErrorRedirect = FALSEobjEH.TryORA ( OraSession )On Error Resume NextOraDatabase.ExecuteSQL "BEGIN PK_BUILDAPI.UPDATE_DAEMON_CONFIG(:RCON_ID, :BMCON_ID, :DAEMON_MODE, :GBE_BUILDFILTER); END;"OraSession.CommitTransobjEH.CatchORA ( OraSession )OraDatabase.Parameters.Remove "RCON_ID"OraDatabase.Parameters.Remove "BMCON_ID"OraDatabase.Parameters.Remove "DAEMON_MODE"OraDatabase.Parameters.Remove "GBE_BUILDFILTER"If objEH.Finally ThenCall OpenInParentWindow ("release_config.asp?rtag_id="&parRtag_id)Call CloseWindow()End IfrsQry.CloseSet rsQry = nothingElseOraDatabase.Parameters.Add "RTAG_ID", Request("rtag_id"), ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.Parameters.Add "BMCON_ID", bmcon_id, ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.Parameters.Add "DAEMON_MODE", Request("daemon_mode"), ORAPARM_INPUT, ORATYPE_VARCHAR2OraDatabase.Parameters.Add "GBE_BUILDFILTER", Request("gbe_buildfilter"), ORAPARM_INPUT, ORATYPE_VARCHAR2objEH.ErrorRedirect = FALSEobjEH.TryORA ( OraSession )On Error Resume NextOraDatabase.ExecuteSQL "BEGIN PK_BUILDAPI.ADD_DAEMON_CONFIG(:RTAG_ID, :BMCON_ID, :DAEMON_MODE, :GBE_BUILDFILTER); END;"objEH.CatchORA ( OraSession )OraDatabase.Parameters.Remove "RTAG_ID"OraDatabase.Parameters.Remove "BMCON_ID"OraDatabase.Parameters.Remove "DAEMON_MODE"OraDatabase.Parameters.Remove "GBE_BUILDFILTER"If objEH.Finally ThenCall OpenInParentWindow ("release_config.asp?rtag_id="&parRtag_id)Call CloseWindow()End IfrsQry.CloseSet rsQry = nothingEnd IfEnd IfEnd Ifcall GetData'----------------------------------------------Sub InsertJavaScript %><script type="text/javascript" charset="utf-8">var platformXref = {};$(document).ready(function(){// Function to init Platform CrossRef Data// Create a two dimensional associative array// First level - Platform Name// Second Level - BMCONID//function AddXrefEntry(platform, bmconid){platform = platform.toUpperCase();if ( ! platformXref[platform] ) {platformXref[platform] = {};}platformXref[platform][bmconid] = 1;};// Function calls generated by the ASP code to create a data structure<%Call InsertXrefData%>// Add in two special platforms. NONE and TOOLSETAddXrefEntry('TOOLSET', 'ALL');AddXrefEntry('NONE', 'ALL');// Init the Daemon Host CombosetDaemonHost();// Initial config of visible PLATFORMSsetbmConId();// Initial Focus$("#daemonHostDiv").focus();// Wire up the MachType selector to modify the available PLATFORMS$('#selBmConId').change( setbmConId );// Wire up the GBE_BUILDFILTER so that user changes are represented$('#gbe_buildfilter').change( setbmConId );// Update the available platforms when the user changes the GBE_MACHTYPE// Sanitise the value of GBE_BUILDFILTER// Operation relies on the fact that// Hidden items will not be submitted as a part of the form// Platforms supported on multiple machines will appear multiple timesfunction setbmConId( ){var bmConId = $('#bmcon_id').val();var table = $('#selPlat');table.empty();// Parse the existing GBE_BUILDFILTER so that we can determine any platforms that are not// supported on the selected build machine// Convert the GBE_BUILDFILTER into an object for easy processingvar curFilter = {};var curFilterArray = getBuildFilter();for ( i = 0; i < curFilterArray.length; i++ ) {curFilter[curFilterArray[i]] = 1;}// Insert platforms supported on selected machineObject.keys(platformXref).sort().forEach(platform => {if ( platformXref[platform][bmConId] || platformXref[platform]['ALL'] ){table.append(createPlatformRow(platform, curFilter[platform], undefined));delete curFilter[platform];}});// Insert platforms NOT supported on selected machine// Prepend in reverse orderObject.keys(curFilter).sort().reverse().forEach(platform => {if ( platform ) {table.prepend(createPlatformRow(platform, true, 'err_alert'));}});setBuildFilter();}// Local function to create a platform row, with checkbox//function createPlatformRow(platform, state, eClass){var row = $("<tr/>").addClass('body_txt selPlat').addClass(eClass);var td = $("<td/>");var item = $("<input/>").attr('type', 'checkbox').css('margin','0px 3px').prop('checked', state).change(togglePlatforms);if ( platform == 'NONE' ) {item.attr('id', 'check_none');}var itemText = $("<span/>").text(platform);if ( eClass ) {itemText.append(' - Not available');}td.append(item);td.append(itemText);row.append(td);return row;}// Update GBE_BUILDFILTER as the user selects and deselects platformsfunction togglePlatforms(){var state = this.checked;var platform = $(this).parent().text().trim();var idx = platform.indexOf(' - ');if ( idx >= 0 )platform = platform.substring(0, idx );// Add or remove item// Split the string into an array// Always remove the item// Append the platform - if adding// Sort and reform a space-seperated string//var gbeFilter = getBuildFilter()gbeFilter = gbeFilter.filter(e => e !== platform);if ( state ) {gbeFilter.push(platform);}setBuildFilter(gbeFilter);}//// Get the current gbe_buildfilter and return an array//function getBuildFilter() {var uniq = [ ...new Set($('#gbe_buildfilter').val().replace(/,/g, ' ').trim().toUpperCase().split(/\s+/)) ];return uniq;}// Handle the special NONE case// Remove NONE - if there are others// Insert NONE if there are no others// Pretty up the GBE_BUIDLFILTER// Sort the list// Force upper case//function setBuildFilter(gbeFilter) {var hasNone = false;var hasOthers = false;if ( !gbeFilter ) {gbeFilter = getBuildFilter();}gbeFilter.forEach (platform => {if (platform.length <= 0) {} else if ( platform == 'NONE' ) {hasNone = true;} else if ( platform != 'TOOLSET' ) {hasOthers = true;}});// Insert NONE, if there are no othersif ( !hasNone && !hasOthers ) {gbeFilter.push('NONE');gbeFilter = gbeFilter.sort();$('#check_none').prop('checked', true);}// Remove NONE, if there are othersif ( hasNone && hasOthers ) {var idx = gbeFilter.indexOf('NONE');if ( idx >= 0 ) {gbeFilter.splice(idx, 1);}$('#check_none').prop('checked', false);}// Pretty up the display$('#gbe_buildfilter').val(gbeFilter.sort().join(' '));}// Multicolumn combo box handling//$('.comboParent').on('keydown',function(e) {if(e.which == 13) {openComboBox(e, this);}});$('.comboParent').click(openComboBox);$('.comboBox tr').click(function(){if ( $(this).hasClass('available') ){var elp = $(this).closest('.comboContainer');closeComboBox(elp)// Capture the data and store it in the parent elementelp.find('.selected').removeClass('selected');$(this).addClass('selected');var $clone = $(this).clone();$('.comboParent table').first().html($clone);// Update the field that will be submittedvar bmconid = $(this).data('bmconid');$('#bmcon_id').val(bmconid);setbmConId();}});// Show the combo box//function openComboBox(e, that) {if ( that == undefined ) {that = this;}var el = $(that).find('.comboContainer:first');if (el.is(":hidden")) {el.show();event.stopImmediatePropagation();$(document).on('click.comboBox', function(){var elp = $(that).closest('.comboContainer');if ( elp.size() <= 0 ) {closeComboBox(elp)}});} else {// Combobox is already showncloseComboBox(el);}}// Hide the combo box and remove handlers//function closeComboBox( el) {el.hide();$(document).off('click.comboBox');$("#daemonHostDiv").focus();event.stopImmediatePropagation();}// Init the Deamon Host display.// Select the required data from the tablesfunction setDaemonHost() {var el = $("#daemonHost").find('.selected');if ( el.size() > 0 ) {var $clone = el.clone();$('#daemonHostDiv table').first().html($clone)}}});</script><%End Sub'-------------------------------------------------%><html><head><title>Release Manager</title><link rel="shortcut icon" href="<%=FavIcon%>"/><meta HTTP-EQUIV="Pragma" CONTENT="no-cache"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link href="images/release_manager_style.css?ver=<%=VixVerNum%>" rel="stylesheet" type="text/css"><script language="JavaScript" src="scripts/common.js?ver=<%=VixVerNum%>"></script><!--#include file="_jquery_includes.asp"--><%Call InsertJavaScript %><style>.comboBox {}.comboParent { position:relative; background:white;}.comboParent table {border-collapse:collapse;}.comboParent table td {border:1px solid darkgrey; padding-right: 10px;white-space: nowrap;overflow-x: hidden;}.comboParent table {color:#000000;font:11px tahoma,sans-serif;text-decoration:none;}.comboContainer{position:absolute;overflow-y:scroll;background:white; border: 1px solid darkgrey;display:none;xxtop:0px;right:0px;left:0px;}table.comboBox {border-collapse:collapse;}table.comboBox td {border:1px solid darkgrey;padding-right: 10px;white-space: normal}table.comboBox tr.available:hover {background: #1e90ff;}table.comboBox tr.selected {background: #d5e8fb;}table.comboBox tr.disabled {color:grey;}.icon-down:before {content: "\25BC"; position:absolute;top:2;right:2;font-size:11px}</style></head><body background="images/bg_bage_0.gif" leftmargin="0" topmargin="0" ><table width="100%" border="0" cellspacing="0" cellpadding="10"><tr><td bgcolor="#FFFFFF" class="body_txt"><%If bAdd Then%>Add a new DAEMON<%Else%>Edit an existing DAEMON<%End If%></td></tr><%'-- FROM START --------------------------------------------------------------------------------------------------------------objFormComponent.FormName = "FormName"objFormComponent.FormClass = "form_tight"objFormComponent.Action = ScriptNameobjFormComponent.OnSubmit = "ShowProgress();"Call objFormComponent.FormStart()%><tr><td><!-- LOCAL ERROR +++++++++++++++++++++++++++++++++++++++++++++++ --><%Call Messenger ( sMessage , 3, "100%" )%><!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ --><!--#include file="messages/_msg_inline.asp"--><table border="0" width='700px'><tr><td width=1%><span class="body_txt">Daemon Host</span></td><td><div id='daemonHostDiv' class='comboParent icon-down' tabindex=0 ><table width=100%><tr><td>Select Deamon Host</td></tr></table><div class=comboContainer style="height:10em;"><%DisplayBuildMachines%></div></div></td></tr><tr><td><span class="body_txt">Daemon Mode</span></td><td><select name="daemon_mode" class='body_txt'><option value=M <%=iif(daemon_mode="M","selected","")%>>Master</option><option value=S <%=iif(daemon_mode="S","selected","")%>>Slave</option></select></td></tr><tr><tr><td><span class="body_txt">GBE_BUILDFILTER</span></td><td><input id=gbe_buildfilter name="gbe_buildfilter" type="text" class="body_txt" size="120" spellcheck="false" value="<%=gbe_buildfilter%>"></td></tr></tr><tr><td><span class="body_txt nowrap">Platforms</span></td><td style="border: darkgrey 1px solid"><div style="overflow-y: scroll;height: 20em;"><table id=selPlat></table></div></td></tr></table></td></tr><tr><td bgcolor=#FFFFFF><table class="full_table"><tr><td><%=ProgressBar()%></td><td align="right"><input name="btn" type="submit" class="form_btn" value="Add/Update"><input name="btn" type="reset" class="form_btn" value="Cancel" onclick="parent.closeIFrame();"></td></tr></table></td></tr><%=objPMod.ComposeHiddenTags()%><input type="hidden" name="action" value="true"><input type="hidden" name="base_bmcon_id" value="<%=bmcon_id%>"><input type="hidden" id=bmcon_id name="bmcon_id" value="<%=bmcon_id%>"><%If NOT bAdd Then%><input type="hidden" name="rcon_id" value="<%=Request("rcon_id")%>"><% End If %><%Call objFormComponent.FormEnd()'-- FROM END ----------------------------------------------------------------------------------------------------------------%></table></body></html><%'------------ RUN AFTER PAGE RENDER -----------Set objFormCollector = Nothing'----------------------------------------------Call Destroy_All_Objects%>