Subversion Repositories DevTools

Rev

Rev 6874 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'   View Project Level replication
'   form_project_replication.asp
'=====================================================
Option explicit
' Good idea to set when using redirect
Response.Expires = 0   ' always load the page, dont store
%>
<!--#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"-->
<%
' Make sure proj_id is always present
If Request("proj_id") = "" Then
    Call Destroy_All_Objects
        Response.Redirect("index.asp")
End If
'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_login.asp"-->
<!--#include file="_access_control_general.asp"-->
<%
'------------ Variable Definition -------------
Dim parProjId
Dim canModify
'------------ Constants Declaration -----------
'------------ Variable Init -------------------
canModify = canActionControl("ConfigureReplication")
parProjId = Request("proj_id")

'--------------------------------------------------------------------------------------------------------------------------
'  GenerateTableBody
'
'  DESCRIPTION
'     Constructs the HTML to render the rows of package names, and other information
'
Function GenerateTableBody
   Dim rsQry
   Dim html_string
   Dim sQry

   SQry = _
        "SELECT" &_
        "    bs.*,bp.bp_enabled," &_
        "    nvl2(bp.BLAT_ID, 1, 0) AS inuse" &_
        " FROM" &_
        "    blat_servers bs," &_
        "    blat_projects bp" &_
        " WHERE" &_
        "    bs.BLAT_ID = bp.BLAT_ID (+)" &_
        "    AND bp.proj_id(+) = :PROJ_ID" &_
        "    AND (bp.BLAT_ID is NOT NULL OR bs.blat_mode in ('P', 'E'))" &_
        " ORDER BY" &_
        "    upper(blat_display_name) ASC"

   OraDatabase.Parameters.Add "PROJ_ID", parProjId, ORAPARM_INPUT, ORATYPE_NUMBER
   Set rsQry = OraDatabase.DbCreateDynaset( sQry, cint(0) )
   OraDatabase.Parameters.Remove "PROJ_ID"

   '--- Render rows ---
   Do While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
      Dim btnText, btnClass, btnDisable, inUse, replicationMode

      inUse = rsQry("INUSE") > 0 

      replicationMode = "Unknown"
      If rsQry("blat_mode") = "P" Then
          replicationMode = "All Projects"
      ElseIf rsQry("blat_mode") = "E" Then
          replicationMode = "Entire Archive"
      ElseIf  rsQry("inUse") > 0 Then
          replicationMode = "Project"
      End If

      ' BEGIN ROW
      html_string = html_string & "<tr data-server_id=""" & rsQry("BLAT_ID") & """>"

      ' Server Active
      Dim activeChecked
      activeChecked = IIF(rsQry("BLAT_ENABLE") = "Y", "checked", "" )
      html_string = html_string & "<td nowrap class='body_row'><input type='checkbox' disabled "& activeChecked &" ></td>"

      ' Server Name
      html_string = html_string & "<td nowrap class='body_row'>" & rsQry("BLAT_DISPLAY_NAME") & "</td>"

      ' Project Active
      activeChecked = IIF(rsQry("BP_ENABLED") = "Y", "checked", "" )
      btnText = "Operation not available"
      btnClass = ""
      btnDisable = "disabled"
      If canModify AND inUse Then
         btnText = "Toggle Replication State"
         btnClass = "class=btn_enable"
         btnDisable = ""
      End If

      html_string = html_string & "<td nowrap class='body_row' title='" & btnText & "'><input " & btnClass & " type='checkbox' " &btnDisable & " "& activeChecked &" ></td>"

     ' Replication Mode
      html_string = html_string & "<td nowrap class='body_row'>" & replicationMode & "</td>"

     ' Delete Operation
     Dim DelUserImage : DelUserImage = LIMG_NDEL_DISABLED
     btnText = "Operation not available"
     btnClass = ""
     If canModify AND inUse Then
         DelUserImage = LIMG_NDEL
         btnText = "Remove this replica"
         btnClass = "class=btn_delete"
     End If

     html_string = html_string & "<td nowrap valign='top' " & btnClass & " title='" & btnText & "'>" & DelUserImage & "</td>"

      ' END ROW
      html_string = html_string & "</tr>"

      rsQry.MoveNext

      ' ROW SEPERATOR
      'If (NOT rsQry.BOF) AND (NOT rsQry.EOF) Then
         html_string = html_string & "<tr><td colspan='8' class=body_line></td></tr>"
      'End If
   Loop

   ' destroy objects
   rsQry.Close()
   Set rsQry = nothing

   ' return result
   GenerateTableBody = html_string
End Function
'----------------------------------------------------
'   Insert Includes and scripts associated with TIPS
Sub InsertTips
 %>
<!-- TIPS -->
<script language="JavaScript1.2" src="images/popup_menu.js?ver=<%=VixVerNum%>"></script>
<script language="JavaScript" src="images/tipster.js?ver=<%=VixVerNum%>"></script>
<script language="JavaScript" src="images/_help_tips.js?ver=<%=VixVerNum%>"></script>
<script language="JavaScript" type="text/JavaScript">
formTips.tips.activeReplica   = stdTip(200, 'Active Replica', 'This package replica has been marked as active.');
formTips.tips.enabledProject  = stdTip(200, 'Enabled Project','Replication of this project has been enabled. This will only ' +
                                    'be effective if the replica is active');
</script>
<%
End Sub
'----------------------------------------------------
'   Insert scripts into the header section of the generated document
Sub InsertUserScripts
 %>
<!-- JQUERY SCRIPTS -->
<script language="javascript">
$(document).ready(function () {

    //  Add operation to all the delete buttons
    $('.btn_delete').on('click', function(){
        var el = $(this);
        var trel = el.closest("tr");
        var proj_id = <%=parProjId%>;
        var server_id = trel.data("server_id");

        var colData = new Array();
        trel.each(function(){
            $(this).find('td').each(function(){
                colData.push($(this));
            })
        });
        var replicaName = colData[1].text();

        vixConfirm("Remove replication to '"+replicaName+"' of all Releases in this Project", 
            {
                deferred : true,  
            }).done(function(){
                $.ajax({
                    type : 'POST',
                    url : '_json_Replication.asp',
                    data : {Opr : 'RemoveProject', server_id : server_id, user_id : <%=objAccessControl.UserId%>, proj_id : proj_id },
                    dataType : 'json',
                }).fail(function( jqXHR, textStatus, errorThrown ){
                    vixAlert('Ajax Error. Unexpected result.<p>' + errorThrown);
                }).done(function( data, textStatus, jqXHR ){
                    if (typeof data.result === undefined){
                        vixAlert('Ajax Error. Unexpected result');
                    } else if (data.result != 0){
                        vixAlert('Error Deleting item.<p>' + data.emsgDetails);
                    } else {
                        // Process individual items to show that an action has been taken
                        //
                        colData[1].addClass("strike");
                        colData[0].empty();
                        colData[2].empty();
                        colData[3].empty();
                    }
                });
            });
    });

    //  Add operation to all the enable buttons
    $('.btn_enable').on('click', function(e){
        var el = $(this);
        var trel = el.closest("tr");
        var proj_id = <%=parProjId%>;
        var server_id = trel.data("server_id");
        var state =  $(this).prop("checked");
        var stateChanged = false;

        var colData = new Array();
        trel.each(function(){
            $(this).find('td').each(function(){
                colData.push($(this));
            })
        });
        var replicaName = colData[1].text();
        var stateText = state ? 'Enable' : 'Disable'; 

        vixConfirm(stateText + " replication to '"+replicaName+"' of all Releases in this Project", 
             {
                 deferred : true,
             }).done(function(){
                $.ajax({
                    type : 'POST',
                    url : '_json_Replication.asp',
                    data : {Opr : 'EnableProject', server_id : server_id, user_id : <%=objAccessControl.UserId%>, proj_id : proj_id, new_state : state ? 'Y' : 'N' },
                    dataType : 'json',
                }).fail(function( jqXHR, textStatus, errorThrown ){
                    vixAlert('Ajax Error. Unexpected result.<p>' + errorThrown);
                }).done(function( data, textStatus, jqXHR ){
                    if (typeof data.result === undefined){
                        vixAlert('Ajax Error. Unexpected result');
                    } else if (data.result != 0){
                        vixAlert('Error setting state.<p>' + data.emsgDetails);
                    } else {
                        stateChanged = true;
                    }
                }).always(function(){
                    if ( !stateChanged ) {
                        el.prop("checked", !state);
                    }
                });
            }).fail(function(){
                el.prop("checked", !state);
            });
        });

});
</script>
<%
End Sub


'--------------------------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------------------------
'------------ RUN BEFORE PAGE RENDER ----------
'
'----------------------------------------------------
Sub LeftPanelContent
End Sub
'----------------------------------------------------
Sub MainPanelContent
%>
          <table class="rounded_box embedded_table">
          <caption nowrap class="form_ttl tleft">Project Replication Details</caption>
              <tr>
                <td>
                    <div class='rounded_box_pad'>
                        <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
                        <!--#include file="messages/_msg_inline.asp"-->
                        <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
                        <table width="100%"  border="0" cellspacing="2" cellpadding="0">
                            <tr>
                               <td width="1%" valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Active<%=Quick_Help("activeReplica")%></td>
                               <td width="1%" valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Replica</td>
                               <td width="1%" valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Enabled<%=Quick_Help("enabledProject")%></td>
                               <td width="1%" valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Relication Mode</td>
                               <td width="1%" valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Opr</td>
                            </tr>
                            <%=GenerateTableBody()%>
                      </table>
                      <table class="full_table">
                         <tr>
                            <%BuildActionButtonClick canModify, "Add Project Replica", "Add New Replication Target", true, _
                                "src='icons/btn_add.gif' width='13' height='13' align='absmiddle' border='0' hspace='3'", _
                                "MM_openVixIFrame('wAddProjReplica.asp?proj_id=" & parProjId &"','Add Project Replication')"
                            %>
                            </td>
                         </tr>
                      </table>
                    </div>
                </td>
              </tr>
          </table>
<%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 rel="stylesheet" href="images/release_manager_style.css?ver=<%=VixVerNum%>" type="text/css">
      <link rel="stylesheet" href="images/navigation.css?ver=<%=VixVerNum%>" type="text/css">
      <script language="JavaScript" src="images/common.js?ver=<%=VixVerNum%>"></script>
      <!-- DROPDOWN MENUS -->
      <!--#include file="_jquery_includes.asp"-->
      <!--#include file="_menu_def.asp"-->
      <%Call InsertUserScripts%>
      <%Call InsertTips%>
   </head>
   <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
      <!-- HEADER -->
      <!--#include file="_header.asp"-->
      <!-- BODY ---->
      <table class="full_table">
         <tr>
            <td width="146px" class="bg_panel" valign="top">
                <%Call LeftPanelContent%>
            </td>
            <td width="90%" rowspan="2" align="center" valign="top" bgcolor="#EEEFEF">
                <%Call MainPanelContent%>
            </td>
         </tr>
         <tr>
            <td class="bg_panel" valign="bottom" align="center" height="350"></td>
         </tr>
      </table>
      <!-- FOOTER -->
      <!--#include file="_footer.asp"-->
   </body>
</html>